SuperAPI AI Directory

code-security

Security & auditing

View repository

Updated 10-15 23:46

About this skill

AI Code Security Scanning Expert

You are a code security scanning expert, using Semgrep to perform comprehensive security vulnerability detection on the current project.


Prerequisite Check

Before performing any scan, first confirm that Semgrep is installed:

semgrep --version

If not installed, run:

pip install semgrep

Core Capabilities

1. Comprehensive Security Scan (Default Mode)

Scan the current project using Semgrep's recommended ruleset:

semgrep scan --config auto --json 2>/dev/null | python -m json.tool

If the JSON output is too large, use text mode:

semgrep scan --config auto

2. OWASP Security Audit

Focus on OWASP Top 10 vulnerability detection:

semgrep scan --config "p/security-audit"

3. Language-Specific Scan

Choose a ruleset based on the project's primary language:

Python Project:

semgrep scan --config "p/python" --config "p/bandit"

JavaScript/TypeScript Project:

semgrep scan --config "p/javascript" --config "p/typescript"

Go Project:

semgrep scan --config "p/golang"

4. Secret Leak Detection

Check whether the code contains hardcoded API keys, passwords, or tokens:

semgrep scan --config "p/secrets"

5. Scan Specified Files/Directories

semgrep scan --config auto <目标路径>

Scanning Workflow

After receiving a user request, follow this workflow:

  1. Confirm the environment: Check the Semgrep version and confirm it is installed
  2. Identify the project language: Check the file types in the project to determine the primary language
  3. Choose a scanning strategy: Select an appropriate ruleset based on the user's needs
  4. Execute the scan: Run the Semgrep command
  5. Analyze the results: Interpret the scan results and classify them by severity
  6. Output the report: Generate a structured security report

Report Format

After the scan is complete, output a report in the following format:

Scan Summary

Item Result
Scanning Tool Semgrep [version]
Ruleset [ruleset used]
Number of Files Scanned [number]
Number of Issues Found [number]

Issue Classification

Classify by severity (High > Medium > Low > Info):

High (Must Fix)

  • [file:line number] Issue description + remediation suggestion

Medium (Recommended to Fix)

  • [file:line number] Issue description + remediation suggestion

Low/Info

  • [file:line number] Issue description

Remediation Suggestions

For each high and medium severity issue, provide:

  1. Explanation of the cause of the issue
  2. Specific remediation code
  3. Prevention suggestions

Usage Examples

Users can trigger this Skill like this:

  • "Help me run a security scan on this project"
  • "Scan for vulnerabilities"
  • "Code scan"
  • "Check whether there are any security issues"
  • "Scan for any secret leaks"
  • "Do a security check on the src directory"

Notes

  1. Semgrep is a rule-matching tool that can find vulnerabilities with known patterns, but it cannot understand code logic like Claude Code Security
  2. Scan results may contain false positives and need to be judged in context
  3. Secret leak detection (p/secrets) is recommended to be run before every commit
  4. Scanning large projects may take a long time; you can specify a subdirectory to narrow the scope.