commit 71f3d087ef0bcd10de3316f022f1beee0d74a588 Author: bpmcdevitt Date: Sat May 29 22:44:10 2021 -0500 added initial commit diff --git a/background.js b/background.js new file mode 100644 index 0000000..76baa80 --- /dev/null +++ b/background.js @@ -0,0 +1,53 @@ +// adapted from heavily from: +// https://medium.com/bugbountywriteup/sputnik-an-open-source-intelligence-browser-extension-da2f2c22c8ec +// https://github.com/mitchmoser/sputnik + +browser.contextMenus.create({ + id: "CVE Search", + title: "CVE Search", + contexts: ["selection"] +}); + +browser.contextMenus.create({ + id: "NVD", + title: "NVD", + contexts: ["selection"], + parentId: "CVE Search", + icons: { + "48": "icons/nvd_48.png" + } +}); + +browser.contextMenus.create({ + id: "MITRE", + title: "MITRE", + contexts: ["selection"], + parentId: "CVE Search", + icons: { + "48": "icons/mitre_48.png" + } +}); + +// create empty url variable +var url = "" + +/* + * The click event listener: + * where we perform the approprate action + * given the ID of the menu item that was clicked + */ + +browser.contextMenus.onClicked.addListener((info, tab) => { + // copy the selection to clipboard + navigator.clipboard.writeText(info.selectionText); + + switch (info.menuItemId) { + case "NVD": + url = "https://nvd.nist.gov/vuln/detail/"+info.selectionText; + break; + case "MITRE": + url = "https://cve.mitre.org/cgi-bin/cvename.cgi?name="+info.selectionText; + break; + } + browser.tabs.create({url: url}); +}); diff --git a/icons/logo_48.png b/icons/logo_48.png new file mode 100644 index 0000000..90687de Binary files /dev/null and b/icons/logo_48.png differ diff --git a/icons/mitre_48.png b/icons/mitre_48.png new file mode 100644 index 0000000..90687de Binary files /dev/null and b/icons/mitre_48.png differ diff --git a/icons/nvd_48.png b/icons/nvd_48.png new file mode 100644 index 0000000..90687de Binary files /dev/null and b/icons/nvd_48.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a50ee84 --- /dev/null +++ b/manifest.json @@ -0,0 +1,21 @@ +{ + + "manifest_version": 2, + "name": "CVE Searcher", + "version": "1.0", + + "description": "Search a piece of highlighted text in either nvd.nist.gov or cve.mitre.org", + + "icons": { + "48": "icons/logo_48.png" + }, + "permissions": [ + "clipboardWrite", + "contextMenus", + "menus" + ], + "background": { + "scripts": ["background.js"] + } + +}