@@ -45,9 +45,11 @@ function get_security_findings(dt_results_api_key, mobile_app_id, results_since,
4545 const baseUrl = "https://api.securetheorem.com/apis/mobile_security/results/v2/security_findings" ;
4646 const params = new URLSearchParams ( {
4747 mobile_app_id,
48- results_since,
4948 status_group : "OPEN" ,
5049 } ) ;
50+ if ( results_since ) {
51+ params . append ( "results_since" , results_since ) ;
52+ }
5153 if ( severity ) {
5254 params . append ( "severity" , severity ) ;
5355 }
@@ -61,7 +63,7 @@ function get_security_findings(dt_results_api_key, mobile_app_id, results_since,
6163 } ) ;
6264 } ) ;
6365}
64- function check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , severity_level ) {
66+ function check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , severity_level , check_scope ) {
6567 return __awaiter ( this , void 0 , void 0 , function * ( ) {
6668 const severity_checks = {
6769 HIGH : [ "HIGH" ] ,
@@ -73,8 +75,10 @@ function check_severity_findings(dt_results_api_key, mobile_app_id, results_sinc
7375 throw new Error ( `Invalid severity level: ${ severity_level } ` ) ;
7476 }
7577 let total_findings = 0 ;
78+ // Determine which results_since to use based on scope
79+ const effective_results_since = check_scope . toUpperCase ( ) === "ALL_ISSUES" ? null : results_since ;
7680 for ( const severity of severities_to_check ) {
77- const findings_response = yield get_security_findings ( dt_results_api_key , mobile_app_id , results_since , severity ) ;
81+ const findings_response = yield get_security_findings ( dt_results_api_key , mobile_app_id , effective_results_since , severity ) ;
7882 if ( findings_response . status !== 200 ) {
7983 throw new Error ( `Error fetching security findings for ${ severity } severity: HTTP ${ findings_response . status } ` ) ;
8084 }
@@ -108,6 +112,7 @@ function run() {
108112 const warn_on_severity = core . getInput ( "WARN_ON_SEVERITY" ) ;
109113 const polling_timeout = core . getInput ( "POLLING_TIMEOUT" ) ;
110114 const wait_for_static_scan_only = core . getInput ( "WAIT_FOR_STATIC_SCAN_ONLY" ) ;
115+ const severity_check_scope = core . getInput ( "SEVERITY_CHECK_SCOPE" ) || "CURRENT_SCAN" ;
111116 var parsed_polling_timeout ;
112117 if ( polling_timeout ) {
113118 parsed_polling_timeout = parseInt ( polling_timeout , 10 ) ;
@@ -127,6 +132,9 @@ function run() {
127132 ! [ "HIGH" , "MEDIUM" , "LOW" ] . includes ( warn_on_severity . toUpperCase ( ) ) ) {
128133 throw new Error ( "WARN_ON_SEVERITY must be one of: HIGH, MEDIUM, LOW" ) ;
129134 }
135+ if ( ! [ "CURRENT_SCAN" , "ALL_ISSUES" ] . includes ( severity_check_scope . toUpperCase ( ) ) ) {
136+ throw new Error ( "SEVERITY_CHECK_SCOPE must be one of: CURRENT_SCAN, ALL_ISSUES" ) ;
137+ }
130138 // Mask the sensitive fields
131139 core . setSecret ( dt_upload_api_key ) ;
132140 core . setSecret ( dt_results_api_key ) ;
@@ -330,13 +338,19 @@ function run() {
330338 // Check for blocking vulnerabilities first
331339 if ( block_on_severity ) {
332340 try {
333- const { has_findings, total_count } = yield check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , block_on_severity ) ;
341+ const { has_findings, total_count } = yield check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , block_on_severity , severity_check_scope ) ;
334342 if ( has_findings ) {
335- console . log ( `Found ${ total_count } security findings at or above ${ block_on_severity } severity level` ) ;
336- core . setFailed ( `Build blocked due to ${ total_count } security findings at or above ${ block_on_severity } severity level` ) ;
343+ const scope_description = severity_check_scope . toUpperCase ( ) === "ALL_ISSUES"
344+ ? "in the mobile app"
345+ : "in this scan" ;
346+ console . log ( `Found ${ total_count } security findings ${ scope_description } at or above ${ block_on_severity } severity level` ) ;
347+ core . setFailed ( `Build blocked due to ${ total_count } security findings ${ scope_description } at or above ${ block_on_severity } severity level` ) ;
337348 return ;
338349 }
339- console . log ( `No security findings found at or above ${ block_on_severity } severity level for scan ${ scan_id } ` ) ;
350+ const scope_description = severity_check_scope . toUpperCase ( ) === "ALL_ISSUES"
351+ ? "in the mobile app"
352+ : `for scan ${ scan_id } ` ;
353+ console . log ( `No security findings found at or above ${ block_on_severity } severity level ${ scope_description } ` ) ;
340354 }
341355 catch ( error ) {
342356 console . log ( `Error checking security findings for scan ${ scan_id } : ${ error . message } ` ) ;
@@ -346,13 +360,19 @@ function run() {
346360 // Check for warning vulnerabilities
347361 if ( warn_on_severity ) {
348362 try {
349- const { has_findings, total_count } = yield check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , warn_on_severity ) ;
363+ const { has_findings, total_count } = yield check_severity_findings ( dt_results_api_key , mobile_app_id , results_since , warn_on_severity , severity_check_scope ) ;
350364 if ( has_findings ) {
351- console . log ( `⚠️ WARNING: Found ${ total_count } security findings at or above ${ warn_on_severity } severity level for scan ${ scan_id } ` ) ;
365+ const scope_description = severity_check_scope . toUpperCase ( ) === "ALL_ISSUES"
366+ ? "in the mobile app"
367+ : `for scan ${ scan_id } ` ;
368+ console . log ( `⚠️ WARNING: Found ${ total_count } security findings ${ scope_description } at or above ${ warn_on_severity } severity level` ) ;
352369 console . log ( `⚠️ These findings do not block the build, but should be reviewed and addressed.` ) ;
353370 }
354371 else {
355- console . log ( `No security findings found at or above ${ warn_on_severity } severity level for scan ${ scan_id } ` ) ;
372+ const scope_description = severity_check_scope . toUpperCase ( ) === "ALL_ISSUES"
373+ ? "in the mobile app"
374+ : `for scan ${ scan_id } ` ;
375+ console . log ( `No security findings found at or above ${ warn_on_severity } severity level ${ scope_description } ` ) ;
356376 }
357377 }
358378 catch ( error ) {
0 commit comments