|
| 1 | +name: Check binaries |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 16 * * 1-5" # min h d Mo DoW / 9am PST M-F |
| 7 | + |
| 8 | +jobs: |
| 9 | + check-for-vulnerabilities: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + report_contents: ${{ steps.save-output.outputs.report_contents }} |
| 13 | + steps: |
| 14 | + - name: Setup python |
| 15 | + uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + python-version: '3.11' |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: main |
| 22 | + - name: Download latest release |
| 23 | + |
| 24 | + with: |
| 25 | + latest: true |
| 26 | + fileName: 'aws-lambda-rie*' |
| 27 | + out-file-path: "bin" |
| 28 | + - name: Run check for vulnerabilities |
| 29 | + id: check-binaries |
| 30 | + run: | |
| 31 | + make check-binaries |
| 32 | + - if: always() && failure() # `always()` to run even if the previous step failed. Failure means that there are vulnerabilities |
| 33 | + name: Save content of the vulnerabilities report as GitHub output |
| 34 | + id: save-output |
| 35 | + run: | |
| 36 | + report_csv="$(ls -tr output.cve-bin-*.csv 2>/dev/null | tail -n1)" # last file generated |
| 37 | + echo "Vulnerabilities stored in $report_csv" |
| 38 | + final_report="${report_csv}.txt" |
| 39 | + awk -F',' '{n=split($10, path, "/"); print $2,$3,$4,$5,path[n]}' "$report_csv" | column -t > "$final_report" # make the CSV nicer |
| 40 | + echo "report_contents<<EOF" >> "$GITHUB_OUTPUT" |
| 41 | + cat "$final_report" >> "$GITHUB_OUTPUT" |
| 42 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 43 | + - if: always() && steps.check-binaries.outcome == 'failure' |
| 44 | + name: Build new binaries and check vulnerabilities again |
| 45 | + id: check-new-version |
| 46 | + run: | |
| 47 | + mkdir ./bin2 |
| 48 | + mv ./bin/* ./bin2 |
| 49 | + make compile-with-docker-all |
| 50 | + latest_version=$(strings bin/aws-lambda-rie* | grep '^go1\.' | sort | uniq) |
| 51 | + echo "latest_version=$latest_version" >> "$GITHUB_OUTPUT" |
| 52 | + make check-binaries |
| 53 | + - if: always() && steps.check-binaries.outcome == 'failure' |
| 54 | + name: Save outputs for the check with the latest build |
| 55 | + id: save-new-version |
| 56 | + run: | |
| 57 | + if [ "${{ steps.check-new-version.outcome }}" == "failure" ]; then |
| 58 | + fixed="No" |
| 59 | + else |
| 60 | + fixed="Yes" |
| 61 | + fi |
| 62 | + echo "fixed=$fixed" >> "$GITHUB_OUTPUT" |
| 63 | + - if: always() && steps.check-binaries.outcome == 'failure' |
| 64 | + name: Create GitHub Issue indicating vulnerabilities |
| 65 | + id: create-issue |
| 66 | + uses: dacbd/create-issue-action@main |
| 67 | + with: |
| 68 | + token: ${{ github.token }} |
| 69 | + title: | |
| 70 | + CVEs found in latest RIE release |
| 71 | + body: | |
| 72 | + ### CVEs found in latest RIE release |
| 73 | + ``` |
| 74 | + ${{ steps.save-output.outputs.report_contents }} |
| 75 | + ``` |
| 76 | + |
| 77 | + #### Are these resolved by building with the latest patch version of Go (${{ steps.check-new-version.outputs.latest_version }})?: |
| 78 | + > **${{ steps.save-new-version.outputs.fixed }}** |
0 commit comments