Merge pull request #525 from AcreetionOS-Code/fix/ai-guardian-2026052… #628
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Security Scan | |
| on: | |
| push: | |
| branches: [ main ] | |
| schedule: | |
| - cron: '0 6 * * *' # daily at 6am UTC | |
| workflow_dispatch: | |
| jobs: | |
| secret-scan: | |
| name: Secret Detection | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Scan for secrets | |
| run: | | |
| set -e | |
| FOUND=false | |
| # Scan for actual secret VALUES (API keys, tokens) — exclude workflow files (contain regex patterns) | |
| MATCHES=$(git grep -n -I -E \ | |
| "(sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}|gho_[A-Za-z0-9]{36}|xox[baprs]-[0-9a-zA-Z-]{10,}|BEGIN RSA PRIVATE KEY|BEGIN PRIVATE KEY)" \ | |
| -- . 2>/dev/null | grep -v "\.yml:" | grep -v "\.yaml:" || true) | |
| if [ -n "$MATCHES" ]; then | |
| echo "Potential secret VALUES found:" | |
| echo "$MATCHES" | |
| echo "::error::Potential secret VALUES found! Review above." | |
| FOUND=true | |
| fi | |
| # Scan for SECRET NAMES only in files where they'd be actual values (not docs/configs) | |
| for pattern in "CLOUDFLARE_API_TOKEN" "OPENROUTER_API_KEY"; do | |
| MATCHES=$(git grep -n -I "$pattern" -- . 2>/dev/null | \ | |
| grep -v "\.md:" | grep -v "\.example:" | grep -v "wrangler\.toml" | \ | |
| grep -v "README" | grep -v "tools/" | grep -v "\.yml:" | grep -v "\.yaml:" | \ | |
| grep -v "\.js:" | grep -v "\.py:" || true) | |
| if [ -n "$MATCHES" ]; then | |
| echo "Potential secret NAME reference in non-doc file:" | |
| echo "$MATCHES" | |
| echo "::error::Secret name '$pattern' found outside documentation" | |
| FOUND=true | |
| fi | |
| done | |
| if [ "$FOUND" = "true" ]; then exit 1; fi | |
| echo "✓ No secrets detected" | |
| cve-scan: | |
| name: CVE Dependency Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check for package manifests | |
| run: | | |
| if [ -f package.json ]; then | |
| echo "Node project detected — running npm audit" | |
| npm audit --audit-level=moderate 2>&1 || true | |
| fi | |
| if [ -f requirements.txt ]; then | |
| echo "Python project detected" | |
| pip-audit --desc on . 2>/dev/null || pip3 install pip-audit && pip-audit --desc on . 2>/dev/null || echo "pip-audit not available" | |
| fi | |
| - name: Check for known vulnerable CDN libraries | |
| run: | | |
| VULN_LIBS=( | |
| "jquery:<3.5.0" | |
| "lodash:<4.17.21" | |
| "bootstrap:<4.6.0" | |
| ) | |
| for entry in "${VULN_LIBS[@]}"; do | |
| LIB="${entry%%:*}" | |
| VER="${entry#*:}" | |
| FILES=$(grep -r "$LIB" --include="*.html" --include="*.js" . 2>/dev/null || true) | |
| if [ -n "$FILES" ]; then | |
| echo "⚠ Found: $LIB in files:" | |
| echo "$FILES" | head -5 | |
| fi | |
| done | |
| echo "✓ CDN library check complete" |