agentleFS
lodetomasilodetomasi/claude-code-skills-tools/.claude/skills/security-scanner/SKILL.md

security-scanner

Skill0 starsChanged 13 months agoMITView on GitHub

Automated security scanning for hardcoded secrets, insecure file permissions, vulnerable dependencies, and unsafe code patterns

  • Pipes a download into a shell
  • Reads credentials
  • Deletes or force-pushes
  • Installs packages

14 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 13 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Before committing code to version control

    line 13
  2. Distinctive:

    After adding new dependencies

    line 17
  3. Distinctive:

    When onboarding new projects

    line 18
  4. Distinctive:

    Document accepted risks in security-exceptions.txt:

    line 238
  5. Distinctive:

    Never commit secrets: - Use environment variables

    line 247
  6. Distinctive:

    Input validation: - Never trust user input

    line 255
  7. Distinctive:

    Pre-commit: Every commit (via git hooks)

    line 277
  8. Distinctive:

    CI/CD: Every push to repository

    line 278
  9. Distinctive:

    If you encounter false positives:

    line 289
  10. Distinctive:

    Verify it's actually safe

    line 291
  11. Distinctive:

    Document why in comments

    line 292
  12. Distinctive:

    Consider refactoring for clarity

    line 293
  13. Distinctive:

    Add to exceptions list if necessary

    line 294

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security Scanner

Overview

Comprehensive security scanning tool that checks for hardcoded secrets, insecure file permissions, vulnerable Python dependencies, unsafe bash script patterns, and insecure Python code patterns in repositories.

When to Use

  • Before committing code to version control
  • During pull request reviews
  • As part of CI/CD pipeline security gates
  • Regular security audits (weekly/monthly)
  • After adding new dependencies
  • When onboarding new projects

Security Checks

1. Secrets & Credentials Detection

Patterns Checked:

  • Hardcoded passwords
  • API keys (10+ characters)
  • Secret tokens
  • AWS access keys
  • Private keys (PEM format)

Example Detections:

# ❌ Will be flagged
password = "MySecretPass123"
api_key = "sk_live_abc123def456"
AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCY"

2. File Permissions Check

  • World-writable files (permissions 002)
  • Executable files that shouldn't be
  • Configuration files with overly permissive access

3. Python Dependency Vulnerabilities

Tools Used:

  • pip-audit: Scan requirements.txt for known CVEs
  • safety: Additional vulnerability database

Detects:

  • Packages with known security issues
  • Outdated versions with patches available
  • Severity levels (Critical, High, Medium, Low)

4. Unsafe Bash Script Patterns

Dangerous Patterns:

  • eval $variable - Code injection risk
  • curl | bash - Remote code execution
  • rm -rf / - Destructive commands
  • Unquoted variables in dangerous contexts

5. Insecure Python Code Patterns

Patterns Checked:

  • import pickle - Unsafe deserialization
  • eval() / exec() - Code injection
  • shell=True in subprocess - Command injection
  • Bare assert statements - Can be disabled
  • input() with exec - Direct code execution

Usage

Basic Scan

./claude/skills/security-scanner/security-scanner.sh .

Scan Specific Directory

./claude/skills/security-scanner/security-scanner.sh /path/to/project

Review Generated Report

cat security-reports/security_report_YYYYMMDD_HHMMSS.txt

Sample Output

╔════════════════════════════════════════════════════════════════╗
║           SECURITY SCANNER - Skills & Tools Repository        ║
╚════════════════════════════════════════════════════════════════╝

Target: /Users/user/project
Timestamp: 2025-01-15 14:30:00

[1/6] Checking for secrets and credentials...
⚠️  Found potential API key at config.py:15
⚠️  Found hardcoded password at setup.py:42
✗ Found 2 potential secrets!
  Review the above matches and remove any hardcoded credentials

[2/6] Checking file permissions...
✓ File permissions look good

[3/6] Checking Python dependencies...
Running pip-audit...
⚠️  requests==2.25.1 has known vulnerability (CVE-2023-32681)
    Upgrade to: 2.31.0

[4/6] Checking bash scripts for security issues...
✗ deploy.sh: Uses 'eval' with variables (dangerous)
✗ install.sh: Pipes curl to bash (dangerous)

[5/6] Checking Python files for insecure patterns...
⚠️  Found potentially unsafe pattern: shell=True
  utils/backup.py:34: subprocess.call(..., shell=True)

[6/6] Generating security report...
✓ Report saved to: security-reports/security_report_20250115_143000.txt

╔════════════════════════════════════════════════════════════════╗
║                      SCAN COMPLETE                             ║
╚════════════════════════════════════════════════════════════════╝

Security Report Contents

The generated report includes:

  • Executive summary
  • Detailed findings by category
  • Recommendations for each issue
  • Next steps and remediation guidance
  • Links to security best practices

Common Issues & Fixes

Hardcoded Secrets

# ❌ BAD
API_KEY = "sk_live_abc123"

# ✅ GOOD
import os
API_KEY = os.environ.get('API_KEY')

Subprocess with shell=True

# ❌ BAD
subprocess.run(f"ls {user_input}", shell=True)

# ✅ GOOD
subprocess.run(["ls", user_input], shell=False)

Dangerous Bash Commands

# ❌ BAD
eval "$user_command"
curl https://example.com/script.sh | bash

# ✅ GOOD
# Validate input first
if [[ "$user_command" =~ ^[a-zA-Z0-9_-]+$ ]]; then
    "$user_command"
fi

Insecure File Permissions

# ❌ BAD: World-writable
chmod 666 config.json

# ✅ GOOD: Owner read/write only
chmod 600 config.json

CI/CD Integration

GitHub Actions

name: Security Scan

on: [push, pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install dependencies
        run: |
          pip install pip-audit safety

      - name: Run Security Scanner
        run: |
          chmod +x .claude/skills/security-scanner/security-scanner.sh
          ./.claude/skills/security-scanner/security-scanner.sh .

      - name: Upload Security Report
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: security-report
          path: security-reports/

GitLab CI

security_scan:
  stage: test
  script:
    - pip install pip-audit safety
    - chmod +x .claude/skills/security-scanner/security-scanner.sh
    - ./.claude/skills/security-scanner/security-scanner.sh .
  artifacts:
    paths:
      - security-reports/
    when: always

Exclusions & False Positives

Exclude Directories

Edit the script to add exclusions:

# Add to grep commands:
--exclude-dir=venv \
--exclude-dir=node_modules \
--exclude-dir=.git \
--exclude-dir=dist

Suppress Specific Warnings

Document accepted risks in security-exceptions.txt:

# Accepted security exceptions
config.py:15 - API key in test configuration (not production)
utils/backup.py:34 - shell=True needed for wildcard expansion (input sanitized)

Security Best Practices

  1. Never commit secrets - Use environment variables
  2. Scan before commit - Pre-commit hooks
  3. Regular dependency updates - Weekly checks
  4. Review all HIGH/CRITICAL - Within 24 hours
  5. Document exceptions - Why risks are accepted
  6. Automated scanning - CI/CD integration
  7. Security training - Educate developers
  8. Principle of least privilege - Minimal file permissions
  9. Input validation - Never trust user input
  10. Defense in depth - Multiple security layers

Additional Security Tools

For comprehensive security:

  • SAST Analyzer skill: Deep static analysis with Semgrep
  • DAST Scanner skill: Runtime testing
  • Dependency Checker skill: Advanced SCA
  • Penetration Tester skill: Authorized security testing

Requirements

# Python tools
pip install pip-audit safety

# Bash (built-in on Unix/macOS/Linux)

Scan Frequency Recommendations

  • Pre-commit: Every commit (via git hooks)
  • CI/CD: Every push to repository
  • Scheduled: Weekly full scans
  • After changes: Dependency updates, major features
  • Quarterly: Comprehensive security audit

Exit Codes

The scanner always returns 0 (success) but reports issues in the output and report file. Review the report to determine if action is needed.

False Positive Handling

If you encounter false positives:

  1. Review the flagged code
  2. Verify it's actually safe
  3. Document why in comments
  4. Consider refactoring for clarity
  5. Add to exceptions list if necessary

Support

For security issues or questions:

  • Review generated reports carefully
  • Check OWASP guidelines
  • Consult security team for critical findings
  • Update dependencies promptly

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.