Skip to content

Commit

Permalink
Merge pull request #134 from ninoseki/refactor
Browse files Browse the repository at this point in the history
add SearchableType & ScannableType for more clear type definitions
  • Loading branch information
ninoseki committed Nov 7, 2018
2 parents 53bde6c + 2098fa6 commit 6eebdb6
Show file tree
Hide file tree
Showing 38 changed files with 77 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/lib/scanner/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { Scanner } from "./scanner";
export { ScannableType, Scanner } from "./scanner";
export { Urlscan } from "./urlscan";
export { VirusTotal } from "./virustotal";

Expand Down
4 changes: 3 additions & 1 deletion src/lib/scanner/scanner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export type ScannableType = "ip" | "domain" | "url";

export interface Scanner {
endpoint: string;
name: string;
supportedTypes: string[];
supportedTypes: ScannableType[];
scanByIP?(query: string);
scanByDomain?(query: string);
scanByURL?(query: string);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scanner/urlscan.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios from "axios";
import { Scanner } from "./scanner";
import { ScannableType, Scanner } from "./scanner";

export class Urlscan implements Scanner {
public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "url"];
public supportedTypes: ScannableType[] = ["ip", "domain", "url"];
protected apiKey: string | undefined;

constructor() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scanner/virustotal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";
import * as qs from "qs";
import { Scanner } from "./scanner";
import { ScannableType, Scanner } from "./scanner";

export class VirusTotal implements Scanner {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["url"];
public supportedTypes: ScannableType[] = ["url"];
protected apiKey: string | undefined;

constructor() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/blockcypher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class BlockCypher implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["btc"];
public supportedTypes: SearchableType[] = ["btc"];

constructor() {
this.endpoint = "https://live.blockcypher.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/censys.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Censys implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["text"];
public supportedTypes: SearchableType[] = ["text"];

constructor() {
this.endpoint = "https://censys.io";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/cymon.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Cymon implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain"];
public supportedTypes: SearchableType[] = ["ip", "domain"];

constructor() {
this.endpoint = "https://cymon.io";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/dnslytics.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class DNSlytics implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain"];
public supportedTypes: SearchableType[] = ["ip", "domain"];

constructor() {
this.endpoint = "https://dnslytics.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/domainbigdata.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class DomainBigData implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["domain"];
public supportedTypes: SearchableType[] = ["domain"];

constructor() {
this.endpoint = "https://domainbigdata.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/domainwatch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class DomainWatch implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["domain", "email"];
public supportedTypes: SearchableType[] = ["domain", "email"];

constructor() {
this.endpoint = "https://domainwat.ch";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/findsubdomains.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class FindSubDomains implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["domain"];
public supportedTypes: SearchableType[] = ["domain"];

constructor() {
this.endpoint = "https://findsubdomains.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/fortiguard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class FortiGuard implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "url", "cve"];
public supportedTypes: SearchableType[] = ["ip", "url", "cve"];

constructor() {
this.endpoint = "https://fortiguard.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/hybridanalysis.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class HybridAnalysis implements Searcher {
public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "hash"];
public supportedTypes: SearchableType[] = ["ip", "domain", "hash"];

constructor() {
this.endpoint = "https://www.hybrid-analysis.com";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/searcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export { PubDB } from "./pubdb";
export { PublicWWW } from "./publicwww";
export { Pulsedive } from "./pulsedive";
export { RiskIQ } from "./riskiq";
export { Searcher } from "./searcher";
export { SearchableType, Searcher } from "./searcher";
export { SecurityTrails } from "./securitytrails";
export { Shodan } from "./shodan";
export { Sploitus } from "./sploitus";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/intelligencex.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as crypto from "crypto-js";
import * as url from "url";
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class IntelligenceX implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "url", "email", "btc"];
public supportedTypes: SearchableType[] = ["ip", "domain", "url", "email", "btc"];

constructor() {
this.endpoint = "https://intelx.io";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/onyphe.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class ONYPHE implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip"];
public supportedTypes: SearchableType[] = ["ip"];

constructor() {
this.endpoint = "https://www.onyphe.io";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/otx.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class OTX implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "hash"];
public supportedTypes: SearchableType[] = ["ip", "domain", "hash"];

constructor() {
this.endpoint = "https://otx.alienvault.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/pipl.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Pipl implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["email"];
public supportedTypes: SearchableType[] = ["email"];

constructor() {
this.endpoint = "https://pipl.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/pubdb.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class PubDB implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["gaTrackID", "gaPubID"];
public supportedTypes: SearchableType[] = ["gaTrackID", "gaPubID"];

constructor() {
this.endpoint = "http://pub-db.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/publicwww.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class PublicWWW implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["text"];
public supportedTypes: SearchableType[] = ["text"];

constructor() {
this.endpoint = "https://publicwww.com/websites";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/pulsedive.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as crypto from "crypto-js";
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Pulsedive implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "url", "hash"];
public supportedTypes: SearchableType[] = ["ip", "domain", "url", "hash"];

constructor() {
this.endpoint = "https://pulsedive.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/riskiq.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class RiskIQ implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain", "email"];
public supportedTypes: SearchableType[] = ["ip", "domain", "email"];

constructor() {
this.endpoint = "https://community.riskiq.com";
Expand Down
4 changes: 3 additions & 1 deletion src/lib/searcher/searcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export type SearchableType = "text" | "ip" | "domain" | "url" | "email" | "hash" | "cve" | "btc" | "xmr" | "gaTrackID" | "gaPubID";

export interface Searcher {
endpoint: string;
name: string;
supportedTypes: string[];
supportedTypes: SearchableType[];
searchByText?(query: string);
searchByIP?(query: string);
searchByDomain?(query: string);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/searcher/searchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SecurityTrails,
Shodan,
Sploitus,
SpyOnWeb,
Talos,
ThreatCrowd,
Urlscan,
Expand All @@ -30,7 +31,6 @@ import {
XForceExchange,
ZoomEye,
} from ".";
import { SpyOnWeb } from "./spyonweb";

export const Searchers: Searcher[] = [
new BlockCypher(),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/securitytrails.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class SecurityTrails implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["domain", "ip"];
public supportedTypes: SearchableType[] = ["domain", "ip"];

constructor() {
this.endpoint = "https://securitytrails.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/shodan.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Shodan implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["text"];
public supportedTypes: SearchableType[] = ["text"];

constructor() {
this.endpoint = `https://www.shodan.io`;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/sploitus.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Sploitus implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["cve"];
public supportedTypes: SearchableType[] = ["cve"];

constructor() {
this.endpoint = "https://sploitus.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/spyonweb.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class SpyOnWeb implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain", "gaPubID", "gaTrackID"];
public supportedTypes: SearchableType[] = ["ip", "domain", "gaPubID", "gaTrackID"];

constructor() {
this.endpoint = "http://spyonweb.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/talos.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Talos implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain"];
public supportedTypes: SearchableType[] = ["ip", "domain"];

constructor() {
this.endpoint = "https://talosintelligence.com";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/threatcrowd.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class ThreatCrowd implements Searcher {

public endpoint: string;
public name;
public supportedTypes: string[] = ["ip", "domain", "email"];
public supportedTypes: SearchableType[] = ["ip", "domain", "email"];

constructor() {
this.endpoint = "https://www.threatcrowd.org";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searcher/urlscan.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Searcher } from "./searcher";
import { SearchableType, Searcher } from "./searcher";

export class Urlscan implements Searcher {

public endpoint: string;
public name: string;
public supportedTypes: string[] = ["ip", "domain", "url"];
public supportedTypes: SearchableType[] = ["ip", "domain", "url"];

constructor() {
this.endpoint = "https://urlscan.io/api/v1";
Expand Down
Loading

0 comments on commit 6eebdb6

Please sign in to comment.