semgrep-appsec-scanner

$npx mdskill add seaworld008/Commonly-used-high-value-skills/semgrep-appsec-scanner

Run Semgrep SAST, custom rules, secret scanning, and supply chain analysis.

  • Scan source code for vulnerabilities and insecure patterns across languages.
  • Depends on Semgrep CLI, registry rules, and package manager lockfiles.
  • Inspects repo languages, frameworks, and lockfiles to select appropriate rules.
  • Returns findings with file, line, rule ID, and dataflow context for triage.

SKILL.md

.github/skills/semgrep-appsec-scannerView on GitHub ↗
---
name: semgrep-appsec-scanner
description: '用于通过 Semgrep 执行应用安全 SAST、源码扫描、自定义规则、密钥流程和供应链依赖分析。'
zh_description: "用于通过 Semgrep 执行应用安全 SAST、源码扫描、自定义规则、密钥流程和供应链依赖分析。"
version: "1.0.0"
author: seaworld008
source: "in-house"
source_url: ""
tags: '[security, sast, semgrep, code-scanning, supply-chain, secrets, ci, appsec]'
created_at: "2026-05-20"
updated_at: "2026-05-20"
quality: 4
complexity: advanced
---

# Semgrep AppSec Scanner

## Trigger / When to Use

Use this skill when the user asks for source-code vulnerability scanning, secure coding rule enforcement, custom SAST checks, secret scanning workflow design, or Semgrep Supply Chain dependency analysis.

Good trigger phrases:
- "scan this code with Semgrep"
- "find injection bugs"
- "add SAST to CI"
- "write a Semgrep rule"
- "scan dependencies with Semgrep Supply Chain"
- "triage Semgrep findings"

## Core Capabilities

- Run SAST checks across many common programming languages.
- Use community and organization rules from the Semgrep registry.
- Author custom rules for project-specific insecure patterns.
- Triage findings with file, line, rule ID, and dataflow context.
- Integrate scans into pull requests and CI.
- Combine SAST with supply-chain and secrets workflows when the Semgrep plan supports them.

## Workflow

### 1. Identify Languages and Frameworks

Before scanning, inspect the repo:

```bash
rg --files | sed -n '1,120p'
```

Classify:
- Primary languages.
- Web frameworks.
- Package managers and lockfiles.
- Generated directories to exclude.
- Test fixtures that may intentionally contain insecure samples.

### 2. Verify Semgrep

```bash
semgrep --version
```

If missing, recommend official installation. For one-off local scans, a package manager or containerized Semgrep run is usually enough.

### 3. Run Baseline SAST

```bash
semgrep scan --config auto
```

For stricter security-focused scans:

```bash
semgrep scan --config p/security-audit
semgrep scan --config p/owasp-top-ten
```

For JSON output:

```bash
semgrep scan --config auto --json --output semgrep-results.json
```

For SARIF:

```bash
semgrep scan --config auto --sarif --output semgrep-results.sarif
```

### 4. Triage Findings

For each finding, record:
- Rule ID.
- File and line.
- Vulnerability class.
- Source and sink, if dataflow is available.
- User-controlled input evidence.
- Exploit preconditions.
- Suggested fix and regression test.

Prioritize:
1. Injection, deserialization, auth bypass, SSRF, path traversal, and unsafe crypto.
2. Findings in production paths over tests or examples.
3. Framework-specific high-confidence rules.
4. Repeated patterns that deserve custom guardrails.

### 5. Write Custom Rules When Needed

Use custom rules when the project has a known unsafe wrapper or banned API:

```yaml
rules:
  - id: no-dangerous-shell
    message: Avoid shell=True with interpolated input.
    severity: ERROR
    languages: [python]
    patterns:
      - pattern: subprocess.run($CMD, shell=True, ...)
```

Validate the rule with positive and negative examples before adding it to CI.

### 6. Remediate

For code fixes:
- Prefer framework-native safe APIs.
- Add tests for the vulnerable path.
- Avoid broad sanitizers that hide root causes.
- Keep suppressions narrow and justified.

For dependency findings:
- Prefer package-manager native updates.
- Check whether the vulnerable dependency is reachable.
- Treat supply-chain results as complementary to OSV, Grype, Trivy, or Snyk scans.

## Common Patterns

### Pull Request CI

```yaml
name: semgrep
on: [pull_request]
jobs:
  semgrep:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Semgrep scan
        run: semgrep scan --config auto --error
```

### Project Rule Directory

```text
.semgrep/
  rules/
    no-dangerous-shell.yml
    no-raw-sql-wrapper.yml
  tests/
    no-dangerous-shell.py
```

### Finding Report Template

```markdown
## Semgrep Finding

- Rule:
- Severity:
- Location:
- User input source:
- Sensitive sink:
- Exploit path:
- Fix:
- Test:
- Suppression status:
```

## Interpretation Rules

- Semgrep is strongest when rules match the language and framework accurately.
- Do not report test fixtures, docs, or intentionally vulnerable examples unless they can ship.
- A finding without a feasible data path may be a hardening recommendation rather than a vulnerability.
- Use custom rules for local conventions; do not force generic rules to carry all policy.
- Keep false-positive feedback in rule tests so the signal improves over time.

## Boundaries

- Do not upload private code to a hosted service without approval.
- Do not suppress a rule across the entire repo unless the pattern is demonstrably irrelevant.
- Do not claim SAST coverage means dependency or runtime security is complete.
- Do not auto-fix security code without running tests around the behavior.
- Do not scan vendored dependencies as first-party code unless the user asks.

## Reference Sources

- Semgrep docs: https://semgrep.dev/docs/
- Running rules: https://semgrep.dev/docs/running-rules/
- Semgrep Supply Chain overview: https://semgrep.dev/docs/semgrep-supply-chain/overview/

More from seaworld008/Commonly-used-high-value-skills

SkillDescription
agent-hubMulti-agent collaboration plugin that spawns N parallel subagents competing on the same task via git worktree isolation. Agents work independently, results are evaluated by metric or LLM judge, and the best branch is merged. Use when: user wants multiple approaches tried in parallel — code optimization, content variation, research exploration, or any task that benefits from parallel competition. Requires: a git repo.
andrej-karpathy-skillsKarpathy-inspired coding discipline for AI agents: think before coding, keep changes simple, edit surgically, and define verifiable success criteria before implementation.
arenaSpecialist orchestrating codex exec / Antigravity CLI through dual paradigms — COMPETE (multi-variant comparison, select best) and COLLABORATE (decompose tasks across engines, integrate). Supports Solo/Team/Quick execution modes.
azure-kubernetesPlan, create, and configure production-ready Azure Kubernetes Service (AKS) clusters. Covers Day-0 checklist, SKU selection (Automatic vs Standard), networking options (private API server, Azure CNI Overlay, egress configuration), security, and operations (autoscaling, upgrade strategy, cost analysis). WHEN: create AKS environment, provision AKS, enable AKS observability, design AKS networking, choose AKS SKU, secure AKS, optimize AKS, AKS spot nodes, AKS cluster-autoscaler, rightsize AKS pod, pod rightsizing, over-provisioned AKS pod, pod resource requests and limits, Vertical Pod Autoscaler, VPA recommendations.
azure-kubernetes-automatic-readinessAssess Kubernetes workloads and cluster configuration for AKS Automatic compatibility. Identifies incompatibilities, generates fixes, and guides migration from AKS Standard to AKS Automatic. WHEN: migrate to AKS Automatic, check AKS Automatic readiness, validate manifests for Automatic, assess cluster for Automatic compatibility, fix deployment for Automatic compatibility, identify AKS Automatic migration blockers, is my cluster ready for AKS Automatic.
cc-devops-skillsSRE, DevOps, Kubernetes, CI/CD, PromQL, Terraform, Docker, and incident operations playbook for building reliable delivery and operations workflows.
chatgpt-appsBuild, scaffold, refactor, and troubleshoot ChatGPT Apps SDK applications that combine an MCP server and widget UI. Use when Codex needs to design tools, register UI resources, wire the MCP Apps bridge or ChatGPT compatibility APIs, apply Apps SDK metadata or CSP or domain settings, or produce a docs-aligned project scaffold. Prefer a docs-first workflow by invoking the openai-docs skill or OpenAI developer docs MCP tools before generating code.
clayAI 3D model generation agent. Generates text-to-3D and image-to-3D code (Python/JS/OpenSCAD) using Meshy, Tripo, Hunyuan3D, Rodin, Sloyd, and Stability APIs. Handles game pipeline integration, LOD, retopology, UV, and QC validation.
codeql-security-scanner用于通过 CodeQL 执行语义代码扫描、安全查询、自定义规则、SARIF 报告和 GitHub Code Scanning 集成。
complyRegulatory compliance and audit agent. Maps business regulatory requirements (SOC2/PCI-DSS/HIPAA/ISO 27001), checks control implementations, designs audit trails, and implements Policy as Code. Use when compliance auditing is needed.