Skip to content
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

Added a workflow to ignore some audit findings #44672

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ignore-some-audit-findings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Ignore some audit findings
on:
issues:
types: [opened]

jobs:
create-pr:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.AUDIT_CONFIG_TOKEN }}
IGNORE_PAT: 'cwe-133|cwe-400|cwe-1050|cwe-1333|denial of service|dos|redos|resource exhaustion|regexp|rxdos'
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
steps:
- name: Trigger the creation of an audit-config PR to ignore an audit finding if it matches the specified criteria
if: startsWith(github.event.issue.title, 'Audit finding:') &&
contains(github.event.issue.labels.*.name, 'bot/type/audit') &&
github.event.issue.user.login == 'brave-builds'
run: |
set -eEo pipefail
shopt -s inherit_errexit

if advisory_id="$(cut -d' ' -f3 <<<"${ISSUE_TITLE:?}"|grep -oP 'GHSA-\w+-\w+-\w+')"; then
advisory_details="$(gh api -H "Accept: application/vnd.github+json" "/advisories/$advisory_id" \
-q '.cwes[].cwe_id + "\n" + .summary + "\n" + .description')"

if grep -qwiE "${IGNORE_PAT:?}" <<<"${advisory_details:?}"; then
gh -R "${GITHUB_REPOSITORY_OWNER:?}"/audit-config workflow run create_pull_request.yml \
-f advisory="${advisory_id:?}" \
-f issue="${ISSUE_URL:?}"
echo "Opened a PR to ignore $advisory_id"|tee "${GITHUB_STEP_SUMMARY:?}"
fi
fi