agentleFS
vhmarquezvhmarquez/argo/skills/security-scan/SKILL.md

security-scan

Skill1 starsChanged 7 months agoMITView on GitHub

Run PMD with the Apex security ruleset against the project's Apex source. Surfaces SOQL injection vectors, missing CRUD/FLS checks, hardcoded credentials, sharing violations, and other Apex-specific security issues. CI mode emits SARIF for GitHub Code Scanning.

89 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use django-security, deployment-patterns and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mstuder-slalomSkill

    django-security

    Django security best practices, authentication, authorization, CSRF protection, SQL injection prevention, XSS prevention, and secure deployment configurations.

    Also in 5 projects that use this

  • royaluniondesign-sysSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 5 projects that use this

  • mstuder-slalomSkill

    springboot-security

    Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.

    Also in 4 projects that use this

  • DonTiziSkill

    dependency-check

    Analyze project dependencies for outdated packages, security vulnerabilities, and licensing issues. Use for dependency audits and maintenance.

    Also in 3 projects that use this

  • RojiosSkill

    security-bounty-hunter

    Hunt for exploitable, bounty-worthy security issues in repositories. Focuses on remotely reachable vulnerabilities that qualify for real reports instead of noisy local-only findings.

    Also in 3 projects that use this

  • nek1987Skill

    postgres-patterns

    PostgreSQL patterns for reviewing migrations and writing efficient queries. Use when reviewing Alembic migrations, optimizing queries, or debugging database issues.

    Also in 6 projects that use this

  • +2 more from mstuder-slalom

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 80 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default Markdown (one report per scan):

    line 95
  2. Very specific:

    Honor .pmd-suppressions.xml: if the user adds one — PMD reads it natively

    line 136

“Common” is measured: kept by at least 6 in 10 of the 80 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are running a security scan of the Apex source. The scan uses PMD with its apex-security ruleset (built-in to PMD 7.x). PMD is downloaded on first use into the plugin data directory.

Read Project Config First

source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/pmd.sh"
APEX_SRC="$(sf_config_get '.paths.apexSource' "$ENV")"

Input

$ARGUMENTS:

  • (empty) — scan the entire Apex source directory
  • <ClassName> — scan one class
  • <path> — scan a specific path
  • --ruleset <name> — additional rulesets beyond apex-security (e.g., apex-bestpractices, apex-performance, apex-codestyle). Comma-separated. Default is apex-security only
  • --baseline <path> — diff against a baseline scan; only report new findings (Phase 8 builds on this)
  • --ci — machine output
  • --format json|sarif (default sarif in CI mode)
  • --out <path> — output file

Steps

1. Ensure PMD is installed

pmd_install || exit 2

First call downloads PMD; subsequent calls reuse the cache.

2. Build the ruleset arg

PMD 7.x reference categories:

  • category/apex/security.xml — SOQL injection, CRUD/FLS, hardcoded URLs, weak randomness, etc.
  • category/apex/bestpractices.xml
  • category/apex/performance.xml
  • category/apex/codestyle.xml
  • category/apex/design.xml
  • category/apex/errorprone.xml
  • category/apex/documentation.xml

Default: category/apex/security.xml only.

3. Run PMD

pmd_run check \
  --dir "$APEX_SRC" \
  --rulesets "category/apex/security.xml${EXTRA:+,$EXTRA}" \
  --format json \
  --report-file /tmp/security-scan.pmd.json \
  --no-progress

Capture exit code separately — PMD exits non-zero on findings, which is expected.

4. Convert PMD output to internal finding shape

Map each PMD violation to:

{
  "ruleId":   "SEC-${PMD_RULE_NAME}",
  "severity": "error|warning|note",  // map from PMD priority 1-2 → error, 3 → warning, 4-5 → note
  "message":  "<PMD description>",
  "file":     "<relative path>",
  "line":     <beginline>,
  "endLine":  <endline>,
  "ruleHelpUri": "https://docs.pmd-code.org/.../<rule>.html",
  "tool":     "security-scan"
}

Common rules in apex-security (mapped IDs):

PMD ruleMappedSeverity
ApexBadCryptoSEC-BAD-CRYPTOerror
ApexCRUDViolationSEC-CRUD-VIOLATIONerror
ApexInsecureEndpointSEC-INSECURE-ENDPOINTerror
ApexOpenRedirectSEC-OPEN-REDIRECTerror
ApexSharingViolationsSEC-SHARING-VIOLATIONerror
ApexSOQLInjectionSEC-SOQL-INJECTIONerror
ApexSuggestUsingNamedCredSEC-USE-NAMED-CREDwarning
ApexXSSFromEscapeFalseSEC-XSS-ESCAPE-FALSEerror
ApexXSSFromURLParamSEC-XSS-URL-PARAMerror
ApexDangerousMethodsSEC-DANGEROUS-METHODSerror

5. Output

Default Markdown (one report per scan):

# Security Scan: <project.name>

Scanned: 47 Apex files
PMD: 7.6.0 | Ruleset: apex-security
Run at: 2026-04-28T12:45:00Z

## Findings

### Critical (3)
- `SEC-SOQL-INJECTION` — force-app/.../OrderController.cls:42 — Dynamic SOQL with unescaped user input
- ...

### High (5)
- `SEC-CRUD-VIOLATION` — force-app/.../OrderService.cls:84 — Missing CRUD check before insert
- ...

### Medium (8)
- `SEC-USE-NAMED-CRED` — force-app/.../OldClient.cls:12 — Endpoint hardcoded; use Named Credential (SF-15)
- ...

## Pattern compliance reminders
- SF-15: HTTP callouts via Named Credential
- SF-11: Dynamic field-name whitelist before SOQL composition
- SF-17: Custom Metadata Type lookup; do not put credentials in Custom Settings

(See ${paths.patternsSalesforceDoc} for full pattern docs.)

CI mode: pipe internal findings through sarif_emit "argo/security-scan" "$VERSION".

6. Exit codes

  • 0 — no findings
  • 1 — any error or warning findings
  • 2 — PMD failed to run

Rules

  • Don't auto-fix. This scan is a report; the user reads and fixes
  • Don't run on test classes by default — they're allowed to violate sharing for setup. Skip *<testSuffix>.cls
  • Honor .pmd-suppressions.xml if the user adds one — PMD reads it natively
  • Don't shadow @qa. This scan is narrower (Apex security only) than /code-review; both should be run
  • Update PMD version pinning intentionally. New PMD versions add rules — never silently upgrade. Pin in hooks/lib/pmd.sh and bump in a chore commit

Consumers

  • /argo:code-review and @qa recommend running /security-scan for any class touching DML, callouts, or dynamic SOQL
  • CI pipelines run /security-scan --ci --format sarif --out scan.sarif and upload to GitHub Code Scanning
  • @security-reviewer (Phase 5) reads scan results to focus its analysis

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.