8000 Adding integration tests for trivy security scanner by SebieF · Pull Request #650 · secureCodeBox/secureCodeBox · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,19 @@ jobs:
cd tests/integration/
npx jest --ci --color scanner/sslyze.test.js

# ---- Trivy Integration Tests ----

- name: "trivy Integration Tests"
run: |
kubectl -n integration-tests delete scans --all
helm -n integration-tests install trivy ./scanners/trivy/ \
--set="parser.image.tag=sha-$(git rev-parse --short HEAD)" \
--set="parser.image.repository=docker.io/${{ env.DOCKER_NAMESPACE }}/parser-trivy" \
--set="parser.env[0].name=CRASH_ON_FAILED_VALIDATION" \
--set-string="parser.env[0].value=true"
cd tests/integration/
npx jest --ci --color scanner/trivy.test.js

# ---- Typo3scan Integration Tests ----

- name: "typo3scan Integration Tests"
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/scanner/trivy.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2021 iteratec GmbH
//
// SPDX-License-Identifier: Apache-2.0

const { scan } = require("../helpers");

jest.retryTimes(3);

test(
"trivy scans vulnerable juiceshop demo target",
async () => {
const { categories, severities, count } = await scan(
"trivy-juice-shop",
"trivy",
["bkimminich/juice-shop:v10.2.0"],
90
);

expect(count).toBeGreaterThanOrEqual(134);
expect(categories["Image Vulnerability"]).toBeGreaterThanOrEqual(26);
expect(categories["NPM Package Vulnerability"]).toBeGreaterThanOrEqual(108);
expect(severities["high"]).toBeGreaterThanOrEqual(82);
expect(severities["medium"]).toBeGreaterThanOrEqual(47);
expect(severities["low"]).toBeGreaterThanOrEqual(5);
},
3 * 60 * 1000
);

test(
"Invalid argument should be marked as errored",
async () => {
await expect(
scan(
"trivy-invalidArg",
"trivy",
["--invalidArg", "not/a-valid-image:v0.0.0"],
90
)
).rejects.toThrow("HTTP request failed");
},
3 * 60 * 1000
);
0