|
| 1 | +name: Argus Retest After Fix |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [closed] |
| 5 | + |
| 6 | +jobs: |
| 7 | + retest: |
| 8 | + # Only run when an argus/fix- PR is merged |
| 9 | + if: > |
| 10 | + github.event.pull_request.merged == true && |
| 11 | + startsWith(github.event.pull_request.head.ref, 'argus/fix-') |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: '3.11' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: pip install -r requirements.txt |
| 29 | + |
| 30 | + - name: Extract fix metadata |
| 31 | + id: meta |
| 32 | + run: | |
| 33 | + BRANCH="${{ github.event.pull_request.head.ref }}" |
| 34 | + # Extract vuln type and finding ID from branch name: argus/fix-{type}-{id} |
| 35 | + VULN_TYPE=$(echo "$BRANCH" | sed 's|argus/fix-||' | sed 's|-[a-f0-9]*$||') |
| 36 | + FINDING_ID=$(echo "$BRANCH" | grep -oP '[a-f0-9]{8}$' || echo "unknown") |
| 37 | + echo "vuln_type=$VULN_TYPE" >> $GITHUB_OUTPUT |
| 38 | + echo "finding_id=$FINDING_ID" >> $GITHUB_OUTPUT |
| 39 | + # Get changed files from the PR |
| 40 | + CHANGED_FILES=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' || echo "") |
| 41 | + echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT |
| 42 | + env: |
| 43 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Run regression tests |
| 46 | + id: regression |
| 47 | + continue-on-error: true |
| 48 | + run: | |
| 49 | + python -c " |
| 50 | + import sys |
| 51 | + sys.path.insert(0, 'scripts') |
| 52 | + try: |
| 53 | + from regression_tester import RegressionTester |
| 54 | + tester = RegressionTester() |
| 55 | + results = tester.run('tests/security_regression') |
| 56 | + passed = results.get('passed', 0) |
| 57 | + failed = results.get('failed', 0) |
| 58 | + print(f'Regression tests: {passed} passed, {failed} failed') |
| 59 | + sys.exit(1 if failed > 0 else 0) |
| 60 | + except Exception as e: |
| 61 | + print(f'Regression test error: {e}') |
| 62 | + sys.exit(1) |
| 63 | + " |
| 64 | +
|
| 65 | + - name: Run targeted SAST rescan |
| 66 | + id: rescan |
| 67 | + continue-on-error: true |
| 68 | + env: |
| 69 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 70 | + run: | |
| 71 | + python scripts/run_ai_audit.py \ |
| 72 | + --project-type auto \ |
| 73 | + --only-changed \ |
| 74 | + --review-type security |
| 75 | +
|
| 76 | + - name: Update finding status |
| 77 | + if: steps.regression.outcome == 'success' && steps.rescan.outcome == 'success' |
| 78 | + run: | |
| 79 | + python -c " |
| 80 | + import sys |
| 81 | + sys.path.insert(0, 'scripts') |
| 82 | + try: |
| 83 | + from findings_store import FindingsStore |
| 84 | + store = FindingsStore() |
| 85 | + store.record_fix( |
| 86 | + finding_id='${{ steps.meta.outputs.finding_id }}', |
| 87 | + fix_commit='${{ github.sha }}', |
| 88 | + fix_method='autofix', |
| 89 | + retest_passed=True, |
| 90 | + ) |
| 91 | + print('Finding marked as fix-verified') |
| 92 | + except Exception as e: |
| 93 | + print(f'Could not update findings store: {e}') |
| 94 | + " |
| 95 | +
|
| 96 | + - name: Post retest results |
| 97 | + if: always() |
| 98 | + uses: actions/github-script@v7 |
| 99 | + with: |
| 100 | + script: | |
| 101 | + const regression = '${{ steps.regression.outcome }}'; |
| 102 | + const rescan = '${{ steps.rescan.outcome }}'; |
| 103 | + const allPassed = regression === 'success' && rescan === 'success'; |
| 104 | +
|
| 105 | + const body = `## Argus Retest Results |
| 106 | +
|
| 107 | + | Check | Status | |
| 108 | + |-------|--------| |
| 109 | + | Regression Tests | ${regression === 'success' ? 'Passed' : 'Failed'} | |
| 110 | + | SAST Rescan | ${rescan === 'success' ? 'Clean' : 'Issues found'} | |
| 111 | + | **Overall** | **${allPassed ? 'Fix Verified' : 'Needs Review'}** | |
| 112 | +
|
| 113 | + ${allPassed ? 'The fix has been verified. The vulnerability is confirmed resolved.' : 'The retest found issues. Please review the scan results.'} |
| 114 | +
|
| 115 | + --- |
| 116 | + *Argus Security Retest — triggered by merge of \`${{ github.event.pull_request.head.ref }}\`*`; |
| 117 | +
|
| 118 | + // Comment on the merged PR |
| 119 | + await github.rest.issues.createComment({ |
| 120 | + owner: context.repo.owner, |
| 121 | + repo: context.repo.repo, |
| 122 | + issue_number: ${{ github.event.pull_request.number }}, |
| 123 | + body: body |
| 124 | + }); |
0 commit comments