Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
453 changes: 260 additions & 193 deletions src/list.rs

Large diffs are not rendered by default.

45 changes: 42 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,20 @@ enum Commands {
project_name: Option<String>,
},
/// Wait for the latest in progress scan
Wait { scan_id: Option<String> },
Wait {
scan_id: Option<String>,
#[arg(
long,
conflicts_with = "repo",
help = "Query this exact Corgea project name directly (skips repo auto-resolution)."
)]
project_name: Option<String>,
#[arg(
long,
help = "Resolve the project from this repo (org/repo slug or remote URL) instead of the git remote."
)]
repo: Option<String>,
},
/// List something, by default it lists the scans
#[command(alias = "ls")]
List {
Expand All @@ -159,6 +172,19 @@ enum Commands {

#[arg(long, value_parser = clap::value_parser!(u16), help = "Number of items per page")]
page_size: Option<u16>,

#[arg(
long,
conflicts_with = "repo",
help = "Query this exact Corgea project name directly (skips repo auto-resolution)."
)]
project_name: Option<String>,

#[arg(
long,
help = "Resolve the project from this repo (org/repo slug or remote URL) instead of the git remote."
)]
repo: Option<String>,
},
/// Inspect something, by default it will inspect a scan
Inspect {
Expand Down Expand Up @@ -600,9 +626,18 @@ fn main() {
),
}
}
Some(Commands::Wait { scan_id }) => {
Some(Commands::Wait {
scan_id,
project_name,
repo,
}) => {
verify_token_and_exit_when_fail(&corgea_config);
wait::run(&corgea_config, scan_id.clone(), None);
wait::run(
&corgea_config,
scan_id.clone(),
project_name.clone(),
repo.clone(),
);
}
Some(Commands::List {
issues,
Expand All @@ -611,6 +646,8 @@ fn main() {
page_size,
scan_id,
sca_issues,
project_name,
repo,
}) => {
verify_token_and_exit_when_fail(&corgea_config);
if *issues && *sca_issues {
Expand All @@ -629,6 +666,8 @@ fn main() {
page,
page_size,
scan_id,
project_name.clone(),
repo.clone(),
);
}
Some(Commands::Inspect {
Expand Down
26 changes: 9 additions & 17 deletions src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub fn run_command(base_cmd: &String, mut command: Command) -> String {

pub struct ScanUploadResult {
pub scan_id: String,
pub project_id: Option<String>,
}

pub fn run_semgrep(config: &Config, project_name: Option<String>) {
Expand All @@ -65,8 +64,10 @@ pub fn run_semgrep(config: &Config, project_name: Option<String>) {

let output = run_command(&base_command.to_string(), command);

if let Some(result) = parse_scan(config, output, true, project_name) {
crate::wait::run(config, Some(result.scan_id), result.project_id);
if let Some(result) = parse_scan(config, output, true, project_name.clone()) {
// Preserve an explicit --project-name for the post-scan wait; when None,
// wait resolves by the git remote / CWD (COR-1577).
crate::wait::run(config, Some(result.scan_id), project_name, None);
}
}

Expand All @@ -80,8 +81,10 @@ pub fn run_snyk(config: &Config, project_name: Option<String>) {

let output = run_command(&base_command.to_string(), command);

if let Some(result) = parse_scan(config, output, true, project_name) {
crate::wait::run(config, Some(result.scan_id), result.project_id);
if let Some(result) = parse_scan(config, output, true, project_name.clone()) {
// Preserve an explicit --project-name for the post-scan wait; when None,
// wait resolves by the git remote / CWD (COR-1577).
crate::wait::run(config, Some(result.scan_id), project_name, None);
}
}

Expand Down Expand Up @@ -369,7 +372,6 @@ pub fn upload_scan(
};

let mut sast_scan_id: Option<String> = None;
let mut project_id: Option<String> = None;

let mut upload_failed = false;

Expand All @@ -396,13 +398,6 @@ pub fn upload_scan(
sast_scan_id = Some(id_num.to_string());
}
}
if let Some(pid_val) = json.get("project_id") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we drop project id?

if let Some(pid_str) = pid_val.as_str() {
project_id = Some(pid_str.to_string());
} else if let Some(pid_num) = pid_val.as_i64() {
project_id = Some(pid_num.to_string());
}
}
}
Err(e) => {
log::warn!("Failed to parse response JSON: {}", e);
Expand Down Expand Up @@ -514,8 +509,5 @@ pub fn upload_scan(

println!("Go to {base_url} to see results.");

sast_scan_id.map(|scan_id| ScanUploadResult {
scan_id,
project_id,
})
sast_scan_id.map(|scan_id| ScanUploadResult { scan_id })
}
Loading
Loading