diff --git a/lib/response-builder.ts b/lib/response-builder.ts index d4a11b62..dff7c353 100644 --- a/lib/response-builder.ts +++ b/lib/response-builder.ts @@ -200,6 +200,10 @@ async function buildResponse( facts: [depGraphFact, ...additionalFacts], target: { image: depGraph.rootPkg.name, + ...(options && + options["remote-repo-url"] && { + remoteUrl: options["remote-repo-url"], + }), }, identity: { type: depGraph.pkgManager.name, diff --git a/lib/types.ts b/lib/types.ts index 2b8ddcc1..3d1f22f1 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -104,6 +104,8 @@ export interface AutoDetectedUserInstructions { export interface ContainerTarget { image: string; + /** Set the remote URL for a container image image. */ + remoteUrl?: string; } /** @@ -228,6 +230,8 @@ export interface PluginOptions { /** The default is "false". */ "collect-application-files": boolean | string; "target-reference": string; + + "remote-repo-url": string; } export interface DepTreeDep { diff --git a/test/system/plugin-option.spec.ts b/test/system/plugin-option.spec.ts index 12108660..6a8fd621 100644 --- a/test/system/plugin-option.spec.ts +++ b/test/system/plugin-option.spec.ts @@ -60,3 +60,18 @@ it("provides imageName fact with imageNameAndDigest and imageNameAndTag scan opt ]), ); }); + +it("remoteUrl is set in ContainerTarget when remote-repo-url scan option is provided", async () => { + const fixturePath = getFixture(["/docker-archives", "alpine-arm64.tar"]); + const imagePath = `docker-archive:${fixturePath}`; + + const pluginResponse = await plugin.scan({ + path: imagePath, + "remote-repo-url": "https://github.com/org/my-repo-test", + }); + pluginResponse.scanResults.forEach((scanResult) => { + expect(scanResult.target.remoteUrl).toEqual( + "https://github.com/org/my-repo-test", + ); + }); +});