|
| 1 | +name: IOC Candidate Monitor |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "15 10 * * *" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + generate-candidates: |
| 14 | + name: Generate OSV blacklist candidates |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Go |
| 21 | + uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version-file: go.mod |
| 24 | + |
| 25 | + - name: Fetch IOC candidates |
| 26 | + run: | |
| 27 | + go run ./scripts/ioc-candidates \ |
| 28 | + -since 24h \ |
| 29 | + -min-severity HIGH \ |
| 30 | + -ecosystems npm,PyPI,Go \ |
| 31 | + -out /tmp/candidates.json \ |
| 32 | + -existing pkg/analyzer/data/blacklist.json |
| 33 | +
|
| 34 | + - name: Count candidates |
| 35 | + id: candidate_count |
| 36 | + run: | |
| 37 | + count="$(jq 'length' /tmp/candidates.json)" |
| 38 | + echo "count=$count" >> "$GITHUB_OUTPUT" |
| 39 | +
|
| 40 | + - name: Merge candidates into blacklist |
| 41 | + if: steps.candidate_count.outputs.count != '0' |
| 42 | + run: | |
| 43 | + jq -s ' |
| 44 | + (.[0] + .[1]) |
| 45 | + | unique_by("\(.ecosystem)|\(.component)|\(.affected_versions | join(","))") |
| 46 | + | sort_by(.ecosystem, .component) |
| 47 | + ' pkg/analyzer/data/blacklist.json /tmp/candidates.json > /tmp/merged-blacklist.json |
| 48 | + mv /tmp/merged-blacklist.json pkg/analyzer/data/blacklist.json |
| 49 | +
|
| 50 | + - name: Create pull request |
| 51 | + if: steps.candidate_count.outputs.count != '0' |
| 52 | + uses: peter-evans/create-pull-request@v7 |
| 53 | + with: |
| 54 | + token: ${{ secrets.TOOLTRUST_BOT_TOKEN || github.token }} |
| 55 | + branch: ioc-candidates/${{ github.run_id }} |
| 56 | + title: "ioc: ${{ steps.candidate_count.outputs.count }} new blacklist candidate(s)" |
| 57 | + commit-message: "data(blacklist): auto-append ${{ steps.candidate_count.outputs.count }} OSV candidate(s)" |
| 58 | + body: | |
| 59 | + Automated IOC blacklist candidates generated from OSV ecosystem feeds for the last 24 hours. |
| 60 | +
|
| 61 | + Review each entry carefully: |
| 62 | + - Is the version pinning exact and narrow enough? |
| 63 | + - Is `BLOCK` the right action, or should this be downgraded to `WARN`? |
| 64 | + - Is the reason clear enough for someone triaging a finding? |
| 65 | +
|
| 66 | + Close this PR if any candidate looks incorrect. The workflow will retry on the next scheduled run. |
| 67 | + labels: | |
| 68 | + ioc |
| 69 | + automated |
0 commit comments