Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds composite actions support to known-vulnerable-actions #367

Merged
merged 1 commit into from
Dec 26, 2024
Merged
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
6 changes: 3 additions & 3 deletions docs/audits.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ within an authentic commit (or an authentic tag/branch reference).

## `known-vulnerable-actions`

| Type | Examples | Introduced in | Works offline | Enabled by default |
|----------|--------------------------------|---------------|----------------|--------------------|
| Workflow | [known-vulnerable-actions.yml] | v0.1.0 | ❌ | ✅ |
| Type | Examples | Introduced in | Works offline | Enabled by default |
|------------------|--------------------------------|---------------|----------------|--------------------|
| Workflow, Action | [known-vulnerable-actions.yml] | v0.1.0 | ❌ | ✅ |

[known-vulnerable-actions.yml]: https://github.com/woodruffw/gha-hazmat/blob/main/.github/workflows/known-vulnerable-actions.yml

Expand Down
31 changes: 29 additions & 2 deletions src/audit/known_vulnerable_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

use anyhow::{anyhow, Context, Result};

use super::{audit_meta, Audit};
use crate::finding::Finding;
use crate::models::CompositeStep;
use crate::{
finding::{Confidence, Severity},
github_api,
models::{RepositoryUses, Uses},
state::AuditState,
};

use super::{audit_meta, Audit};

pub(crate) struct KnownVulnerableActions {
client: github_api::Client,
}
Expand Down Expand Up @@ -161,4 +162,30 @@ impl Audit for KnownVulnerableActions {

Ok(findings)
}

fn audit_composite_step<'a>(&self, step: &CompositeStep<'a>) -> Result<Vec<Finding<'a>>> {
let mut findings = vec![];

let Some(Uses::Repository(uses)) = step.uses() else {
return Ok(findings);
};

for (severity, id) in self.action_known_vulnerabilities(&uses)? {
findings.push(
Self::finding()
.confidence(Confidence::High)
.severity(severity)
.add_location(
step.location()
.primary()
.with_keys(&["uses".into()])
.annotated(&id)
.with_url(format!("https://github.com/advisories/{id}")),
)
.build(step.action())?,
);
}

Ok(findings)
}
}
Loading