skills/appsec/sast-semgrep/SKILL.md
Static application security testing (SAST) using Semgrep for vulnerability detection, security code review, and secure coding guidance with OWASP and CWE framework mapping. Use when: (1) Scanning code for security vulnerabilities across multiple languages, (2) Performing security code reviews with pattern-based detection, (3) Integrating SAST checks into CI/CD pipelines, (4) Providing remediation guidance with OWASP Top 10 and CWE mappings, (5) Creating custom security rules for organization-specific patterns, (6) Analyzing dependencies for known vulnerabilities.
npx skillsauth add agentsecops/secopsagentkit sast-semgrepInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Perform comprehensive static application security testing using Semgrep, a fast, open-source static analysis tool. This skill provides automated vulnerability detection, security code review workflows, and remediation guidance mapped to OWASP Top 10 and CWE standards.
Scan a codebase for security vulnerabilities:
semgrep --config=auto --severity=ERROR --severity=WARNING /path/to/code
Run with OWASP Top 10 ruleset:
semgrep --config="p/owasp-top-ten" /path/to/code
scripts/semgrep_scan.py with appropriate rulesetssemgrep --diff to scan only modified codereferences/remediation_guide.mdassets/rule_template.yamlreferences/custom_rules.mdassets/ci_config_examples/Sensitive Data Handling: Semgrep scans code locally; ensure scan results don't leak
secrets or proprietary code patterns. Use --max-lines-per-finding to limit output.
Access Control: Semgrep scans require read access to source code. Restrict scan result access to authorized security and development teams.
Audit Logging: Log all scan executions with timestamps, user, commit hash, and findings count for compliance auditing.
Compliance: SAST scanning supports SOC2, PCI-DSS, and GDPR compliance requirements. Maintain scan history and remediation tracking.
Safe Defaults: Use --config=auto for balanced detection. For security-critical
applications, use --config="p/security-audit" for comprehensive coverage.
Semgrep supports 30+ languages including:
scripts/semgrep_scan.py - Full-featured scanning with OWASP/CWE mapping and reportingscripts/baseline_scan.sh - Quick baseline scan for CI/CDscripts/diff_scan.sh - Scan only changed files (for PRs)references/owasp_cwe_mapping.md - OWASP Top 10 to CWE mapping with Semgrep rulesreferences/remediation_guide.md - Vulnerability remediation patterns by categoryreferences/rule_library.md - Curated list of useful Semgrep rulesetsassets/rule_template.yaml - Template for creating custom Semgrep rulesassets/ci_config_examples/ - CI/CD integration examples (GitHub Actions, GitLab CI)assets/semgrep_config.yaml - Recommended Semgrep configuration# Run comprehensive scan and generate report
scripts/semgrep_scan.py --config security-audit \
--output results.json \
--format json \
--severity HIGH CRITICAL
# Scan only changed files, fail on HIGH/CRITICAL
scripts/diff_scan.sh --fail-on high \
--base-branch main \
--output sarif
# Search for specific vulnerability patterns
semgrep --config "r/javascript.lang.security.audit.xss" \
--json /path/to/code | jq '.results'
# Test custom rule against vulnerable samples
semgrep --config assets/custom_rules.yaml \
--test tests/vulnerable_samples/
semgrep/semgrep-action@v1 with SARIF uploadSee assets/ci_config_examples/ for ready-to-use configurations.
Semgrep findings are classified by severity:
For large codebases:
# Use --jobs for parallel scanning
semgrep --config auto --jobs 4
# Exclude vendor/test code
semgrep --config auto --exclude "vendor/" --exclude "test/"
# Use lightweight rulesets for faster feedback
semgrep --config "p/owasp-top-ten" --exclude-rule "generic.*"
Solution:
--exclude-rule to disable noisy rules.semgrepignore file to exclude false positive patterns--severity filtering# nosemgrep comments for confirmed false positives (with justification)Solution:
--exclude for vendor/generated code--jobs for parallel processing--config=auto--diffSolution:
p/security-audit or p/owasp-top-tenreferences/rule_library.md for specialized rulesSee references/rule_library.md for guidance on writing effective Semgrep rules.
Use assets/rule_template.yaml as a starting point.
Example rule structure:
rules:
- id: custom-sql-injection
patterns:
- pattern: execute($QUERY)
- pattern-inside: |
$QUERY = $USER_INPUT + ...
message: Potential SQL injection from user input concatenation
severity: ERROR
languages: [python]
metadata:
cwe: "CWE-89"
owasp: "A03:2021-Injection"
This skill provides detection for all OWASP Top 10 2021 categories.
See references/owasp_cwe_mapping.md for complete coverage matrix.
testing
Linux privilege escalation enumeration and attack surface analysis using LinPEAS (Linux Privilege Escalation Awesome Script). Automates post-exploitation discovery of escalation vectors, misconfigurations, and credential exposure on Linux targets. Use when: (1) Enumerating privilege escalation vectors after initial access on a Linux system, (2) Identifying SUID/SGID binaries, sudo misconfigurations, and capability abuses, (3) Hunting for credentials in config files, history, and logs, (4) Detecting container breakout opportunities and writable service files, (5) Mapping kernel exploits and CVE exposure for a target system, (6) Conducting authorized CTF, red team, or penetration test post-exploitation phases.
development
Operational Technology (OT) security assessment using a two-stage methodology: (1) Identification/Discovery of OT devices and protocols, and (2) Vulnerability Assessment using online sources and Metasploit. Use when: (1) Conducting authorized OT/ICS security assessments, (2) Identifying and enumerating OT protocols (Modbus, S7, IEC 104, DNP3, BACnet, EtherNet/IP), (3) Discovering industrial control devices and PLCs, (4) Assessing OT protocol vulnerabilities and security weaknesses, (5) Performing compliance scanning aligned with IEC 62443 standards, (6) Validating network segmentation and access controls in OT environments.
tools
Vulnerability management and findings aggregation using DefectDojo. Centralizes security findings from all SecOpsAgentKit scanners (Semgrep, Bandit, ZAP, Trivy, Grype, Gitleaks, Nuclei, Checkov, Horusec) into a unified platform with automatic deduplication, SLA tracking, risk-based prioritization, and compliance reporting. Use when: (1) Aggregating findings from multiple scanners across products and pipelines, (2) Tracking remediation status and SLA compliance against policy thresholds, (3) Deduplicating overlapping findings across security tools, (4) Generating vulnerability reports for compliance audits (SOC2, PCI-DSS, GDPR), (5) Managing security debt and vulnerability backlog across teams and applications.
tools
Python-based threat modeling using pytm library for programmatic STRIDE analysis, data flow diagram generation, and automated security threat identification. Use when: (1) Creating threat models programmatically using Python code, (2) Generating data flow diagrams (DFDs) with automatic STRIDE threat identification, (3) Integrating threat modeling into CI/CD pipelines and shift-left security practices, (4) Analyzing system architecture for security threats across trust boundaries, (5) Producing threat reports with STRIDE categories and mitigation recommendations, (6) Maintaining threat models as code for version control and automation.