aiskillstore/marketplace/sast-bandit
Claude Code and agent skill by aiskillstore/marketplace
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Author "aiskillstore" has blocked skill(s)
Python security vulnerability detection using Bandit SAST with CWE and OWASP mapping. Use when: (1) Scanning Python code for security vulnerabilities and anti-patterns, (2) Identifying hardcoded secrets, SQL injection, command injection, and insecure APIs, (3) Generating security reports with severity classifications for CI/CD pipelines, (4) Providing remediation guidance with security framework references, (5) Enforcing Python security best practices in development workflows.
Install
npx vskill@latest install aiskillstore/marketplace/sast-banditSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as aiskillstore/marketplace/sast-bandit.
Bandit Python SAST
Overview
Bandit is a security-focused static analysis tool for Python that identifies common security vulnerabilities and coding anti-patterns. It parses Python code into Abstract Syntax Trees (AST) and executes security plugins to detect issues like hardcoded credentials, SQL injection, command injection, weak cryptography, and insecure API usage. Bandit provides actionable reports with severity classifications aligned to industry security standards.
Quick Start
Scan a Python file or directory for security vulnerabilities:
Core Workflow
Step 1: Install and Configure Bandit
Install Bandit via pip:
Create a configuration file .bandit or .bandit.yaml to customize scans:
Step 2: Execute Security Scan
Run Bandit against Python codebase:
Step 3: Analyze Results
Bandit reports findings with:
- Issue Type: Vulnerability category (e.g., hardcoded_password, sql_injection)
- Severity: LOW, MEDIUM, HIGH
- Confidence: LOW, MEDIUM, HIGH
- CWE: Common Weakness Enumeration reference
- Location: File path and line number
Example output:
Step 4: Prioritize Findings
Focus remediation efforts using this priority matrix:
- Critical: HIGH severity + HIGH confidence
- High: HIGH severity OR MEDIUM severity + HIGH confidence
- Medium: MEDIUM severity + MEDIUM confidence
- Low: LOW severity OR LOW confidence
Step 5: Remediate Vulnerabilities
For each finding, consult the bundled references/remediation_guide.md for secure coding patterns. Common remediation strategies:
- Hardcoded Secrets (B105, B106): Use environment variables or secret management services
- SQL Injection (B608): Use parameterized queries with SQLAlchemy or psycopg2
- Command Injection (B602, B605): Avoid
shell=True, useshlex.split()for argument parsing - Weak Cryptography (B303, B304): Replace MD5/SHA1 with SHA256/SHA512 or bcrypt for passwords
- Insecure Deserialization (B301): Avoid pickle, use JSON or MessagePack with schema validation
Step 6: Integrate into CI/CD
Add Bandit to CI/CD pipelines to enforce security gates:
Use the bundled script scripts/bandit_analyzer.py for enhanced reporting with OWASP mapping.
Security Considerations
- Sensitive Data Handling: Bandit reports may contain code snippets with hardcoded credentials. Ensure reports are stored securely and access is restricted. Use
--no-codeflag to exclude code snippets from reports.
- Access Control: Run Bandit in sandboxed CI/CD environments with read-only access to source code. Restrict write permissions to prevent tampering with security configurations.
- Audit Logging: Log all Bandit executions with timestamps, scan scope, findings count, and operator identity for security auditing and compliance purposes.
- Compliance: Bandit supports SOC2, PCI-DSS, and GDPR compliance by identifying security weaknesses. Document scan frequency, remediation timelines, and exception approvals for audit trails.
- False Positives: Review LOW confidence findings manually. Use inline
# noseccomments sparingly and document justifications in code review processes.
Bundled Resources
Scripts (scripts/)
bandit_analyzer.py- Enhanced Bandit wrapper that parses JSON output, maps findings to OWASP Top 10, generates HTML reports, and integrates with ticketing systems. Use for comprehensive security reporting.
References (references/)
remediation_guide.md- Detailed secure coding patterns for common Bandit findings, including code examples for SQLAlchemy parameterization, secure subprocess usage, and cryptographic best practices. Consult when remediating specific vulnerability types.
cwe_owasp_mapping.md- Complete mapping between Bandit issue codes, CWE identifiers, and OWASP Top 10 categories. Use for security framework alignment and compliance reporting.
Assets (assets/)
bandit_config.yaml- Production-ready Bandit configuration with optimized test selection, exclusion patterns for common false positives, and severity thresholds. Use as baseline configuration for projects.
pre-commit-config.yaml- Pre-commit hook configuration for Bandit integration. Prevents commits with HIGH severity findings.
Common Patterns
Pattern 1: Baseline Security Scan
Establish security baseline for legacy codebases:
Pattern 2: Security Gating in Pull Requests
Block merges with HIGH severity findings:
Pattern 3: Progressive Security Hardening
Incrementally increase security standards:
Pattern 4: Suppressing False Positives
Document exceptions inline with justification:
Integration Points
- CI/CD: Integrate as GitHub Actions, GitLab CI, Jenkins pipeline stage, or pre-commit hook. Use
scripts/bandit_analyzer.pyfor enhanced reporting.
- Security Tools: Combine with Semgrep for additional SAST coverage, Safety for dependency scanning, and SonarQube for code quality metrics.
- SDLC: Execute during development (pre-commit), code review (PR checks), and release gates (pipeline stage). Establish baseline scans for legacy code and enforce strict checks for new code.
- Ticketing Integration: Use
scripts/bandit_analyzer.pyto automatically create Jira/GitHub issues for HIGH severity findings with remediation guidance.
Troubleshooting
Issue: Too Many False Positives
Solution:
- Use confidence filtering:
bandit -r . -i(HIGH confidence only) - Exclude test files:
bandit -r . --exclude /tests/ - Customize
.bandit.yamlto skip specific tests for known safe patterns - Review and suppress with inline
# noseccomments with justification
Issue: Scan Performance on Large Codebases
Solution:
- Exclude dependencies: Add
/venv/,/.venv/,/site-packages/to.bandit.yamlexclude_dirs - Use multiprocessing: Bandit automatically parallelizes for directories
- Scan only changed files in CI/CD:
git diff --name-only origin/main | grep '.py$' | xargs bandit
Issue: Missing Specific Vulnerability Types
Solution:
- Check enabled tests:
bandit -l(list all tests) - Ensure tests are not skipped in
.bandit.yaml - Combine with Semgrep for additional coverage (e.g., business logic vulnerabilities)
- Update Bandit regularly:
pip install --upgrade bandit
Issue: Integration with Pre-commit Hooks
Solution: Use the bundled assets/pre-commit-config.yaml:
Install hooks: pre-commit install
References
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/agentsecops/sast-bandit/SKILL.md
Popularity
- Repository stars
- 429
- Repository forks
- 45
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooksconfigConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aiskillstore/marketplace/sast-bandit)