Skip to content

Commit f0d777d

Browse files
authored
feat: override inline-scan-image option (#8)
1 parent e987fdd commit f0d777d

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ Additional parameters added to the secure-inline-scan container execution.
6666

6767
Additional parameters added to the docker command when executing the secure-inline-scan container execution.
6868

69+
### `inline-scan-image`
70+
71+
The image `quay.io/sysdig/secure-inline-scan:2` which points to the latest 2.x version of the Sysdig Secure inline scanner is used by default.
72+
This parameter allows overriding the default image, to use a specific version or for air-gapped environments.
73+
6974
## SARIF Report
7075

7176
The action generates a SARIF report that can be uploaded using the `codeql-action/upload-sarif` action.

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function parseActionInputs() {
3131
inputPath: core.getInput('input-path'),
3232
runAsUser: core.getInput('run-as-user'),
3333
extraParameters: core.getInput('extra-parameters'),
34-
extraDockerParameters: core.getInput('extra-docker-parameters')
34+
extraDockerParameters: core.getInput('extra-docker-parameters'),
35+
inlineScanImage: core.getInput('inline-scan-image'),
3536
}
3637
}
3738

@@ -129,8 +130,12 @@ async function run() {
129130
printOptions(opts);
130131
let flags = composeFlags(opts);
131132

132-
await pullScanImage(secureInlineScanImage);
133-
let scanResult = await executeInlineScan(secureInlineScanImage, flags.dockerFlags, flags.runFlags);
133+
let inlineScanImage = secureInlineScanImage;
134+
if (opts.inlineScanImage) {
135+
inlineScanImage = opts.inlineScanImage;
136+
}
137+
await pullScanImage(inlineScanImage);
138+
let scanResult = await executeInlineScan(inlineScanImage, flags.dockerFlags, flags.runFlags);
134139
let success = await processScanResult(scanResult);
135140
if (!(success || opts.ignoreFailedScan)) {
136141
core.setFailed(`Scan was FAILED.`)

tests/index.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe("input parsing", () => {
6262
"runAsUser": "",
6363
"sysdigSecureURL": "",
6464
"sysdigSkipTLS": false,
65+
"inlineScanImage": "",
6566
})
6667
})
6768

@@ -77,6 +78,7 @@ describe("input parsing", () => {
7778
process.env['INPUT_RUN-AS-USER'] = "user";
7879
process.env['INPUT_SYSDIG-SECURE-URL'] = "https://foo";
7980
process.env['INPUT_SYSDIG-SKIP-TLS'] = "true";
81+
process.env['INPUT_INLINE-SCAN-IMAGE'] = "my-custom-image:latest";
8082
let opts = index.parseActionInputs()
8183

8284
expect(opts).toEqual({
@@ -91,6 +93,7 @@ describe("input parsing", () => {
9193
"runAsUser": "user",
9294
"sysdigSecureURL": "https://foo",
9395
"sysdigSkipTLS": true,
96+
"inlineScanImage": "my-custom-image:latest",
9497
})
9598
})
9699

@@ -594,4 +597,18 @@ describe("run the full action", () => {
594597
expect(core.setFailed).toBeCalled();
595598
})
596599

600+
601+
it("allows override of inline-scan image", async () => {
602+
process.env['INPUT_INLINE-SCAN-IMAGE'] = "my-custom-image:latest";
603+
604+
exec.exec = jest.fn(() => {
605+
return Promise.resolve(0);
606+
});
607+
608+
await index.run();
609+
expect(exec.exec).toBeCalledTimes(2);
610+
expect(exec.exec).toBeCalledWith("docker pull my-custom-image:latest", null);
611+
expect(exec.exec).toBeCalledWith(expect.stringMatching(/docker run .* my-custom-image:latest/), null, expect.anything());
612+
})
613+
597614
})

0 commit comments

Comments
 (0)