Skip to content

Commit

Permalink
feat: pass image id to snyk docker plugin
Browse files Browse the repository at this point in the history
When image id is available in workload metadata, we want snyk docker plugin to collect
image names as a new fact for populating in the container image store.
  • Loading branch information
ivanstanev authored and minsiyang committed Jan 12, 2023
1 parent 94ecbef commit 2f336de
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/scanner/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export async function scanImages(
const pluginResponse = await scan({
path: archivePath,
imageNameAndTag: imageName,
imageNameAndDigest: imageWithDigest,
});

if (
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function getUniqueImages(workloadMetadata: IWorkload[]): IScanImage[] {

accum[meta.imageName] = {
imageWithDigest: digest && `${imageName}@${digest}`,
imageName: meta.imageName, // Image name with tag
imageName: meta.imageName, // Image name with tag or digest, according to metadata image field declaration
skopeoRepoType: SkopeoRepositoryType.DockerArchive,
};

Expand Down
7 changes: 7 additions & 0 deletions test/system/kind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ test('Kubernetes-Monitor with KinD', async () => {
{ type: 'imageLayers', data: expect.any(Array) },
{ type: 'rootFs', data: expect.any(Array) },
{ type: 'imageOsReleasePrettyName', data: expect.any(String) },
{
type: 'imageNames',
data: [
'docker.io/library/openjdk:latest',
expect.stringContaining('docker.io/library/openjdk@sha256:'),
],
},
]),
target: { image: 'docker-image|docker.io/library/openjdk' },
identity: { type: 'rpm', args: { platform: 'linux/amd64' } },
Expand Down
2 changes: 1 addition & 1 deletion test/unit/scanner/images.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('getImageParts()', () => {
.imageName,
).toEqual('kind-registry:5000/python-27');
});
it('removed repository/image:tag contining dashes', () => {
it('removed repository/image:tag continuing dashes', () => {
expect(
scannerImages.getImageParts(
'kind-registry:5000/test/python-27:rc-buster',
Expand Down

0 comments on commit 2f336de

Please sign in to comment.