-
Notifications
You must be signed in to change notification settings - Fork 863
Create ghas-push-protection-resolve-block.prompt.md #28
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
nomdal
wants to merge
3
commits into
github:main
Choose a base branch
from
nomdal:patch-1
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.
+88
−0
Open
Changes from all commits
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
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,85 @@ | ||
--- | ||
mode: "agent" | ||
tools: ["changes", "codebase", "editFiles", "problems", "terminal"] | ||
description: "Help developers resolve GitHub Advanced Security push protection blocked pushes containing secrets" | ||
--- | ||
# GHAS Push Protection: Resolve Blocked Push | ||
|
||
nomdal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Your goal is to help me resolve a blocked push that was prevented by GitHub Advanced Security push protection due to detected secrets in my commits. You should automatically analyze the CLI output, detect the blocked push information, and guide me through the proper resolution strategy. | ||
|
||
## Automated Analysis and Strategy Selection | ||
|
||
You will automatically: | ||
|
||
1. **Gather context** by running diagnostic commands and parsing terminal output | ||
2. **Extract key information** from the push protection error: | ||
- Commit IDs and file paths where secrets were detected | ||
- Secret types (API keys, tokens, etc.) from error headers | ||
- Chronological order of affected commits | ||
3. **Select optimal resolution strategy** based on commit analysis and recommendations detailed in GitHub Documentation: | ||
- Resolving a blocked push: https://docs.github.com/en/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push | ||
4. **Execute the resolution** with real-time validation, and if any manual intervention following a command in the CLI is expected of the user, I will inform them of this before I execute the command, with a recommendation of what they will need to do (such as entering ":q") | ||
|
||
### Error Pattern Recognition | ||
You will parse patterns like: | ||
``` | ||
remote: —— GitHub Personal Access Token —————————————————————— | ||
remote: - commit: 8728dbe67 | ||
remote: path: README.md:4 | ||
``` | ||
|
||
## Resolution Strategies | ||
|
||
You will automatically choose and execute the appropriate strategy: | ||
|
||
### Latest Commit Only | ||
```bash | ||
# Remove secret from code, then: | ||
git add . | ||
git commit --amend --no-edit | ||
git push | ||
``` | ||
|
||
### Earlier Commits | ||
```bash | ||
# Find earliest problematic commit and rebase: | ||
git rebase -i <EARLIEST_COMMIT>~1 | ||
# When using interactive rebase to squash commits containing secrets, you will provide automated sed commands to modify the rebase TODO file without user manual intervention. | ||
``` | ||
|
||
### Multiple Commits | ||
Plan comprehensive rebase strategy addressing all detected commit IDs. | ||
|
||
## Secret Removal Best Practices | ||
|
||
- **Remove the actual secret**: Replace API keys, tokens, passwords, or other sensitive data with placeholders or environment variables | ||
- **Use environment variables**: Move secrets to environment variables or secure configuration files | ||
- **Update .gitignore**: Add patterns to prevent similar files from being committed in the future | ||
|
||
## Automated Error Handling | ||
|
||
You will handle common scenarios: | ||
- **Merge conflicts** during rebase (identify conflicted files, guide resolution) | ||
- **Large repositories** (optimize commands for performance) | ||
- **Branch protection rules** (check for restrictions that might affect resolution) | ||
|
||
## Smart Bypass Assessment | ||
|
||
If patterns suggest false positives, you will analyze for: | ||
- Test data patterns ("test_api_key", "fake_token") | ||
- Placeholder values ("YOUR_API_KEY_HERE") | ||
- Example/documentation code | ||
|
||
You will extract bypass URLs from error messages and recommend appropriate reasons: | ||
- "It's used in tests" - for harmless test secrets | ||
- "It's a false positive" - for non-secrets | ||
- "I'll fix it later" - for real secrets to be addressed soon | ||
|
||
## Post-Resolution Verification | ||
|
||
After resolving, you will automatically: | ||
1. **Verify secret removal** using pattern matching and Git history checks | ||
2. **Test push capability** with `git push --dry-run` | ||
3. **Suggest prevention measures** (pre-commit hooks, .gitignore updates) | ||
|
||
**Goal**: Maintain security while enabling productive development. Always prioritize removing real secrets over bypassing protection. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description doesn't match the one in the prompt file. Ensure this is generated using the
update-readme.js
scriptThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I generate this using the update-readme.js script? I don't follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge the
main
branch in and runnode update-readme.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "merge the main branch in"? Sorry, I don't follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are merge conflicts with the
main
branch that need to be resolved. Here's a guide for doing that with GitHub Desktop - https://docs.github.com/en/desktop/working-with-your-remote-repository-on-github-or-github-enterprise/syncing-your-branch-in-github-desktop