Skip to content

Dependency & Security Check #45

Dependency & Security Check

Dependency & Security Check #45

name: Dependency & Security Check
on:
push:
branches: [master, main, develop]
pull_request:
branches: [master, main, develop]
schedule:
# Daily at 06:00 UTC
- cron: '0 6 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
security-events: write
pull-requests: write
env:
NODE_VERSION: '20'
jobs:
npm-audit:
name: NPM Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Run npm audit (high severity)
run: npm audit --audit-level=high
- name: Generate full audit report
if: always()
run: npm audit --json > audit-report.json || true
- name: Upload audit report
if: always()
uses: actions/upload-artifact@v7
with:
name: npm-audit-report
path: audit-report.json
retention-days: 30
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [javascript-typescript]
steps:
- uses: actions/checkout@v6
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
outdated-check:
name: Outdated Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Check outdated packages
run: |
echo "## Outdated Dependencies" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
npm outdated || true >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
license-check:
name: License Compliance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Install license-checker
run: npm install -g license-checker
- name: Check licenses
run: |
license-checker --production --summary > license-summary.txt
cat license-summary.txt
# Fail on disallowed licenses
license-checker --production \
--failOn 'GPL;AGPL;LGPL;NGPL' \
--excludePackages 'stellar-dev-dashboard@0.1.0' || true
- name: Upload license report
if: always()
uses: actions/upload-artifact@v7
with:
name: license-report
path: license-summary.txt
retention-days: 30
secrets-scan:
name: Secrets Detection
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
- name: Dependency Review
uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
comment-summary-in-pr: always