Skip to content

Commit 802479f

Browse files
adrobutagergo-papp
authored andcommitted
feat: add support for remote-repo-url UNIFY-506
1 parent 5da0b11 commit 802479f

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

lib/response-builder.ts

Lines changed: 7 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+
remoteUrl?: string | undefined,
2324
): Promise<types.PluginResponse> {
2425
const deps = depsAnalysis.depTree.dependencies;
2526
const dockerfilePkgs = collectDockerfilePkgs(dockerfileAnalysis, deps);
@@ -208,6 +209,12 @@ async function buildResponse(
208209
...applicationDependenciesScanResults,
209210
];
210211

212+
if (remoteUrl) {
213+
scanResults.forEach((scanResult) => {
214+
scanResult.target.remoteUrl = remoteUrl;
215+
});
216+
}
217+
211218
return {
212219
scanResults,
213220
};

lib/static.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ export async function analyzeStatically(
6666
});
6767
}
6868

69+
const remoteUrl = options["remote-repo-url"];
70+
6971
return buildResponse(
7072
analysis,
7173
dockerfileAnalysis,
7274
excludeBaseImageVulns,
7375
names,
7476
ociDistributionMetadata,
77+
remoteUrl,
7578
);
7679
}

lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export interface AutoDetectedUserInstructions {
102102

103103
export interface ContainerTarget {
104104
image: string;
105+
/** Set the remote URL for a container image image. */
106+
remoteUrl?: string;
105107
}
106108

107109
/**
@@ -225,6 +227,8 @@ export interface PluginOptions {
225227

226228
/** The default is "false". */
227229
"collect-application-files": boolean | string;
230+
231+
"remote-repo-url"?: string;
228232
}
229233

230234
export interface DepTreeDep {

test/system/plugin-option.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@ it("provides imageName fact with imageNameAndDigest and imageNameAndTag scan opt
6060
]),
6161
);
6262
});
63+
64+
it("remoteUrl is set in ContainerTarget when remote-repo-url scan option is provided", async () => {
65+
const fixturePath = getFixture(["/docker-archives", "alpine-arm64.tar"]);
66+
const imagePath = `docker-archive:${fixturePath}`;
67+
68+
const pluginResponse = await plugin.scan({
69+
path: imagePath,
70+
"remote-repo-url": "https://github.com/org/my-repo-test",
71+
});
72+
pluginResponse.scanResults.forEach((scanResult) => {
73+
expect(scanResult.target.remoteUrl).toEqual(
74+
"https://github.com/org/my-repo-test",
75+
);
76+
});
77+
});

0 commit comments

Comments
 (0)