Skip to content

Commit 830c9b6

Browse files
authored
Merge pull request #42 from facutuesca/separate-issues
Create one issue per vulnerability, and prevent duplicates
2 parents 596ec22 + 7ef2dc2 commit 830c9b6

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---
2-
title: Vulnerability check reported failure on {{ env.NODEJS_STREAM }} - {{ date | date('YYYY-MM-DD') }}
2+
title: New vulnerability {{ env.VULN_ID }} found on {{ env.NODEJS_STREAM }}
33
asignees:
44
labels:
55
---
66
Failed run: {{ env.ACTION_URL }}
7+
Vulnerability ID: {{ env.VULN_ID }}
78

8-
Output:
9+
Full output:
910
--------------------
1011
```
1112
{{ env.ERROR_MSG }}
1213
```
14+

.github/workflows/check-vulns.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ permissions:
2323
jobs:
2424
check-vulns:
2525
runs-on: ubuntu-latest
26+
outputs:
27+
matrix: ${{ steps.set_matrix.outputs.matrix }}
28+
full_output: ${{ steps.collect_error.outputs.result }}
2629
steps:
2730
- name: Setup Python 3.9
2831
uses: actions/setup-python@v3
@@ -44,6 +47,17 @@ jobs:
4447
set -o pipefail
4548
python main.py --gh-token ${{ secrets.GITHUB_TOKEN }} --nvd-key=${{ secrets.NVD_API_KEY }} 2>&1 | tee result.log
4649
)
50+
- name: build matrix
51+
id: set_matrix
52+
if: ${{ failure() }}
53+
working-directory: ./node/tools/dep_checker
54+
run: |
55+
matrix=$((echo '{ "vulnerability" : ['
56+
cat result.log | sed -n 's/.*\(CVE-.*\|GHSA-.*\).*/"\1",/p' | sed '$s/,//'
57+
echo "]}"
58+
) | jq -c .)
59+
echo "::set-output name=matrix::$matrix"
60+
4761
- name: collect error
4862
id: collect_error
4963
if: ${{ failure() }}
@@ -55,13 +69,21 @@ jobs:
5569
content="${content//$'\n'/'%0A'}"
5670
content="${content//$'\r'/'%0D'}"
5771
echo "::set-output name=result::$content"
72+
create-issues:
73+
needs: check-vulns
74+
if: ${{ always() }}
75+
runs-on: ubuntu-latest
76+
strategy:
77+
matrix: ${{ fromJson(needs.check-vulns.outputs.matrix) }}
78+
steps:
5879
- uses: actions/checkout@v3
59-
if: ${{ failure() }}
60-
- uses: JasonEtco/create-an-issue@v2
61-
if: ${{ failure() }}
80+
- uses: dblock/create-a-github-issue@v3
81+
with:
82+
update_existing: false
83+
search_existing: all
6284
env:
6385
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
ERROR_MSG: ${{ steps.collect_error.outputs.result }}
86+
ERROR_MSG: ${{ needs.check-vulns.outputs.full_output }}
87+
VULN_ID: ${{ matrix.vulnerability }}
6588
NODEJS_STREAM: ${{ inputs.nodejsStream }}
6689
ACTION_URL: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
67-

0 commit comments

Comments
 (0)