@securityreviewai/securityreview-kit 0.1.42 → 0.1.44
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/README.md +4 -4
- package/package.json +1 -1
- package/src/generators/mcp/claude.js +2 -2
- package/src/generators/mcp/claude.test.js +3 -0
- package/src/generators/rules/claude.js +14 -27
- package/src/generators/rules/claude.test.js +12 -15
- package/src/generators/rules/codex.js +22 -27
- package/src/generators/rules/codex.test.js +16 -15
- package/src/generators/rules/content.js +9 -23
- package/src/generators/rules/content.md +11 -8
- package/src/generators/rules/cursor.js +27 -21
- package/src/generators/rules/guardrails-selection/SKILL.md +6 -6
- package/src/generators/rules/guardrails-selection/references/category-threat-map.md +1 -1
- package/src/generators/rules/guardrails_rule.md +5 -5
- package/src/generators/rules/hooks.json +1 -1
- package/src/generators/rules/skill.md +28 -17
- package/src/generators/rules/vibereview-sync/SKILL.md +358 -0
- package/src/generators/rules/vscode.js +22 -11
- package/src/generators/rules/vscode.test.js +15 -12
- package/src/utils/constants.js +6 -6
- package/src/generators/rules/create-ide-workflow.md +0 -34
- package/src/generators/rules/ctm_sync.md +0 -215
- package/src/generators/rules/ctm_sync_rule.md +0 -88
package/src/utils/constants.js
CHANGED
|
@@ -83,12 +83,12 @@ export const THREAT_MODELLING_SKILL_REL_DIR = {
|
|
|
83
83
|
codex: '.codex/skills/threat-modelling',
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
/** Relative workspace
|
|
87
|
-
export const
|
|
88
|
-
cursor: '.cursor/
|
|
89
|
-
claude: '.claude/
|
|
90
|
-
vscode: '.github/
|
|
91
|
-
codex: '.codex/
|
|
86
|
+
/** Relative workspace dirs for the VibeReview markdown sync skill (per IDE / CLI). */
|
|
87
|
+
export const VIBEREVIEW_SYNC_SKILL_REL_DIR = {
|
|
88
|
+
cursor: '.cursor/skills/vibereview-sync',
|
|
89
|
+
claude: '.claude/skills/vibereview-sync',
|
|
90
|
+
vscode: '.github/skills/vibereview-sync',
|
|
91
|
+
codex: '.codex/skills/vibereview-sync',
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export const SENTINEL_START = '<!-- securityreview-kit:start -->';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: create-ide-workflow
|
|
3
|
-
description: Create an AI IDE workflow in SRAI via security-review-mcp.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Create IDE Workflow
|
|
7
|
-
|
|
8
|
-
Use `security-review-mcp` to create a workflow by calling:
|
|
9
|
-
|
|
10
|
-
- `create_ai_ide_workflow`
|
|
11
|
-
|
|
12
|
-
Required payload fields:
|
|
13
|
-
|
|
14
|
-
- `project_id`
|
|
15
|
-
- `name`
|
|
16
|
-
- `description`
|
|
17
|
-
|
|
18
|
-
## Steps
|
|
19
|
-
|
|
20
|
-
1. Resolve `project_id`.
|
|
21
|
-
- Use configured project name `<SRAI_PROJECT_NAME>` by default.
|
|
22
|
-
- Call `find_project_by_name` with `name="<SRAI_PROJECT_NAME>"`.
|
|
23
|
-
- If not found, call `list_projects` and select the right project.
|
|
24
|
-
2. Build `name` and `description` from the user request.
|
|
25
|
-
- Keep `name` short and action-oriented.
|
|
26
|
-
- Keep `description` specific about trigger and output.
|
|
27
|
-
3. Call `create_ai_ide_workflow` with:
|
|
28
|
-
- `project_id`
|
|
29
|
-
- `name`
|
|
30
|
-
- `description`
|
|
31
|
-
4. Return a concise confirmation including:
|
|
32
|
-
- project id
|
|
33
|
-
- workflow name
|
|
34
|
-
- workflow id from MCP response (if returned)
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ctm_sync
|
|
3
|
-
description: Command/workflow triggered whenever a threat model is generated or updated, or guardrails are proposed/modified. Writes a grounded AI IDE sync markdown file and uploads it through security-review-mcp.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# CTM Sync Workflow
|
|
7
|
-
|
|
8
|
-
Configured SRAI project name: `<SRAI_PROJECT_NAME>`
|
|
9
|
-
|
|
10
|
-
When invoked:
|
|
11
|
-
|
|
12
|
-
0. Verify `sync_ai_ide_markdown` exists in `security-review-mcp`.
|
|
13
|
-
1. Read the parent agent context and extract the latest threat model details, guardrail outcomes, and grounded code snippets from the actual work completed in this session.
|
|
14
|
-
2. **Chat session identity (required)** — The markdown MUST include a stable `chat_session_id` for the current IDE chat session:
|
|
15
|
-
- Use a session identifier supplied by the host environment when one exists (for example, the IDE conversation or session id).
|
|
16
|
-
- If none exists, use a single UUID (or equivalent) generated **once** at the start of this chat and reused for every `ctm_sync` in the same session.
|
|
17
|
-
- Put `chat_session_id` in frontmatter whenever possible. The value must exist somewhere in the markdown even if frontmatter is unavailable.
|
|
18
|
-
3. **Create a structured markdown artifact** — `ctm_sync` is now a thin sync shim. Do not build a JSON payload and do not perform workflow lookup or creation client-side. Instead, write a `.md` file under `vibereview/` so all sync artifacts stay in one predictable place. Create the directory if it does not already exist. The markdown file should give the server everything it needs to extract the structured event.
|
|
19
|
-
4. **Populate the markdown with grounded content**:
|
|
20
|
-
- Include the exact shortlisted existing guardrails selected earlier plus any `ide_generated` guardrails created during the session.
|
|
21
|
-
- Use real code snippets from the files changed or inspected in this session. Never invent code or mitigation text.
|
|
22
|
-
- Keep threat names, severities, PWNISMS categories, guardrail satisfaction, and OWASP mappings aligned with the actual work performed.
|
|
23
|
-
5. **Upload the markdown**:
|
|
24
|
-
- Call `sync_ai_ide_markdown` with the markdown artifact.
|
|
25
|
-
- The server is responsible for normalizing author identity, deriving a workflow name from the title when needed, and extracting structured output from the markdown.
|
|
26
|
-
6. **Stop there** — Do not call `create_ai_ide_event`, `create_ai_ide_workflow`, or client-side user identity tools from `ctm_sync`.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Markdown Contract
|
|
31
|
-
|
|
32
|
-
The markdown file must be a `.md` document written under `vibereview/`, with frontmatter when available and clear, structured sections underneath. Keep the structure deterministic so the server can parse it reliably.
|
|
33
|
-
|
|
34
|
-
Recommended path pattern:
|
|
35
|
-
|
|
36
|
-
```text
|
|
37
|
-
vibereview/<chat_session_id>-<slugified-title-or-event-name>.md
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
If a safe filename cannot be derived, use any stable `.md` filename inside `vibereview/`.
|
|
41
|
-
|
|
42
|
-
### Frontmatter
|
|
43
|
-
|
|
44
|
-
Use YAML frontmatter at the top of the file whenever possible:
|
|
45
|
-
|
|
46
|
-
```yaml
|
|
47
|
-
---
|
|
48
|
-
chat_session_id: "<required stable session id>"
|
|
49
|
-
workflow_name: "<optional short workflow name>"
|
|
50
|
-
workflow_description: "<optional workflow description>"
|
|
51
|
-
title: "<required event title if event_name is omitted>"
|
|
52
|
-
event_name: "<required event name if title is omitted>"
|
|
53
|
-
summary: "<required concise summary>"
|
|
54
|
-
---
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Rules:
|
|
58
|
-
|
|
59
|
-
- `chat_session_id` must exist somewhere in the markdown, but frontmatter is preferred.
|
|
60
|
-
- `workflow_name` is optional. If omitted, the server derives it from the title.
|
|
61
|
-
- `workflow_description` is optional.
|
|
62
|
-
- Either `event_name` or `title` must exist. Including both is allowed.
|
|
63
|
-
- `summary` must exist.
|
|
64
|
-
- `developer_name` and `developer_email` in the markdown are ignored. The server always uses the authenticated API user.
|
|
65
|
-
|
|
66
|
-
### Body sections
|
|
67
|
-
|
|
68
|
-
Use clear Markdown headings. The exact wording below is preferred because it keeps parsing simple and consistent.
|
|
69
|
-
|
|
70
|
-
#### Best Practices Achieved
|
|
71
|
-
|
|
72
|
-
Use plain bullet strings:
|
|
73
|
-
|
|
74
|
-
```md
|
|
75
|
-
## Best Practices Achieved
|
|
76
|
-
|
|
77
|
-
- Enforced server-side authorization before updating workflow state.
|
|
78
|
-
- Used parameterized queries for threat-model persistence.
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Internally the server accepts both `best_practises_achieved` and `best_practices_achieved`, but authored markdown should prefer a normal `Best Practices Achieved` section with bullets.
|
|
82
|
-
|
|
83
|
-
#### Threats Mitigated
|
|
84
|
-
|
|
85
|
-
Each threat entry should include all of the following:
|
|
86
|
-
|
|
87
|
-
- `threat_name`
|
|
88
|
-
- `pwnisms_category`
|
|
89
|
-
- `severity`
|
|
90
|
-
- `mitigation_applied`
|
|
91
|
-
- grounded code snippet info if available
|
|
92
|
-
|
|
93
|
-
Preferred structure:
|
|
94
|
-
|
|
95
|
-
```md
|
|
96
|
-
## Threats Mitigated
|
|
97
|
-
|
|
98
|
-
### Threat 1
|
|
99
|
-
- threat_name: Missing authorization check on workflow sync endpoint
|
|
100
|
-
- pwnisms_category: IAM
|
|
101
|
-
- severity: High
|
|
102
|
-
- mitigation_applied: Added server-side authorization before allowing markdown sync writes.
|
|
103
|
-
- file_path: src/routes/sync.js
|
|
104
|
-
- language: javascript
|
|
105
|
-
- snippet: |
|
|
106
|
-
if (!user || !user.canSyncWorkflows) {
|
|
107
|
-
throw new ForbiddenError('Not allowed to sync workflow markdown');
|
|
108
|
-
}
|
|
109
|
-
- explanation: Prevents unauthorized users from creating or updating AI IDE sync events.
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Notes:
|
|
113
|
-
|
|
114
|
-
- Snippets must be real code from the repo or actual generated output, not invented text.
|
|
115
|
-
- If no code snippet exists for a threat, omit the snippet block and explain the mitigation in prose.
|
|
116
|
-
|
|
117
|
-
#### Secure Code Snippets
|
|
118
|
-
|
|
119
|
-
Include security-relevant snippets that may or may not map 1:1 with a threat:
|
|
120
|
-
|
|
121
|
-
```md
|
|
122
|
-
## Secure Code Snippets
|
|
123
|
-
|
|
124
|
-
### Snippet 1
|
|
125
|
-
- file_path: src/server/markdown-sync.ts
|
|
126
|
-
- language: typescript
|
|
127
|
-
- snippet: |
|
|
128
|
-
const markdown = await fs.readFile(inputPath, 'utf8');
|
|
129
|
-
await securityReview.syncAiIdeMarkdown({ markdown });
|
|
130
|
-
- explanation: Sends the structured markdown artifact directly to the server-side sync pipeline.
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
#### Guardrails Applied
|
|
134
|
-
|
|
135
|
-
Each guardrail should include:
|
|
136
|
-
|
|
137
|
-
- `title`
|
|
138
|
-
- `rule_type` as `must` or `must_not`
|
|
139
|
-
- `source` as `existing` or `ide_generated`
|
|
140
|
-
- `satisfied` as `true` or `false`
|
|
141
|
-
|
|
142
|
-
Preferred structure:
|
|
143
|
-
|
|
144
|
-
```md
|
|
145
|
-
## Guardrails Applied
|
|
146
|
-
|
|
147
|
-
### Guardrail 1
|
|
148
|
-
- title: Enforce authorization on workflow updates
|
|
149
|
-
- rule_type: must
|
|
150
|
-
- category: authorization
|
|
151
|
-
- instruction: Require an authenticated, authorized user before mutating workflow records.
|
|
152
|
-
- source: existing
|
|
153
|
-
- satisfied: true
|
|
154
|
-
- notes: Applied in the server-side markdown sync handler.
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
The exact shortlist from earlier in the session must be carried forward. Do not call `get_guardrails` or `get_guardrail_by_id` inside `ctm_sync`.
|
|
158
|
-
|
|
159
|
-
#### OWASP Top 10 2025 Mappings
|
|
160
|
-
|
|
161
|
-
Use exact IDs and names:
|
|
162
|
-
|
|
163
|
-
```md
|
|
164
|
-
## OWASP Top 10 2025 Mappings
|
|
165
|
-
|
|
166
|
-
- A01: Broken Access Control
|
|
167
|
-
- A04: Cryptographic Failures
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Allowed values:
|
|
171
|
-
|
|
172
|
-
| ID | Name |
|
|
173
|
-
|---|---|
|
|
174
|
-
| `A01` | Broken Access Control |
|
|
175
|
-
| `A02` | Security Misconfiguration |
|
|
176
|
-
| `A03` | Software Supply Chain Failures |
|
|
177
|
-
| `A04` | Cryptographic Failures |
|
|
178
|
-
| `A05` | Injection |
|
|
179
|
-
| `A06` | Insecure Design |
|
|
180
|
-
| `A07` | Authentication Failures |
|
|
181
|
-
| `A08` | Software or Data Integrity Failures |
|
|
182
|
-
| `A09` | Security Logging and Alerting Failures |
|
|
183
|
-
| `A10` | Mishandling of Exceptional Conditions |
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Constraints
|
|
188
|
-
|
|
189
|
-
- The artifact written by `ctm_sync` must be a `.md` file under `vibereview/`.
|
|
190
|
-
- `chat_session_id` must never be omitted.
|
|
191
|
-
- `summary` must never be omitted.
|
|
192
|
-
- `event_name` or `title` must exist.
|
|
193
|
-
- `workflow_name` and `workflow_description` are optional.
|
|
194
|
-
- `developer_name` and `developer_email` should not influence sync behavior; the server ignores them.
|
|
195
|
-
- Every threat entry must include `threat_name`, `pwnisms_category`, `severity`, and `mitigation_applied`.
|
|
196
|
-
- PWNISMS categories must match the supported set: `Product`, `Workload`, `Network`, `IAM`, `Secrets`, `Monitoring`, `Supply Chain`.
|
|
197
|
-
- `severity` should be one of `Critical`, `High`, `Medium`, or `Low`.
|
|
198
|
-
- Guardrails must include `title`, `rule_type`, `source`, and `satisfied`.
|
|
199
|
-
- `rule_type` must be `must` or `must_not`.
|
|
200
|
-
- `source` must be `existing` or `ide_generated`.
|
|
201
|
-
- `satisfied` must be `true` or `false`.
|
|
202
|
-
- OWASP mappings must use the exact IDs and names listed above.
|
|
203
|
-
- Snippets must be grounded in real code. Never fabricate examples just to fill the markdown.
|
|
204
|
-
- Do not call client-side workflow creation, event creation, or developer identity tools from `ctm_sync`.
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## Output Contract
|
|
209
|
-
|
|
210
|
-
- Never skip sync when a threat model or guardrail-compliance update exists.
|
|
211
|
-
- Never invent missing values; omit optional fields or use concise prose when exact structured data is unavailable.
|
|
212
|
-
- Return a compact confirmation after upload including:
|
|
213
|
-
- the markdown file path used for sync, which should point inside `vibereview/`
|
|
214
|
-
- whether `workflow_name` was explicit or left for server-side derivation
|
|
215
|
-
- count of guardrails included (existing vs IDE-generated)
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: ctm_sync agent trigger rule
|
|
3
|
-
alwaysApply: true
|
|
4
|
-
---
|
|
5
|
-
# Continuous Threat Modeling Sync (`ctm_sync`)
|
|
6
|
-
|
|
7
|
-
**Always synchronize threat models and guardrail compliance after they are (re)generated.**
|
|
8
|
-
|
|
9
|
-
Any time an AI agent:
|
|
10
|
-
- generates a **new threat model**, or
|
|
11
|
-
- **updates** an existing threat model, or
|
|
12
|
-
- performs a **non-trivial extension** of an existing threat model (e.g., adds new threat scenarios, countermeasures, data flows, or components), or
|
|
13
|
-
- **applies vibe guardrails** during a code-generation task (existing or IDE-generated) and has guardrail compliance data to report,
|
|
14
|
-
|
|
15
|
-
it **must immediately call** the `ctm_sync` agent to synchronize the latest threat modeling state and guardrail data.
|
|
16
|
-
|
|
17
|
-
This rule applies regardless of:
|
|
18
|
-
- which methodology is used (PWNISMS, STRIDE, OWASP, etc.),
|
|
19
|
-
- which skill or MCP was used to produce the threat model, and
|
|
20
|
-
- whether the threat model is partial, incremental, or "draft" form.
|
|
21
|
-
|
|
22
|
-
If in doubt — **assume this rule applies**.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## When this rule applies
|
|
27
|
-
|
|
28
|
-
This rule is **triggered** whenever the assistant:
|
|
29
|
-
|
|
30
|
-
- **Produces a threat model** in any form, such as:
|
|
31
|
-
- Threat scenarios (even a short list)
|
|
32
|
-
- Data flow diagrams or component diagrams described in text
|
|
33
|
-
- Security objectives or misuse cases
|
|
34
|
-
- Attack trees or abuse cases
|
|
35
|
-
- Structured PWNISMS analysis
|
|
36
|
-
- **Extends or refines** an earlier threat model, e.g.:
|
|
37
|
-
- "Add more threats for the Payments service"
|
|
38
|
-
- "Update the data flow for the auth system"
|
|
39
|
-
- "Refine the mitigations for threat X"
|
|
40
|
-
- **Enforces guardrails** during code generation and has compliance data:
|
|
41
|
-
- Guardrails were shortlisted via the guardrails-selection workflow (`get_guardrails` + `get_guardrail_by_id`) and applied to generated code
|
|
42
|
-
- New guardrails were created by the IDE agent based on gaps found
|
|
43
|
-
- Existing guardrails were flagged as unsatisfiable or conflicting
|
|
44
|
-
|
|
45
|
-
This includes both:
|
|
46
|
-
- Threat modeling done **directly in this conversation**, and
|
|
47
|
-
- Threat modeling done by calling **MCP tools or skills** that output threat scenarios, countermeasures, data dictionaries, or other CTM artifacts.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Required behavior
|
|
52
|
-
|
|
53
|
-
**After completing any threat modeling step that produces or modifies threat content, or any code-generation step where guardrails were enforced, the assistant must:**
|
|
54
|
-
|
|
55
|
-
1. **Ensure threat modeling output is finalized for this step**
|
|
56
|
-
|
|
57
|
-
- The assistant should finish producing the current threat modeling content (threat scenarios, components, data dictionaries, etc.) in the user-visible message or via tools.
|
|
58
|
-
- The assistant should not call `ctm_sync` *before* the threat model content exists; it must be called **after** threat data for this step is available.
|
|
59
|
-
|
|
60
|
-
2. **Immediately call the `ctm_sync` agent**
|
|
61
|
-
|
|
62
|
-
- Use the `Task` tool (or equivalent agent launcher) with `subagent_type="ctm_sync"`.
|
|
63
|
-
- **Session routing:** In the prompt (or structured handoff), always include the **current chat's stable `chat_session_id`** — the same id for every `ctm_sync` in this conversation, and a new id for a different chat. Use the IDE/session id when exposed; otherwise generate one UUID at the start of the chat and reuse it. This ensures SRAI attaches events to the correct per-session workflow.
|
|
64
|
-
- Provide a clear, concise description in the `description`/`prompt` fields explaining:
|
|
65
|
-
- What system or component the threat model covers
|
|
66
|
-
- Whether this is a new threat model or an update
|
|
67
|
-
- Where the latest threat content can be found (e.g., "from this conversation" or "from the last threat modeling step")
|
|
68
|
-
- The `chat_session_id` value to use for this sync
|
|
69
|
-
- Whether guardrails were applied (existing and/or IDE-generated)
|
|
70
|
-
- That `ctm_sync` should write a structured `.md` artifact and upload it via `sync_ai_ide_markdown`
|
|
71
|
-
- **Do NOT include developer name or email in the handoff prompt.** Any identity fields in the markdown are ignored server-side; the authenticated API user is authoritative.
|
|
72
|
-
|
|
73
|
-
**Example invocation (conceptual, not literal code):**
|
|
74
|
-
|
|
75
|
-
Use Task tool with:
|
|
76
|
-
- subagent_type: "ctm_sync"
|
|
77
|
-
- description: "Sync latest threat model for <system/component>"
|
|
78
|
-
- prompt: Brief summary of what was threat-modeled, what artifacts were produced (threat scenarios, countermeasures, components, data dictionary, guardrails applied/proposed, etc.), and that the agent should write the sync markdown and upload it accordingly.
|
|
79
|
-
- readonly: false (it must be allowed to write/update CTM data)
|
|
80
|
-
|
|
81
|
-
3. Let `ctm_sync` complete its work
|
|
82
|
-
The assistant should wait for the ctm_sync agent to complete (or reach a healthy steady state) before declaring the threat-modeling step fully done.
|
|
83
|
-
If ctm_sync returns errors that can be reasonably fixed (e.g., missing project name), the assistant should fix the issue and retry once, if possible.
|
|
84
|
-
|
|
85
|
-
Acknowledge completion to the user
|
|
86
|
-
After ctm_sync completes, the assistant should briefly tell the user that:
|
|
87
|
-
Threat modeling is finished for this step, and
|
|
88
|
-
The results have been synchronized via ctm_sync (without leaking internal tooling details beyond what is appropriate for the user's context).
|