Skip to content

Commit 6e889ac

Browse files
committed
fix: add graphlib types
It was previously typed as any by mistake
1 parent 4befe57 commit 6e889ac

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/lib/plugins/convert-single-splugin-res-to-multi-custom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { legacyPlugin as pluginApi } from '@snyk/cli-interface';
22
import { MultiProjectResultCustom } from './get-multi-plugin-result';
33
import { SupportedPackageManagers } from '../package-managers';
4+
import { CallGraph } from '@snyk/cli-interface/legacy/common';
45

56
export function convertSingleResultToMultiCustom(
67
inspectRes: pluginApi.SinglePackageResult,
@@ -28,7 +29,7 @@ function convertDepGraphResult(
2829
{
2930
plugin: plugin as any,
3031
depGraph,
31-
callGraph,
32+
callGraph: callGraph as CallGraph,
3233
meta,
3334
targetFile: plugin.targetFile,
3435
packageManager,
@@ -63,7 +64,7 @@ function convertDepTreeResult(
6364
{
6465
plugin: plugin as any,
6566
depTree,
66-
callGraph,
67+
callGraph: callGraph as CallGraph,
6768
meta,
6869
targetFile: plugin.targetFile,
6970
packageManager,

src/lib/snyk-test/run-test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { validateOptions } from '../options-validator';
5757
import { findAndLoadPolicy } from '../policy';
5858
import { assembleIacLocalPayloads, parseIacTestResult } from './run-iac-test';
5959
import { Payload, PayloadBody, DepTreeFromResolveDeps } from './types';
60-
import { CallGraphError } from '@snyk/cli-interface/legacy/common';
60+
import { CallGraphError, CallGraph } from '@snyk/cli-interface/legacy/common';
6161
import * as alerts from '../alerts';
6262
import { abridgeErrorMessage } from '../error-format';
6363
import { getDockerToken } from '../api-token';
@@ -533,7 +533,10 @@ async function assembleLocalPayloads(
533533
body.depGraph = depGraph;
534534
}
535535

536-
if (options.reachableVulns && scannedProject.callGraph?.message) {
536+
if (
537+
options.reachableVulns &&
538+
(scannedProject.callGraph as CallGraphError)?.message
539+
) {
537540
const err = scannedProject.callGraph as CallGraphError;
538541
const analyticsError = err.innerError || err;
539542
analytics.add('callGraphError', {
@@ -555,7 +558,9 @@ async function assembleLocalPayloads(
555558
callGraph,
556559
nodeCount,
557560
edgeCount,
558-
} = serializeCallGraphWithMetrics(scannedProject.callGraph);
561+
} = serializeCallGraphWithMetrics(
562+
scannedProject.callGraph as CallGraph,
563+
);
559564
debug(
560565
`Adding call graph to payload, node count: ${nodeCount}, edge count: ${edgeCount}`,
561566
);

test/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { tmpdir } from 'os';
22
import { join } from 'path';
33
import { mkdir, readFileSync } from 'fs';
4-
import * as graphlib from '@snyk/graphlib';
4+
import * as graphlib from 'graphlib';
5+
import { CallGraph } from '@snyk/cli-interface/legacy/common';
56

67
export function silenceLog() {
78
const old = console.log;
@@ -52,6 +53,6 @@ export function loadJson(filename: string) {
5253
return JSON.parse(readFileSync(filename, 'utf-8'));
5354
}
5455

55-
export function createCallGraph(callGraphPayload: any): string | Buffer {
56+
export function createCallGraph(callGraphPayload: any): CallGraph {
5657
return graphlib.json.read(callGraphPayload);
5758
}

0 commit comments

Comments
 (0)