Skip to content

CHORE Zizmor: branch protection for GH workflows#3103

Open
BenjaminBossan wants to merge 3 commits intohuggingface:mainfrom
BenjaminBossan:chore-branch-protection-for-zizmor
Open

CHORE Zizmor: branch protection for GH workflows#3103
BenjaminBossan wants to merge 3 commits intohuggingface:mainfrom
BenjaminBossan:chore-branch-protection-for-zizmor

Conversation

@BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented Mar 16, 2026

Zizmor currently gives the following type of warning:

  --> .github/workflows/build_docker_images.yml:33:25
   |
19 |   latest-cpu:
   |   ---------- this job
...
33 |           username: ${{ secrets.DOCKERHUB_USERNAME }}
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^ secret is accessed outside of a dedicated environment

https://github.com/huggingface/peft/actions/runs/23046711202/job/66937507862

This is not really an issue, since these workflows are only triggered on main, thus attackers cannot exfiltrate secrets this way. Moreover, maintainers vet each PR before allowing CI to run. Finally, GH doesn't expose secrets to forks by default. There are thus multiple layers of protection, which make these warnings false positives.

However, for forward security, I still added a GH Environment with branch protection (only 'main') and wait timer where appropriate.

https://github.com/huggingface/peft/settings/environments

This should add yet another protection layer in case the others are inadvertently removed in the future.

With these changes, I had to update the Zizmor config, as the lines to ignore moved around. There, I also saw that there were some lines in build_docker_images.yml that no longer exists, as we have removed the BNB CI, so these lines were removed too.

Zizmor currently gives the following type of warning:

  --> .github/workflows/build_docker_images.yml:33:25
   |
19 |   latest-cpu:
   |   ---------- this job
...
33 |           username: ${{ secrets.DOCKERHUB_USERNAME }}
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^ secret is accessed outside of a dedicated environment

https://github.com/huggingface/peft/actions/runs/23046711202/job/66937507862

This is not really an issue, since these workflows are only triggered on
main, thus attackers cannot exfiltrate secrets this way. Moreover,
maintainers vet each PR before allowing CI to run. Finally, GH doesn't
expose secrets to forks by default. There are thus multiple layers of
protection, which make these warnings false positives.

However, for forward security, I still added a GH Environment with
branch protection (only 'main') and wait timer where appropriate.

https://github.com/huggingface/peft/settings/environments

This should add yet another protection layer in case the others are
inadvertently removed in the future.

With these changes, I had to update the Zizmor config, as the lines to
ignore moved around. There, I also saw that there were some lines in
build_docker_images.yml that no longer exists, as we have removed the
BNB CI, so these lines were removed too.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@githubnemo githubnemo left a comment

Choose a reason for hiding this comment

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

One comment, otherwise LGTM

Comment on lines +21 to +22
# GH Environment for extra protection: https://github.com/huggingface/peft/settings/environments
environment: branch-protection-main
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean that when testing a change for, say, building & pushing the container the build will now fail at the push stage since the secret is not available? Maybe we should document that this will limit the token availability to main so that we don't trip over this in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

When testing a change to the docker build, we only run https://github.com/huggingface/peft/blob/main/.github/workflows/test-docker-build.yml, i.e. only building it but not pushing it, so that should be fine. AFAICT, we don't have testing where we also push the docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants