|
| 1 | +name: Secret Scanning |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + secret-scan: |
| 11 | + name: Detect Secrets |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 # Full history for comprehensive scanning |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: '3.11' |
| 24 | + |
| 25 | + - name: Install detect-secrets |
| 26 | + run: | |
| 27 | + pip install detect-secrets |
| 28 | +
|
| 29 | + - name: Run detect-secrets scan |
| 30 | + run: | |
| 31 | + detect-secrets scan \ |
| 32 | + --exclude-files 'configs/.*\.json' \ |
| 33 | + --exclude-files '\.md$' \ |
| 34 | + --exclude-files 'package-lock\.json' \ |
| 35 | + --exclude-files '\.lock$' \ |
| 36 | + --baseline .secrets.baseline |
| 37 | +
|
| 38 | + - name: Check for secrets in git history (last 100 commits) |
| 39 | + run: | |
| 40 | + # Scan recent git history for accidentally committed secrets |
| 41 | + git log --all --pretty=format: -p -100 | \ |
| 42 | + detect-secrets scan --stdin \ |
| 43 | + --exclude-files 'configs/.*\.json' \ |
| 44 | + --exclude-files '\.md$' || true |
| 45 | +
|
| 46 | + - name: Security scan summary |
| 47 | + if: always() |
| 48 | + run: | |
| 49 | + echo "✅ Secret scanning complete" |
| 50 | + echo "If secrets were detected, the job will fail above" |
| 51 | + echo "To update baseline: detect-secrets scan --baseline .secrets.baseline" |
| 52 | +
|
| 53 | + prompt-injection-check: |
| 54 | + name: Prompt Injection Security Scan |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Set up Python |
| 62 | + uses: actions/setup-python@v5 |
| 63 | + with: |
| 64 | + python-version: '3.11' |
| 65 | + |
| 66 | + - name: Install uv |
| 67 | + uses: astral-sh/setup-uv@v3 |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: uv sync |
| 71 | + |
| 72 | + - name: Run prompt injection detection (baseline mode) |
| 73 | + run: | |
| 74 | + echo "Scanning for NEW prompt injection patterns (baseline mode)..." |
| 75 | +
|
| 76 | + # Run our custom prompt injection scanner with baseline |
| 77 | + if uv run python .security/check_prompt_injections.py --baseline src/ tests/ *.md *.yml *.yaml *.json; then |
| 78 | + echo "✅ No NEW prompt injection patterns detected" |
| 79 | + echo " (Known findings are tracked in .prompt_injections.baseline)" |
| 80 | + else |
| 81 | + echo "❌ NEW prompt injection patterns found!" |
| 82 | + echo "" |
| 83 | + echo "These patterns may indicate attempts to:" |
| 84 | + echo "- Override system instructions (ignore previous instructions)" |
| 85 | + echo "- Extract sensitive prompts (show me your instructions)" |
| 86 | + echo "- Change AI behavior (you are now a different AI)" |
| 87 | + echo "- Manipulate PTAB data (extract all IPR trial numbers)" |
| 88 | + echo "- Bypass USPTO API restrictions (bypass PTAB API limits)" |
| 89 | + echo "- Hide malicious content (Unicode steganography)" |
| 90 | + echo "" |
| 91 | + echo "Please review the flagged content to ensure it is not malicious." |
| 92 | + echo "" |
| 93 | + echo "If these are legitimate patterns (test cases, documentation):" |
| 94 | + echo " 1. Verify they are not malicious" |
| 95 | + echo " 2. Run: uv run python .security/check_prompt_injections.py --update-baseline src/ tests/ *.md" |
| 96 | + echo " 3. Commit the updated .prompt_injections.baseline file" |
| 97 | + exit 1 |
| 98 | + fi |
0 commit comments