Skip to content

Commit

Permalink
fix: dont crash when an expression does not expand a matrix (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubiratansoares authored Dec 12, 2024
1 parent 2099732 commit b27c254
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/audit/self_hosted_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ impl WorkflowAudit for SelfHostedRunner {
// The entire `runs-on:` is an expression, which may or may
// not be a self-hosted runner when expanded, like above.
LoE::Expr(exp) => {
let matrix = Matrix::try_from(&job)?;
let Ok(matrix) = Matrix::try_from(&job) else {
continue;
};

let expansions = matrix.expanded_values;

Expand Down
5 changes: 5 additions & 0 deletions tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ fn self_hosted() -> Result<()> {
.args(["--persona=auditor"])
.run()?);

// Fixed regressions
insta::assert_snapshot!(zizmor()
.workflow(workflow_under_test("self-hosted/issue-283-repro.yml"))
.args(["--persona=auditor"])
.run()?);
Ok(())
}

Expand Down
6 changes: 6 additions & 0 deletions tests/snapshots/snapshot__self_hosted-8.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/snapshot.rs
expression: "zizmor().workflow(workflow_under_test(\"self-hosted/issue-283-repro.yml\")).args([\"--persona=auditor\"]).run()?"
snapshot_kind: text
---
No findings to report. Good job!
13 changes: 13 additions & 0 deletions tests/test-data/self-hosted/issue-283-repro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Workflow

on:
workflow_call:
inputs:
os:
type: string

jobs:
deploy:
runs-on: ${{inputs.os}}
steps:
- run: echo "Hello world"

0 comments on commit b27c254

Please sign in to comment.