Repository navigation
ci: fix Zizmor-identified issues in workflows - #27642
Conversation
|
PTAL @ashley-cui |
Luap99
left a comment
There was a problem hiding this comment.
Thanks, this is a large change which is doing many things at once, please split them into small commits to fix one issue at a time to make reviewing easier and clearly document in each commit what problem you are solving and why this fixes it.
Overall I think most of the changes seem good but it is really hard to follow the logic here so I really like to see the commits split so I can review this better
|
Marking as draft while I split the PR into multiple commits as requested. |
Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Also remove some unnecessary permissions: * The notification job in release-artifacts.yml only needs to read repo contents, not write contents and actions. * All jobs in release.yml except "Create release" and "Update podman.io" only need to read repo contents. "Update podman.io" only needs to write repo contents and pull requests. * Likewise, permissions for update-podmanio.yml can be restricted to only writing repo contents and pull requests. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Explicitly set `persist-credentials: true` for uses of `actions/checkout` where it's needed (when the job does git operations using the stored credentials) and `persist-credentials: false` where the stored credentials are not later used. This reduces the risk of cached credentials accidentally being leaked via artifacts. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
This mitigates a potential cache-poisoning attack. For details, see: https://docs.zizmor.sh/audits/#cache-poisoning Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Using `secrets: inherit` forwards all secrets to the workflow and makes it harder to determine which secrets the workflow was actually executed with. See: https://docs.zizmor.sh/audits/#secrets-inherit Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
sed scripts are capable of doing file I/O and executing arbitrary commands. The `--sandbox` option prevents this by rejecting sed commands with such capabilities; it's good practice to use this whenever the sed script is dynamically generated (e.g. if it involves a variable expansion). Also fixed an error in one sed script where `.*` had been placed outside of the quoted string (and would therefore be subject to shell globbing), presumably due to single-quotes having been changed to double-quotes at some point in the past. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Template expansions are not aware of shell script syntax, and therefore can potentially result in code injection vulnerabilities when used in code contexts: https://docs.zizmor.sh/audits/#template-injection To avoid this, instead use environment variables to safely store the values of the template expansions. Also (in the process of doing the above) added double-quotes around a some instances of variable expansions in shell scripts, which is necessary to avoid unintended shell splitting and globbing. (I didn't see any instances where this was actually likely to result in erroneous behavior, but it's good practice and makes shell scripts more robust.) Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
3 similar comments
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
PR has been split into multiple commits, each addressing just one issue. (Let me know if it'd be better to also make this multiple PRs—that'd be easy enough to do now that I've split the commits.) |
|
@timcoding1988 ptal |
|
LGTM |
|
Thanks for the PR @HastD . I just checked out your branch locally and tried zizmor v1.18.0 installed via pip on Fedora 43 and got this: Is that expected? Also, @containers/podman-maintainers , I think it'd be nice to have zizmor run as a separate CI job or part of validate. |
|
@lsm5 Yes, this PR doesn't fix that issue—replacing I also agree it'd be a good idea to add a Zizmor workflow to flag workflow issues if future PRs reintroduce them. It's easy to set up, there's a GitHub action: https://docs.zizmor.sh/integrations/#via-zizmorcorezizmor-action |
SGTM
Great! Would be nice to get in once the insecure workflow trigger is fixed. Thanks @HastD |
|
I am not sure how we could replace pull_request_target for machine-os-pr or the issue-labler but sure create an issue if you have ideas and we can discus there. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: HastD, lsm5, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
9a811bf
into
podman-container-tools:main
Zizmor (https://docs.zizmor.sh/) is a static analysis tool for GitHub Actions. Most of the issues identified by Zizmor were fixed in podman-container-tools#27642. This Zizmor action integrates with GitHub Advanced Security and scans workflows for potential security issues, which should help ensure that such issues aren't reintroduced in the future. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Zizmor (https://docs.zizmor.sh/) is a static analysis tool for GitHub Actions. Most of the issues identified by Zizmor were fixed in podman-container-tools#27642. This Zizmor action integrates with GitHub Advanced Security and scans workflows for potential security issues, which should help ensure that such issues aren't reintroduced in the future. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
Fix various potentially security-relevant issues identified by Zizmor:
persist-credentialsforactions/checkout: https://docs.zizmor.sh/audits/#artipackedcache: falsewithactions/setup-goto prevent possible cache poisoning: https://docs.zizmor.sh/audits/#cache-poisoningAlso, a couple shell script issues fixed:
--sandboxforsedcommands with dynamically generated scripts: https://www.gnu.org/software/sed/manual/sed.html#Command_002dLine-Options ("Sandbox mode ensuressedoperates only on the input files designated on the command line, and cannot run external programs.")Checklist
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?