Skip to content

Security Code Scan #164

Security Code Scan

Security Code Scan #164

Workflow file for this run

name: Security Code Scan
on:
schedule:
# every UTC 7PM from Mon to Fri
- cron: "0 19 * * 1-5"
push:
branches:
- develop
- releases/*
workflow_dispatch: # run on request (no need for PR)
workflow_call: # run by other workflow
# Declare default permissions as read only.
permissions: read-all
jobs:
Trivy-Scan:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install .
pip freeze > requirements.txt
- name: Run Trivy security scan
uses: aquasecurity/[email protected]
with:
scan-type: fs
scan-ref: requirements.txt
output: trivy-scan-results.txt
- name: Run Trivy spdx scan
uses: aquasecurity/[email protected]
with:
scan-type: fs
scan-ref: requirements.txt
format: spdx-json
output: trivy-scan-results.spdx.json
- name: Upload Trivy scan results
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: trivy-scan-results
path: trivy-scan-results.*
# Use always() to always run this step to publish scan results when there are test failures
if: ${{ always() }}
Bandit-Scan:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.10"
- name: Install dependencies
run: pip install bandit
- name: Bandit Scanning
run: bandit -r -c .ci/ipas_default.config . -f txt -o bandit-scan-results.txt
- name: Upload Bandit artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: bandit-scan-results
path: bandit-scan-results.txt
# Use always() to always run this step to publish scan results when there are test failures
if: ${{ always() }}
CodeQL-Scan:
runs-on: ubuntu-22.04
timeout-minutes: 60
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
with:
category: "/language:${{matrix.language}}"
- name: Generate Security Report
uses: rsdmike/github-security-report-action@a149b24539044c92786ec39af8ba38c93496495d # v3.0.4
with:
template: report
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload CodeQL Artifacts
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
with:
name: codeql-scan-results
path: "./report.pdf"