mirror of
https://github.com/personamanagmentlayer/pcl.git
synced 2026-09-14 15:40:22 +08:00
014b97e668
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
171 lines
5.1 KiB
YAML
171 lines
5.1 KiB
YAML
name: Security Scanning
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
schedule:
|
|
# Run daily at 2 AM UTC
|
|
- cron: '0 2 * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
actions: read
|
|
|
|
jobs:
|
|
dependency-review:
|
|
name: Dependency Review
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Dependency Review
|
|
id: dependency-review
|
|
uses: actions/dependency-review-action@v4
|
|
continue-on-error: true
|
|
with:
|
|
fail-on-severity: moderate
|
|
|
|
- name: Note if dependency graph is disabled
|
|
if: steps.dependency-review.outcome == 'failure'
|
|
run: |
|
|
echo "::notice::Dependency Review failed. This may be because Dependency graph is not enabled."
|
|
echo "::notice::To enable it, visit: https://github.com/${{ github.repository }}/settings/security_analysis"
|
|
echo "::notice::Dependency Review is not critical for this workflow and can be enabled later."
|
|
|
|
npm-audit:
|
|
name: NPM Security Audit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run npm audit
|
|
run: npm audit --audit-level=moderate
|
|
continue-on-error: true
|
|
|
|
- name: Run npm audit (production only)
|
|
run: npm audit --production --audit-level=high
|
|
|
|
codeql-analysis:
|
|
name: CodeQL Analysis
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
security-events: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
language: ['javascript']
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Initialize CodeQL
|
|
uses: github/codeql-action/init@v4
|
|
with:
|
|
languages: ${{ matrix.language }}
|
|
queries: security-and-quality
|
|
|
|
- name: Autobuild
|
|
uses: github/codeql-action/autobuild@v4
|
|
|
|
- name: Perform CodeQL Analysis
|
|
uses: github/codeql-action/analyze@v4
|
|
with:
|
|
category: '/language:${{matrix.language}}'
|
|
|
|
secret-scanning:
|
|
name: Secret Scanning
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check for Gitleaks License
|
|
id: check-license
|
|
run: |
|
|
if [ -n "${{ secrets.GITLEAKS_LICENSE }}" ]; then
|
|
echo "license_available=true" >> $GITHUB_OUTPUT
|
|
echo "::notice::Gitleaks license found, using Gitleaks for secret scanning"
|
|
else
|
|
echo "license_available=false" >> $GITHUB_OUTPUT
|
|
echo "::notice::Gitleaks license not found. Using TruffleHog as alternative."
|
|
echo "::notice::For organization repos, obtain a Gitleaks license from gitleaks.io to use Gitleaks"
|
|
fi
|
|
|
|
- name: Gitleaks Scan
|
|
if: steps.check-license.outputs.license_available == 'true'
|
|
uses: gitleaks/gitleaks-action@v2
|
|
continue-on-error: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
|
|
|
|
- name: Alternative Secret Scan (truffleHog)
|
|
if: steps.check-license.outputs.license_available != 'true'
|
|
continue-on-error: true
|
|
uses: trufflesecurity/trufflehog@main
|
|
with:
|
|
path: ./
|
|
base: ${{ github.event.repository.default_branch }}
|
|
head: HEAD
|
|
extra_args: --only-verified
|
|
|
|
license-compliance:
|
|
name: License Compliance
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Check licenses
|
|
run: npx license-checker --summary --production --onlyAllow "MIT;Apache-2.0;BSD;ISC;CC0-1.0;Unlicense;Python-2.0"
|
|
continue-on-error: true
|
|
|
|
security-summary:
|
|
name: Security Summary
|
|
runs-on: ubuntu-latest
|
|
needs: [npm-audit, codeql-analysis, secret-scanning, license-compliance]
|
|
if: always()
|
|
steps:
|
|
- name: Summary
|
|
run: |
|
|
echo "## Security Scan Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "✅ All security scans completed" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "### Scan Results:" >> $GITHUB_STEP_SUMMARY
|
|
echo "- NPM Audit: ${{ needs.npm-audit.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- CodeQL Analysis: ${{ needs.codeql-analysis.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- Secret Scanning: ${{ needs.secret-scanning.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- License Compliance: ${{ needs.license-compliance.result }}" >> $GITHUB_STEP_SUMMARY
|