@wrongstack/core 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/defaults/index.d.ts +595 -3
- package/dist/defaults/index.js +1098 -5
- package/dist/defaults/index.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +1105 -12
- package/dist/index.js.map +1 -1
- package/dist/{session-reader-7AutWHut.d.ts → session-reader-9sOTgmeC.d.ts} +31 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/skills/audit-log/SKILL.md +67 -0
- package/skills/bug-hunter/SKILL.md +87 -0
- package/skills/refactor-planner/SKILL.md +94 -0
- package/skills/security-scanner/SKILL.md +117 -0
|
@@ -682,6 +682,37 @@ interface SubagentConfig {
|
|
|
682
682
|
tools?: string[];
|
|
683
683
|
model?: string;
|
|
684
684
|
priority?: number;
|
|
685
|
+
/**
|
|
686
|
+
* Provider registry id (e.g. `'anthropic'`, `'openai'`, `'google'`).
|
|
687
|
+
* Allows a director to mix providers across siblings — one subagent on
|
|
688
|
+
* Sonnet, another on GPT-5, another on Haiku. Falls back to the
|
|
689
|
+
* factory's default provider when omitted, which is the legacy
|
|
690
|
+
* single-provider behavior.
|
|
691
|
+
*/
|
|
692
|
+
provider?: string;
|
|
693
|
+
/**
|
|
694
|
+
* Per-subagent session JSONL path. When omitted the orchestrator-
|
|
695
|
+
* supplied factory derives a path under `<sessionRoot>/<runId>/`.
|
|
696
|
+
* Override to redirect the transcript elsewhere (long-term storage,
|
|
697
|
+
* a different filesystem, etc.).
|
|
698
|
+
*/
|
|
699
|
+
sessionPath?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Additional text appended to the role's base system prompt. Does not
|
|
702
|
+
* replace it. Useful for last-mile guidance like "you may only call
|
|
703
|
+
* read tools, never write" or "respond in JSON only".
|
|
704
|
+
*/
|
|
705
|
+
systemPromptOverride?: string;
|
|
706
|
+
/**
|
|
707
|
+
* Routing for streaming output. `'director'` (default) forwards
|
|
708
|
+
* text/tool events to the parent's FleetBus so the director can read
|
|
709
|
+
* the subagent's stream. `'silent'` keeps everything subagent-local;
|
|
710
|
+
* the director only sees the final task result. `'user'` forwards
|
|
711
|
+
* direct to the user-facing renderer (gate this behind an explicit
|
|
712
|
+
* config flag — it can confuse the chat surface).
|
|
713
|
+
*/
|
|
714
|
+
textStream?: 'director' | 'silent' | 'user';
|
|
715
|
+
toolStream?: 'director' | 'silent' | 'user';
|
|
685
716
|
}
|
|
686
717
|
interface TaskResult<T = unknown> {
|
|
687
718
|
subagentId: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { A as AgentError, C as CacheStats, a as Capabilities, b as ConfigError, c as ContentBlock, E as ErrorCode, d as ErrorSeverity, e as ErrorSubsystem, I as ImageBlock, J as JSONSchema, M as Message, f as MessageRole, P as Permission, g as PluginError, h as Provider, i as ProviderError, j as ProviderErrorBody, R as Request, k as Response, l as ResumedSession, S as SessionData, m as SessionError, n as SessionEvent, o as SessionMetadata, p as SessionStore, q as SessionSummary, r as SessionWriter, s as StopReason, t as StreamEvent, T as TextBlock, u as TokenCounter, v as Tool, w as ToolCallContext, x as ToolError, y as ToolFinalEvent, z as ToolProgressEvent, B as ToolResultBlock, D as ToolStreamEvent, F as ToolUseBlock, U as Usage, W as WrongStackError, G as asBlocks, H as asText, K as isAgentError, L as isConfigError, N as isImageBlock, O as isPluginError, Q as isSessionError, V as isTextBlock, X as isToolError, Y as isToolResultBlock, Z as isToolUseBlock, _ as isWrongStackError, $ as toWrongStackError } from '../provider-txgB0Oq9.js';
|
|
2
2
|
export { C as CompactReport, a as Compactor, b as Config, c as ConfigLoader, d as ConfigStore, e as ContextConfig, D as DEFAULT_MODES, E as ErrorHandler, F as FeaturesConfig, I as InputReader, L as LogConfig, f as LogLevel, g as Logger, M as MCPServerConfig, h as MemoryEntry, i as MemoryScope, j as MemoryStore, k as Mode, l as ModeConfig, m as ModeManifest, n as ModeStore, o as ModelsDevModel, p as ModelsDevPayload, q as ModelsDevProvider, r as ModelsRegistry, P as PathResolver, s as PermissionDecision, t as PermissionPolicy, u as PluginConfig, v as PromptOption, w as ProviderApiKey, x as ProviderConfig, R as RecoveryDecision, y as Renderer, z as ResolvedModel, A as ResolvedProvider, B as RetryPolicy, S as SecretScrubber, G as SkillEntry, H as SkillLoader, J as SkillManifest, T as ToolsConfig, K as TrustPolicy, W as WireFamily } from '../mode-Pjt5vMS6.js';
|
|
3
|
-
export { A as AddAttachmentInput, a as AgentBridge, b as AgentBridgeConfig, c as AggregateHealth, d as Attachment, e as AttachmentKind, f as AttachmentMeta, g as AttachmentRef, h as AttachmentStore, B as BridgeMessage, i as BridgeMessageType, j as BridgeTransport, C as ConfirmAwaiter, k as CoordinatorEvents, l as CoordinatorStatus, m as CriticalPathResult, D as DEFAULT_SPEC_TEMPLATE, n as DefaultSessionReaderOptions, o as DoneCondition, E as ENCRYPTED_PREFIX, H as HealthCheck, p as HealthCheckResult, q as HealthRegistry, r as HealthStatus, M as MCPRegistryView, s as MetricLabels, t as MetricSeries, u as MetricsSink, v as MetricsSnapshot, w as MultiAgentConfig, x as MultiAgentCoordinator, P as Plugin, y as PluginAPI, z as PluginCapabilities, F as PluginDependency, G as PluginPipelines, I as ProviderFactory, J as ProviderRegistryView, S as SecretVault, K as SessionEventType, L as SessionExportOptions, N as SessionQuery, O as SessionReader, Q as SessionSearchHit, R as SessionSearchQuery, T as SessionSummaryLite, U as SlashCommand, V as SlashCommandRegistryView, W as Span, X as SpawnResult, Y as SpecAnalysis, Z as SpecApiEndpoint, _ as SpecRequirement, $ as SpecSection, a0 as SpecSectionType, a1 as SpecStatus, a2 as SpecTemplate, a3 as SpecValidationResult, a4 as Specification, a5 as SubagentConfig, a6 as SubagentContext, a7 as SubagentRunContext, a8 as SubagentRunOutcome, a9 as SubagentRunner, aa as TaskAssignment, ab as TaskDelegation, ac as TaskDependency, ad as TaskEdge, ae as TaskFilter, af as TaskGraph, ag as TaskNode, ah as TaskPriority, ai as TaskProgress, aj as TaskResult, ak as TaskSort, al as TaskSpec, am as TaskStatus, an as TaskType, ao as ToolBatchResult, ap as ToolConfirmPendingResult, aq as ToolExecution, ar as ToolExecutionOutput, as as ToolExecutorInit, at as ToolExecutorOptions, au as ToolExecutorStrategy, av as ToolRegistryView, aw as Tracer, ax as computeTaskProgress, ay as findCriticalPath, az as topologicalSort } from '../session-reader-
|
|
3
|
+
export { A as AddAttachmentInput, a as AgentBridge, b as AgentBridgeConfig, c as AggregateHealth, d as Attachment, e as AttachmentKind, f as AttachmentMeta, g as AttachmentRef, h as AttachmentStore, B as BridgeMessage, i as BridgeMessageType, j as BridgeTransport, C as ConfirmAwaiter, k as CoordinatorEvents, l as CoordinatorStatus, m as CriticalPathResult, D as DEFAULT_SPEC_TEMPLATE, n as DefaultSessionReaderOptions, o as DoneCondition, E as ENCRYPTED_PREFIX, H as HealthCheck, p as HealthCheckResult, q as HealthRegistry, r as HealthStatus, M as MCPRegistryView, s as MetricLabels, t as MetricSeries, u as MetricsSink, v as MetricsSnapshot, w as MultiAgentConfig, x as MultiAgentCoordinator, P as Plugin, y as PluginAPI, z as PluginCapabilities, F as PluginDependency, G as PluginPipelines, I as ProviderFactory, J as ProviderRegistryView, S as SecretVault, K as SessionEventType, L as SessionExportOptions, N as SessionQuery, O as SessionReader, Q as SessionSearchHit, R as SessionSearchQuery, T as SessionSummaryLite, U as SlashCommand, V as SlashCommandRegistryView, W as Span, X as SpawnResult, Y as SpecAnalysis, Z as SpecApiEndpoint, _ as SpecRequirement, $ as SpecSection, a0 as SpecSectionType, a1 as SpecStatus, a2 as SpecTemplate, a3 as SpecValidationResult, a4 as Specification, a5 as SubagentConfig, a6 as SubagentContext, a7 as SubagentRunContext, a8 as SubagentRunOutcome, a9 as SubagentRunner, aa as TaskAssignment, ab as TaskDelegation, ac as TaskDependency, ad as TaskEdge, ae as TaskFilter, af as TaskGraph, ag as TaskNode, ah as TaskPriority, ai as TaskProgress, aj as TaskResult, ak as TaskSort, al as TaskSpec, am as TaskStatus, an as TaskType, ao as ToolBatchResult, ap as ToolConfirmPendingResult, aq as ToolExecution, ar as ToolExecutionOutput, as as ToolExecutorInit, at as ToolExecutorOptions, au as ToolExecutorStrategy, av as ToolRegistryView, aw as Tracer, ax as computeTaskProgress, ay as findCriticalPath, az as topologicalSort } from '../session-reader-9sOTgmeC.js';
|
|
4
4
|
export { B as BuildContext, M as ModelCapabilities, S as SystemPromptBuilder } from '../system-prompt-vAB0F54-.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "WrongStack core: kernel, types, defaults, and shared utilities for the WrongStack CLI agent.",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dist",
|
|
44
44
|
"skills"
|
|
45
45
|
],
|
|
46
|
-
"wrongstackApiVersion": "0.1.
|
|
46
|
+
"wrongstackApiVersion": "0.1.9",
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^22.19.19",
|
|
49
49
|
"tsup": "^8.5.1",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audit-log
|
|
3
|
+
description: |
|
|
4
|
+
System-wide audit log analysis. Covers log parsing, anomaly detection,
|
|
5
|
+
pattern recognition across sessions, and structured reporting.
|
|
6
|
+
Use for post-mortems, trend analysis, and operational insights.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Audit Log Agent
|
|
11
|
+
|
|
12
|
+
Analyzes session logs, event streams, and system traces to surface patterns,
|
|
13
|
+
anomalies, and actionable insights.
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
- Parse structured JSONL session logs
|
|
18
|
+
- Detect repeated failure patterns across runs
|
|
19
|
+
- Identify tool usage anomalies (over-use, misuse, failures)
|
|
20
|
+
- Track token consumption trends per agent/session
|
|
21
|
+
- Generate markdown audit reports
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. **Collect** — Read session logs from `sessionRoot` or provided path
|
|
26
|
+
2. **Parse** — Extract events: tool calls, iterations, errors, usage
|
|
27
|
+
3. **Analyze** — Group by category, detect anomalies
|
|
28
|
+
4. **Report** — Output structured markdown summary
|
|
29
|
+
|
|
30
|
+
## Input
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"task": "analyze | report | trends",
|
|
35
|
+
"sessionPath": "<path to session JSONL>",
|
|
36
|
+
"focus": "errors | tools | usage | all"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Output Format
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
## Audit Report — <date>
|
|
44
|
+
|
|
45
|
+
### Summary
|
|
46
|
+
- Total sessions: N
|
|
47
|
+
- Total tool calls: N
|
|
48
|
+
- Error rate: X%
|
|
49
|
+
|
|
50
|
+
### Top Errors
|
|
51
|
+
1. <error-type>: <count>x — <context>
|
|
52
|
+
2. ...
|
|
53
|
+
|
|
54
|
+
### Tool Usage
|
|
55
|
+
| Tool | Calls | Failures | Avg Duration |
|
|
56
|
+
|------|-------|----------|--------------|
|
|
57
|
+
| read | 142 | 3 | 45ms |
|
|
58
|
+
|
|
59
|
+
### Anomalies
|
|
60
|
+
- `<pattern-detected>` — <severity: low/medium/high>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Anti-patterns
|
|
64
|
+
|
|
65
|
+
- Don't summarize what you didn't parse — be precise
|
|
66
|
+
- Don't mix session paths — analyze one at a time or aggregate clearly
|
|
67
|
+
- Don't skip error context — the user's log is the source of truth
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-hunter
|
|
3
|
+
description: |
|
|
4
|
+
Systematic bug and code smell detection. Covers static analysis patterns,
|
|
5
|
+
anti-pattern recognition, error-prone construct detection, and severity ranking.
|
|
6
|
+
Use before refactoring or as a standalone health check.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Bug Hunter Agent
|
|
11
|
+
|
|
12
|
+
Scans source code for bugs, anti-patterns, and code smells using pattern matching
|
|
13
|
+
and heuristics. Outputs a prioritized hit list with file:line references.
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
- Detect common bug patterns (uncaught errors, resource leaks, race conditions)
|
|
18
|
+
- Identify anti-patterns (callback hell, God objects, circular deps)
|
|
19
|
+
- Find TypeScript-specific issues (unsafe any, missing null checks)
|
|
20
|
+
- Flag security-sensitive constructs (eval, innerHTML, hardcoded secrets)
|
|
21
|
+
- Rank findings by severity: critical > high > medium > low
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. **Scope** — Accept file/dir globs or explicit paths
|
|
26
|
+
2. **Scan** — Run grep/read across target files
|
|
27
|
+
3. **Classify** — Categorize findings by type and severity
|
|
28
|
+
4. **Rank** — Sort by severity, then frequency
|
|
29
|
+
5. **Report** — Markdown output with fix suggestions
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"task": "scan | hunt | check",
|
|
36
|
+
"paths": ["src/**/*.ts", "lib/*.js"],
|
|
37
|
+
"focus": "bugs | patterns | security | all",
|
|
38
|
+
"severityThreshold": "medium"
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Output Format
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
## Bug Hunt Report — <scope>
|
|
46
|
+
|
|
47
|
+
### Critical (must fix)
|
|
48
|
+
1. **[RACE]** `src/auth.ts:47` — setTimeout without clearTimeout in loop
|
|
49
|
+
2. **[SECRET]** `lib/config.ts:12` — hardcoded API key detected
|
|
50
|
+
|
|
51
|
+
### High (should fix)
|
|
52
|
+
3. **[MEMORY]** `tools/pool.ts:89` — event listener never removed
|
|
53
|
+
4. **[TYPE]** `core/agent.ts:103` — unsafe `any` cast loses type safety
|
|
54
|
+
|
|
55
|
+
### Medium
|
|
56
|
+
...
|
|
57
|
+
|
|
58
|
+
### Low (consider)
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
## Summary
|
|
62
|
+
| Severity | Count |
|
|
63
|
+
|----------|-------|
|
|
64
|
+
| Critical | 2 |
|
|
65
|
+
| High | 4 |
|
|
66
|
+
| Medium | 7 |
|
|
67
|
+
| Low | 3 |
|
|
68
|
+
|
|
69
|
+
Total: 16 findings in 12 files
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Bug Pattern Reference
|
|
73
|
+
|
|
74
|
+
| Pattern | Regex Hint | Severity |
|
|
75
|
+
|---------|------------|----------|
|
|
76
|
+
| Uncaught promise | `\.then\(` without `catch` | high |
|
|
77
|
+
| Event leak | `on\(` without `off`/`removeListener` | high |
|
|
78
|
+
| Hardcoded secret | `[a-zA-Z0-9/_-]{20,}` in config | critical |
|
|
79
|
+
| unsafe any | `: any\b` or `<any>` | medium |
|
|
80
|
+
| innerHTML | `innerHTML\s*=` | high |
|
|
81
|
+
| TODO without FIXME | `TODO(?!.*FIXME)` | low |
|
|
82
|
+
|
|
83
|
+
## Anti-patterns
|
|
84
|
+
|
|
85
|
+
- Don't scan node_modules — waste of time and false positives
|
|
86
|
+
- Don't report without file:line — useless for fixing
|
|
87
|
+
- Don't ignore false positive rates — if >30% of findings are noise, lower confidence
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactor-planner
|
|
3
|
+
description: |
|
|
4
|
+
Structured refactoring planning from code analysis. Covers dependency mapping,
|
|
5
|
+
risk assessment, phased planning, and migration strategy.
|
|
6
|
+
Use before large rewrites or when technical debt is blocking progress.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Refactor Planner Agent
|
|
11
|
+
|
|
12
|
+
Analyzes code structure and produces a concrete, phased refactoring plan with
|
|
13
|
+
risk assessment, dependency ordering, and rollback considerations.
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
- Map module-level dependencies (import graph)
|
|
18
|
+
- Identify coupling hotspots (high fan-in/out modules)
|
|
19
|
+
- Assess refactoring risk by cyclomatic complexity and test coverage
|
|
20
|
+
- Generate phased plans with checkpoint milestones
|
|
21
|
+
- Produce diff-friendly task lists (one task = one concern)
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. **Analyze** — Build dependency graph, count coupling
|
|
26
|
+
2. **Score** — Rate each module by: size, complexity, test coverage, change frequency
|
|
27
|
+
3. **Plan** — Order tasks by risk, dependency, and payoff
|
|
28
|
+
4. **Document** — Output phased markdown plan
|
|
29
|
+
|
|
30
|
+
## Input
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"task": "plan | assess | roadmap",
|
|
35
|
+
"target": "src/core | packages/tools | .",
|
|
36
|
+
"constraint": "no-breaking-changes | minimal-downtime | full-rewrite",
|
|
37
|
+
"focus": "architecture | performance | maintainability"
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Output Format
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
## Refactor Plan — <target>
|
|
45
|
+
|
|
46
|
+
### Phase 1: Low Risk / High Payoff (do first)
|
|
47
|
+
| # | Task | Module | Risk | Est. Time |
|
|
48
|
+
|---|------|--------|------|-----------|
|
|
49
|
+
| 1 | Extract `ToolExecutor` interface | core/tool-executor.ts | low | 2h |
|
|
50
|
+
| 2 | Decouple `SessionStore` from Agent | core/session-store.ts | low | 4h |
|
|
51
|
+
|
|
52
|
+
### Phase 2: Medium Risk (test heavily)
|
|
53
|
+
| # | Task | Module | Risk | Est. Time |
|
|
54
|
+
|---|------|--------|------|-----------|
|
|
55
|
+
| 3 | Break circular dep: Config ↔ Logger | core/config.ts | medium | 6h |
|
|
56
|
+
| 4 | Split `Context` into read/write slices | core/context.ts | medium | 8h |
|
|
57
|
+
|
|
58
|
+
### Phase 3: High Risk (requires full regression)
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
### Dependency Graph (abbreviated)
|
|
62
|
+
```
|
|
63
|
+
config.ts → logger.ts → path-resolver.ts
|
|
64
|
+
↓ ↓
|
|
65
|
+
secret-vault.ts session-store.ts
|
|
66
|
+
↓ ↓
|
|
67
|
+
└────────→ agent.ts ←←←
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Rollback Strategy
|
|
71
|
+
Each phase commits independently. On failure: `git checkout phase<N>`.
|
|
72
|
+
Run `pnpm test` before advancing.
|
|
73
|
+
|
|
74
|
+
### Exit Criteria
|
|
75
|
+
- [ ] All Phase 1 tasks pass `pnpm test`
|
|
76
|
+
- [ ] No circular deps in `src/core`
|
|
77
|
+
- [ ] `Context` interface < 20 methods
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Risk Criteria
|
|
81
|
+
|
|
82
|
+
| Factor | Low Risk | Medium Risk | High Risk |
|
|
83
|
+
|--------|----------|-------------|-----------|
|
|
84
|
+
| Cyclomatic complexity | <10 | 10-20 | >20 |
|
|
85
|
+
| Test coverage | >80% | 50-80% | <50% |
|
|
86
|
+
| Fan-out (imports) | <5 | 5-15 | >15 |
|
|
87
|
+
| Change frequency | low | medium | high |
|
|
88
|
+
|
|
89
|
+
## Anti-patterns
|
|
90
|
+
|
|
91
|
+
- Don't plan without analyzing — assumptions cause wasted work
|
|
92
|
+
- Don't skip rollback strategy — every refactor can fail
|
|
93
|
+
- Don't over-phase — if a task takes <1h, merge it
|
|
94
|
+
- Don't ignore team constraints — parallelization only works if reviewers exist
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-scanner
|
|
3
|
+
description: |
|
|
4
|
+
Security vulnerability scanning for code and configuration. Covers secret detection,
|
|
5
|
+
injection vectors, dependency vulnerabilities, and supply chain risks.
|
|
6
|
+
Use during CI, before releases, or as a standalone audit.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Security Scanner Agent
|
|
11
|
+
|
|
12
|
+
Scans code, configs, and dependencies for security issues ranging from
|
|
13
|
+
hardcoded secrets to injection vulnerabilities and supply chain risks.
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
- Detect hardcoded secrets: API keys, tokens, passwords, private keys
|
|
18
|
+
- Find injection vectors: eval, innerHTML, SQL concatenation, shell injection
|
|
19
|
+
- Identify insecure patterns: weak crypto, hardcoded IVs, disabled TLS verification
|
|
20
|
+
- Scan dependencies for known CVEs (via package audit)
|
|
21
|
+
- Flag supply chain risks: unverified scripts, postinstall hooks, .npmrc issues
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. **Scope** — Accept paths or use sensible defaults
|
|
26
|
+
2. **Secrets Scan** — Regex scan for credential patterns
|
|
27
|
+
3. **Injection Scan** — Pattern match dangerous constructs
|
|
28
|
+
4. **Config Scan** — Check TLS, crypto, auth configurations
|
|
29
|
+
5. **Dependency Scan** — Run audit on package.json
|
|
30
|
+
6. **Report** — Prioritized markdown with remediation
|
|
31
|
+
|
|
32
|
+
## Input
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"task": "scan | audit | secrets | dependencies",
|
|
37
|
+
"paths": ["src", "config"],
|
|
38
|
+
"depth": "quick | normal | deep",
|
|
39
|
+
"excludePaths": ["node_modules", "dist"]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Output Format
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
## Security Scan Report — <timestamp>
|
|
47
|
+
|
|
48
|
+
### CRITICAL: Secrets Found
|
|
49
|
+
1. **[CRITICAL]** `config/keys.ts:8` — AWS Access Key ID exposed
|
|
50
|
+
```
|
|
51
|
+
const awsKey = "AKIAIOSFODNN7EXAMPLE"; // ← remove this
|
|
52
|
+
```
|
|
53
|
+
2. **[CRITICAL]** `.env:3` — Private key committed to repo
|
|
54
|
+
```
|
|
55
|
+
PEM_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIE..."
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### HIGH: Injection Vectors
|
|
59
|
+
3. **[HIGH]** `lib/renderer.ts:42` — innerHTML assignment
|
|
60
|
+
```ts
|
|
61
|
+
element.innerHTML = userInput; // ← sanitize or use textContent
|
|
62
|
+
```
|
|
63
|
+
4. **[HIGH]** `tools/shell.ts:15` — shell injection via template literal
|
|
64
|
+
```ts
|
|
65
|
+
exec(`echo ${userInput}`); // ← escape or use array form
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### MEDIUM: Insecure Patterns
|
|
69
|
+
5. **[MEDIUM]** `lib/crypto.ts:9` — MD5 used for hashing (not for passwords)
|
|
70
|
+
6. **[MEDIUM]** `server.ts:22` — TLS certificate verification disabled
|
|
71
|
+
|
|
72
|
+
### Dependency Issues
|
|
73
|
+
7. **[HIGH]** `lodash < 4.17.21` — CVE-2021-23337
|
|
74
|
+
8. **[MEDIUM]** `minimist < 1.2.6` — CVE-2021-44906
|
|
75
|
+
|
|
76
|
+
## Summary
|
|
77
|
+
| Severity | Count |
|
|
78
|
+
|----------|-------|
|
|
79
|
+
| Critical | 2 |
|
|
80
|
+
| High | 4 |
|
|
81
|
+
| Medium | 3 |
|
|
82
|
+
| Low | 1 |
|
|
83
|
+
|
|
84
|
+
## Remediation Checklist
|
|
85
|
+
- [ ] Remove hardcoded secrets from `config/keys.ts`
|
|
86
|
+
- [ ] Sanitize user input before innerHTML assignment
|
|
87
|
+
- [ ] Update lodash to >= 4.17.21
|
|
88
|
+
- [ ] Enable TLS verification in production
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Secret Pattern Reference
|
|
92
|
+
|
|
93
|
+
| Pattern | Example | Severity |
|
|
94
|
+
|---------|---------|----------|
|
|
95
|
+
| AWS Access Key | `AKIAIOSFODNN7EXAMPLE` | critical |
|
|
96
|
+
| AWS Secret Key | `[a-zA-Z0-9/+=]{40}` base64 | critical |
|
|
97
|
+
| GitHub Token | `ghp_[a-zA-Z0-9]{36}` | critical |
|
|
98
|
+
| Private Key PEM | `-----BEGIN.*PRIVATE KEY-----` | critical |
|
|
99
|
+
| JWT | `eyJ[a-zA-Z0-9_-]+` | high |
|
|
100
|
+
| Generic API Key | `[a-zA-Z0-9]{32,}` | medium |
|
|
101
|
+
|
|
102
|
+
## Injection Patterns
|
|
103
|
+
|
|
104
|
+
| Construct | Safe Alternative |
|
|
105
|
+
|-----------|-----------------|
|
|
106
|
+
| `eval(str)` | `new Function()` or parse |
|
|
107
|
+
| `innerHTML = x` | `textContent` or sanitize |
|
|
108
|
+
| `exec(\`cmd ${input}\`)` | `execFile` with args array |
|
|
109
|
+
| `SQL = "SELECT * FROM " + table` | parameterized query |
|
|
110
|
+
| `fs.readFile(path + userInput)` | `path.resolve` + allowlist |
|
|
111
|
+
|
|
112
|
+
## Anti-patterns
|
|
113
|
+
|
|
114
|
+
- Don't scan node_modules — noise, use `npm audit` instead
|
|
115
|
+
- Don't report without remediation — "found X" is useless without "do Y"
|
|
116
|
+
- Don't ignore false positives — verify before flagging (especially regex-based secrets)
|
|
117
|
+
- Don't skip dependency scanning — supply chain is a real attack vector
|