nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: woodruffw/zizmor
Pull request #284 (2024-12-12 20:15:59)

fix: dont crash when an expression does not expand a matrix
A tentative fix for #283 

Added both the repro Workflow and the snapshot test to get us covered!

woodruffw: LGTM, thanks for the fast fix @ubiratansoares! I'll get this out in `0.9.1` now.

Patch:
diff --git a/src/audit/self_hosted_runner.rs b/src/audit/self_hosted_runner.rs
index c0122f3..733bb67 100644
--- a/src/audit/self_hosted_runner.rs
+++ b/src/audit/self_hosted_runner.rs
@@ -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;
 


Test patch:
diff --git a/tests/snapshot.rs b/tests/snapshot.rs
index 8318a26..16d22f3 100644
--- a/tests/snapshot.rs
+++ b/tests/snapshot.rs
@@ -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(())
 }
 
diff --git a/tests/snapshots/snapshot__self_hosted-8.snap b/tests/snapshots/snapshot__self_hosted-8.snap
new file mode 100644
index 0000000..cd4e905
--- /dev/null
+++ b/tests/snapshots/snapshot__self_hosted-8.snap
@@ -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!
diff --git a/tests/test-data/self-hosted/issue-283-repro.yml b/tests/test-data/self-hosted/issue-283-repro.yml
new file mode 100644
index 0000000..8379f8a
--- /dev/null
+++ b/tests/test-data/self-hosted/issue-283-repro.yml
@@ -0,0 +1,13 @@
+name: Workflow
+
+on:
+  workflow_call:
+    inputs:
+      os:
+        type: string
+
+jobs:
+  deploy:
+    runs-on: ${{inputs.os}}
+    steps:
+      - run: echo "Hello world"