diff --git a/package.json b/package.json index cec7c1fdb78..1d846bddc17 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "proxy-from-env": "^1.0.0", "semver": "^6.0.0", "snyk-config": "3.1.0", - "snyk-cpp-plugin": "1.4.1", + "snyk-cpp-plugin": "1.4.3", "snyk-docker-plugin": "3.19.0", "snyk-go-plugin": "1.16.0", "snyk-gradle-plugin": "3.6.2", diff --git a/src/lib/ecosystems.ts b/src/lib/ecosystems.ts index 84ce38361ae..9b6e684c24d 100644 --- a/src/lib/ecosystems.ts +++ b/src/lib/ecosystems.ts @@ -6,6 +6,8 @@ import { isCI } from './is-ci'; import { makeRequest } from './request/promise'; import { Options } from './types'; import { TestCommandResult } from '../cli/commands/types'; +import * as spinner from '../lib/spinner'; + export interface Artifact { type: string; data: any; @@ -13,37 +15,35 @@ export interface Artifact { } export interface ScanResult { - type: string; artifacts: Artifact[]; meta: { [key: string]: any; }; } -export interface TestResult { - depGraph: DepGraphData; - affectedPkgs: { - [pkgId: string]: { - pkg: { - name: string; - version: string; - }; - issues: { - [issueId: string]: { - issueId: string; - }; - }; - }; +export interface Issue { + pkgName: string; + pkgVersion?: string; + issueId: string; + fixInfo: { + nearestFixedInVersion?: string; }; - issuesData: { - [issueId: string]: { - id: string; - severity: string; - title: string; - }; +} + +export interface IssuesData { + [issueId: string]: { + id: string; + severity: string; + title: string; }; } +export interface TestResult { + issues: Issue[]; + issuesData: IssuesData; + depGraphData: DepGraphData; +} + export interface EcosystemPlugin { scan: (options: Options) => Promise; display: ( @@ -84,7 +84,6 @@ export async function testEcosystem( const results = await plugin.scan(options); scanResultsByPath[path] = results; } - const [testResults, errors] = await testDependencies(scanResultsByPath); const stringifiedData = JSON.stringify(testResults, null, 2); if (options.json) { @@ -106,6 +105,7 @@ export async function testDependencies(scans: { const results: TestResult[] = []; const errors: string[] = []; for (const [path, scanResults] of Object.entries(scans)) { + await spinner(`Testing dependencies in ${path}`); for (const scanResult of scanResults) { const payload = { method: 'POST', @@ -116,7 +116,6 @@ export async function testDependencies(scans: { authorization: 'token ' + snyk.api, }, body: { - type: scanResult.type, artifacts: scanResult.artifacts, meta: {}, }, @@ -132,5 +131,6 @@ export async function testDependencies(scans: { } } } + spinner.clearAll(); return [results, errors]; } diff --git a/test/fixtures/cpp-project/display.txt b/test/fixtures/cpp-project/display.txt index 34dcc67e112..fbd51d94da4 100644 --- a/test/fixtures/cpp-project/display.txt +++ b/test/fixtures/cpp-project/display.txt @@ -1,15 +1,15 @@ -Dependency Fingerprints ------------------------ +Fingerprints 52d1b046047db9ea0c581cafd4c68fe5 add.cpp aeca71a6e39f99a24ecf4c088eee9cb8 add.h ad3365b3370ef6b1c3e778f875055f19 main.cpp -Dependencies ------------- +Dependencies add@1.2.3 -Issues ------- -Tested 1 dependency for known issues, found 1 issue. +Issues +✗ Cross-site Scripting (XSS) [medium] + https://snyk.io/vuln/cpp:add:20161130 + in add@1.2.3 + fix version 1.2.4 -✗ Cross-site Scripting (XSS) [medium severity][https://snyk.io/vuln/cpp:add:20161130] in add@1.2.3 +Tested 1 dependency for known issues, found 1 issue. diff --git a/test/fixtures/cpp-project/error.txt b/test/fixtures/cpp-project/error.txt index bf8246cacbe..c71f3d90aea 100644 --- a/test/fixtures/cpp-project/error.txt +++ b/test/fixtures/cpp-project/error.txt @@ -1,10 +1,7 @@ -Dependency Fingerprints ------------------------ +Fingerprints 52d1b046047db9ea0c581cafd4c68fe5 add.cpp aeca71a6e39f99a24ecf4c088eee9cb8 add.h ad3365b3370ef6b1c3e778f875055f19 main.cpp - -Errors ------- +Errors Could not test dependencies in . diff --git a/test/fixtures/cpp-project/testResults.json b/test/fixtures/cpp-project/testResults.json index 360767c7b2a..d8cc04050f1 100644 --- a/test/fixtures/cpp-project/testResults.json +++ b/test/fixtures/cpp-project/testResults.json @@ -1,17 +1,12 @@ { - "affectedPkgs": { - "add@1.2.3": { - "pkg": { - "name": "add", - "version": "1.2.3" - }, - "issues": { - "cpp:add:20161130": { - "issueId": "cpp:add:20161130" - } - } + "issues": [{ + "pkgName": "add", + "pkgVersion": "1.2.3", + "issueId": "cpp:add:20161130", + "fixInfo": { + "nearestFixedInVersion": "1.2.4" } - }, + }], "issuesData": { "cpp:add:20161130": { "id": "cpp:add:20161130", @@ -19,7 +14,7 @@ "title": "Cross-site Scripting (XSS)" } }, - "depGraph": { + "depGraphData": { "schemaVersion": "1.2.0", "pkgManager": { "name": "cpp"