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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ gives up after 10 hours; override with `CORGEA_SCAN_TIMEOUT_SECONDS`.
evaluated; override with `CORGEA_BLOCKING_RULES_TIMEOUT_SECONDS`.

When the scan finishes, `scan` and `wait` print a results summary: open issues
by severity, every finding by status, and the results link. By default it
by severity, the scan's dependency findings, every code finding by status, and
the results link. A `Malware:` line counts the malicious packages among the
dependencies. If the dependency findings cannot be read, the summary says so
and does not count them as zero. By default it
prints tables for a person. `--format` picks a format for a program instead:
`agent` (tab-separated records for coding agents), `json` (one document on
stdout) or `quiet` (no summary). With `--format`, progress goes to stderr, so
Expand Down
8 changes: 4 additions & 4 deletions skills/corgea/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Removing, disabling or editing a project ignore rule (scan settings → File Ign

When the scan finishes, `scan` and `wait` print one results summary. Pass `--format agent` when you are a coding agent reading the output:

- no `--format`: tables of open issues by severity and of every finding by status (open, fix in progress, fixed, accepted risk, false positive, duplicate), then the results link. Colors only on a terminal without `NO_COLOR`; no spinners or `\r` redraws on a pipe.
- `agent`: tab-separated records, each kind under its own `record` header row: `gate` first (result `pass|fail|none`, exit code, condition, tripped count), then `scan`, open counts by `severity`, counts by `status` with what each status means, and up to five open `issue` rows (critical first) to fix first. `Hint: Run ...` lines for `corgea ls --issues --scan-id <id> --json` and `corgea inspect --issue <id>` go to stderr, as does every progress line, `CORGEA_SCAN_SKIPPED=` included, so stdout holds only the records.
- `json`: one document with `schema_version: 1`, `scan`, `gate`, `total_findings`, `by_status` (each with `critical`, `high`, `medium`, `low`, `total`), `unrecognized`, `fix_first` and `results_url`; `scan.reused_recent_scan` appears with `--skip-if-commit-scanned-recently`. Every other line the run prints, `CORGEA_SCAN_SKIPPED=` included, goes to stderr.
- no `--format`: tables of open issues by severity, of dependency findings (malicious and vulnerable packages), and of every code finding by status (open, fix in progress, fixed, accepted risk, false positive, duplicate), then the results link. A `Malware: N malicious packages` line follows the counts when the dependencies hold malware. When the dependency findings cannot be read, the summary prints `dependencies not fetched` and the error instead of a dependency table. Colors only on a terminal without `NO_COLOR`; no spinners or `\r` redraws on a pipe.
- `agent`: tab-separated records, each kind under its own `record` header row: `gate` first (result `pass|fail|none`, exit code, condition, tripped count), then `scan`, open counts by `severity`, counts by `status` with what each status means, `dependency` rows for `malicious` and `vulnerable` packages (counts by severity, `unrated`, `total`) or one `dependency_error` record when they could not be read, and up to five open `issue` rows (critical first) to fix first. `Hint: Run ...` lines for `corgea ls --issues --scan-id <id> --json` and `corgea inspect --issue <id>` go to stderr, as does every progress line, `CORGEA_SCAN_SKIPPED=` included, so stdout holds only the records.
- `json`: one document with `schema_version: 2`, `scan`, `gate`, `total_findings` (code and dependency findings; `null` when the dependency findings could not be read), `by_status` (code findings, each with `critical`, `high`, `medium`, `low`, `total`), `dependencies` (`malicious` and `vulnerable`, each with the four severities, `unrated` and `total`, plus `total` and `error`), `unrecognized`, `fix_first` and `results_url`. When the dependency findings could not be read, `dependencies.error` holds the error and its counts are `null`. `scan.reused_recent_scan` appears with `--skip-if-commit-scanned-recently`. Every other line the run prints, `CORGEA_SCAN_SKIPPED=` included, goes to stderr.
- `quiet`: no summary.

There is no `--format human`: omit the flag for tables. Agent environments are not detected for `scan` and `wait` (unlike `deps`), so an agent must pass `--format agent` or `--format json`. Open counts only findings with status `open` that are not held as false positives; `--fail-on` still counts every finding except false positives, as before, so its exit code is unchanged. Exit codes are the same in every format, and `--format` is independent of `--out-format`/`--out-file` and `--sbom`.
There is no `--format human`: omit the flag for tables. Agent environments are not detected for `scan` and `wait` (unlike `deps`), so an agent must pass `--format agent` or `--format json`. Open counts only findings with status `open` that are not held as false positives. Dependency findings count in every status, because the dependency endpoint does not report a status. `unrated` counts dependency findings whose severity is missing or not one of the four. `--fail-on` still counts every finding except false positives, as before, so its exit code is unchanged. Exit codes are the same in every format, and `--format` is independent of `--out-format`/`--out-file` and `--sbom`.

`--only-uncommitted` and `--target` are mutually exclusive. `--fail-on`, `--fail`, and `--block-on` are mutually exclusive.

Expand Down
24 changes: 9 additions & 15 deletions src/scanners/blast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub fn run(
&project_name,
&scan_id,
&counts_excluding_false_positives,
issues.dependencies(),
out_format.as_deref(),
out_file.as_deref(),
);
Expand All @@ -222,10 +223,10 @@ pub fn run(

let gate = evaluate_gate(
config,
&project_name,
&scan_id,
&gate_request,
&counts_excluding_false_positives,
issues.dependencies(),
);

let summary = ScanSummary::build(
Expand Down Expand Up @@ -259,10 +260,10 @@ pub enum GateRequest {

fn evaluate_gate(
config: &Config,
project_name: &str,
scan_id: &str,
request: &GateRequest,
counts_excluding_false_positives: &HashMap<String, usize>,
dependencies: Result<&[SCAIssue], &str>,
) -> Gate {
let fail_on = match request {
GateRequest::NotRequested => return Gate::NotRequested,
Expand Down Expand Up @@ -311,11 +312,7 @@ fn evaluate_gate(
};

let sca_issues = if tokens.iter().any(|t| t == "malicious") {
match utils::api::get_all_sca_issues(
&config.get_url(),
project_name,
Some(scan_id.to_string()),
) {
match dependencies {
Comment thread
juangaitanv marked this conversation as resolved.
Resolved
Ok(issues) => issues,
Err(e) => {
log::error!(
Expand All @@ -326,11 +323,11 @@ fn evaluate_gate(
}
}
} else {
Vec::new()
&[]
};

let condition = format!("--fail-on {fail_on} (findings in any status, not only open)");
match fail_on_tripped_count(&tokens, counts_excluding_false_positives, &sca_issues) {
match fail_on_tripped_count(&tokens, counts_excluding_false_positives, sca_issues) {
0 => Gate::Passed { condition },
tripped => Gate::Failed { condition, tripped },
}
Expand Down Expand Up @@ -945,6 +942,7 @@ fn write_scan_report(
project_name: &str,
scan_id: &str,
classifications: &HashMap<String, usize>,
dependencies: Result<&[SCAIssue], &str>,
out_format: Option<&str>,
out_file: Option<&str>,
) {
Expand Down Expand Up @@ -979,11 +977,7 @@ fn write_scan_report(
std::process::exit(1);
}
};
let sca_issues = match utils::api::get_all_sca_issues(
&config.get_url(),
project_name,
Some(scan_id.into()),
) {
let sca_issues = match dependencies {
Ok(issues) => issues,
Err(e) => {
stop_spinner();
Expand Down Expand Up @@ -1992,10 +1986,10 @@ mod tests {
.unwrap();
let gate = evaluate_gate(
&config,
"goof",
"scan-1",
&GateRequest::FailOn("HI".into()),
&summary::legacy_urgency_counts(&issues),
Ok(&[]),
);
assert_eq!(
gate,
Expand Down
Loading
Loading