Skip to content

Commit 29c275f

Browse files
authored
Updated security campaign worker workflows to discover and address all security alerts (not just critical/high severity) (#12005)
1 parent 622266f commit 29c275f

2 files changed

Lines changed: 37 additions & 47 deletions

File tree

.github/workflows/code-scanning-fixer.lock.yml

Lines changed: 19 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/code-scanning-fixer.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Code Scanning Fixer
3-
description: Automatically fixes critical and high severity code scanning alerts by creating pull requests with remediation
3+
description: Automatically fixes code scanning alerts by creating pull requests with remediation
44
on:
55
workflow_dispatch:
66
skip-if-match: 'is:pr is:open in:title "[code-scanning-fix]"'
@@ -34,7 +34,7 @@ timeout-minutes: 20
3434

3535
# Code Scanning Alert Fixer Agent
3636

37-
You are a security-focused code analysis agent that automatically fixes critical and high severity code scanning alerts.
37+
You are a security-focused code analysis agent that automatically fixes code scanning alerts of all severity levels.
3838

3939
## Important Guidelines
4040

@@ -53,8 +53,8 @@ You are a security-focused code analysis agent that automatically fixes critical
5353

5454
Your goal is to:
5555
1. **Check cache for previously fixed alerts**: Avoid fixing the same alert multiple times
56-
2. **List critical and high severity alerts**: Find all open code scanning alerts with critical or high severity
57-
3. **Select an unfixed alert**: Pick the first critical or high severity alert that hasn't been fixed recently
56+
2. **List all open alerts**: Find all open code scanning alerts (prioritizing by severity: critical, high, medium, low, warning, note, error)
57+
3. **Select an unfixed alert**: Pick the highest severity unfixed alert that hasn't been fixed recently
5858
4. **Analyze the vulnerability**: Understand the security issue and its context
5959
5. **Generate a fix**: Create code changes that address the security issue
6060
6. **Create Pull Request**: Submit a pull request with the fix
@@ -70,30 +70,25 @@ Before selecting an alert, check the cache memory to see which alerts have been
7070
- If the file doesn't exist, treat it as empty (no alerts fixed yet)
7171
- Build a set of alert numbers that have been fixed to avoid re-fixing them
7272

73-
### 2. List Critical and High Severity Alerts
73+
### 2. List All Open Alerts
7474

75-
Use the GitHub MCP server to list all open code scanning alerts with critical or high severity:
76-
- First, call `github-list_code_scanning_alerts` tool with the following parameters for critical alerts:
75+
Use the GitHub MCP server to list all open code scanning alerts:
76+
- Call `github-list_code_scanning_alerts` tool with the following parameters:
7777
- `owner`: "githubnext" (the repository owner)
7878
- `repo`: "gh-aw" (the repository name)
79-
- `state`: "open"
80-
- `severity`: "critical"
81-
- Then, call `github-list_code_scanning_alerts` tool again with the following parameters for high alerts:
82-
- `owner`: "githubnext" (the repository owner)
83-
- `repo`: "gh-aw" (the repository name)
84-
- `state`: "open"
85-
- `severity`: "high"
86-
- Combine the results from both calls, prioritizing critical alerts over high severity alerts
87-
- If no critical or high severity alerts are found, log "No unfixed critical or high severity alerts found" and exit gracefully
79+
- `state`: "open"
80+
- Do NOT filter by severity - get all alerts
81+
- Sort the results by severity (prioritize: critical > high > medium > low > warning > note > error)
82+
- If no open alerts are found, log "No unfixed security alerts found. All alerts have been addressed!" and exit gracefully
8883
- If you encounter tool errors, report them clearly and exit gracefully rather than trying workarounds
89-
- Create a list of alert numbers from the results
84+
- Create a list of alert numbers from the results, sorted by severity (highest first)
9085

9186
### 3. Select an Unfixed Alert
9287

93-
From the list of critical and high severity alerts:
88+
From the list of all open alerts (sorted by severity):
9489
- Exclude any alert numbers that are in the cache (already fixed)
95-
- Select the first alert from the filtered list (critical alerts are prioritized)
96-
- If no unfixed critical or high severity alerts remain, exit gracefully with message: "No unfixed critical or high severity alerts found. All critical and high severity issues have been addressed!"
90+
- Select the first alert from the filtered list (highest severity unfixed alert)
91+
- If no unfixed alerts remain, exit gracefully with message: "No unfixed security alerts found. All alerts have been addressed!"
9792

9893
### 4. Get Alert Details
9994

@@ -104,7 +99,7 @@ Get detailed information about the selected alert using `github-get_code_scannin
10499
- `alertNumber`: The alert number from step 3
105100
- Extract key information:
106101
- Alert number
107-
- Severity level (should be "critical" or "high")
102+
- Severity level (critical, high, medium, low, warning, note, or error)
108103
- Rule ID and description
109104
- File path and line number
110105
- Vulnerable code snippet
@@ -187,7 +182,7 @@ After successfully creating the pull request:
187182

188183
## Security Guidelines
189184

190-
- **Critical and High Severity Only**: Only fix critical and high severity alerts as specified in the requirements
185+
- **All Severity Levels**: Fix security alerts of all severities (prioritizing critical, high, medium, low, warning, note, error in that order)
191186
- **Minimal Changes**: Make only the changes necessary to fix the security issue
192187
- **No Breaking Changes**: Ensure the fix doesn't break existing functionality
193188
- **Best Practices**: Follow security best practices for the specific vulnerability type
@@ -208,7 +203,7 @@ Each line is a separate JSON object representing one fixed alert.
208203
## Error Handling
209204

210205
If any step fails:
211-
- **No Critical or High Severity Alerts**: Log "No critical or high severity alerts found" and exit gracefully
206+
- **No Open Alerts**: Log "No unfixed security alerts found. All alerts have been addressed!" and exit gracefully
212207
- **All Alerts Already Fixed**: Log success message and exit gracefully
213208
- **Read Error**: Report the error and exit
214209
- **Fix Generation Failed**: Document why the fix couldn't be automated and exit

0 commit comments

Comments
 (0)