Skip to content

Commit

Permalink
feat: add NIST NVD lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Jul 13, 2019
1 parent 8e844c7 commit ba0f638
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/searcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export { IPinfo } from "./ipinfo";
export { JoeSandbox } from "./joesandbox";
export { Malshare } from "./malshare";
export { Maltiverse } from "./maltiverse";
export { NVD } from "./nvd";
export { OCCRP } from "./occrp";
export { ONYPHE } from "./onyphe";
export { OTX } from "./otx";
Expand Down
17 changes: 17 additions & 0 deletions src/lib/searcher/nvd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { buildURL } from "../url_builder";
import { SearchableType, Searcher } from "./searcher";

export class NVD implements Searcher {
public endpoint: string;
public name: string;
public supportedTypes: SearchableType[] = ["cve"];

public constructor() {
this.endpoint = "https://nvd.nist.gov";
this.name = "NVD";
}

public searchByCVE(query: string): string {
return buildURL(this.endpoint, `/vuln/detail/${query}`);
}
}
2 changes: 2 additions & 0 deletions src/lib/searcher/searchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
JoeSandbox,
Malshare,
Maltiverse,
NVD,
OCCRP,
ONYPHE,
OTX,
Expand Down Expand Up @@ -81,6 +82,7 @@ export const Searchers: Searcher[] = [
new JoeSandbox(),
new Malshare(),
new Maltiverse(),
new NVD(),
new OCCRP(),
new ONYPHE(),
new OTX(),
Expand Down
19 changes: 19 additions & 0 deletions src/spec/searcher/nvd.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from "chai";
import "mocha";
import { NVD } from "../../lib/searcher";

describe("NVD", () => {
const subject = new NVD();

it("should support CVE type IOC", () => {
expect(subject.supportedTypes).to.deep.equal(["cve"]);
});

describe("#searchByCVE", () => {
it("should return URL", () => {
expect(subject.searchByCVE("CVE-2018-8013")).to.equal(
"https://nvd.nist.gov/vuln/detail/CVE-2018-8013"
);
});
});
});

0 comments on commit ba0f638

Please sign in to comment.