Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Detect app vulnerabilities in container scans #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions snykTask/src/__tests__/task-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ test('finds no issues in code test of high threshold', () => {
expect(itemsFound).toBe(false);
});

test('finds issues in container test of high threshold', () => {
const fixturePath = 'snykTask/test/fixtures/container-test-error-issues.json';
const itemsFound = doVulnerabilitiesExistForFailureThreshold(
fixturePath,
'high',
);

expect(itemsFound).toBe(true);
});

test('getOptionsToExecuteSnykCLICommand builds IExecOptions like we need it', () => {
const taskNameForAnalytics = 'AZURE_PIPELINES';
const version = '1.2.3';
Expand Down
7 changes: 7 additions & 0 deletions snykTask/src/task-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ function hasMatchingVulnerabilities(project: any, thresholdOrdinal: number) {
return true;
}
}
if (project['applications']) {
for (const application of project['applications']) {
if (hasMatchingVulnerabilities(application, thresholdOrdinal)) {
return true;
}
}
}
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions snykTask/test/fixtures/container-test-error-issues.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"vulnerabilities": [],
"ok": true,
"applications": [
{
"vulnerabilities": [
{
"severity": "critical"
}
]
}
]
}