@@ -30,8 +30,8 @@ pub async fn pipeline_failure(
30
30
let mut pipeline_sast_sca_data = HashMap :: new ( ) ;
31
31
let mut pipeline_secret_license_data = HashMap :: new ( ) ;
32
32
let mut found_issues = false ;
33
- let mut found_sast_issues = false ;
34
- let mut found_sca_issues = false ;
33
+ let found_sast_issues = false ;
34
+ let found_sca_issues = false ;
35
35
let mut found_secret_issues = false ;
36
36
let found_license_issues = false ;
37
37
@@ -60,9 +60,7 @@ pub async fn pipeline_failure(
60
60
if code_path. contains ( "@" ) {
61
61
cleaned_code_path = code_path. split ( "@" ) . collect :: < Vec < & str > > ( ) [ 1 ] . to_string ( ) ;
62
62
}
63
- let mut commit_path = String :: new ( ) ;
64
- commit_path = format ! ( "{}/commit" , cleaned_code_path. clone( ) ) ;
65
- slack_alert_msg. push_str ( format ! ( "\n \n Commit: {}" , commit_path) . as_str ( ) ) ;
63
+ let commit_path = format ! ( "{}/commit" , cleaned_code_path. clone( ) ) ;
66
64
println ! (
67
65
"\n \n 🔎 Hela Security Scan Results for {}" ,
68
66
redacted_code_path
@@ -90,12 +88,10 @@ pub async fn pipeline_failure(
90
88
} ;
91
89
let vuln_path_str = format ! ( "{}:{}" , vuln_path_result, vuln_path_line) ;
92
90
let vuln_path = String :: from ( vuln_path_str) ;
93
- let commit_id =
94
- find_commit_for_snippet ( & vuln_path, & result[ "extra" ] [ "lines" ] . to_string ( ) ) . unwrap ( ) ;
95
91
sast_result. insert ( "check_id" , result[ "check_id" ] . to_string ( ) ) ;
96
92
sast_result. insert ( "path" , vuln_path) ;
97
93
sast_result. insert ( "severity" , result[ "extra" ] [ "severity" ] . to_string ( ) ) ;
98
- let mut message = result[ "extra" ] [ "message" ] . to_string ( ) ;
94
+ let message = result[ "extra" ] [ "message" ] . to_string ( ) ;
99
95
sast_result. insert ( "message" , message) ;
100
96
sast_result. insert ( "lines" , result[ "extra" ] [ "lines" ] . to_string ( ) ) ;
101
97
@@ -135,8 +131,6 @@ pub async fn pipeline_failure(
135
131
}
136
132
137
133
table. add_row ( row ! [ bFg->"S.No" , bFg->"Path" , bFg->"Severity" , bFg->"Message" ] ) ;
138
- let mut sast_count = 0 ;
139
- let mut messages: Vec < String > = Vec :: new ( ) ;
140
134
let mut message_to_hash: HashMap < String , ( String , String , String , String , String ) > =
141
135
HashMap :: new ( ) ;
142
136
@@ -477,11 +471,11 @@ pub async fn pipeline_failure(
477
471
slack_alert_msg. push_str ( "\n \n " ) ;
478
472
slack_alert_msg. push_str ( "================== Secret Results ==================" ) ;
479
473
table. add_row (
480
- row ! [ bFg->"S.No" , bFg->"File" , bFg->"Line" , bFg->"Raw" , bFg->"Detector Name" ] ,
474
+ row ! [ bFg->"S.No" , bFg->"File" , bFg->"Line" , bFg->"Raw" , bFg->"Detector Name" , bFg-> "Commit" ] ,
481
475
) ;
482
476
}
483
477
484
- let mut secret_count = 0 ;
478
+ let secret_count = 0 ;
485
479
let mut message_to_hash: HashMap < String , ( String , String , String , String , String ) > =
486
480
HashMap :: new ( ) ;
487
481
@@ -544,11 +538,22 @@ pub async fn pipeline_failure(
544
538
let raw_truncated = raw. chars ( ) . take ( 50 ) . collect :: < String > ( ) ;
545
539
546
540
// Add row to table
547
- table. add_row ( row ! [ secret_count, file, line, raw_truncated, detector_name] ) ;
541
+ table. add_row ( row ! [
542
+ secret_count,
543
+ file,
544
+ line,
545
+ raw_truncated,
546
+ detector_name,
547
+ commit_link
548
+ ] ) ;
548
549
549
550
slack_alert_msg. push_str ( & format ! (
550
551
"\n \n File: {}\n Line: {}\n Raw: {}\n Detector Name: {}\n Commit: {}" ,
551
- file, line, raw, detector_name, commit_link
552
+ file,
553
+ line,
554
+ raw,
555
+ detector_name,
556
+ commit_link. clone( )
552
557
) ) ;
553
558
554
559
// Register the missing hash
@@ -759,6 +764,20 @@ pub async fn pipeline_failure(
759
764
if is_secret {
760
765
let mut secret_results = Vec :: new ( ) ;
761
766
for result in json_output[ "secret" ] [ "results" ] . as_array ( ) . unwrap ( ) {
767
+ let file_path = result[ "SourceMetadata" ] [ "Data" ] [ "Filesystem" ] [ "file" ]
768
+ . as_str ( )
769
+ . unwrap ( ) ;
770
+ let raw_value = result[ "Raw" ] . as_str ( ) . unwrap ( ) ;
771
+ let commit_id = find_commit_for_snippet ( file_path, raw_value) . unwrap ( ) ;
772
+ let commit_base_link = commit_path. split ( "/commit" ) . collect :: < Vec < & str > > ( ) [ 0 ] ;
773
+ let commit_link = format ! (
774
+ "{}/commit/{}" ,
775
+ commit_base_link,
776
+ match commit_id {
777
+ Some ( commit_id) => commit_id,
778
+ None => "UNKNOWN" . to_string( ) ,
779
+ }
780
+ ) ;
762
781
let mut secret_result = serde_json:: Map :: new ( ) ;
763
782
secret_result. insert (
764
783
"ruleId" . to_string ( ) ,
@@ -769,7 +788,7 @@ pub async fn pipeline_failure(
769
788
"Secret of {} with value {} exposed\n \n Commit: {}" ,
770
789
result[ "DetectorName" ] . as_str( ) . unwrap( ) ,
771
790
result[ "Raw" ] . as_str( ) . unwrap( ) ,
772
- commit_path
791
+ commit_link
773
792
) ;
774
793
let msg_val = serde_json:: Value :: String ( msg) ;
775
794
message. insert ( "text" . to_string ( ) , msg_val) ;
0 commit comments