@@ -20,33 +20,36 @@ function downloadFile(url) {
2020
2121async function getRawResults ( ) {
2222 const rawResultUrl = process . argv [ 2 ] ;
23- const response = await downloadFile ( rawResultUrl )
23+ const response = await downloadFile ( rawResultUrl ) ;
2424 console . log ( `Fetched raw result file contents from the file storage` ) ;
25- return await response . text ( )
25+ return await response . text ( ) ;
2626}
2727
2828async function getFindings ( ) {
2929 const findingsUrl = process . argv [ 3 ] ;
30- const response = await downloadFile ( findingsUrl )
31- const findings = await response . json ( )
30+ const response = await downloadFile ( findingsUrl ) ;
31+ const findings = await response . json ( ) ;
3232 console . log ( `Fetched ${ findings . length } findings from the file storage` ) ;
3333 return findings ;
3434}
3535
3636async function uploadFile ( url , fileContents ) {
3737 try {
38- const response = await fetch ( url , { method : "PUT" , headers : { "content-type" : "" } } )
38+ const response = await fetch ( url , {
39+ method : "PUT" ,
40+ headers : { "content-type" : "" } ,
41+ } ) ;
3942 } catch ( error ) {
4043 if ( error . response ) {
4144 // The request was made and the server responded with a status code
4245 // that falls out of the range of 2xx
4346 console . error (
44- `File Upload Failed with Response Code: ${ error . response . status } `
47+ `File Upload Failed with Response Code: ${ error . response . status } ` ,
4548 ) ;
4649 console . error ( `Error Response Body: ${ error . response . data } ` ) ;
4750 } else if ( error . request ) {
4851 console . error (
49- "No response received from FileStorage when uploading finding"
52+ "No response received from FileStorage when uploading finding" ,
5053 ) ;
5154 console . error ( error ) ;
5255 } else {
@@ -61,11 +64,11 @@ function updateRawResults(fileContents) {
6164 const rawResultUploadUrl = process . argv [ 4 ] ;
6265 if ( rawResultUploadUrl === undefined ) {
6366 console . error (
64- "Tried to upload RawResults but didn't find a valid URL to upload the findings to."
67+ "Tried to upload RawResults but didn't find a valid URL to upload the findings to." ,
6568 ) ;
6669 console . error ( "This probably means that this hook is a ReadOnly hook." ) ;
6770 console . error (
68- "If you want to change RawResults you'll need to use a ReadAndWrite Hook."
71+ "If you want to change RawResults you'll need to use a ReadAndWrite Hook." ,
6972 ) ;
7073 }
7174 return uploadFile ( rawResultUploadUrl , fileContents ) ;
@@ -74,19 +77,19 @@ function updateRawResults(fileContents) {
7477function severityCount ( findings , severity ) {
7578 return findings . filter (
7679 ( { severity : findingSeverity } ) =>
77- findingSeverity . toUpperCase ( ) === severity
80+ findingSeverity . toUpperCase ( ) === severity ,
7881 ) . length ;
7982}
8083
8184async function updateFindings ( findings ) {
8285 const findingsUploadUrl = process . argv [ 5 ] ;
8386 if ( findingsUploadUrl === undefined ) {
8487 console . error (
85- "Tried to upload Findings but didn't find a valid URL to upload the findings to."
88+ "Tried to upload Findings but didn't find a valid URL to upload the findings to." ,
8689 ) ;
8790 console . error ( "This probably means that this hook is a ReadOnly hook." ) ;
8891 console . error (
89- "If you want to change Findings you'll need to use a ReadAndWrite Hook."
92+ "If you want to change Findings you'll need to use a ReadAndWrite Hook." ,
9093 ) ;
9194 }
9295 await uploadFile ( findingsUploadUrl , JSON . stringify ( findings ) ) ;
@@ -124,7 +127,7 @@ async function updateFindings(findings) {
124127 undefined ,
125128 undefined ,
126129 undefined ,
127- { headers : { "content-type" : "application/merge-patch+json" } }
130+ { headers : { "content-type" : "application/merge-patch+json" } } ,
128131 ) ;
129132 console . log ( "Updated status successfully" ) ;
130133}
@@ -137,7 +140,7 @@ async function main() {
137140 "v1" ,
138141 namespace ,
139142 "scans" ,
140- scanName
143+ scanName ,
141144 ) ;
142145 scan = body ;
143146 } catch ( err ) {
0 commit comments