Skip to content

Commit

Permalink
Merge pull request #363 from ninoseki/add-vmray
Browse files Browse the repository at this point in the history
feat: add VMRay
  • Loading branch information
ninoseki authored Jan 15, 2020
2 parents 64d9218 + 5ef9ad4 commit f002a91
Show file tree
Hide file tree
Showing 4 changed files with 53 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 @@ -55,6 +55,7 @@ export { URLhaus } from "./urlhaus";
export { Urlscan } from "./urlscan";
export { ViewDNS } from "./viewdns";
export { VirusTotal } from "./virustotal";
export { VMRay } from "./vmray";
export { Vulmon } from "./vulmon";
export { VulncodeDB } from "./vulncode-db";
export { VxCube } from "./vxcube";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/searcher/searchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
Urlscan,
ViewDNS,
VirusTotal,
VMRay,
Vulmon,
VulncodeDB,
VxCube,
Expand Down Expand Up @@ -125,6 +126,7 @@ export const Searchers: Searcher[] = [
new Urlscan(),
new ViewDNS(),
new VirusTotal(),
new VMRay(),
new Vulmon(),
new VulncodeDB(),
new VxCube(),
Expand Down
21 changes: 21 additions & 0 deletions src/lib/searcher/vmray.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { buildURL } from "../url_builder";
import { Searcher, SearchableType } from "../types";

export class VMRay implements Searcher {
public baseURL: string;
public name: string;
public supportedTypes: SearchableType[] = ["hash"];

public constructor() {
this.baseURL = "https://www.vmray.com";
this.name = "VMRay";
}

public searchByHash(query: string): string {
if (query.length !== 64) {
throw new Error("VMRay supports SHA256 hash only");
}
const trimmed = query.substring(0, 12);
return buildURL(this.baseURL, `/analyses/${trimmed}/report/overview.html`);
}
}
29 changes: 29 additions & 0 deletions test/searcher/vmray.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect } from "chai";
import "mocha";
import { VMRay } from "../../src/lib/searcher";

describe("VMRay", function() {
const subject = new VMRay();

it("should support hash type IOC", function() {
expect(subject.supportedTypes).to.deep.equal(["hash"]);
});

describe("#searchByHash", function() {
it("should return URL", function() {
expect(
subject.searchByHash(
"4e38fd97f1d64237659653a6f82e1d144636e69671c7e07ca7137bc59823c4d3"
)
).to.equal(
"https://www.vmray.com/analyses/4e38fd97f1d6/report/overview.html"
);
});

it("should throw an error when given hash which is not SHA256", function() {
expect(() => {
subject.searchByHash("5584cd3c99cde56e459f30eec3bb470b");
}).to.throw("VMRay supports SHA256 hash only");
});
});
});

0 comments on commit f002a91

Please sign in to comment.