-
Notifications
You must be signed in to change notification settings - Fork 37
Pin GitHub Actions to commit SHAs and document security practices #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Miladiir
wants to merge
3
commits into
tailscale:main
Choose a base branch
from
Miladiir:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Contributing to gitops-acl-action | ||
|
|
||
| Thank you for your interest in contributing to this project! | ||
|
|
||
| ## GitHub Actions Best Practices | ||
|
|
||
| This repository follows GitHub Actions security best practices to ensure the integrity and security of our CI/CD pipeline. | ||
|
|
||
| ### Action Pinning Standard | ||
|
|
||
| All GitHub Actions used in this repository **must** be pinned to a specific commit SHA rather than using mutable tags like `@main`, `@latest`, or even version tags like `@v1`. | ||
|
|
||
| **Why pin to commit SHAs?** | ||
| - Prevents supply chain attacks where an action maintainer's account could be compromised | ||
| - Ensures reproducible builds - the action won't change unexpectedly | ||
| - Provides an immutable reference that can't be altered | ||
| - Allows security audits of the exact code being executed | ||
|
|
||
| **Format:** | ||
| ```yaml | ||
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | ||
| ``` | ||
| Note: We include the version tag in a comment for human readability, but the commit SHA is what's actually used. | ||
| ### Dependabot for Action Updates | ||
| This repository uses Dependabot to automatically check for updates to pinned GitHub Actions. Dependabot is configured in `.github/dependabot.yml` to: | ||
| - Check for updates weekly | ||
| - Monitor both workflow files (`.github/workflows/`) and composite action files (`action.yml`) | ||
| - Create pull requests when new versions are available | ||
|
|
||
| When Dependabot creates a PR to update an action: | ||
| 1. Review the changelog and release notes for the new version | ||
| 2. Verify the action source code if there are significant changes | ||
| 3. Test the changes in the PR | ||
| 4. Merge only if all checks pass and changes are reviewed | ||
|
|
||
| ### Security Best Practices | ||
|
|
||
| When working with GitHub Actions in this repository: | ||
|
|
||
| 1. **Minimal Permissions**: Use the `permissions` key to grant only the minimal permissions required | ||
| 2. **Verified Actions**: Prefer official GitHub Actions and verified creators | ||
| 3. **Secret Handling**: Never pass secrets to untrusted third-party actions | ||
| 4. **Code Review**: Review action source code before introducing new dependencies | ||
| 5. **Avoid Remote Code Execution**: Never run untrusted remote code (e.g., `curl | bash`) | ||
| 6. **Regular Updates**: Keep actions up-to-date through Dependabot and periodic manual reviews | ||
|
|
||
| ### Adding New Actions | ||
|
|
||
| When adding a new GitHub Action to a workflow or composite action: | ||
|
|
||
| 1. Find the latest release/tag of the action | ||
| 2. Get the commit SHA for that tag | ||
| 3. Pin to the commit SHA with a version comment | ||
| 4. Document why the action is needed in your PR | ||
|
|
||
| Example: | ||
| ```yaml | ||
| # Get the commit SHA for a tag | ||
| git ls-remote https://github.com/actions/checkout v4 | ||
| # Use the resulting SHA in your workflow | ||
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| ``` | ||
|
|
||
| ### Updating Actions | ||
|
|
||
| Dependabot will automatically create PRs to update pinned actions. Manual updates can be done by: | ||
|
|
||
| 1. Finding the new version's commit SHA | ||
| 2. Updating the SHA and version comment | ||
| 3. Testing the changes | ||
| 4. Creating a PR with a clear description of what's being updated | ||
|
|
||
| ### Maintaining Documentation Examples | ||
|
|
||
| **Important:** Dependabot automatically updates action references in `action.yml` and `.github/workflows/` files, but it **does not** update code examples in markdown documentation files like README.md. | ||
|
|
||
| When Dependabot updates action versions in `action.yml`: | ||
| 1. Review the README.md file to check if examples need updating | ||
| 2. Update the pinned commit SHAs in the README examples to match | ||
| 3. Include these documentation updates in the same PR or a follow-up commit | ||
|
|
||
| This ensures users always have current examples showing the correct pinning format. | ||
|
|
||
| ## Questions? | ||
|
|
||
| If you have questions about these practices or need help implementing them, please open an issue for discussion. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.