mirror of
https://github.com/zizmorcore/zizmor.git
synced 2025-12-23 08:47:33 +00:00
fix: disambiguate workflows with misleading names (#1345)
Some checks are pending
CI / Test site build (push) Waiting to run
CI / All tests pass (push) Blocked by required conditions
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build macOS wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (manylinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (musllinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Windows wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build source distribution (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Release (push) Blocked by required conditions
Deploy zizmor documentation site 🌐 / Deploy zizmor documentation to GitHub Pages 🌐 (push) Waiting to run
GitHub Actions Security Analysis with zizmor 🌈 / Run zizmor 🌈 (push) Waiting to run
Some checks are pending
CI / Test site build (push) Waiting to run
CI / All tests pass (push) Blocked by required conditions
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build macOS wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (manylinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (musllinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Windows wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build source distribution (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Release (push) Blocked by required conditions
Deploy zizmor documentation site 🌐 / Deploy zizmor documentation to GitHub Pages 🌐 (push) Waiting to run
GitHub Actions Security Analysis with zizmor 🌈 / Run zizmor 🌈 (push) Waiting to run
This commit is contained in:
parent
a06377f9ab
commit
8ad180b38d
5 changed files with 50 additions and 2 deletions
|
|
@ -384,16 +384,29 @@ impl InputGroup {
|
|||
) -> Result<Self, CollectionError> {
|
||||
let config = Config::discover(options, || Config::discover_local(path)).await?;
|
||||
|
||||
// Workflows can be named anything, including `dependabot.yml`
|
||||
// (overlapping with Dependabot configs) and `action.yml` (overlapping
|
||||
// with action definitions). Consequently, we make a best effort
|
||||
// disambiguate them by looking at their parent path.
|
||||
// See: https://github.com/zizmorcore/zizmor/issues/1341
|
||||
let is_workflow_path = {
|
||||
let resolved = path.canonicalize_utf8()?;
|
||||
|
||||
resolved
|
||||
.parent()
|
||||
.is_some_and(|parent| parent.ends_with(".github/workflows"))
|
||||
};
|
||||
|
||||
let mut group = Self::new(config);
|
||||
|
||||
// When collecting individual files, we don't know which part
|
||||
// of the input path is the prefix.
|
||||
let (key, kind) = match (path.file_stem(), path.extension()) {
|
||||
(Some("dependabot"), Some("yml" | "yaml")) => (
|
||||
(Some("dependabot"), Some("yml" | "yaml")) if !is_workflow_path => (
|
||||
InputKey::local(Group(path.as_str().into()), path, None),
|
||||
InputKind::Dependabot,
|
||||
),
|
||||
(Some("action"), Some("yml" | "yaml")) => (
|
||||
(Some("action"), Some("yml" | "yaml")) if !is_workflow_path => (
|
||||
InputKey::local(Group(path.as_str().into()), path, None),
|
||||
InputKind::Action,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -430,3 +430,21 @@ fn issue_1300() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Regression test for #1341.
|
||||
///
|
||||
/// Ensures that we successfully collect a *workflow* named `dependabot.yml`, rather
|
||||
/// than failing to parse it as a Dependabot config.
|
||||
#[test]
|
||||
fn issue_1341() -> Result<()> {
|
||||
insta::assert_snapshot!(
|
||||
zizmor()
|
||||
.offline(true)
|
||||
.input(input_under_test(
|
||||
"issue-1341-repro/.github/workflows/dependabot.yml"
|
||||
))
|
||||
.run()?,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
source: crates/zizmor/tests/integration/e2e.rs
|
||||
expression: "zizmor().offline(true).input(input_under_test(\"issue-1341-repro/.github/workflows/dependabot.yml\")).run()?"
|
||||
---
|
||||
No findings to report. Good job! (2 suppressed)
|
||||
8
crates/zizmor/tests/integration/test-data/issue-1341-repro/.github/workflows/dependabot.yml
vendored
Normal file
8
crates/zizmor/tests/integration/test-data/issue-1341-repro/.github/workflows/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
name: a valid workflow
|
||||
on: [push]
|
||||
permissions: {}
|
||||
jobs:
|
||||
something:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo ok
|
||||
|
|
@ -35,6 +35,10 @@ of `zizmor`.
|
|||
* The [concurrency-limits] audit now correctly detects job-level `concurrency`
|
||||
settings, in addition to workflow-level settings (#1338)
|
||||
|
||||
* Fixed a bug where `zizmor` would fail to collect workflows with names that
|
||||
overlapped with other input types (e.g. `action.yml` and `dependabot.yml`)
|
||||
when passed explicitly by path (#1345)
|
||||
|
||||
## 1.16.3
|
||||
|
||||
### Bug Fixes 🐛
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue