Skip to content

Add Fix for known-vulnerable-actions audit rule - #1019

Merged
woodruffw merged 32 commits into
zizmorcore:mainfrom
mostafa:known-vulnerable-actions-fix
Jul 21, 2025
Merged

Add Fix for known-vulnerable-actions audit rule#1019
woodruffw merged 32 commits into
zizmorcore:mainfrom
mostafa:known-vulnerable-actions-fix

Conversation

@mostafa

@mostafa mostafa commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

xref #876

Comment thread crates/zizmor/src/audit/known_vulnerable_actions.rs Outdated
@woodruffw woodruffw added enhancement New feature or request autofix Auto-fix functionality labels Jul 12, 2025
Comment thread crates/zizmor/src/audit/known_vulnerable_actions.rs
Comment thread crates/zizmor/src/audit/known_vulnerable_actions.rs Outdated
Comment on lines +114 to +118
// Get the first patched version from the first vulnerability in the advisory
let first_patched_version = vuln
.vulnerabilities
.first()
.and_then(|v| v.first_patched_version.clone());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting: this looks great to me for now, but we might want to additionally filter by semver compatibility between versions. But that can be a future problem 🙂

@woodruffw

Copy link
Copy Markdown
Member

Thanks @mostafa, this looks great! One comment about the patch we apply, but otherwise this LGTM.

Comment thread crates/zizmor/src/audit/known_vulnerable_actions.rs Outdated
Comment thread crates/zizmor/src/audit/known_vulnerable_actions.rs Outdated
Still not correct, but closer.
runs-on: ubuntu-latest
steps:
- name: Commit pinned action
uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 # v4.0.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Whoops, invalidated my own earlier comment.)

Removing some of the mocking revealed this bug -- our current RewriteFragment is probably too brittle with respect to whitespace. I think what we need to do here is either extend the RewriteFragment API to allow regexes or use two different fragments here (one for the commit hash, and one for the version itself).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it some more, we'll probably need to do it with a regex -- there will be a lot of small variations in syntax and whitespace that we'll need to match consistently for the replacement.

Specifically, we should probably match Dependabot's own behavior here:

https://github.com/dependabot/dependabot-core/pull/5951/files#diff-fd484a22a8411825b6409071a0d839654c9629162c27b0be71e6abe7b7a8d08b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(More random thoughts)

I think what we can do to make this clean here is move the Fragment and Subfeature APIs (along with Span) into a common crate, which the location APIs (in zizmor) and the RewriteFragment op (in yamlpatch) can then both consume. That'll give us regex-based fragment rewriting using the primitives that are already well-tested in the codebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've already implemeneted it, so I'll leave it up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I guess we should release a new version of yamlpatch as well.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep -- I have yamlpatch set up with trusted publishing on crates.io, so I'll cut a tag after this is merged and it'll auto-release 🙂

@woodruffw woodruffw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a ton @mostafa!

@woodruffw
woodruffw merged commit 558bec2 into zizmorcore:main Jul 21, 2025
@mostafa
mostafa deleted the known-vulnerable-actions-fix branch July 21, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autofix Auto-fix functionality enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants