From 6df207c74822d99b0217fe62ed54694daed0e81a Mon Sep 17 00:00:00 2001 From: Jannik Hollenbach Date: Fri, 23 Apr 2021 13:20:28 +0200 Subject: [PATCH 1/3] Try a jest retry lib --- .../hooks/finding-post-processing.test.js | 9 ++-- .../hooks/notification-hook.test.js | 49 ++++++++++-------- tests/integration/package-lock.json | 5 ++ tests/integration/package.json | 3 ++ tests/integration/scanner/amass.test.js | 17 ++++--- .../scanner/cascade-nmap-ncrack.test.js | 27 +++++----- .../scanner/cascade-nmap-sslyze.test.js | 11 ++-- .../scanner/git-repo-scanner.test.js | 18 ++++--- tests/integration/scanner/gitleaks.test.js | 40 ++++++++------- tests/integration/scanner/kube-hunter.test.js | 5 +- tests/integration/scanner/kubeaudit.test.js | 5 +- tests/integration/scanner/ncrack.test.js | 51 ++++++++++--------- tests/integration/scanner/nikto.test.js | 14 ++++- tests/integration/scanner/nmap.test.js | 21 ++++---- tests/integration/scanner/ssh-scan.test.js | 7 ++- tests/integration/scanner/sslyze.test.js | 8 ++- tests/integration/scanner/wpscan.test.js | 17 ++++--- tests/integration/scanner/zap.test.js | 5 +- 18 files changed, 188 insertions(+), 124 deletions(-) diff --git a/tests/integration/hooks/finding-post-processing.test.js b/tests/integration/hooks/finding-post-processing.test.js index c2fe9a0b37..73b18e34b0 100644 --- a/tests/integration/hooks/finding-post-processing.test.js +++ b/tests/integration/hooks/finding-post-processing.test.js @@ -1,7 +1,10 @@ -const { scan } = require('../helpers') +const retry = require("jest-retries"); -test( +const { scan } = require("../helpers"); + +retry( "Finding Post Processing after test-scan", + 3, async () => { const { severities, count } = await scan( "finding-post-processing", @@ -11,7 +14,7 @@ test( ); expect(count).toBe(2); - expect(severities.high).toBe(1) + expect(severities.high).toBe(1); }, 3 * 60 * 1000 ); diff --git a/tests/integration/hooks/notification-hook.test.js b/tests/integration/hooks/notification-hook.test.js index 08149336ef..e28d4cee10 100644 --- a/tests/integration/hooks/notification-hook.test.js +++ b/tests/integration/hooks/notification-hook.test.js @@ -1,15 +1,13 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -const k8s = require('@kubernetes/client-node'); +const k8s = require("@kubernetes/client-node"); -test( +retry( "should trigger notification", + 3, async () => { - await scan( - "test-scan-notification-web-hook", - "test-scan", - [], - 90 - ); + await scan("test-scan-notification-web-hook", "test-scan", [], 90); const WEBHOOK = "http-webhook"; const NAMESPACE = "integration-tests"; @@ -20,12 +18,12 @@ test( const k8sApi = kc.makeApiClient(k8s.CoreV1Api); function containsPod(item) { - return item.metadata.name.includes(WEBHOOK) + return item.metadata.name.includes(WEBHOOK); } let podName; - await k8sApi.listNamespacedPod(NAMESPACE, 'true').then((res) => { - let podArray = res.body.items.filter((containsPod)); + await k8sApi.listNamespacedPod(NAMESPACE, "true").then((res) => { + let podArray = res.body.items.filter(containsPod); if (podArray.length === 0) { throw new Error(`Did not find Pod for "${WEBHOOK}" Hook`); } @@ -39,26 +37,35 @@ test( k8sApi, podName, namespace: NAMESPACE, - containerName - } + containerName, + }; const result = await delayedRepeat(isHookTriggered, params, 1000, 10); - expect(result).toBe(true) + expect(result).toBe(true); }, 3 * 60 * 1000 ); async function isHookTriggered(params) { - console.log("Fetch Container Logs...") - let containerLog = await params.k8sApi.readNamespacedPodLog(params.podName, params.namespace, params.containerName, false); + console.log("Fetch Container Logs..."); + let containerLog = await params.k8sApi.readNamespacedPodLog( + params.podName, + params.namespace, + params.containerName, + false + ); return containerLog.body.includes("/slack-notification"); } +const sleep = (durationInMs) => + new Promise((resolve) => setTimeout(resolve, durationInMs)); -const sleep = durationInMs => - new Promise(resolve => setTimeout(resolve, durationInMs)); - -async function delayedRepeat(fun, functionParamObject, intervalInMs, maxRetries,) { +async function delayedRepeat( + fun, + functionParamObject, + intervalInMs, + maxRetries +) { for (let i = 0; i < maxRetries; i++) { const condition = await fun(functionParamObject); if (condition) { @@ -68,5 +75,5 @@ async function delayedRepeat(fun, functionParamObject, intervalInMs, maxRetries, await sleep(intervalInMs); } - throw new Error("Reached max retries") + throw new Error("Reached max retries"); } diff --git a/tests/integration/package-lock.json b/tests/integration/package-lock.json index f67276d08d..0f7f87b7de 100644 --- a/tests/integration/package-lock.json +++ b/tests/integration/package-lock.json @@ -2992,6 +2992,11 @@ "jest-snapshot": "^26.6.2" } }, + "jest-retries": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/jest-retries/-/jest-retries-1.0.1.tgz", + "integrity": "sha512-tR9tCXs9+Vqw/2toQEOg+CpzOwUqReppcZH2550EnuEhw4F8TR+NbICPUJexegjN9xnuF4ABSGPgzCgAFZI0Ng==" + }, "jest-runner": { "version": "26.6.3", "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-26.6.3.tgz", diff --git a/tests/integration/package.json b/tests/integration/package.json index 0056ce67e8..59f3cf3471 100644 --- a/tests/integration/package.json +++ b/tests/integration/package.json @@ -12,5 +12,8 @@ "@kubernetes/client-node": "^0.13.1", "jest": "^26.6.3", "prettier": "^2.2.1" + }, + "dependencies": { + "jest-retries": "^1.0.1" } } diff --git a/tests/integration/scanner/amass.test.js b/tests/integration/scanner/amass.test.js index 0992af1449..0a09917dad 100644 --- a/tests/integration/scanner/amass.test.js +++ b/tests/integration/scanner/amass.test.js @@ -1,12 +1,15 @@ -const {scan} = require('../helpers'); +const retry = require("jest-retries"); -test( - 'amass should find at least 20 subdomains', +const { scan } = require("../helpers"); + +retry( + "amass should find at least 20 subdomains", + 3, async () => { - const {count} = await scan( - 'amass-scanner-dummy-scan', - 'amass', - ['-passive', '-noalts', '-norecursive', '-d', 'owasp.org'], + const { count } = await scan( + "amass-scanner-dummy-scan", + "amass", + ["-passive", "-noalts", "-norecursive", "-d", "owasp.org"], 90 ); expect(count).toBeGreaterThanOrEqual(20); diff --git a/tests/integration/scanner/cascade-nmap-ncrack.test.js b/tests/integration/scanner/cascade-nmap-ncrack.test.js index b87c9df95c..a06901bffd 100644 --- a/tests/integration/scanner/cascade-nmap-ncrack.test.js +++ b/tests/integration/scanner/cascade-nmap-ncrack.test.js @@ -1,7 +1,10 @@ -const { cascadingScan } = require('../helpers') +const retry = require("jest-retries"); -test( +const { cascadingScan } = require("../helpers"); + +retry( "Cascading Scan nmap -> ncrack on dummy-ssh", + 3, async () => { const { categories, severities, count } = await cascadingScan( "nmap-dummy-ssh", @@ -11,23 +14,19 @@ test( nameCascade: "ncrack-ssh", matchLabels: { "securecodebox.io/invasive": "invasive", - "securecodebox.io/intensive": "high" - } + "securecodebox.io/intensive": "high", + }, }, 120 ); expect(count).toBe(1); - expect(categories).toEqual( - { - "Discovered Credentials": 1, - } - ); - expect(severities).toEqual( - { - "high": 1, - } - ); + expect(categories).toEqual({ + "Discovered Credentials": 1, + }); + expect(severities).toEqual({ + high: 1, + }); }, 3 * 60 * 1000 ); diff --git a/tests/integration/scanner/cascade-nmap-sslyze.test.js b/tests/integration/scanner/cascade-nmap-sslyze.test.js index 64175052ef..1012b7a13e 100644 --- a/tests/integration/scanner/cascade-nmap-sslyze.test.js +++ b/tests/integration/scanner/cascade-nmap-sslyze.test.js @@ -1,7 +1,10 @@ -const { cascadingScan } = require('../helpers') +const retry = require("jest-retries"); -test( +const { cascadingScan } = require("../helpers"); + +retry( "Cascading Scan nmap -> sslyze on unsafe-https", + 3, async () => { const { categories, severities, count } = await cascadingScan( "nmap-unsafe-https-sslyze", @@ -11,8 +14,8 @@ test( nameCascade: "https-tls-scan", matchLabels: { "securecodebox.io/invasive": "non-invasive", - "securecodebox.io/intensive": "light" - } + "securecodebox.io/intensive": "light", + }, }, 4 * 60 ); diff --git a/tests/integration/scanner/git-repo-scanner.test.js b/tests/integration/scanner/git-repo-scanner.test.js index 2bd74737db..7e16ffc7e9 100644 --- a/tests/integration/scanner/git-repo-scanner.test.js +++ b/tests/integration/scanner/git-repo-scanner.test.js @@ -1,14 +1,17 @@ -const {scan} = require('../helpers'); +const retry = require("jest-retries"); -test( - 'gitleaks should find at least 1 repository in the GitHub secureCodeBox organisation', +const { scan } = require("../helpers"); + +retry( + "gitleaks should find at least 1 repository in the GitHub secureCodeBox organisation", + 3, async () => { // This integration tests runs about 30min because of the GitHub Public API call rate limit. // If you want to speed up you need to add an valid access token like: ['--git-type', 'github', '--organization', 'secureCodeBox', '--access-token', '23476VALID2345TOKEN'], - const {count} = await scan( - 'git-repo-scanner-dummy-scan', - 'git-repo-scanner', - ['--git-type', 'github', '--organization', 'secureCodeBox'], + const { count } = await scan( + "git-repo-scanner-dummy-scan", + "git-repo-scanner", + ["--git-type", "github", "--organization", "secureCodeBox"], 90 ); // There must be >= 28 Repositories found in the GitHub secureCodeBox organisation. @@ -16,4 +19,3 @@ test( }, 3 * 60 * 1000 ); - diff --git a/tests/integration/scanner/gitleaks.test.js b/tests/integration/scanner/gitleaks.test.js index bcec05f123..5edcab9141 100644 --- a/tests/integration/scanner/gitleaks.test.js +++ b/tests/integration/scanner/gitleaks.test.js @@ -1,27 +1,31 @@ -const {scan} = require('../helpers'); +const retry = require("jest-retries"); -test( - 'gitleaks should find 1 credential in the testfiles', +const { scan } = require("../helpers"); + +retry( + "gitleaks should find 1 credential in the testfiles", + 3, async () => { - const {categories, severities, count} = await scan( - 'gitleaks-dummy-scan', - 'gitleaks', - ['-r', 'https://github.com/secureCodeBox/secureCodeBox', '--commit=ec0fe179ccf178b56fcd51d1730448bc64bb9ab5', '--config-path', '/home/config_all.toml'], + const { categories, severities, count } = await scan( + "gitleaks-dummy-scan", + "gitleaks", + [ + "-r", + "https://github.com/secureCodeBox/secureCodeBox", + "--commit=ec0fe179ccf178b56fcd51d1730448bc64bb9ab5", + "--config-path", + "/home/config_all.toml", + ], 90 ); expect(count).toBe(1); - expect(categories).toEqual( - { - 'Potential Secret': 1 - } - ); - expect(severities).toEqual( - { - 'high': 1 - } - ); + expect(categories).toEqual({ + "Potential Secret": 1, + }); + expect(severities).toEqual({ + high: 1, + }); }, 3 * 60 * 1000 ); - diff --git a/tests/integration/scanner/kube-hunter.test.js b/tests/integration/scanner/kube-hunter.test.js index 77a9dced83..18e80a97c6 100644 --- a/tests/integration/scanner/kube-hunter.test.js +++ b/tests/integration/scanner/kube-hunter.test.js @@ -1,7 +1,10 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -test( +retry( "kube-hunter should find a fixed number of findings for the kind cluster", + 3, async () => { await scan( "kube-hunter-in-cluster", diff --git a/tests/integration/scanner/kubeaudit.test.js b/tests/integration/scanner/kubeaudit.test.js index a4344c185b..e519bcac51 100644 --- a/tests/integration/scanner/kubeaudit.test.js +++ b/tests/integration/scanner/kubeaudit.test.js @@ -1,7 +1,10 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -test( +retry( "kubeaudit should run and check the jshop in kubeaudit-tests namespace", + 3, async () => { const { categories, severities } = await scan( "kubeaudit-tests", diff --git a/tests/integration/scanner/ncrack.test.js b/tests/integration/scanner/ncrack.test.js index 1d18612358..12178c048e 100644 --- a/tests/integration/scanner/ncrack.test.js +++ b/tests/integration/scanner/ncrack.test.js @@ -1,27 +1,30 @@ -const { scan } = require('../helpers') +const retry = require("jest-retries"); -test( - "ncrack should find 1 credential in vulnerable ssh service", - async () => { - const { categories, severities, count } = await scan( - "ncrack-dummy-ssh", - "ncrack", - ["-v","--user=root,admin", "--pass=THEPASSWORDYOUCREATED,12345", "ssh://dummy-ssh.demo-apps.svc"], - 90 - ); +const { scan } = require("../helpers"); - expect(count).toBe(1); - expect(categories).toEqual( - { - "Discovered Credentials": 1, - } - ); - expect(severities).toEqual( - { - "high": 1, - } - ); - }, - 3 * 60 * 1000 -); +retry( + "ncrack should find 1 credential in vulnerable ssh service", + 3, + async () => { + const { categories, severities, count } = await scan( + "ncrack-dummy-ssh", + "ncrack", + [ + "-v", + "--user=root,admin", + "--pass=THEPASSWORDYOUCREATED,12345", + "ssh://dummy-ssh.demo-apps.svc", + ], + 90 + ); + expect(count).toBe(1); + expect(categories).toEqual({ + "Discovered Credentials": 1, + }); + expect(severities).toEqual({ + high: 1, + }); + }, + 3 * 60 * 1000 +); diff --git a/tests/integration/scanner/nikto.test.js b/tests/integration/scanner/nikto.test.js index a8e09b4e5d..4deae7efb9 100644 --- a/tests/integration/scanner/nikto.test.js +++ b/tests/integration/scanner/nikto.test.js @@ -1,12 +1,22 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -test( +retry( "nikto scan against bodgeit demo-app", + 3, async () => { const { categories, severities, count } = await scan( "nikto-bodgeit", "nikto", - ["-h", "bodgeit.demo-apps.svc", "-port", "8080", "-Tuning", "1,2,3,5,7,b"], // See nikto bodgeit example + [ + "-h", + "bodgeit.demo-apps.svc", + "-port", + "8080", + "-Tuning", + "1,2,3,5,7,b", + ], // See nikto bodgeit example 90 ); diff --git a/tests/integration/scanner/nmap.test.js b/tests/integration/scanner/nmap.test.js index ebca1bb69f..3e98c48eeb 100644 --- a/tests/integration/scanner/nmap.test.js +++ b/tests/integration/scanner/nmap.test.js @@ -1,7 +1,10 @@ -const { scan } = require('../helpers') +const retry = require("jest-retries"); -test( +const { scan } = require("../helpers"); + +retry( "localhost port scan should only find a host finding", + 3, async () => { const { categories, severities, count } = await scan( "nmap-localhost", @@ -25,15 +28,15 @@ test( 3 * 60 * 1000 ); -test( +retry( "invalid port scan should be marked as errored", + 3, async () => { - await expect(scan( - "nmap-localhost", - "nmap", - ["-invalidFlag", "localhost"], - 90 - )).rejects.toThrow('Scan failed with description "Failed to run the Scan Container, check k8s Job and its logs for more details"'); + await expect( + scan("nmap-localhost", "nmap", ["-invalidFlag", "localhost"], 90) + ).rejects.toThrow( + 'Scan failed with description "Failed to run the Scan Container, check k8s Job and its logs for more details"' + ); }, 3 * 60 * 1000 ); diff --git a/tests/integration/scanner/ssh-scan.test.js b/tests/integration/scanner/ssh-scan.test.js index 94bbca67b2..145ed6d89a 100644 --- a/tests/integration/scanner/ssh-scan.test.js +++ b/tests/integration/scanner/ssh-scan.test.js @@ -1,8 +1,10 @@ +const retry = require("jest-retries"); // todo: Integrate into github ci pipeline const { scan } = require("../helpers"); -test( +retry( "ssh-scan should find a couple of findings for a dummy ssh service", + 3, async () => { const { categories, severities, count } = await scan( "ssh-scan-dummy-ssh", @@ -28,8 +30,9 @@ test( 3 * 60 * 1000 ); -test( +retry( "ssh-scan should gracefully handle a non-existing target", + 3, async () => { await expect( scan( diff --git a/tests/integration/scanner/sslyze.test.js b/tests/integration/scanner/sslyze.test.js index 55821b058d..1c04eaf6fa 100644 --- a/tests/integration/scanner/sslyze.test.js +++ b/tests/integration/scanner/sslyze.test.js @@ -1,7 +1,10 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -test( +retry( "Sslyze scans the self-signed unsafe-https demo-app", + 3, async () => { const { categories, severities, count } = await scan( "sslyze-unsafe-https", @@ -28,8 +31,9 @@ test( 3 * 60 * 1000 ); -test( +retry( "Invalid argument should be marked as errored", + 3, async () => { await expect( scan("sslyze-invalidArg", "sslyze", ["--invalidArg", "example.com"], 90) diff --git a/tests/integration/scanner/wpscan.test.js b/tests/integration/scanner/wpscan.test.js index 01e98b2ce8..d8c9d61aca 100644 --- a/tests/integration/scanner/wpscan.test.js +++ b/tests/integration/scanner/wpscan.test.js @@ -1,12 +1,15 @@ -const {scan} = require('../helpers'); +const retry = require("jest-retries"); -test( - 'WPScan should find at least 1 finding regarding the old-wordpress demo app', +const { scan } = require("../helpers"); + +retry( + "WPScan should find at least 1 finding regarding the old-wordpress demo app", + 3, async () => { - const {count} = await scan( - 'wpscan-scanner-dummy-scan', - 'wpscan', - ['--url', 'old-wordpress.demo-apps.svc'], + const { count } = await scan( + "wpscan-scanner-dummy-scan", + "wpscan", + ["--url", "old-wordpress.demo-apps.svc"], 90 ); expect(count).toBeGreaterThanOrEqual(1); diff --git a/tests/integration/scanner/zap.test.js b/tests/integration/scanner/zap.test.js index b9b712f50f..983c1b4932 100644 --- a/tests/integration/scanner/zap.test.js +++ b/tests/integration/scanner/zap.test.js @@ -1,7 +1,10 @@ +const retry = require("jest-retries"); + const { scan } = require("../helpers"); -test( +retry( "zap baseline scan against a plain nginx container should only find couple findings", + 3, async () => { const { categories, severities } = await scan( "zap-nginx-baseline", From b7289f9f3e032c2c6056677dd6803bfe39821220 Mon Sep 17 00:00:00 2001 From: Jannik Hollenbach Date: Fri, 23 Apr 2021 13:45:05 +0200 Subject: [PATCH 2/3] Vendor jest retry lib --- .../hooks/finding-post-processing.test.js | 2 +- .../hooks/notification-hook.test.js | 2 +- tests/integration/package-lock.json | 5 -- tests/integration/package.json | 3 -- tests/integration/retry.js | 46 +++++++++++++++++++ tests/integration/scanner/amass.test.js | 2 +- .../scanner/cascade-nmap-ncrack.test.js | 2 +- .../scanner/cascade-nmap-sslyze.test.js | 2 +- .../scanner/git-repo-scanner.test.js | 2 +- tests/integration/scanner/gitleaks.test.js | 2 +- tests/integration/scanner/kube-hunter.test.js | 2 +- tests/integration/scanner/kubeaudit.test.js | 2 +- tests/integration/scanner/ncrack.test.js | 2 +- tests/integration/scanner/nikto.test.js | 2 +- tests/integration/scanner/nmap.test.js | 2 +- tests/integration/scanner/ssh-scan.test.js | 2 +- tests/integration/scanner/sslyze.test.js | 2 +- tests/integration/scanner/wpscan.test.js | 2 +- tests/integration/scanner/zap.test.js | 2 +- 19 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 tests/integration/retry.js diff --git a/tests/integration/hooks/finding-post-processing.test.js b/tests/integration/hooks/finding-post-processing.test.js index 73b18e34b0..bd416bead4 100644 --- a/tests/integration/hooks/finding-post-processing.test.js +++ b/tests/integration/hooks/finding-post-processing.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/hooks/notification-hook.test.js b/tests/integration/hooks/notification-hook.test.js index e28d4cee10..673e18ee2c 100644 --- a/tests/integration/hooks/notification-hook.test.js +++ b/tests/integration/hooks/notification-hook.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); const k8s = require("@kubernetes/client-node"); diff --git a/tests/integration/package-lock.json b/tests/integration/package-lock.json index 0f7f87b7de..f67276d08d 100644 --- a/tests/integration/package-lock.json +++ b/tests/integration/package-lock.json @@ -2992,11 +2992,6 @@ "jest-snapshot": "^26.6.2" } }, - "jest-retries": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/jest-retries/-/jest-retries-1.0.1.tgz", - "integrity": "sha512-tR9tCXs9+Vqw/2toQEOg+CpzOwUqReppcZH2550EnuEhw4F8TR+NbICPUJexegjN9xnuF4ABSGPgzCgAFZI0Ng==" - }, "jest-runner": { "version": "26.6.3", "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-26.6.3.tgz", diff --git a/tests/integration/package.json b/tests/integration/package.json index 59f3cf3471..0056ce67e8 100644 --- a/tests/integration/package.json +++ b/tests/integration/package.json @@ -12,8 +12,5 @@ "@kubernetes/client-node": "^0.13.1", "jest": "^26.6.3", "prettier": "^2.2.1" - }, - "dependencies": { - "jest-retries": "^1.0.1" } } diff --git a/tests/integration/retry.js b/tests/integration/retry.js new file mode 100644 index 0000000000..6740a38e9e --- /dev/null +++ b/tests/integration/retry.js @@ -0,0 +1,46 @@ +function runTest(handler) { + return new Promise((resolve, reject) => { + const result = handler((err) => (err ? reject(err) : resolve())); + + if (result && result.then) { + result.catch(reject).then(resolve); + } else { + resolve(); + } + }); +} + +async function retry(description, retries, handler, ...args) { + if (!description || typeof description !== "string") { + throw new Error("Invalid argument, description must be a string"); + } + + if (typeof retries === "function" && !handler) { + handler = retries; + retries = 1; + } + + if (!retries || typeof retries !== "number" || retries < 1) { + throw new Error("Invalid argument, retries must be a greather than 0"); + } + + test( + description, + async () => { + let latestError; + for (let tries = 0; tries < retries; tries++) { + try { + await runTest(handler); + return; + } catch (error) { + latestError = error; + } + } + + throw latestError; + }, + ...args + ); +} + +module.exports = retry; diff --git a/tests/integration/scanner/amass.test.js b/tests/integration/scanner/amass.test.js index 0a09917dad..6291523f45 100644 --- a/tests/integration/scanner/amass.test.js +++ b/tests/integration/scanner/amass.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/cascade-nmap-ncrack.test.js b/tests/integration/scanner/cascade-nmap-ncrack.test.js index a06901bffd..65ca69be05 100644 --- a/tests/integration/scanner/cascade-nmap-ncrack.test.js +++ b/tests/integration/scanner/cascade-nmap-ncrack.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { cascadingScan } = require("../helpers"); diff --git a/tests/integration/scanner/cascade-nmap-sslyze.test.js b/tests/integration/scanner/cascade-nmap-sslyze.test.js index 1012b7a13e..be8a8f14df 100644 --- a/tests/integration/scanner/cascade-nmap-sslyze.test.js +++ b/tests/integration/scanner/cascade-nmap-sslyze.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { cascadingScan } = require("../helpers"); diff --git a/tests/integration/scanner/git-repo-scanner.test.js b/tests/integration/scanner/git-repo-scanner.test.js index 7e16ffc7e9..3f03eafe7d 100644 --- a/tests/integration/scanner/git-repo-scanner.test.js +++ b/tests/integration/scanner/git-repo-scanner.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/gitleaks.test.js b/tests/integration/scanner/gitleaks.test.js index 5edcab9141..2809c09e8b 100644 --- a/tests/integration/scanner/gitleaks.test.js +++ b/tests/integration/scanner/gitleaks.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/kube-hunter.test.js b/tests/integration/scanner/kube-hunter.test.js index 18e80a97c6..8ebd992506 100644 --- a/tests/integration/scanner/kube-hunter.test.js +++ b/tests/integration/scanner/kube-hunter.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/kubeaudit.test.js b/tests/integration/scanner/kubeaudit.test.js index e519bcac51..8609af6135 100644 --- a/tests/integration/scanner/kubeaudit.test.js +++ b/tests/integration/scanner/kubeaudit.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/ncrack.test.js b/tests/integration/scanner/ncrack.test.js index 12178c048e..60fb2a8ff5 100644 --- a/tests/integration/scanner/ncrack.test.js +++ b/tests/integration/scanner/ncrack.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/nikto.test.js b/tests/integration/scanner/nikto.test.js index 4deae7efb9..88912a1267 100644 --- a/tests/integration/scanner/nikto.test.js +++ b/tests/integration/scanner/nikto.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/nmap.test.js b/tests/integration/scanner/nmap.test.js index 3e98c48eeb..a68d55dfb6 100644 --- a/tests/integration/scanner/nmap.test.js +++ b/tests/integration/scanner/nmap.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/ssh-scan.test.js b/tests/integration/scanner/ssh-scan.test.js index 145ed6d89a..f2f51cbc54 100644 --- a/tests/integration/scanner/ssh-scan.test.js +++ b/tests/integration/scanner/ssh-scan.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); // todo: Integrate into github ci pipeline const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/sslyze.test.js b/tests/integration/scanner/sslyze.test.js index 1c04eaf6fa..87882143ed 100644 --- a/tests/integration/scanner/sslyze.test.js +++ b/tests/integration/scanner/sslyze.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/wpscan.test.js b/tests/integration/scanner/wpscan.test.js index d8c9d61aca..4150b27a55 100644 --- a/tests/integration/scanner/wpscan.test.js +++ b/tests/integration/scanner/wpscan.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); diff --git a/tests/integration/scanner/zap.test.js b/tests/integration/scanner/zap.test.js index 983c1b4932..b32c2451be 100644 --- a/tests/integration/scanner/zap.test.js +++ b/tests/integration/scanner/zap.test.js @@ -1,4 +1,4 @@ -const retry = require("jest-retries"); +const retry = require("../retry"); const { scan } = require("../helpers"); From 5931c697cbdf5b4daa6776d9af9529d7b2275e96 Mon Sep 17 00:00:00 2001 From: Jannik Hollenbach Date: Fri, 23 Apr 2021 14:45:46 +0200 Subject: [PATCH 3/3] Add note about vendored lib --- tests/integration/retry.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/retry.js b/tests/integration/retry.js index 6740a38e9e..78e2a47f56 100644 --- a/tests/integration/retry.js +++ b/tests/integration/retry.js @@ -1,3 +1,6 @@ +// Vendored from https://www.npmjs.com/package/jest-retries MIT License +// Includes adjustments to pass in timeout values to the underlying jest test function + function runTest(handler) { return new Promise((resolve, reject) => { const result = handler((err) => (err ? reject(err) : resolve()));