Skip to content

Code Scanning

Code Scanning #266

Workflow file for this run

name: Code Scanning
on:
workflow_dispatch: # run on request (no need for PR)
push:
branches: [ "develop", "releases/*" ]
schedule:
# every UTC 6PM from Mon to Fri
- cron: "0 18 * * 1-5"
jobs:
Trivy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install pip-tools
- name: Freeze dependencies
run: |
pip-compile -o .ci/requirements.txt requirements.txt
mkdir -p .ci/tests
pip-compile -o .ci/tests/requirements.txt tests/requirements.txt
mkdir -p .ci/docker/segment-anything/
pip-compile -o .ci/docker/segment-anything/requirements.txt docker/segment-anything/requirements.txt
mkdir -p .ci/docs
pip-compile -o .ci/docs/requirements.txt docs/requirements.txt
mkdir -p .ci/gui
pip-compile -o .ci/gui/requirements.txt gui/requirements.txt
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # 0.18.0
with:
trivy-config: ".ci/trivy.yaml"
scan-type: 'fs'
scan-ref: ".ci/"
scanners: vuln,secret
- name: Upload Trivy results artifact
uses: actions/upload-artifact@v4
with:
name: trivy-results
path: '${{ github.workspace }}/trivy-results.csv'
Bandit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install tox
- name: Bandit Scanning
run: tox -e bandit-scan
- name: Upload Bandit artifact
uses: actions/upload-artifact@v4
with:
name: bandit-report
path: .tox/bandit-report.txt
# Use always() to always run this step to publish scan results when there are test failures
if: ${{ always() }}
call-notify-to-teams:
needs: [Trivy, Bandit]
if: |
always() &&
contains(needs.*.result, 'failure')
uses: ./.github/workflows/notify_teams.yml
secrets: inherit