Skip to content

chore/security : add code scan in ci #283

chore/security : add code scan in ci

chore/security : add code scan in ci #283

Workflow file for this run

name: LRM Client CI
on:
push:
branches:
- 'main'
paths:
- 'web/lrm/client/**'
pull_request:
branches:
- '**'
paths:
- 'web/lrm/client/**'
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web/lrm/client
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '19'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint:js
- name: Run Stylelint
run: npm run lint:css
- name: Run Prettier check
run: npx prettier --check "**/*.{js,ts,vue,css,scss}"
security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '19'
cache: 'npm'
cache-dependency-path: 'web/lrm/client/package-lock.json'
- name: Install Node.js dependencies for Trivy scan
working-directory: web/lrm/client
run: |
npm ci
- name: Run Trivy vulnerability scanner - Dependencies
uses: aquasecurity/trivy-action@0.24.0
with:
scan-type: 'fs'
scan-ref: 'web/lrm/client'
format: 'sarif'
output: 'trivy-dependencies.sarif'
severity: 'HIGH,CRITICAL'
exit-code: '1'
scanners: 'vuln'
continue-on-error: false
- name: Fix SARIF file paths for GitHub Security tab
if: always() && hashFiles('trivy-dependencies.sarif') != ''
uses: ./.github/actions/fix-trivy-sarif
with:
sarif-file: 'trivy-dependencies.sarif'
scan-path: 'web/lrm/client'
- name: Upload Trivy scan results to GitHub Security tab - Dependencies
if: always() && hashFiles('trivy-dependencies.sarif') != ''
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-dependencies.sarif'
category: 'trivy-lrm-client-dependencies'
- name: Run Trivy vulnerability scanner - Dockerfile
id: trivy-dockerfile
uses: aquasecurity/trivy-action@0.24.0
with:
scan-type: 'config'
scan-ref: 'web/lrm/client/Dockerfile'
format: 'sarif'
output: 'trivy-dockerfile.sarif'
severity: 'LOW,MEDIUM,HIGH,CRITICAL'
exit-code: '1'
scanners: 'config,secret,vuln,license'
continue-on-error: true
- name: Fix Dockerfile SARIF file paths for GitHub Security tab
if: always() && hashFiles('trivy-dockerfile.sarif') != ''
uses: ./.github/actions/fix-trivy-sarif
with:
sarif-file: 'trivy-dockerfile.sarif'
scan-path: 'web/lrm/client'
- name: Upload Trivy scan results to GitHub Security tab - Dockerfile
if: always() && hashFiles('trivy-dockerfile.sarif') != ''
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-dockerfile.sarif'
category: 'trivy-lrm-client-dockerfile'
- name: Upload Trivy reports as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: trivy-reports-lrm-client
path: '*.sarif'
retention-days: 7