Harness Security Scan
Lightweight mechanical security scan. Fast triage, not deep review.
When to Use
- As part of the codebase-health-analyst sweep
- For quick security triage on a project or changed files
- On scheduled cron runs for continuous security coverage
- NOT for deep security review (use harness-security-review)
- NOT for threat modeling (use harness-security-review --deep)
Process
Phase 1: SCAN — Run Mechanical Scanner
Resolve project root. Use provided path or cwd.
Load security config. Read harness.config.json and extract security
section. Fall back to defaults if absent.
Determine file scope.
- If
--changed-only or triggered by PR: run git diff --name-only HEAD~1
to get changed files. Filter to source files only (exclude node_modules,
dist, test files per config).
- Otherwise: scan all source files in the project.
Run SecurityScanner. Call SecurityScanner.scanFiles() from
@harness-engineering/core.
Filter by severity threshold. Remove findings below the configured
threshold:
error: only errors
warning: errors and warnings (default)
info: all findings
Check security trends. Check get_security_trends to compare current scan results against the project's security posture history and identify trajectory changes.
Output report. Present findings grouped by severity:
Security Scan: [PASS/FAIL]
Scanned: N files, M rules applied
Errors: N | Warnings: N | Info: N
[List findings with rule ID, file:line, severity, message, remediation]
Gates
- Error-severity findings are blocking. Report is FAIL if any error-severity
finding exists after filtering.
- No AI review. This skill is mechanical only. Do not perform OWASP analysis
or threat modeling.
Harness Integration
harness check-security — CLI command that invokes this skill's scanner.
SecurityScanner — Core class from @harness-engineering/core that executes the rule engine. Its injection rule set (SEC-INJ-*) is the load-bearing enforcement of the owasp-injection-prevention domain skill's concrete anti-patterns — eval/Function, SQL string concatenation, command injection, and Prisma $queryRawUnsafe/$executeRawUnsafe called with interpolated input. Deep injection classes that need data-flow (NoSQL operator injection, second-order injection) are intentionally out of scope for this mechanical scan and belong to /harness:security-review.
harness.config.json — Security section configures severity threshold and file exclusions.
- codebase-health-analyst persona — Invokes this skill as part of its sweep.
Evidence Requirements
When this skill makes claims about existing code, architecture, or behavior,
it MUST cite evidence using one of:
- File reference:
file:line format (e.g., src/auth.ts:42)
- Code pattern reference:
file with description (e.g., src/utils/hash.ts —
"existing bcrypt wrapper")
- Test/command output: Inline or referenced output from a test run or CLI command
- Session evidence: Write to the
evidence session section via manage_state
Uncited claims: Technical assertions without citations MUST be prefixed with
[UNVERIFIED]. Example: [UNVERIFIED] The auth middleware supports refresh tokens.
Red Flags
Universal
These apply to ALL skills. If you catch yourself doing any of these, STOP.
- "I believe the codebase does X" — Stop. Read the code and cite a file:line
reference. Belief is not evidence.
- "Let me recommend [pattern] for this" without checking existing patterns — Stop.
Search the codebase first. The project may already have a convention.
- "While we're here, we should also [unrelated improvement]" — Stop. Flag the idea
but do not expand scope beyond the stated task.
Domain-Specific
- "This finding is in test code, so it's not a real issue" — Stop. Test code can leak secrets, establish bad patterns, and be copy-pasted to production.
- "This dependency is widely used, so it's safe" — Stop. Popularity is not a security guarantee. Check CVE databases and advisory feeds.
- "This is a low-severity finding, skipping" — Stop. Low-severity findings compound. Document why you are deprioritizing, do not silently skip.
- "The scanner didn't flag it, so it's clean" — Stop. Scanners have false negatives. A clean scan is not proof of security — it is absence of evidence.
Rationalizations to Reject
Universal
These reasoning patterns sound plausible but lead to bad outcomes. Reject them.
- "It's probably fine" — "Probably" is not evidence. Verify before asserting.
- "This is best practice" — Best practice in what context? Cite the source and
confirm it applies to this codebase.
- "We can fix it later" — If it is worth flagging, it is worth documenting now
with a concrete follow-up plan.
Domain-Specific
| Rationalization |
Reality |
| "No attacker would find this" |
Security by obscurity. If the code is wrong, flag it regardless of discoverability. |
| "We're behind a firewall" |
Network boundaries change. Code should be secure at every layer regardless of deployment topology. |
| "The framework handles this for us" |
Verify the framework's actual behavior. Misuse of a secure framework is still insecure. |
Escalation
- When error-severity findings are disputed: The scanner is mechanical — it may flag false positives. If a finding is a false positive, add a
// harness-ignore SEC-XXX comment on the line and document the rationale. Do not suppress without explanation.
- When the scanner misses a known vulnerability: This skill runs pattern-based rules only. For semantic analysis (taint tracking, control flow), use
/harness:security-review instead.
- When scan is too slow on large codebases: Use
--changed-only to scope to recently changed files. Full scans can run on a scheduled cron instead.
Success Criteria
- Scanner ran and produced findings (or confirmed clean)
- Findings are filtered by the configured severity threshold
- Report follows the structured format
- Exit code reflects pass/fail status
Examples
Example: Clean Scan
Security Scan: PASS
Scanned: 42 files, 12 rules applied
Errors: 0 | Warnings: 0 | Info: 0
Example: Findings Detected
Security Scan: FAIL
Scanned: 42 files, 12 rules applied
Errors: 1 | Warnings: 2 | Info: 0
[SEC-SECRET-001] src/config.ts:15 (error)
Hardcoded API key detected: `const API_KEY = "sk-..."`
Remediation: Move to environment variable, use dotenv or secrets manager.
[SEC-NET-001] src/cors.ts:5 (warning)
CORS wildcard origin: `origin: "*"`
Remediation: Restrict to specific allowed origins.
[SEC-CRYPTO-001] src/auth.ts:22 (warning)
Weak hash algorithm: `crypto.createHash("md5")`
Remediation: Use SHA-256 or stronger.
1---2name: harness-security-scan3description: Harness Security Scan4metadata:5 source: https://skillmd.com/skills/intense-visions/harness-security-scan6---7# Harness Security Scan89> Lightweight mechanical security scan. Fast triage, not deep review.1011## When to Use1213- As part of the codebase-health-analyst sweep14- For quick security triage on a project or changed files15- On scheduled cron runs for continuous security coverage16- NOT for deep security review (use harness-security-review)17- NOT for threat modeling (use harness-security-review --deep)1819## Process2021### Phase 1: SCAN — Run Mechanical Scanner22231. **Resolve project root.** Use provided path or cwd.24252. **Load security config.** Read `harness.config.json` and extract `security`26 section. Fall back to defaults if absent.27283. **Determine file scope.**29 - If `--changed-only` or triggered by PR: run `git diff --name-only HEAD~1`30 to get changed files. Filter to source files only (exclude node_modules,31 dist, test files per config).32 - Otherwise: scan all source files in the project.33344. **Run SecurityScanner.** Call `SecurityScanner.scanFiles()` from35 `@harness-engineering/core`.36375. **Filter by severity threshold.** Remove findings below the configured38 threshold:39 - `error`: only errors40 - `warning`: errors and warnings (default)41 - `info`: all findings42436. **Check security trends.** Check `get_security_trends` to compare current scan results against the project's security posture history and identify trajectory changes.44457. **Output report.** Present findings grouped by severity:4647 ```48 Security Scan: [PASS/FAIL]49 Scanned: N files, M rules applied50 Errors: N | Warnings: N | Info: N5152 [List findings with rule ID, file:line, severity, message, remediation]53 ```5455## Gates5657- **Error-severity findings are blocking.** Report is FAIL if any error-severity58 finding exists after filtering.59- **No AI review.** This skill is mechanical only. Do not perform OWASP analysis60 or threat modeling.6162## Harness Integration6364- **`harness check-security`** — CLI command that invokes this skill's scanner.65- **`SecurityScanner`** — Core class from `@harness-engineering/core` that executes the rule engine. Its injection rule set (`SEC-INJ-*`) is the load-bearing enforcement of the `owasp-injection-prevention` domain skill's concrete anti-patterns — `eval`/`Function`, SQL string concatenation, command injection, and Prisma `$queryRawUnsafe`/`$executeRawUnsafe` called with interpolated input. Deep injection classes that need data-flow (NoSQL operator injection, second-order injection) are intentionally out of scope for this mechanical scan and belong to `/harness:security-review`.66- **`harness.config.json`** — Security section configures severity threshold and file exclusions.67- **codebase-health-analyst persona** — Invokes this skill as part of its sweep.6869## Evidence Requirements7071When this skill makes claims about existing code, architecture, or behavior,72it MUST cite evidence using one of:73741. **File reference:** `file:line` format (e.g., `src/auth.ts:42`)752. **Code pattern reference:** `file` with description (e.g., `src/utils/hash.ts` —76 "existing bcrypt wrapper")773. **Test/command output:** Inline or referenced output from a test run or CLI command784. **Session evidence:** Write to the `evidence` session section via `manage_state`7980**Uncited claims:** Technical assertions without citations MUST be prefixed with81`[UNVERIFIED]`. Example: `[UNVERIFIED] The auth middleware supports refresh tokens`.8283## Red Flags8485### Universal8687These apply to ALL skills. If you catch yourself doing any of these, STOP.8889- **"I believe the codebase does X"** — Stop. Read the code and cite a file:line90 reference. Belief is not evidence.91- **"Let me recommend [pattern] for this"** without checking existing patterns — Stop.92 Search the codebase first. The project may already have a convention.93- **"While we're here, we should also [unrelated improvement]"** — Stop. Flag the idea94 but do not expand scope beyond the stated task.9596### Domain-Specific9798- **"This finding is in test code, so it's not a real issue"** — Stop. Test code can leak secrets, establish bad patterns, and be copy-pasted to production.99- **"This dependency is widely used, so it's safe"** — Stop. Popularity is not a security guarantee. Check CVE databases and advisory feeds.100- **"This is a low-severity finding, skipping"** — Stop. Low-severity findings compound. Document why you are deprioritizing, do not silently skip.101- **"The scanner didn't flag it, so it's clean"** — Stop. Scanners have false negatives. A clean scan is not proof of security — it is absence of evidence.102103## Rationalizations to Reject104105### Universal106107These reasoning patterns sound plausible but lead to bad outcomes. Reject them.108109- **"It's probably fine"** — "Probably" is not evidence. Verify before asserting.110- **"This is best practice"** — Best practice in what context? Cite the source and111 confirm it applies to this codebase.112- **"We can fix it later"** — If it is worth flagging, it is worth documenting now113 with a concrete follow-up plan.114115### Domain-Specific116117| Rationalization | Reality |118| ----------------------------------- | -------------------------------------------------------------------------------------------------- |119| "No attacker would find this" | Security by obscurity. If the code is wrong, flag it regardless of discoverability. |120| "We're behind a firewall" | Network boundaries change. Code should be secure at every layer regardless of deployment topology. |121| "The framework handles this for us" | Verify the framework's actual behavior. Misuse of a secure framework is still insecure. |122123## Escalation124125- **When error-severity findings are disputed:** The scanner is mechanical — it may flag false positives. If a finding is a false positive, add a `// harness-ignore SEC-XXX` comment on the line and document the rationale. Do not suppress without explanation.126- **When the scanner misses a known vulnerability:** This skill runs pattern-based rules only. For semantic analysis (taint tracking, control flow), use `/harness:security-review` instead.127- **When scan is too slow on large codebases:** Use `--changed-only` to scope to recently changed files. Full scans can run on a scheduled cron instead.128129## Success Criteria130131- Scanner ran and produced findings (or confirmed clean)132- Findings are filtered by the configured severity threshold133- Report follows the structured format134- Exit code reflects pass/fail status135136## Examples137138### Example: Clean Scan139140```141Security Scan: PASS142Scanned: 42 files, 12 rules applied143Errors: 0 | Warnings: 0 | Info: 0144```145146### Example: Findings Detected147148```149Security Scan: FAIL150Scanned: 42 files, 12 rules applied151Errors: 1 | Warnings: 2 | Info: 0152153[SEC-SECRET-001] src/config.ts:15 (error)154 Hardcoded API key detected: `const API_KEY = "sk-..."`155 Remediation: Move to environment variable, use dotenv or secrets manager.156157[SEC-NET-001] src/cors.ts:5 (warning)158 CORS wildcard origin: `origin: "*"`159 Remediation: Restrict to specific allowed origins.160161[SEC-CRYPTO-001] src/auth.ts:22 (warning)162 Weak hash algorithm: `crypto.createHash("md5")`163 Remediation: Use SHA-256 or stronger.164```