Skip to content

Commit

Permalink
Merge pull request #1227 from snyk/feat/support-potentially-reachable
Browse files Browse the repository at this point in the history
feat: support potentially reachable on snyk test
  • Loading branch information
Dar Malovani committed Jun 22, 2020
2 parents 5aa1610 + e5efa7f commit d450573
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/cli/commands/test/formatters/format-reachability.ts
Expand Up @@ -8,15 +8,15 @@ const reachabilityLevels: {
} = {
[REACHABILITY.FUNCTION]: {
color: chalk.redBright,
text: 'Likely reachable',
text: 'Reachable',
},
[REACHABILITY.PACKAGE]: {
color: chalk.yellow,
text: '', // Not supported ATM
text: 'Potentially reachable',
},
[REACHABILITY.UNREACHABLE]: {
[REACHABILITY.NOT_REACHABLE]: {
color: chalk.blueBright,
text: 'Likely unreachable',
text: 'Not reachable',
},
[REACHABILITY.NO_INFO]: {
color: (str) => str,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/legacy.ts
Expand Up @@ -24,7 +24,7 @@ export enum SEVERITY {
export enum REACHABILITY {
FUNCTION = 'function',
PACKAGE = 'package',
UNREACHABLE = 'unreachable',
NOT_REACHABLE = 'not-reachable',
NO_INFO = 'no-info',
}

Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/display-test-results.test.ts
Expand Up @@ -108,7 +108,7 @@ test('test reachability info is displayed', async (t) => {
message,
' In addition, found 1 vulnerability with a reachable path.',
);
t.match(message, '[Likely reachable]');
t.match(message, '[Reachable]');
}

snykTestStub.restore();
Expand Down
20 changes: 10 additions & 10 deletions test/reachable-vulns.test.ts
Expand Up @@ -19,18 +19,18 @@ import * as featureFlags from '../src/lib/feature-flags';
import * as utils from './utils';

test('output formatting', (t) => {
t.equal(formatReachability(REACHABILITY.FUNCTION), '[Likely reachable]');
t.equal(formatReachability(REACHABILITY.PACKAGE), '');
t.equal(formatReachability(REACHABILITY.UNREACHABLE), '[Likely unreachable]');
t.equal(formatReachability(REACHABILITY.FUNCTION), '[Reachable]');
t.equal(formatReachability(REACHABILITY.PACKAGE), '[Potentially reachable]');
t.equal(formatReachability(REACHABILITY.NOT_REACHABLE), '[Not reachable]');
t.equal(formatReachability(REACHABILITY.NO_INFO), '');
t.equal(formatReachability(undefined), '');
t.end();
});

test('reachable text', (t) => {
t.equal(getReachabilityText(REACHABILITY.FUNCTION), 'Likely reachable');
t.equal(getReachabilityText(REACHABILITY.PACKAGE), '');
t.equal(getReachabilityText(REACHABILITY.UNREACHABLE), 'Likely unreachable');
t.equal(getReachabilityText(REACHABILITY.FUNCTION), 'Reachable');
t.equal(getReachabilityText(REACHABILITY.PACKAGE), 'Potentially reachable');
t.equal(getReachabilityText(REACHABILITY.NOT_REACHABLE), 'Not reachable');
t.equal(getReachabilityText(REACHABILITY.NO_INFO), '');
t.equal(getReachabilityText(undefined), '');
t.end();
Expand All @@ -39,8 +39,8 @@ test('reachable text', (t) => {
test('formatReachabilitySummaryText', (t) => {
const noReachabilityMetadata = {} as AnnotatedIssue;
const noInfoVuln = { reachability: REACHABILITY.NO_INFO } as AnnotatedIssue;
const unreachableVuln = {
reachability: REACHABILITY.UNREACHABLE,
const notReachableVuln = {
reachability: REACHABILITY.NOT_REACHABLE,
} as AnnotatedIssue;
const reachableByPackageVuln = {
reachability: REACHABILITY.PACKAGE,
Expand Down Expand Up @@ -68,9 +68,9 @@ test('formatReachabilitySummaryText', (t) => {
);

t.equal(
summariseReachableVulns([unreachableVuln]),
summariseReachableVulns([notReachableVuln]),
'',
'unreachable is not implemented yet, should not display anything',
'not reachable is not implemented yet, should not display anything',
);

t.equal(
Expand Down

0 comments on commit d450573

Please sign in to comment.