Skip to content

Commit 74714da

Browse files
authored
Merge pull request #988 from snyk/fix/sanitize-workloadMetadata
RUN-1968 fix: sanitize workload metadata
2 parents 0d87a06 + 5084264 commit 74714da

File tree

4 files changed

+38
-24
lines changed

4 files changed

+38
-24
lines changed

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/supervisor/metadata-extractor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export function buildImageMetadata(
2424

2525
const containerNameToSpec: { [key: string]: V1Container } = {};
2626
for (const container of podSpec.containers) {
27+
delete container.args;
28+
delete container.env;
29+
delete container.command;
2730
containerNameToSpec[container.name] = container;
2831
}
2932

test/fixtures/sidecar-containers/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ spec:
4848
successThreshold: 1
4949
timeoutSeconds: 5
5050
name: hello-world
51+
args: [something]
52+
env:
53+
- name: NODE_EXTRA_CA_CERTS
54+
value: "important info"
55+
command:
56+
- "do something"
5157
ports:
5258
- containerPort: 8080
5359
name: http

test/unit/supervisor/metadata-extractor.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,10 @@ describe('metadata extractor tests', () => {
124124
imageName: 'eu.gcr.io/cookie/hello-world:1.20191125.132107-4664980',
125125
}),
126126
);
127+
const container = imageMetadataResult[0].podSpec.containers[0];
128+
129+
expect(container.args).toBeUndefined();
130+
expect(container.command).toBeUndefined();
131+
expect(container.env).toBeUndefined();
127132
});
128133
});

0 commit comments

Comments
 (0)