diff --git a/package.json b/package.json index 2a993b72f4..c1350820ed 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "proxy-from-env": "^1.0.0", "semver": "^6.0.0", "snyk-config": "3.1.1", - "snyk-cpp-plugin": "1.4.3", + "snyk-cpp-plugin": "1.5.0", "snyk-docker-plugin": "3.21.0", "snyk-go-plugin": "1.16.2", "snyk-gradle-plugin": "3.6.3", diff --git a/src/lib/ecosystems.ts b/src/lib/ecosystems.ts index 9b6e684c24..c5150a761b 100644 --- a/src/lib/ecosystems.ts +++ b/src/lib/ecosystems.ts @@ -50,6 +50,7 @@ export interface EcosystemPlugin { scanResults: ScanResult[], testResults: TestResult[], errors: string[], + options: Options, ) => Promise; } @@ -91,7 +92,12 @@ export async function testEcosystem( } const emptyResults: ScanResult[] = []; const scanResults = emptyResults.concat(...Object.values(scanResultsByPath)); - const readableResult = await plugin.display(scanResults, testResults, errors); + const readableResult = await plugin.display( + scanResults, + testResults, + errors, + options, + ); return TestCommandResult.createHumanReadableTestCommandResult( readableResult, diff --git a/src/lib/types.ts b/src/lib/types.ts index 7014706701..7d19a4cfd8 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -73,6 +73,7 @@ export interface Options { experimental?: boolean; // Used with the Docker plugin only. Allows application scanning. 'app-vulns'?: boolean; + debug?: boolean; } // TODO(kyegupov): catch accessing ['undefined-properties'] via noImplicitAny diff --git a/test/ecosystems.spec.ts b/test/ecosystems.spec.ts index f4aa8a64c7..9a7ecf4aa8 100644 --- a/test/ecosystems.spec.ts +++ b/test/ecosystems.spec.ts @@ -58,6 +58,7 @@ describe('ecosystems', () => { } const displayTxt = readFixture('display.txt'); + const debugDisplayTxt = readFixture('debug-display.txt'); const errorTxt = readFixture('error.txt'); const testResult = readJsonFixture( 'testResults.json', @@ -106,6 +107,22 @@ describe('ecosystems', () => { expect(actual).toEqual(expected); }); + it('should return fingerprints when debug option is set', async () => { + const mock = jest + .spyOn(request, 'makeRequest') + .mockResolvedValue(testResult); + const expected = TestCommandResult.createHumanReadableTestCommandResult( + debugDisplayTxt, + stringifyTestResults, + ); + const actual = await ecosystems.testEcosystem('cpp', ['.'], { + path: '', + debug: true, + }); + expect(mock).toHaveBeenCalled(); + expect(actual).toEqual(expected); + }); + it('should throw error when response code is not 200', async () => { const error = { code: 401, message: 'Invalid auth token' }; jest.spyOn(request, 'makeRequest').mockRejectedValue(error); diff --git a/test/fixtures/cpp-project/debug-display.txt b/test/fixtures/cpp-project/debug-display.txt new file mode 100644 index 0000000000..fbd51d94da --- /dev/null +++ b/test/fixtures/cpp-project/debug-display.txt @@ -0,0 +1,15 @@ +Fingerprints +52d1b046047db9ea0c581cafd4c68fe5 add.cpp +aeca71a6e39f99a24ecf4c088eee9cb8 add.h +ad3365b3370ef6b1c3e778f875055f19 main.cpp + +Dependencies +add@1.2.3 + +Issues +✗ Cross-site Scripting (XSS) [medium] + https://snyk.io/vuln/cpp:add:20161130 + in add@1.2.3 + fix version 1.2.4 + +Tested 1 dependency for known issues, found 1 issue. diff --git a/test/fixtures/cpp-project/display.txt b/test/fixtures/cpp-project/display.txt index fbd51d94da..bd3aaa6bab 100644 --- a/test/fixtures/cpp-project/display.txt +++ b/test/fixtures/cpp-project/display.txt @@ -1,8 +1,3 @@ -Fingerprints -52d1b046047db9ea0c581cafd4c68fe5 add.cpp -aeca71a6e39f99a24ecf4c088eee9cb8 add.h -ad3365b3370ef6b1c3e778f875055f19 main.cpp - Dependencies add@1.2.3 diff --git a/test/fixtures/cpp-project/error.txt b/test/fixtures/cpp-project/error.txt index c71f3d90ae..f02967e60a 100644 --- a/test/fixtures/cpp-project/error.txt +++ b/test/fixtures/cpp-project/error.txt @@ -1,7 +1,2 @@ -Fingerprints -52d1b046047db9ea0c581cafd4c68fe5 add.cpp -aeca71a6e39f99a24ecf4c088eee9cb8 add.h -ad3365b3370ef6b1c3e778f875055f19 main.cpp - Errors Could not test dependencies in .