-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Cannot Dismiss/Delete more than 25 alerts at a time from UI #8250
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
Comments
|
Hi @mismailkhan88, thanks for your question. As far as I'm aware, it's not possible to dismiss more than 25 at a time using the UI. You should be able to use the API to dismiss alerts though, which is described here: https://docs.github.com/en/rest/reference/code-scanning#update-a-code-scanning-alert |
|
Hi @RasmusWL, |
|
@mismailkhan88 It's available out of the box. See https://docs.github.com/en/rest/reference/code-scanning#update-a-code-scanning-alert . The |
|
I was testing out an action that checked the spelling of words in a repository, and it opened 5k+ code scanning alerts. I found this thread, which helped expedite me finding that there was an API for dismissing alerts. Because sharing is caring, below is the script I crafted to bulk search + dismiss alerts: #!/bin/bash
TOOL_NAME="check-spelling"
STATE="open"
GITHUB_REPO="ChrisCarini/sample-intellij-plugin"
DESIRED_STATE="dismissed"
DISMISSAL_REASON="won't fix"
DISMISSAL_COMMENT="I was trying out check-spelling; but it opened a ton of code scanning issues and covered **WAY** more than I wanted/expected. I've since removed it from this repo, and am now dismissing all alerts it generated."
# Loop until no alerts are found
while true; do
# Fetch the results and extract the URLs using jq
result=$(gh api "/repos/${GITHUB_REPO}/code-scanning/alerts?tool_name=${TOOL_NAME}&per_page=100&state=${STATE}" | jq -r '.[].url')
# Check if the result is empty
if [ -z "$result" ]; then
echo "No ${STATE} alerts found for the ${TOOL_NAME} tool. Exiting."
break
else
alert_count=$(echo "$result" | grep -c '^')
echo "Found ${alert_count} ${STATE} alerts for the ${TOOL_NAME} tool."
# Pipe each URL into xargs, and execute the gh api command without using sh -c
echo "$result" | xargs -n 1 -I{} \
gh api --method PATCH {} \
-f "state=${DESIRED_STATE}" \
-f "dismissed_reason=${DISMISSAL_REASON}" \
-f "dismissed_comment=${DISMISSAL_COMMENT}" \
| jq -r '"Alert \(.number) dismissed:\n\tURL: \(.html_url)\n\tState: \(.state)\n\tDismissed by: \(.dismissed_by.login)\n\tDismissed at: \(.dismissed_at)\n\tReason: \(.dismissed_reason)"'
fi
echo "Sleeping for 10 seconds..."
sleep 10
doneHopefully it helps save someone else a bit of time from needing to craft a similar script in the future. 😄 |
In a project I am currently working on, there are 4000+ code scanning alerts (coming from the security-and-quality query) rules we've investigated, which are not a real problem for us, so we'd like to close all of them together.
Through the UI on the Code Scanning Alerts page, I see that only 25 entries can be selected at a time that appears on a single page.
Is this possible to select all of the alerts in bulk and apply some action on all of them at once?
The text was updated successfully, but these errors were encountered: