Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: check dot before selecting #556

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions src/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,41 @@ export class Selector {
);
}

private selectorSlots: SelectorSlot[] = [
{ type: "url", func: (this.getURL = this.getURL.bind(this)) },
{ type: "email", func: (this.getEmail = this.getEmail.bind(this)) },
{ type: "domain", func: (this.getDomain = this.getDomain.bind(this)) },
{ type: "ip", func: (this.getIP = this.getIP.bind(this)) },
{ type: "asn", func: (this.getASN = this.getASN.bind(this)) },
{ type: "hash", func: (this.getHash = this.getHash.bind(this)) },
{ type: "cve", func: (this.getCVE = this.getCVE.bind(this)) },
{ type: "btc", func: (this.getBTC = this.getBTC.bind(this)) },
{
type: "gaTrackID",
func: (this.getGATrackID = this.getGATrackID.bind(this)),
},
{ type: "gaPubID", func: (this.getGAPubID = this.getGAPubID.bind(this)) },
{ type: "eth", func: (this.getETH = this.getETH.bind(this)) },
];
public IsPossibleNetworkIndicator(): boolean {
return this.input.includes(".") || this.input.includes("dot");
}

private getSelectorSlots(): SelectorSlot[] {
let slots: SelectorSlot[] = [];

if (this.IsPossibleNetworkIndicator()) {
slots = slots.concat([
{ type: "url", func: (this.getURL = this.getURL.bind(this)) },
{ type: "email", func: (this.getEmail = this.getEmail.bind(this)) },
{ type: "domain", func: (this.getDomain = this.getDomain.bind(this)) },
{ type: "ip", func: (this.getIP = this.getIP.bind(this)) },
]);
}

return slots.concat([
{ type: "asn", func: (this.getASN = this.getASN.bind(this)) },
{ type: "hash", func: (this.getHash = this.getHash.bind(this)) },
{ type: "cve", func: (this.getCVE = this.getCVE.bind(this)) },
{ type: "btc", func: (this.getBTC = this.getBTC.bind(this)) },
{
type: "gaTrackID",
func: (this.getGATrackID = this.getGATrackID.bind(this)),
},
{ type: "gaPubID", func: (this.getGAPubID = this.getGAPubID.bind(this)) },
{ type: "eth", func: (this.getETH = this.getETH.bind(this)) },
]);
}

public getSearcherEntries(): AnalyzerEntry[] {
const entries: AnalyzerEntry[] = [];
const slots = this.getSelectorSlots();

for (const slot of this.selectorSlots) {
for (const slot of slots) {
const type = slot.type;
const func = slot.func;

Expand Down