@docupace/pipeline 1.0.123-xray.1 → 1.0.123-xray.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tenable-scan.sh +12 -3
- package/package.json +1 -1
- package/src/tenable/docker.js +9 -2
- package/src/tenable/scan.js +4 -0
- package/src/tenable/scan.test.js +22 -0
package/bin/tenable-scan.sh
CHANGED
|
@@ -119,8 +119,8 @@ scan_one() {
|
|
|
119
119
|
"--code-commit-hash" "${COMMIT}"
|
|
120
120
|
"--code-commit-user" "${CODE_USER}"
|
|
121
121
|
"--code-repository-url" "${CODE_REPO_URL}"
|
|
122
|
-
"--min-severity" "${MIN_SEVERITY}"
|
|
123
|
-
"--output-file-formats" "
|
|
122
|
+
"--min-severity" "$(printf '%s' "${MIN_SEVERITY}" | tr 'A-Z' 'a-z')"
|
|
123
|
+
"--output-file-formats" "json,md,junit"
|
|
124
124
|
"--output-path" "/tmp/tenable/out"
|
|
125
125
|
"--output-file-name" "${slug}-tenable"
|
|
126
126
|
"--no-color"
|
|
@@ -134,15 +134,24 @@ scan_one() {
|
|
|
134
134
|
)
|
|
135
135
|
fi
|
|
136
136
|
if [[ -n "${TENABLE_FAIL_ON_MIN_SEVERITY:-}" ]]; then
|
|
137
|
-
scan_args+=("--fail-on-min-severity" "${TENABLE_FAIL_ON_MIN_SEVERITY}")
|
|
137
|
+
scan_args+=("--fail-on-min-severity" "$(printf '%s' "${TENABLE_FAIL_ON_MIN_SEVERITY}" | tr 'A-Z' 'a-z')")
|
|
138
138
|
fi
|
|
139
139
|
|
|
140
140
|
echo "Running Tenable scan for '${slug}' (min-severity=${MIN_SEVERITY}${TENABLE_FAIL_ON_MIN_SEVERITY:+, fail-on=${TENABLE_FAIL_ON_MIN_SEVERITY}})..."
|
|
141
|
+
# --entrypoint is not optional: Tenable's own GitHub action builds FROM this image
|
|
142
|
+
# solely to replace the entrypoint with a script that runs `tenable container-image
|
|
143
|
+
# scan "$@"`, so the image's own entrypoint is not that binary. Handing the
|
|
144
|
+
# subcommand to whatever it does start fails silently — exit 0, no output, no
|
|
145
|
+
# reports. The binary also takes its output destination from the environment (the
|
|
146
|
+
# action passes no --output-path flag at all), so it is set both ways.
|
|
141
147
|
docker run --rm \
|
|
142
148
|
--workdir /tmp/tenable \
|
|
143
149
|
--volume "${work}:/tmp/tenable" \
|
|
144
150
|
--env TENABLE_API_TOKEN \
|
|
145
151
|
--env TENABLE_API_URL \
|
|
152
|
+
--env "TENABLE_OUTPUT_PATH=/tmp/tenable/out" \
|
|
153
|
+
--env "TENABLE_OUTPUT_FILE_NAME=${slug}-tenable" \
|
|
154
|
+
--entrypoint "${TENABLE_SCANNER_ENTRYPOINT:-tenable}" \
|
|
146
155
|
--pull=always \
|
|
147
156
|
"${SCANNER_IMAGE}" "${scan_args[@]}"
|
|
148
157
|
local scan_exit=$?
|
package/package.json
CHANGED
package/src/tenable/docker.js
CHANGED
|
@@ -24,11 +24,18 @@ export const docker = {
|
|
|
24
24
|
return { ok: result.exitCode === 0 };
|
|
25
25
|
},
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// The entrypoint is overridden rather than trusted. Tenable's own GitHub action
|
|
28
|
+
// builds FROM this image purely to replace the entrypoint with a script whose
|
|
29
|
+
// first line is `tenable container-image scan "$@"`, which means the base image's
|
|
30
|
+
// own entrypoint is not that binary. Passing the subcommand as bare arguments
|
|
31
|
+
// hands them to whatever the image does start, and the failure is silent: exit 0,
|
|
32
|
+
// no output, no reports.
|
|
33
|
+
async run({ image, args, volume, workdir, env, entrypoint }) {
|
|
28
34
|
const envFlags = env.flatMap((name) => ['--env', name]);
|
|
35
|
+
const entrypointFlags = entrypoint ? ['--entrypoint', entrypoint] : [];
|
|
29
36
|
const result = await $({
|
|
30
37
|
nothrow: true,
|
|
31
|
-
})`docker run --rm --workdir ${workdir} --volume ${volume} ${envFlags} --pull=always ${image} ${args}`;
|
|
38
|
+
})`docker run --rm --workdir ${workdir} --volume ${volume} ${envFlags} ${entrypointFlags} --pull=always ${image} ${args}`;
|
|
32
39
|
return result.exitCode;
|
|
33
40
|
},
|
|
34
41
|
|
package/src/tenable/scan.js
CHANGED
|
@@ -16,6 +16,7 @@ export async function scanOne(target, ctx) {
|
|
|
16
16
|
const {
|
|
17
17
|
reportDir,
|
|
18
18
|
scannerImage,
|
|
19
|
+
scannerEntrypoint,
|
|
19
20
|
shortSha,
|
|
20
21
|
imageNamePrefix,
|
|
21
22
|
codeBranch,
|
|
@@ -97,6 +98,7 @@ export async function scanOne(target, ctx) {
|
|
|
97
98
|
args: scanArgs,
|
|
98
99
|
volume: `${work}:/tmp/tenable`,
|
|
99
100
|
workdir: '/tmp/tenable',
|
|
101
|
+
entrypoint: scannerEntrypoint,
|
|
100
102
|
// The output destination goes over BOTH transports on purpose. Tenable's own
|
|
101
103
|
// GitHub action passes output-path and output-file-name only as TENABLE_*
|
|
102
104
|
// env vars, never as flags, so a build of the scanner that ignores the flags
|
|
@@ -157,6 +159,7 @@ export async function runTenableScan({
|
|
|
157
159
|
reportDir = process.env.TENABLE_REPORT_DIR || 'tenable-report',
|
|
158
160
|
scannerImage = process.env.TENABLE_SCANNER_IMAGE ||
|
|
159
161
|
'tenable/cloud-security-scanner:latest',
|
|
162
|
+
scannerEntrypoint = process.env.TENABLE_SCANNER_ENTRYPOINT || 'tenable',
|
|
160
163
|
minSeverity = process.env.TENABLE_MIN_SEVERITY || 'Medium',
|
|
161
164
|
failOnMinSeverity = process.env.TENABLE_FAIL_ON_MIN_SEVERITY || '',
|
|
162
165
|
tenableImage = process.env.TENABLE_IMAGE || '',
|
|
@@ -204,6 +207,7 @@ export async function runTenableScan({
|
|
|
204
207
|
const scanCtx = {
|
|
205
208
|
reportDir,
|
|
206
209
|
scannerImage,
|
|
210
|
+
scannerEntrypoint,
|
|
207
211
|
shortSha,
|
|
208
212
|
imageNamePrefix: repoSlug,
|
|
209
213
|
codeBranch,
|
package/src/tenable/scan.test.js
CHANGED
|
@@ -28,6 +28,7 @@ function makeFakeFsops(overrides = {}) {
|
|
|
28
28
|
const baseCtx = (overrides = {}) => ({
|
|
29
29
|
reportDir: 'tenable-report',
|
|
30
30
|
scannerImage: 'tenable/cloud-security-scanner:latest',
|
|
31
|
+
scannerEntrypoint: 'tenable',
|
|
31
32
|
shortSha: 'abc1234',
|
|
32
33
|
imageNamePrefix: 'my-repo',
|
|
33
34
|
codeBranch: 'main',
|
|
@@ -82,6 +83,27 @@ describe('scanOne', () => {
|
|
|
82
83
|
expect(fsops.removeSync).toHaveBeenCalledWith('/work/.tenable-work.abc');
|
|
83
84
|
});
|
|
84
85
|
|
|
86
|
+
test('drives the scanner through the tenable binary, not the image entrypoint', async () => {
|
|
87
|
+
const docker = makeFakeDocker();
|
|
88
|
+
const ctx = baseCtx({ docker });
|
|
89
|
+
|
|
90
|
+
await scanOne(
|
|
91
|
+
{ label: 'image', slug: 'image', prebuiltImage: 'my-image:tag' },
|
|
92
|
+
ctx,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const call = docker.run.mock.calls[0][0];
|
|
96
|
+
expect(call.entrypoint).toBe('tenable');
|
|
97
|
+
// The binary reads its output destination from the environment; the action
|
|
98
|
+
// that ships with the scanner passes no --output-path flag at all.
|
|
99
|
+
expect(call.env).toEqual(
|
|
100
|
+
expect.arrayContaining([
|
|
101
|
+
'TENABLE_OUTPUT_PATH=/tmp/tenable/out',
|
|
102
|
+
'TENABLE_OUTPUT_FILE_NAME=image-tenable',
|
|
103
|
+
]),
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
85
107
|
test('scans a pre-built image without building or removing anything', async () => {
|
|
86
108
|
const docker = makeFakeDocker();
|
|
87
109
|
const fsops = makeFakeFsops();
|