Logo van Sast Bandit

Sast Bandit

Organisatie
AgentSecOps
sast-bandit

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.

Overzicht

UitgeverAgentSecOps
RepositorySecOpsAgentKit
Skillnaamsast-bandit
Sterren
225
Forks
44
Meegeleverde bestanden
4
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 4

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door AgentSecOps op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Sast Bandit in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/appsec/sast-bandit
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AgentSecOps/SecOpsAgentKit.git /tmp/SecOpsAgentKit
mkdir -p .claude/skills
cp -r /tmp/SecOpsAgentKit/skills/appsec/sast-bandit .claude/skills/sast-bandit
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Sast Bandit in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Sast Bandit automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Sast Bandit niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

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:

bash
# Install Bandit
pip install bandit

# Scan single file
bandit suspicious_file.py

# Scan entire directory recursively
bandit -r /path/to/python/project

# Generate JSON report
bandit -r project/ -f json -o bandit_report.json

# Scan with custom config
bandit -r project/ -c .bandit.yaml

Core Workflow

Step 1: Install and Configure Bandit

Install Bandit via pip:

bash
pip install bandit

Create a configuration file .bandit or .bandit.yaml to customize scans:

yaml
# .bandit.yaml
exclude_dirs:
  - /tests/
  - /venv/
  - /.venv/
  - /node_modules/

skips:
  - B101  # Skip assert_used checks in test files

tests:
  - B201  # Flask app run with debug=True
  - B301  # Pickle usage
  - B601  # Shell injection
  - B602  # Shell=True in subprocess

Step 2: Execute Security Scan

Run Bandit against Python codebase:

bash
# Basic scan with severity threshold
bandit -r . -ll  # Report only medium/high severity

# Comprehensive scan with detailed output
bandit -r . -f json -o report.json -v

# Scan with confidence filtering
bandit -r . -i  # Show only high confidence findings

# Exclude specific tests
bandit -r . -s B101,B601

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:

>> Issue: [B105:hardcoded_password_string] Possible hardcoded password: 'admin123'
   Severity: Medium   Confidence: Medium
   CWE: CWE-259 (Use of Hard-coded Password)
   Location: app/config.py:12

Step 4: Prioritize Findings

Focus remediation efforts using this priority matrix:

  1. Critical: HIGH severity + HIGH confidence
  2. High: HIGH severity OR MEDIUM severity + HIGH confidence
  3. Medium: MEDIUM severity + MEDIUM confidence
  4. 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, use shlex.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:

yaml
# .github/workflows/security-scan.yml
name: Security Scan
on: [push, pull_request]

jobs:
  bandit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - name: Install Bandit
        run: pip install bandit
      - name: Run Bandit
        run: bandit -r . -f json -o bandit-report.json
      - name: Check for high severity issues
        run: bandit -r . -ll -f txt || exit 1

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-code flag 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 # nosec comments 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:

bash
# Generate baseline report
bandit -r . -f json -o baseline.json

# Compare future scans against baseline
bandit -r . -f json -o current.json
diff <(jq -S . baseline.json) <(jq -S . current.json)

Pattern 2: Security Gating in Pull Requests

Block merges with HIGH severity findings:

bash
# Exit with error if HIGH severity issues found
bandit -r . -lll -f txt
if [ $? -ne 0 ]; then
    echo "HIGH severity security issues detected - blocking merge"
    exit 1
fi

Pattern 3: Progressive Security Hardening

Incrementally increase security standards:

bash
# Phase 1: Block only CRITICAL (HIGH severity + HIGH confidence)
bandit -r . -ll -i

# Phase 2: Block HIGH severity
bandit -r . -ll

# Phase 3: Block MEDIUM and above
bandit -r . -l

Pattern 4: Suppressing False Positives

Document exceptions inline with justification:

python
# Example: Suppressing pickle warning for internal serialization
import pickle  # nosec B301 - Internal cache, not user input

def load_cache(file_path):
    with open(file_path, 'rb') as f:
        return pickle.load(f)  # nosec B301

Integration Points

  • CI/CD: Integrate as GitHub Actions, GitLab CI, Jenkins pipeline stage, or pre-commit hook. Use scripts/bandit_analyzer.py for 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.py to automatically create Jira/GitHub issues for HIGH severity findings with remediation guidance.

Troubleshooting

Issue: Too Many False Positives

Solution:

  1. Use confidence filtering: bandit -r . -i (HIGH confidence only)
  2. Exclude test files: bandit -r . --exclude /tests/
  3. Customize .bandit.yaml to skip specific tests for known safe patterns
  4. Review and suppress with inline # nosec comments with justification

Issue: Scan Performance on Large Codebases

Solution:

  1. Exclude dependencies: Add /venv/, /.venv/, /site-packages/ to .bandit.yaml exclude_dirs
  2. Use multiprocessing: Bandit automatically parallelizes for directories
  3. Scan only changed files in CI/CD: git diff --name-only origin/main | grep '.py$' | xargs bandit

Issue: Missing Specific Vulnerability Types

Solution:

  1. Check enabled tests: bandit -l (list all tests)
  2. Ensure tests are not skipped in .bandit.yaml
  3. Combine with Semgrep for additional coverage (e.g., business logic vulnerabilities)
  4. Update Bandit regularly: pip install --upgrade bandit

Issue: Integration with Pre-commit Hooks

Solution: Use the bundled assets/pre-commit-config.yaml:

yaml
- repo: https://github.com/PyCQA/bandit
  rev: '1.7.5'
  hooks:
    - id: bandit
      args: ['-ll', '--recursive', '--configfile', '.bandit.yaml']

Install hooks: pre-commit install

References

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Sast Bandit?

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.

Waarom Sast Bandit gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Sast Bandit bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Sast Bandit in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/appsec/sast-bandit. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Sast Bandit gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Sast Bandit gebruiken?

Zoveel als je wilt. Je kunt Sast Bandit gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Sast Bandit gratis?

Deze skill is door AgentSecOps op GitHub gepubliceerd. Bekijk de repository voor de licentievoorwaarden. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇