diff --git a/components/package.json b/components/package.json index 7ab1e3eaefa..ff4bfb05061 100644 --- a/components/package.json +++ b/components/package.json @@ -34,7 +34,7 @@ "metismenu": "~3.0.6", "moment": "^2.29.1", "morris.js": "morrisjs/morris.js", - "pdfmake": "^0.1.70", + "pdfmake": "^0.2.5", "startbootstrap-sb-admin-2": "1.0.7" }, "engines": { diff --git a/components/yarn.lock b/components/yarn.lock index 215ce4b1583..36f695c4aad 100644 --- a/components/yarn.lock +++ b/components/yarn.lock @@ -2,6 +2,46 @@ # yarn lockfile v1 +"@foliojs-fork/fontkit@^1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@foliojs-fork/fontkit/-/fontkit-1.9.1.tgz#8124649168eb5273f580f66697a139fb5041296b" + integrity sha512-U589voc2/ROnvx1CyH9aNzOQWJp127JGU1QAylXGQ7LoEAF6hMmahZLQ4eqAcgHUw+uyW4PjtCItq9qudPkK3A== + dependencies: + "@foliojs-fork/restructure" "^2.0.2" + brfs "^2.0.0" + brotli "^1.2.0" + browserify-optional "^1.0.1" + clone "^1.0.4" + deep-equal "^1.0.0" + dfa "^1.2.0" + tiny-inflate "^1.0.2" + unicode-properties "^1.2.2" + unicode-trie "^2.0.0" + +"@foliojs-fork/linebreak@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@foliojs-fork/linebreak/-/linebreak-1.1.1.tgz#93ecd695b7d2bb0334b9481058c3e610e019a4eb" + integrity sha512-pgY/+53GqGQI+mvDiyprvPWgkTlVBS8cxqee03ejm6gKAQNsR1tCYCIvN9FHy7otZajzMqCgPOgC4cHdt4JPig== + dependencies: + base64-js "1.3.1" + brfs "^2.0.2" + unicode-trie "^2.0.0" + +"@foliojs-fork/pdfkit@^0.13.0": + version "0.13.0" + resolved "https://registry.yarnpkg.com/@foliojs-fork/pdfkit/-/pdfkit-0.13.0.tgz#54f5368d8cf74d8edc81a175ccda1fd9655f2db9" + integrity sha512-YXeG1fml9k97YNC9K8e292Pj2JzGt9uOIiBFuQFxHsdQ45BlxW+JU3RQK6JAvXU7kjhjP8rCcYvpk36JLD33sQ== + dependencies: + "@foliojs-fork/fontkit" "^1.9.1" + "@foliojs-fork/linebreak" "^1.1.1" + crypto-js "^4.0.0" + png-js "^1.0.0" + +"@foliojs-fork/restructure@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@foliojs-fork/restructure/-/restructure-2.0.2.tgz#73759aba2aff1da87b7c4554e6839c70d43c92b4" + integrity sha512-59SgoZ3EXbkfSX7b63tsou/SDGzwUEK6MuB5sKqgVK1/XE0fxmpsOb9DQI8LXW3KfGnAjImCGhhEb7uPPAUVNA== + JUMFlot@jumjum123/JUMFlot#*: version "0.0.0" resolved "https://codeload.github.com/jumjum123/JUMFlot/tar.gz/203147fa2ace27db89e2defcde0800654015ae23" @@ -49,20 +89,7 @@ ast-types@^0.7.0: resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.7.8.tgz#902d2e0d60d071bdcd46dc115e1809ed11c138a9" integrity sha1-kC0uDWDQcb3NRtwRXhgJ7RHBOKk= -babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -base64-js@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" - integrity sha1-EQHpVE9KdrG8OybUUsqW16NeeXg= - -base64-js@^1.1.2, base64-js@^1.3.0: +base64-js@1.3.1, base64-js@^1.1.2, base64-js@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== @@ -114,7 +141,7 @@ browser-resolve@^1.8.1: dependencies: resolve "1.1.7" -browserify-optional@^1.0.0, browserify-optional@^1.0.1: +browserify-optional@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/browserify-optional/-/browserify-optional-1.0.1.tgz#1e13722cfde0d85f121676c2a72ced533a018869" integrity sha1-HhNyLP3g2F8SFnbCpyztUzoBiGk= @@ -190,20 +217,15 @@ convert-source-map@^1.5.1: dependencies: safe-buffer "~5.1.1" -core-js@^2.4.0: - version "2.6.11" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c" - integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== - core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -crypto-js@^3.1.9-1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" - integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== +crypto-js@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf" + integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw== d@1, d@^1.0.1: version "1.0.1" @@ -541,23 +563,6 @@ font-awesome@~4.4: resolved "https://registry.yarnpkg.com/font-awesome/-/font-awesome-4.4.0.tgz#9fe43f82cf72726badcbdb2704407aadaca17da9" integrity sha1-n+Q/gs9ycmuty9snBEB6rayhfak= -fontkit@^1.8.0: - version "1.8.1" - resolved "https://registry.yarnpkg.com/fontkit/-/fontkit-1.8.1.tgz#ae77485376f1096b45548bf6ced9a07af62a7846" - integrity sha512-BsNCjDoYRxmNWFdAuK1y9bQt+igIxGtTC9u/jSFjR9MKhmI00rP1fwSvERt+5ddE82544l0XH5mzXozQVUy2Tw== - dependencies: - babel-runtime "^6.26.0" - brfs "^2.0.0" - brotli "^1.2.0" - browserify-optional "^1.0.1" - clone "^1.0.4" - deep-equal "^1.0.0" - dfa "^1.2.0" - restructure "^0.5.3" - tiny-inflate "^1.0.2" - unicode-properties "^1.2.2" - unicode-trie "^0.3.0" - fullcalendar@^3.10.2: version "3.10.2" resolved "https://registry.yarnpkg.com/fullcalendar/-/fullcalendar-3.10.2.tgz#9b1ba84bb02803621b761d1bba91a4f18affafb7" @@ -597,10 +602,10 @@ has@^1.0.1, has@^1.0.3: dependencies: function-bind "^1.1.1" -iconv-lite@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01" - integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ== +iconv-lite@^0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== dependencies: safer-buffer ">= 2.1.2 < 3.0.0" @@ -711,15 +716,6 @@ lie@~3.3.0: dependencies: immediate "~3.0.5" -linebreak@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/linebreak/-/linebreak-1.0.2.tgz#4b5781733e9a9eb2849dba2f963e47c887f8aa06" - integrity sha512-bJwSRsJeAmaZYnkcwl5sCQNfSDAhBuXxb6L27tb+qkBRtUQSSTUa5bcgCPD6hFEkRNlpWHfK7nFMmcANU7ZP1w== - dependencies: - base64-js "0.0.8" - brfs "^2.0.2" - unicode-trie "^1.0.0" - magic-string@0.25.1: version "0.25.1" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.1.tgz#b1c248b399cd7485da0fe7385c2fc7011843266e" @@ -818,25 +814,14 @@ path-parse@^1.0.6: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== -pdfkit@>=0.8.1, pdfkit@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/pdfkit/-/pdfkit-0.11.0.tgz#9cdb2fc42bd2913587fe3ddf48cc5bbb3c36f7de" - integrity sha512-1s9gaumXkYxcVF1iRtSmLiISF2r4nHtsTgpwXiK8Swe+xwk/1pm8FJjYqN7L3x13NsWnGyUFntWcO8vfqq+wwA== - dependencies: - crypto-js "^3.1.9-1" - fontkit "^1.8.0" - linebreak "^1.0.2" - png-js "^1.0.0" - -pdfmake@^0.1.70: - version "0.1.70" - resolved "https://registry.yarnpkg.com/pdfmake/-/pdfmake-0.1.70.tgz#b5102799deef264defa675dbb2dbf12ad49a9bae" - integrity sha512-xPhkblaQ71U97qhRTPj/1HknAHHFZ3cPRmRdrqEWD2xXBcEjEM3Yw0MIjML8DRy9Dt9n6QRjHVf662f0eLtd7Q== +pdfmake@^0.2.5: + version "0.2.6" + resolved "https://registry.yarnpkg.com/pdfmake/-/pdfmake-0.2.6.tgz#322d6ef94e2503d29353529286e452c801921966" + integrity sha512-gZARnKLJjTuHWKIkqF4G6dafIaPfH7NFqBz9U9wb26PV5koHQ5eeQ/0rgZmIdfJzMKqHzXB9aK25ykG2AnnzEQ== dependencies: - iconv-lite "^0.6.2" - linebreak "^1.0.2" - pdfkit "^0.11.0" - svg-to-pdfkit "^0.1.8" + "@foliojs-fork/linebreak" "^1.1.1" + "@foliojs-fork/pdfkit" "^0.13.0" + iconv-lite "^0.6.3" xmldoc "^1.1.2" png-js@^1.0.0: @@ -883,11 +868,6 @@ readable-stream@^2.0.2, readable-stream@^2.2.2, readable-stream@~2.3.3, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - regexp.prototype.flags@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" @@ -908,13 +888,6 @@ resolve@^1.1.5: dependencies: path-parse "^1.0.6" -restructure@^0.5.3: - version "0.5.4" - resolved "https://registry.yarnpkg.com/restructure/-/restructure-0.5.4.tgz#f54e7dd563590fb34fd6bf55876109aeccb28de8" - integrity sha1-9U591WNZD7NP1r9Vh2EJrsyyjeg= - dependencies: - browserify-optional "^1.0.0" - safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -1035,13 +1008,6 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -svg-to-pdfkit@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/svg-to-pdfkit/-/svg-to-pdfkit-0.1.8.tgz#5921765922044843f0c1a5b25ec1ef8a4a33b8af" - integrity sha512-QItiGZBy5TstGy+q8mjQTMGRlDDOARXLxH+sgVm1n/LYeo0zFcQlcCh8m4zi8QxctrxB9Kue/lStc/RD5iLadQ== - dependencies: - pdfkit ">=0.8.1" - through2@^2.0.0, through2@~2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" @@ -1100,22 +1066,6 @@ unicode-properties@^1.2.2: base64-js "^1.3.0" unicode-trie "^2.0.0" -unicode-trie@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/unicode-trie/-/unicode-trie-0.3.1.tgz#d671dddd89101a08bac37b6a5161010602052085" - integrity sha1-1nHd3YkQGgi6w3tqUWEBBgIFIIU= - dependencies: - pako "^0.2.5" - tiny-inflate "^1.0.0" - -unicode-trie@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unicode-trie/-/unicode-trie-1.0.0.tgz#f649afdca127135edb55ca0ad7c8c60656d92ad1" - integrity sha512-v5raLKsobbFbWLMoX9+bChts/VhPPj3XpkNr/HbqkirXR1DPk8eo9IYKyvk0MQZFkaoRsFj2Rmaqgi2rfAZYtA== - dependencies: - pako "^0.2.5" - tiny-inflate "^1.0.0" - unicode-trie@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unicode-trie/-/unicode-trie-2.0.0.tgz#8fd8845696e2e14a8b67d78fa9e0dd2cad62fec8" diff --git a/dojo/fixtures/test_type.json b/dojo/fixtures/test_type.json index 9bd15d57837..110af14cc1d 100644 --- a/dojo/fixtures/test_type.json +++ b/dojo/fixtures/test_type.json @@ -641,14 +641,14 @@ "name": "AWS Security Hub Scan" }, "model": "dojo.test_type", - "pk": 183 + "pk": 183 }, { "fields": { "name": "Risk Recon API Importer" }, "model": "dojo.test_type", - "pk": 184 + "pk": 184 }, { "fields": { @@ -664,7 +664,7 @@ "model": "dojo.test_type", "pk": 186 }, - { + { "fields": { "name": "Semgrep JSON Report" }, @@ -701,8 +701,8 @@ }, { "fields": { - "name": "OssIndex Devaudit SCA Scan Importer" - }, + "name": "OssIndex Devaudit SCA Scan Importer" + }, "model": "dojo.test_type", "pk": 192 }, @@ -719,5 +719,12 @@ }, "model": "dojo.test_type", "pk": 194 + }, + { + "fields": { + "name": "IntSights" + }, + "model": "dojo.test_type", + "pk": 195 } -] +] \ No newline at end of file diff --git a/dojo/tools/intsights/__init__.py b/dojo/tools/intsights/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dojo/tools/intsights/parser.py b/dojo/tools/intsights/parser.py new file mode 100644 index 00000000000..1bd4d06cee2 --- /dev/null +++ b/dojo/tools/intsights/parser.py @@ -0,0 +1,95 @@ +import json +from urllib.parse import urlparse + +from dojo.models import Endpoint, Finding + + +class IntSightsParser(object): + """ + IntSights Threat Intelligence Feed + """ + + def get_scan_types(self): + return ["IntSights Scan"] + + def get_label_for_scan_types(self, scan_type): + return "IntSights Scan" + + def get_description_for_scan_types(self, scan_type): + return "IntSights report file can be imported in JSON format." + + def get_findings(self, file, test): + duplicates = dict() + data = file.read() + + try: + findings = json.loads(str(data, 'utf-8')) + except: + findings = json.loads(data) + + for finding in findings['Findings']: + unique_id_from_tool = finding['_id'] + title = finding['Details']['Title'] + description = f'{finding["Details"]["Description"]}' \ + f'\r\n\r\n----' \ + f'\r\n\r\n**Type**: {finding["Details"]["Type"]}' \ + f'\r\n**SubType**: {finding["Details"]["SubType"]}' \ + f'\r\n**Source**: {finding["Details"]["Source"]["URL"]}' \ + f'\r\n**Source Type**: {finding["Details"]["Source"]["Type"]}' \ + f'\r\n**Source Network Type**: {finding["Details"]["Source"]["NetworkType"]}' \ + f'\r\n\r\n----' \ + f'\r\n**Asset Type**: {finding["Assets"][0]["Type"]}' \ + f'\r\n\r\n----' \ + f'\r\n**Takedown Status**: {finding["TakedownStatus"]}' + severity = finding['Details']['Severity'] + mitigation = "N/A" + impact = "N/A" + references = finding["Details"]["Source"]["URL"] + output = "N/A" + active = False if finding['Closed']['IsClosed'] else True + try: + url = finding["Assets"][0]["Value"] + parsed_url = urlparse(url) + protocol = parsed_url.scheme + query = parsed_url.query + fragment = parsed_url.fragment + path = parsed_url.path + port = "" + try: + host, port = parsed_url.netloc.split(':') + except ValueError: + host = parsed_url.netloc + except: + url = None + + dupe_key = finding['_id'] + + if dupe_key in duplicates: + finding = duplicates[dupe_key] + duplicates[dupe_key] = finding + else: + duplicates[dupe_key] = True + + finding = Finding(title = title, + test = test, + active = active, + verified = True, + description = description, + severity = severity, + numerical_severity = Finding.get_numerical_severity(severity), + mitigation = mitigation, + impact = impact, + references = references, + static_finding = False, + dynamic_finding = True, + unique_id_from_tool = unique_id_from_tool) + finding.unsaved_endpoints = list() + duplicates[dupe_key] = finding + + if url is not None: + finding.unsaved_endpoints.append(Endpoint( + host = host, port = port, + path = path, + protocol = protocol, + query = query, fragment = fragment)) + return duplicates.values() diff --git a/dojo/unittests/scans/intsights/empty_with_error.json b/dojo/unittests/scans/intsights/empty_with_error.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/dojo/unittests/scans/intsights/empty_with_error.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/dojo/unittests/scans/intsights/intsights_many_vul.json b/dojo/unittests/scans/intsights/intsights_many_vul.json new file mode 100644 index 00000000000..36cb22dd4e3 --- /dev/null +++ b/dojo/unittests/scans/intsights/intsights_many_vul.json @@ -0,0 +1,135 @@ +{ + "Findings": [ + { + "_id": "5c45ebba3100d1000610f27f", + "Details": { + "Source": { + "URL": "https://www.initech.com/websec/?id=YuvecAXC", + "Date": "2019-01-21T15:55:19.270Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c45ebbc5df24f0006eeff6e", + "5c45ebbc05df870006a9523b", + "5c45ebbc1b2a9300068c0731" + ], + "Title": "HTTP headers weakness in initech-conferences.com web server", + "Tags": [ + { + "_id": "603582ded2320f0008ff0187", + "Name": "Pending", + "CreatedBy": "API" + }, + { + "_id": "603582fe1a64380007f745b5", + "Name": "ResID: 265711", + "CreatedBy": "API" + } + ], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-FRAME-OPTIONS, X-XSS-PROTECTION, X-CONTENT-TYPE-OPTIONS and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5d780124b92e7b0007108a60" + ], + "FoundDate": "2019-01-21T15:57:25.709Z", + "Assets": [ + { + "Type": "Domains", + "Value": "initech-conferences.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2021-02-23T22:34:37.669Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + }, + { + "_id": "5c80dbf83b4a3900078b6be6", + "Details": { + "Source": { + "URL": "https://www.initech.com/websec/?id=DSHv46Jg", + "Date": "2019-03-07T08:52:08.917Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c80dbfa3963a40007e01e8d", + "5c80dbfb3b4a3900078b6bea", + "5c80dbfc4626bd0007bd64db" + ], + "Title": "HTTP headers weakness in elsevier.com web server", + "Tags": [], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-XSS-PROTECTION and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5c3c8f64903dfd0006ge5e61" + ], + "FoundDate": "2019-03-08T13:03:30.655Z", + "Assets": [ + { + "Type": "Domains", + "Value": "initech.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2019-03-08T13:03:30.655Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + }, + { + "_id": "5c80dbg83b4a3900078b6be6", + "Details": { + "Source": { + "URL": "https://www.initech.com/websec/?id=DSHv46Jg", + "Date": "2019-03-07T08:52:08.917Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c80dbfa3963a40007e01e8d", + "5c80dbfb3b4a3900078b6bea", + "5c80dbfc4626bd0007bd64db" + ], + "Title": "HTTP headers weakness in elsevier.com web server", + "Tags": [], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-XSS-PROTECTION and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5c3c8f64903dfd0006ge5e61" + ], + "FoundDate": "2019-03-08T13:03:30.655Z", + "Assets": [ + { + "Type": "Domains", + "Value": "initech-test.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2019-03-08T13:03:30.655Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + } + ] +} \ No newline at end of file diff --git a/dojo/unittests/scans/intsights/intsights_one_vul.json b/dojo/unittests/scans/intsights/intsights_one_vul.json new file mode 100644 index 00000000000..d1087d5cbdb --- /dev/null +++ b/dojo/unittests/scans/intsights/intsights_one_vul.json @@ -0,0 +1,44 @@ +{ + "Findings": [ + { + "_id": "5c80dbf83b4a3900078b6be6", + "Details": { + "Source": { + "URL": "https://www.initech.com/websec/?id=DSHv46Jg", + "Date": "2019-03-07T08:52:08.917Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c80dbfa3963a40007e01e8d", + "5c80dbfb3b4a3900078b6bea", + "5c80dbfc4626bd0007bd64db" + ], + "Title": "HTTP headers weakness in elsevier.com web server", + "Tags": [], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-XSS-PROTECTION and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5c3c8f64903dfd0006ge5e61" + ], + "FoundDate": "2019-03-08T13:03:30.655Z", + "Assets": [ + { + "Type": "Domains", + "Value": "initech.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2019-03-08T13:03:30.655Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + } + ] +} \ No newline at end of file diff --git a/dojo/unittests/scans/intsights/intsights_zero_vul.json b/dojo/unittests/scans/intsights/intsights_zero_vul.json new file mode 100644 index 00000000000..59a819be51b --- /dev/null +++ b/dojo/unittests/scans/intsights/intsights_zero_vul.json @@ -0,0 +1 @@ +{"Findings": []} \ No newline at end of file diff --git a/dojo/unittests/tools/test_intsights_parser.py b/dojo/unittests/tools/test_intsights_parser.py new file mode 100644 index 00000000000..8a093b8591a --- /dev/null +++ b/dojo/unittests/tools/test_intsights_parser.py @@ -0,0 +1,50 @@ +from django.test import TestCase +from dojo.tools.intsights.parser import IntSightsParser +from dojo.models import Engagement, Product, Test + + +class TestIntSightsParser(TestCase): + def get_test(self): + test = Test() + test.engagement = Engagement() + test.engagement.product = Product() + return test + + def test_intsights_parser_without_file_has_no_findings(self): + parser = IntSightsParser() + findings = parser.get_findings(None, self.get_test()) + self.assertEqual(0, len(findings)) + + def test_intsights_parser_with_no_vuln_has_no_findings(self): + testfile = open("dojo/unittests/scans/intsights/intsights_zero_vul.json") + parser = IntSightsParser() + findings = parser.get_findings(testfile, self.get_test()) + testfile.close() + self.assertEqual(0, len(findings)) + + def test_intsights_parser_with_one_criticle_vuln_has_one_findings(self): + testfile = open("dojo/unittests/scans/intsights/intsights_one_vul.json") + parser = IntSightsParser() + findings = parser.get_findings(testfile, self.get_test()) + testfile.close() + self.assertEqual(1, len(findings)) + self.assertEqual("handlebars", findings[0].component_name) + self.assertEqual("4.5.2", findings[0].component_version) + + def test_intsights_parser_with_many_vuln_has_many_findings(self): + testfile = open("dojo/unittests/scans/intsights/intsights_many_vul.json") + parser = IntSightsParser() + findings = parser.get_findings(testfile, self.get_test()) + testfile.close() + self.assertEqual(3, len(findings)) + + def test_intsights_parser_empty_with_error(self): + with self.assertRaises(ValueError) as context: + testfile = open("dojo/unittests/scans/intsights/empty_with_error.json") + parser = IntSightsParser() + findings = parser.get_findings(testfile, self.get_test()) + testfile.close() + self.assertTrue( + "IntSights report contains errors:" in str(context.exception) + ) + self.assertTrue("ECONNREFUSED" in str(context.exception)) diff --git a/test.json b/test.json new file mode 100644 index 00000000000..0c382a4f634 --- /dev/null +++ b/test.json @@ -0,0 +1,95 @@ +{ + "Findings": [ + { + "_id": "5c45ebba3100d1000620f27f", + "Details": { + "Source": { + "URL": "https://www.htbridge.com/websec/?id=YuvecAXC", + "Date": "2019-01-21T15:55:19.270Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c45ebbc5df24f0006eeff6e", + "5c45ebbc05df870006a9523b", + "5c45ebbc1b2a9300068c0731" + ], + "Title": "HTTP headers weakness in lexisnexis-conferences.com web server", + "Tags": [ + { + "_id": "603582dad2320f0008ff0187", + "Name": "Pending", + "CreatedBy": "API" + }, + { + "_id": "603582fd1a64380007f745b5", + "Name": "ResID: 265711", + "CreatedBy": "API" + } + ], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-FRAME-OPTIONS, X-XSS-PROTECTION, X-CONTENT-TYPE-OPTIONS and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5d780134b92e7b0007108a60" + ], + "FoundDate": "2019-01-21T15:57:25.709Z", + "Assets": [ + { + "Type": "Domains", + "Value": "lexisnexis-conferences.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2021-02-23T22:34:37.669Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + }, + { + "_id": "5c80dbf83b4a3900078b6be7", + "Details": { + "Source": { + "URL": "https://www.htbridge.com/websec/?id=DSHv46Jg", + "Date": "2019-03-07T08:52:08.917Z", + "Type": "Other", + "NetworkType": "ClearWeb" + }, + "Images": [ + "5c80dbfa3963a40007e01e8d", + "5c80dbfb3b4a3900078b6bea", + "5c80dbfc4626bd0007bd64db" + ], + "Title": "HTTP headers weakness in elsevier.com web server", + "Tags": [], + "Type": "ExploitableData", + "Severity": "Medium", + "SubType": "VulnerabilityInTechnologyInUse", + "Description": "X-XSS-PROTECTION and CONTENT-SECURITY-POLICY headers were not sent by the server, which makes it vulnerable for various attack vectors" + }, + "Assignees": [ + "5c3c8f64903dfd0006fe7e61" + ], + "FoundDate": "2019-03-08T13:03:30.655Z", + "Assets": [ + { + "Type": "Domains", + "Value": "elsevier.com" + } + ], + "TakedownStatus": "NotSent", + "IsFlagged": false, + "UpdateDate": "2019-03-08T13:03:30.655Z", + "RelatedIocs": [], + "RelatedThreatIDs": [], + "Closed": { + "IsClosed": false + } + } + ] +} \ No newline at end of file