Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/response-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export interface AutoDetectedUserInstructions {

export interface ContainerTarget {
image: string;
/** Set the remote URL for a container image image. */
remoteUrl?: string;
}

/**
Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions test/system/plugin-option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
});
});