Skip to content

Merge pull request #2945 from newrelic/trivy-token #98

Merge pull request #2945 from newrelic/trivy-token

Merge pull request #2945 from newrelic/trivy-token #98

Workflow file for this run

name: Security scan
on:
push:
branches:
- main
- dev
pull_request:
schedule:
- cron: '0 9 * * *' # Same time as CI Cron
jobs:
build:
name: Trivy Scan
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Install Ruby 3.3
uses: ruby/setup-ruby@7d3497fd78c07c0d84ebafa58d8dac60cd1f0763 # tag v1.199.0
with:
ruby-version: 3.3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
- run: bundle # Generate a Gemfile.lock to scan
- name: Run Trivy in table mode
# Table output is only useful when running on a pull request or push.
if: contains(fromJSON('["push", "pull_request"]'), github.event_name)
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v0.28.0
with:
scan-type: fs
format: table
exit-code: 1
ignore-unfixed: true
severity: CRITICAL,HIGH,MEDIUM,LOW
- name: Run Trivy in report mode
# Only generate sarif when running nightly on the dev branch.
if: ${{ github.event_name == 'schedule' }}
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v0.28.0
with:
token-setup-trivy: ${{ secrets.GITHUB_TOKEN }}
scan-type: fs
format: sarif
output: trivy-results.sarif
ignore-unfixed: true
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
- name: Upload Trivy scan results to GitHub Security tab
# Only upload sarif when running nightly on the dev branch.
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # tag v3.27.0
with:
sarif_file: trivy-results.sarif
notify_slack_fail:
name: Notify slack fail
needs: [build]
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'schedule' && failure() }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
- uses: ./.github/actions/workflow-conclusion
- uses: voxmedia/github-action-slack-notify-build@3665186a8c1a022b28a1dbe0954e73aa9081ea9e # tag v1.6.0
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.RUBY_GITHUB_ACTIONS_BOT_WEBHOOK }}
with:
channel: ruby-agent-notifications
status: FAILED
color: danger