From f45e960cc1ea42d17124824edbcc24b3190fe715 Mon Sep 17 00:00:00 2001 From: Ed Date: Thu, 30 Nov 2023 12:17:06 -0500 Subject: [PATCH 1/5] INT-1150: Default to Shodan provided error message --- README.md | 4 +++- integration.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f008ef1..95dab79 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Polarity's Shodan integration gives users access to automated IPv4 and IPv6 lookups against the Shodan Host REST API. The Shodan REST API restricts searches to 1 per second. The integration will automatically throttle lookups to stay below this limit and will queue up to 15 search requests per API key. If the queue is full, you will receive back a response indicating that the queue is full and will have the option to rerun the search from the Overlay Window. +You must be using a paid Shodan Membership API key. + Please see [https://www.shodan.io/](https://www.shodan.io/) for more information. | ![image](assets/overlay.png) | @@ -14,7 +16,7 @@ Please see [https://www.shodan.io/](https://www.shodan.io/) for more information ### Shodan API Key -Your Shodan API Key. +Your Shodan API Key. This must be a paid membership API key. ## Installation Instructions diff --git a/integration.js b/integration.js index 206f37f..c5ea967 100644 --- a/integration.js +++ b/integration.js @@ -180,7 +180,7 @@ const requestEntity = (entity, requestOptions, callback) => }); } else { return callback({ - detail: 'Unexpected HTTP Status Received', + detail: body && body.error ? body.error : 'Unexpected HTTP Status Received', httpStatus: res.statusCode, body }); diff --git a/package-lock.json b/package-lock.json index 752bf3c..ba0ada2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "shodan", - "version": "3.4.4", + "version": "3.4.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 884e063..200a488 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shodan", - "version": "3.4.4", + "version": "3.4.5", "main": "./integration.js", "private": true, "dependencies": { From 8639126ceaeab45ce1da3b32f928dfe3083c81ee Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 6 Nov 2024 01:20:05 -0500 Subject: [PATCH 2/5] Bump dependencies and version --- package-lock.json | 34 +++++++++++++++++----------------- package.json | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index ba0ada2..3d44c21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "shodan", - "version": "3.4.5", + "version": "3.4.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -26,9 +26,9 @@ } }, "@postman/tunnel-agent": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/@postman/tunnel-agent/-/tunnel-agent-0.6.3.tgz", - "integrity": "sha512-k57fzmAZ2PJGxfOA4SGR05ejorHbVAa/84Hxh/2nAztjNXc4ZjOm9NUIk6/Z6LCrBvJZqjRZbN8e/nROVUPVdg==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/@postman/tunnel-agent/-/tunnel-agent-0.6.4.tgz", + "integrity": "sha512-CJJlq8V7rNKhAw4sBfjixKpJW00SHqebqNUQKxMoepgeWZIbdPcD+rguRcivGhS4N12PymDcKgUgSD4rVC+RjQ==", "requires": { "safe-buffer": "^5.0.1" } @@ -68,9 +68,9 @@ "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==" }, "aws4": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", - "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==" }, "base64-js": { "version": "1.5.1", @@ -275,13 +275,13 @@ "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, "postman-request": { - "version": "2.88.1-postman.33", - "resolved": "https://registry.npmjs.org/postman-request/-/postman-request-2.88.1-postman.33.tgz", - "integrity": "sha512-uL9sCML4gPH6Z4hreDWbeinKU0p0Ke261nU7OvII95NU22HN6Dk7T/SaVPaj6T4TsQqGKIFw6/woLZnH7ugFNA==", + "version": "2.88.1-postman.40", + "resolved": "https://registry.npmjs.org/postman-request/-/postman-request-2.88.1-postman.40.tgz", + "integrity": "sha512-uE4AiIqhjtHKp4pj9ei7fkdfNXEX9IqDBlK1plGAQne6y79UUlrTdtYLhwXoO0AMOvqyl9Ar+BU6Eo6P/MPgfg==", "requires": { "@postman/form-data": "~3.1.1", "@postman/tough-cookie": "~4.1.3-postman.1", - "@postman/tunnel-agent": "^0.6.3", + "@postman/tunnel-agent": "^0.6.4", "aws-sign2": "~0.7.0", "aws4": "^1.12.0", "brotli": "^1.3.3", @@ -309,9 +309,9 @@ "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, "punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==" }, "qs": { "version": "6.5.3", @@ -339,9 +339,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sshpk": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", - "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", + "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", diff --git a/package.json b/package.json index 200a488..af659c5 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "shodan", - "version": "3.4.5", + "version": "3.4.6", "main": "./integration.js", "private": true, "dependencies": { "bottleneck": "^2.19.5", "lodash": "^4.17.21", "memory-cache": "^0.2.0", - "postman-request": "^2.88.1-postman.33" + "postman-request": "^2.88.1-postman.40" } } From b4195fa70ed0ed1b185dce33458d807fd8c31b05 Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 6 Nov 2024 01:20:23 -0500 Subject: [PATCH 3/5] Default API key to admin only --- config/config.js | 4 ++-- config/config.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.js b/config/config.js index 286fb7f..b350f4a 100644 --- a/config/config.js +++ b/config/config.js @@ -84,8 +84,8 @@ module.exports = { description: 'Your Shodan API Key.', default: '', type: 'password', - userCanEdit: true, - adminOnly: false + userCanEdit: false, + adminOnly: true } ] }; diff --git a/config/config.json b/config/config.json index 8223e98..f4dc0a8 100644 --- a/config/config.json +++ b/config/config.json @@ -32,8 +32,8 @@ "description": "Your Shodan API Key.", "default": "", "type": "password", - "userCanEdit": true, - "adminOnly": false + "userCanEdit": false, + "adminOnly": true } ] } From ed31bbfc3cebf8136e83301d6c00e4a1ad43a76a Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 6 Nov 2024 05:41:21 -0500 Subject: [PATCH 4/5] Ensure results return when ignored IPs looked up --- integration.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/integration.js b/integration.js index c5ea967..904c3fb 100644 --- a/integration.js +++ b/integration.js @@ -31,6 +31,7 @@ const IGNORED_IPS = new Set(['127.0.0.1', '255.255.255.255', '0.0.0.0']); const MAX_FACET_RESULTS = 1000; function doLookup(entities, options, cb) { + const ignoredEntityResults = []; let limiter = bottlneckApiKeyCache.get(options.apiKey); if (!limiter) { @@ -47,9 +48,16 @@ function doLookup(entities, options, cb) { let requestResults = []; Logger.trace({ entities }, 'doLookup'); - const validEntities = entities.filter( - (entity) => !entity.isPrivateIP && !IGNORED_IPS.has(entity.value) - ); + const validEntities = entities.filter((entity) => { + if (entity.isPrivateIP || IGNORED_IPS.has(entity.value)) { + ignoredEntityResults.push({ + entity, + data: null + }); + return false; + } + return true; + }); let requestOptions; validEntities.forEach((entity) => { @@ -129,10 +137,14 @@ function doLookup(entities, options, cb) { }); Logger.trace({ lookupResults }, 'Lookup Results'); - cb(null, lookupResults); + cb(null, lookupResults.concat(ignoredEntityResults)); } }); }); + + if (validEntities.length === 0) { + cb(null, ignoredEntityResults); + } } const parseErrorToReadableJSON = (error) => From 9fdf574a0363e9c318f3724d8665f8db400cbf33 Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 6 Nov 2024 06:22:49 -0500 Subject: [PATCH 5/5] Set dev checklist container to rockylinux:8 --- .github/workflows/run-int-dev-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-int-dev-checklist.yml b/.github/workflows/run-int-dev-checklist.yml index ffa86d7..80e76bd 100644 --- a/.github/workflows/run-int-dev-checklist.yml +++ b/.github/workflows/run-int-dev-checklist.yml @@ -7,7 +7,7 @@ on: jobs: run-integration-development-checklist: runs-on: ubuntu-latest - container: 'centos:7' + container: 'rockylinux:8' steps: - uses: actions/checkout@v2