Skip to content

Commit 80242c4

Browse files
authored
Merge pull request #649 from snyk/feat/add-target-reference-support-for-test
fix: add possible targetreference to plugin response
2 parents 3d0a5e7 + bf42a35 commit 80242c4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/response-builder.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function buildResponse(
2020
excludeBaseImageVulns: boolean,
2121
names?: string[],
2222
ociDistributionMetadata?: OCIDistributionMetadata,
23+
options?: Partial<types.PluginOptions>,
2324
): Promise<types.PluginResponse> {
2425
const deps = depsAnalysis.depTree.dependencies;
2526
const dockerfilePkgs = collectDockerfilePkgs(dockerfileAnalysis, deps);
@@ -204,6 +205,10 @@ async function buildResponse(
204205
type: depGraph.pkgManager.name,
205206
args,
206207
},
208+
...(options &&
209+
options["target-reference"] && {
210+
targetReference: options["target-reference"] ?? depGraph.rootPkg.name,
211+
}),
207212
},
208213
...applicationDependenciesScanResults,
209214
];

lib/static.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@ export async function analyzeStatically(
7272
excludeBaseImageVulns,
7373
names,
7474
ociDistributionMetadata,
75+
options,
7576
);
7677
}

lib/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export interface ScanResult {
9393
identity: Identity;
9494
/** Facts are the collection of things you found. */
9595
facts: Fact[];
96+
/** A reference for differentiating project versions, e.g., branch names, versions, etc. */
97+
targetReference?: string;
9698
}
9799

98100
export interface AutoDetectedUserInstructions {
@@ -225,6 +227,7 @@ export interface PluginOptions {
225227

226228
/** The default is "false". */
227229
"collect-application-files": boolean | string;
230+
"target-reference": string;
228231
}
229232

230233
export interface DepTreeDep {

0 commit comments

Comments
 (0)