corgea-cli 1.3.1__tar.gz → 1.3.3__tar.gz

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.
@@ -195,7 +195,7 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
195
195
 
196
196
  [[package]]
197
197
  name = "corgea"
198
- version = "1.3.1"
198
+ version = "1.3.3"
199
199
  dependencies = [
200
200
  "clap",
201
201
  "dirs",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "corgea"
3
- version = "1.3.1"
3
+ version = "1.3.3"
4
4
  edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: corgea-cli
3
- Version: 1.3.1
3
+ Version: 1.3.3
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -144,7 +144,7 @@ pub fn parse_scan(config: &Config, input: String, save_to_file: bool) {
144
144
  }
145
145
  }
146
146
  // checkmarx report generated by CLI
147
- } else if input.contains("Cx") && data.get("results").is_some() && data.get("scanID").is_some() {
147
+ } else if data.get("totalCount").is_some() && data.get("results").is_some() && data.get("scanID").is_some() {
148
148
  debug("Detected checkmarx cli schema");
149
149
  scanner = "checkmarx".to_string();
150
150
  if let Some(results) = data.get("results").and_then(|v| v.as_array()) {
@@ -163,7 +163,7 @@ pub fn parse_scan(config: &Config, input: String, save_to_file: bool) {
163
163
  }
164
164
  }
165
165
  // for checkmarx report generated by web
166
- } else if input.contains("Cx") && data.get("scanResults").is_some() && data.get("reportId").is_some() {
166
+ } else if data.get("scanResults").is_some() && data.get("reportId").is_some() {
167
167
  debug("Detected checkmarx web schema");
168
168
  scanner = "checkmarx".to_string();
169
169
  if let Some(scan_results) = data.get("scanResults") {
@@ -244,6 +244,8 @@ fn upload_scan(config: &Config, paths: Vec<String>, scanner: String, input: Stri
244
244
  println!("Uploading required files for the scan...");
245
245
 
246
246
  let mut uploaded_paths = HashSet::new();
247
+ let mut uploaded_count = 0;
248
+ let mut upload_error_count = 0;
247
249
 
248
250
  for path in &paths {
249
251
  if !Path::new(&path).exists() {
@@ -261,30 +263,47 @@ fn upload_scan(config: &Config, paths: Vec<String>, scanner: String, input: Stri
261
263
  debug(&format!("Uploading file: {}", path));
262
264
  let fp = Path::new(&path);
263
265
 
264
- let form = reqwest::blocking::multipart::Form::new()
265
- .file("file", fp)
266
- .expect("Failed to read file");
267
-
268
-
269
- debug(&format!("POST: {}", src_upload_url));
270
- let res = client.post(&src_upload_url)
271
- .multipart(form)
272
- .send();
273
-
274
- match res {
275
- Ok(response) => {
276
- if !response.status().is_success() {
277
- eprintln!("Failed to upload file: {}", response.status());
266
+ let mut attempts = 0;
267
+ let mut success = false;
268
+
269
+ while attempts < 3 && !success {
270
+ let form = reqwest::blocking::multipart::Form::new()
271
+ .file("file", fp)
272
+ .expect("Failed to read file");
273
+
274
+ debug(&format!("POST: {}", src_upload_url));
275
+ let res = client.post(&src_upload_url)
276
+ .multipart(form)
277
+ .send();
278
+
279
+ match res {
280
+ Ok(response) => {
281
+ if !response.status().is_success() {
282
+ eprintln!("Failed to upload file {} {}... retrying", response.status(), path);
283
+ std::thread::sleep(std::time::Duration::from_secs(1));
284
+ attempts += 1;
285
+ } else {
286
+ uploaded_count += 1;
287
+ success = true;
288
+ uploaded_paths.insert(path.clone());
289
+ }
290
+ }
291
+ Err(e) => {
292
+ eprintln!("Failed to send request: {}", e);
278
293
  std::process::exit(1);
279
- } else {
280
- uploaded_paths.insert(path.clone());
281
294
  }
282
295
  }
283
- Err(e) => {
284
- eprintln!("Failed to send request: {}", e);
285
- std::process::exit(1);
286
- }
287
296
  }
297
+
298
+ if attempts == 3 && !success {
299
+ upload_error_count += 1;
300
+ eprintln!("Failed to upload file: {} after 3 attempts. skipping...", path);
301
+ }
302
+ }
303
+
304
+ if uploaded_count == 0 {
305
+ eprintln!("Failed to upload any files for the scan, exiting.");
306
+ std::process::exit(1);
288
307
  }
289
308
 
290
309
  println!("Uploading the scan...");
@@ -371,5 +390,10 @@ fn upload_scan(config: &Config, paths: Vec<String>, scanner: String, input: Stri
371
390
  }
372
391
 
373
392
  println!("Successfully scanned using {} and uploaded to Corgea.", scanner);
393
+
394
+ if upload_error_count > 0 {
395
+ println!("Failed to upload {} files, you may not see all fixes in Corgea.", upload_error_count);
396
+ }
397
+
374
398
  println!("Go to {base_url} to see results.");
375
399
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes