Skip to content

Commit 0f6819c

Browse files
committed
Add WAIT_FOR_STATIC_SCAN_ONLY parameter
1 parent 514a362 commit 0f6819c

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ inputs:
6868
description: >
6969
Stop polling the scan result after the specified time in seconds, default is 5 minutes.
7070
required: false
71+
WAIT_FOR_STATIC_SCAN_ONLY:
72+
description: >
73+
When enabled, waits for the static_scan to be COMPLETED instead of the top-level scan. Default is false.
74+
required: false
7175
runs:
7276
using: 'node20'
7377
main: 'main.js'

main.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function check_severity_findings(dt_results_api_key, mobile_app_id, results_sinc
8989
});
9090
}
9191
function run() {
92+
var _a;
9293
return __awaiter(this, void 0, void 0, function* () {
9394
// Get inputs
9495
// Mandatory
@@ -106,6 +107,7 @@ function run() {
106107
const block_on_severity = core.getInput("BLOCK_ON_SEVERITY");
107108
const warn_on_severity = core.getInput("WARN_ON_SEVERITY");
108109
const polling_timeout = core.getInput("POLLING_TIMEOUT");
110+
const wait_for_static_scan_only = core.getInput("WAIT_FOR_STATIC_SCAN_ONLY");
109111
var parsed_polling_timeout;
110112
if (polling_timeout) {
111113
parsed_polling_timeout = parseInt(polling_timeout, 10);
@@ -291,7 +293,20 @@ function run() {
291293
continue;
292294
}
293295
const status_data = yield status_response.json();
294-
const scan_status = status_data.status;
296+
// Check status based on WAIT_FOR_STATIC_SCAN_ONLY parameter
297+
let scan_status;
298+
if (wait_for_static_scan_only === 'true') {
299+
if ((_a = status_data.static_scan) === null || _a === void 0 ? void 0 : _a.status) {
300+
scan_status = status_data.static_scan.status;
301+
}
302+
else {
303+
console.log(`static_scan field not available for scan ${scan_id}, falling back to overall scan status`);
304+
scan_status = status_data.status;
305+
}
306+
}
307+
else {
308+
scan_status = status_data.status;
309+
}
295310
if (scan_status &&
296311
["FAILED", "SCAN_ATTEMPT_ERROR", "CANCELLED"].includes(scan_status)) {
297312
console.log(`Scan ${scan_id} failed, skipping vulnerability check`);

main.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ async function run() {
126126
const block_on_severity = core.getInput("BLOCK_ON_SEVERITY");
127127
const warn_on_severity = core.getInput("WARN_ON_SEVERITY");
128128
const polling_timeout = core.getInput("POLLING_TIMEOUT");
129+
const wait_for_static_scan_only = core.getInput("WAIT_FOR_STATIC_SCAN_ONLY");
129130
var parsed_polling_timeout;
130131
if (polling_timeout) {
131132
parsed_polling_timeout = parseInt(polling_timeout, 10);
@@ -363,7 +364,18 @@ async function run() {
363364
}
364365

365366
const status_data = await status_response.json();
366-
const scan_status = status_data.status;
367+
// Check status based on WAIT_FOR_STATIC_SCAN_ONLY parameter
368+
let scan_status;
369+
if (wait_for_static_scan_only === 'true') {
370+
if (status_data.static_scan?.status) {
371+
scan_status = status_data.static_scan.status;
372+
} else {
373+
console.log(`static_scan field not available for scan ${scan_id}, falling back to overall scan status`);
374+
scan_status = status_data.status;
375+
}
376+
} else {
377+
scan_status = status_data.status;
378+
}
367379

368380
if (
369381
scan_status &&

0 commit comments

Comments
 (0)