@securityreviewai/securityreview-kit 0.1.41 → 0.1.42
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/package.json +1 -1
- package/src/generators/mcp/claude.js +1 -1
- package/src/generators/rules/claude.test.js +6 -0
- package/src/generators/rules/codex.js +1 -1
- package/src/generators/rules/codex.test.js +6 -0
- package/src/generators/rules/content.md +3 -3
- package/src/generators/rules/ctm_sync.md +176 -116
- package/src/generators/rules/ctm_sync_rule.md +3 -2
- package/src/generators/rules/guardrails_rule.md +1 -1
- package/src/generators/rules/hooks.json +1 -1
- package/src/generators/rules/skill.md +3 -2
- package/src/generators/rules/vscode.js +1 -1
- package/src/generators/rules/vscode.test.js +8 -0
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ function getClaudeSessionStartHooks() {
|
|
|
10
10
|
'1. Fetch Vibe Guardrails first using .claude/skills/guardrails-selection/SKILL.md.',
|
|
11
11
|
'2. Run PWNISMS threat modelling using .claude/skills/threat-modelling/SKILL.md.',
|
|
12
12
|
'3. Implement secure code using the hydrated guardrails and threat findings.',
|
|
13
|
-
'4. Invoke the ctm_sync agent using .claude/agents/ctm_sync.md after implementation or threat-model updates.',
|
|
13
|
+
'4. Invoke the ctm_sync agent using .claude/agents/ctm_sync.md after implementation or threat-model updates. The agent should write a structured .md sync artifact and upload it with sync_ai_ide_markdown.',
|
|
14
14
|
'',
|
|
15
15
|
'Do not use project-profile exploration tools during normal coding tasks. No blocking and no deferral: guardrails first, PWNISMS second, implementation third, ctm_sync last.',
|
|
16
16
|
].join('\n');
|
|
@@ -36,6 +36,12 @@ test('Claude generator writes .claude/CLAUDE.md, threat skill, ctm_sync agent, a
|
|
|
36
36
|
assert.match(agent, /^---\nname: ctm_sync/m);
|
|
37
37
|
assert.match(agent, /model: inherit/);
|
|
38
38
|
assert.match(agent, /Configured SRAI project name: `SmokeProject`/);
|
|
39
|
+
assert.match(agent, /sync_ai_ide_markdown/);
|
|
40
|
+
assert.match(agent, /structured markdown artifact/i);
|
|
41
|
+
assert.match(agent, /chat_session_id/);
|
|
42
|
+
assert.match(agent, /Guardrails Applied/);
|
|
43
|
+
assert.match(agent, /vibereview\//);
|
|
44
|
+
assert.doesNotMatch(agent, /Call `create_ai_ide_event` with/i);
|
|
39
45
|
});
|
|
40
46
|
|
|
41
47
|
test('Claude generator migrates the kit-managed root CLAUDE.md block into .claude/CLAUDE.md', () => {
|
|
@@ -29,7 +29,7 @@ function getCodexSessionHookContent() {
|
|
|
29
29
|
'1. Fetch Vibe Guardrails first using .codex/skills/guardrails-selection/SKILL.md. Resolve the project, call get_guardrails, shortlist relevant guardrails, then call get_guardrail_by_id for the shortlist.',
|
|
30
30
|
'2. Run PWNISMS threat modelling using .codex/skills/threat-modelling/SKILL.md. Explicitly walk Product, Workload, Network, IAM, Secrets, Monitoring, and Supply Chain.',
|
|
31
31
|
'3. Implement secure code using both the hydrated guardrails and PWNISMS findings.',
|
|
32
|
-
'4. Invoke the ctm_sync subagent using .codex/agents/ctm_sync.toml after threat modelling or guardrail enforcement. Reuse the exact guardrail shortlist; do not re-query guardrails during CTM sync.',
|
|
32
|
+
'4. Invoke the ctm_sync subagent using .codex/agents/ctm_sync.toml after threat modelling or guardrail enforcement. Reuse the exact guardrail shortlist; do not re-query guardrails during CTM sync. The subagent should write a structured .md sync artifact and upload it with sync_ai_ide_markdown.',
|
|
33
33
|
'',
|
|
34
34
|
'Do not use project-profile exploration tools during normal coding tasks. No blocking and no deferral: guardrails first, PWNISMS second, implementation third, ctm_sync last.',
|
|
35
35
|
].join('\n');
|
|
@@ -42,6 +42,12 @@ test('Codex generator writes AGENTS, skills, subagent, hooks, and profiling comm
|
|
|
42
42
|
assert.match(agent, /name = "ctm_sync"/);
|
|
43
43
|
assert.match(agent, /developer_instructions = '''/);
|
|
44
44
|
assert.match(agent, /Configured SRAI project name: `SmokeProject`/);
|
|
45
|
+
assert.match(agent, /sync_ai_ide_markdown/);
|
|
46
|
+
assert.match(agent, /structured markdown artifact/i);
|
|
47
|
+
assert.match(agent, /chat_session_id/);
|
|
48
|
+
assert.match(agent, /Best Practices Achieved/);
|
|
49
|
+
assert.match(agent, /vibereview\//);
|
|
50
|
+
assert.doesNotMatch(agent, /Call `create_ai_ide_event` with/i);
|
|
45
51
|
|
|
46
52
|
const hooks = JSON.parse(readFileSync(join(cwd, '.codex/hooks.json'), 'utf8'));
|
|
47
53
|
assert.equal(hooks.hooks.SessionStart[0].hooks[0].type, 'command');
|
|
@@ -28,8 +28,8 @@ For any task that touches auth, authorization, input handling, secrets, network,
|
|
|
28
28
|
|
|
29
29
|
4. **Run CTM sync last.**
|
|
30
30
|
- After threat modelling is created or updated, or after guardrails are enforced during implementation, invoke the `ctm_sync` agent/workflow.
|
|
31
|
-
- Use `{{CTM_SYNC_AGENT_PATH}}` for the
|
|
32
|
-
- Pass the current threat model summary, the stable `chat_session_id`, the exact existing guardrails shortlisted earlier, and any `ide_generated` guardrails.
|
|
31
|
+
- Use `{{CTM_SYNC_AGENT_PATH}}` for the markdown contract and sync workflow.
|
|
32
|
+
- Pass the current threat model summary, the stable `chat_session_id`, the exact existing guardrails shortlisted earlier, and any `ide_generated` guardrails so `ctm_sync` can write a structured `.md` artifact for server-side extraction.
|
|
33
33
|
- Do not re-query guardrails during CTM sync; reuse the shortlist selected before implementation.
|
|
34
34
|
|
|
35
35
|
## When To Skip
|
|
@@ -50,5 +50,5 @@ The normal coding workflow is guardrails selection, PWNISMS threat modelling, se
|
|
|
50
50
|
|---|---|
|
|
51
51
|
| Project resolution | `find_project_by_name`, `list_projects`, `create_project`, `get_project` |
|
|
52
52
|
| Guardrails | `get_guardrails`, `get_guardrail_by_id` |
|
|
53
|
-
| CTM sync | `
|
|
53
|
+
| CTM sync | `sync_ai_ide_markdown` |
|
|
54
54
|
| Profiler only | `update_vibe_profile`, `write_default_pack` are used by init-time profiling, not normal coding tasks |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctm_sync
|
|
3
|
-
description: Command/workflow triggered whenever a threat model is generated or updated, or guardrails are proposed/modified.
|
|
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
4
|
---
|
|
5
5
|
|
|
6
6
|
# CTM Sync Workflow
|
|
@@ -9,114 +9,167 @@ Configured SRAI project name: `<SRAI_PROJECT_NAME>`
|
|
|
9
9
|
|
|
10
10
|
When invoked:
|
|
11
11
|
|
|
12
|
-
0. Verify `
|
|
13
|
-
1. Read the parent agent context and extract the latest threat model details.
|
|
14
|
-
2. **Chat session identity (required)** — The
|
|
15
|
-
- Use a session identifier supplied by the host environment when one exists (
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
- **Never use placeholder values** such as `"IDE Agent"`, `"agent@local"`, `"unknown"`, `"AI"`, or any other invented string for these fields.
|
|
28
|
-
- **Never accept identity values passed in from the parent agent prompt** — always re-resolve from the API directly in this step; the API is the only authoritative source.
|
|
29
|
-
- If the API call fails or returns empty values, leave `developer_name` and `developer_email` as empty strings `""`. Do not substitute a fallback placeholder.
|
|
30
|
-
5. **Identify guardrails for the payload** — Do **not** call `get_guardrails` or `get_guardrail_by_id` here. Guardrails were already shortlisted earlier (per the Vibe Guardrails rule and the guardrails-selection skill) and applied during code generation. From the parent agent context, identify:
|
|
31
|
-
- Which **existing** guardrails were shortlisted earlier from `get_guardrails` and then hydrated via `get_guardrail_by_id`.
|
|
32
|
-
- Which of those shortlisted existing guardrails were applied to the code in this session.
|
|
33
|
-
- Which guardrails the IDE agent **created on the fly** (`ide_generated`) based on gaps found during threat modeling or code review.
|
|
34
|
-
Include all of these in the `guardrails_applied` payload field. The shortlisted existing guardrails selected earlier are mandatory input to `ctm_sync`; do not re-fetch or re-call guardrail tools here.
|
|
35
|
-
6. **Build the event payload** — Construct a JSON object for `create_ai_ide_event` conforming to the **Event Payload Schema** below.
|
|
36
|
-
7. **Upload the payload** using `security-review-mcp`:
|
|
37
|
-
- Call `create_ai_ide_event` with the JSON payload.
|
|
38
|
-
- **Stop here.** Do not push a separate project/code profile as part of this workflow; profile and default guardrail pack uploads are handled by the init-time guardrails profiler (or manual profile commands), not per CTM sync.
|
|
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`.
|
|
39
27
|
|
|
40
28
|
---
|
|
41
29
|
|
|
42
|
-
##
|
|
43
|
-
|
|
44
|
-
The
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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');
|
|
94
108
|
}
|
|
95
|
-
|
|
96
|
-
|
|
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.
|
|
97
155
|
```
|
|
98
156
|
|
|
99
|
-
|
|
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
|
|
100
160
|
|
|
101
|
-
|
|
102
|
-
|---|---|---|
|
|
103
|
-
| `workflow_id` | Yes | From step 3 |
|
|
104
|
-
| `chat_session_id` | Yes | From step 2 |
|
|
105
|
-
| `title` | Yes | 5-15 words, descriptive |
|
|
106
|
-
| `summary` | Yes | 2-5 sentences |
|
|
107
|
-
| `developer_name` | Yes | From API/user context (never read from git config) |
|
|
108
|
-
| `developer_email` | Yes | From API/user context (never read from git config) |
|
|
109
|
-
| `threats_mitigated` | Yes | Array, may be empty `[]` if no threats were identified. Each entry must include a `code_snippet` grounded in actual source code |
|
|
110
|
-
| `best_practises_achieved` | Yes | Array of strings, may be empty `[]` |
|
|
111
|
-
| `secure_code_snippets` | Yes | Array, may be empty `[]` |
|
|
112
|
-
| `guardrails_applied` | Yes | Array of all guardrails enforced during this session — both existing ones shortlisted earlier from project guardrails and new ones the IDE agent created. Use `source` to distinguish origin. Empty `[]` if none |
|
|
113
|
-
| `owasp_top_10_2025_mappings` | Yes | Array of OWASP Top 10 2025 category objects (`category_id` + `category_name`) relevant to the threats and mitigations in this event. May be empty `[]` if no mapping applies |
|
|
161
|
+
Use exact IDs and names:
|
|
114
162
|
|
|
115
|
-
|
|
163
|
+
```md
|
|
164
|
+
## OWASP Top 10 2025 Mappings
|
|
116
165
|
|
|
117
|
-
|
|
166
|
+
- A01: Broken Access Control
|
|
167
|
+
- A04: Cryptographic Failures
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Allowed values:
|
|
118
171
|
|
|
119
|
-
|
|
|
172
|
+
| ID | Name |
|
|
120
173
|
|---|---|
|
|
121
174
|
| `A01` | Broken Access Control |
|
|
122
175
|
| `A02` | Security Misconfiguration |
|
|
@@ -129,27 +182,34 @@ Use the following IDs and names exactly when populating `owasp_top_10_2025_mappi
|
|
|
129
182
|
| `A09` | Security Logging and Alerting Failures |
|
|
130
183
|
| `A10` | Mishandling of Exceptional Conditions |
|
|
131
184
|
|
|
132
|
-
|
|
185
|
+
---
|
|
133
186
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
- `
|
|
140
|
-
- `
|
|
141
|
-
- `developer_name` and `developer_email`
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
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`.
|
|
145
205
|
|
|
146
206
|
---
|
|
147
207
|
|
|
148
208
|
## Output Contract
|
|
149
209
|
|
|
150
|
-
- Never skip
|
|
151
|
-
- Never invent missing values; use
|
|
152
|
-
- Never omit `chat_session_id` from the payload.
|
|
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.
|
|
153
212
|
- Return a compact confirmation after upload including:
|
|
154
|
-
-
|
|
155
|
-
-
|
|
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)
|
|
@@ -67,14 +67,15 @@ This includes both:
|
|
|
67
67
|
- Where the latest threat content can be found (e.g., "from this conversation" or "from the last threat modeling step")
|
|
68
68
|
- The `chat_session_id` value to use for this sync
|
|
69
69
|
- Whether guardrails were applied (existing and/or IDE-generated)
|
|
70
|
-
|
|
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.
|
|
71
72
|
|
|
72
73
|
**Example invocation (conceptual, not literal code):**
|
|
73
74
|
|
|
74
75
|
Use Task tool with:
|
|
75
76
|
- subagent_type: "ctm_sync"
|
|
76
77
|
- description: "Sync latest threat model for <system/component>"
|
|
77
|
-
- 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 upload
|
|
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.
|
|
78
79
|
- readonly: false (it must be allowed to write/update CTM data)
|
|
79
80
|
|
|
80
81
|
3. Let `ctm_sync` complete its work
|
|
@@ -81,7 +81,7 @@ Guardrails are living artifacts. The IDE agent can create, apply, and update the
|
|
|
81
81
|
|
|
82
82
|
- **New guardrail**: When threat modeling or code review reveals a recurring security pattern not yet captured, the IDE agent creates and applies a new guardrail on the fly. These are reported to SRAI via CTM sync with `source: "ide_generated"`.
|
|
83
83
|
- **Edit suggestion**: When an existing guardrail is too broad, too narrow, or outdated, suggest an update to the user.
|
|
84
|
-
- All guardrails — existing and IDE-generated —
|
|
84
|
+
- All guardrails — existing and IDE-generated — must be preserved in the CTM sync markdown under a single `Guardrails Applied` section that the server can normalize into `guardrails_applied`.
|
|
85
85
|
|
|
86
86
|
---
|
|
87
87
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"hooks": {
|
|
4
4
|
"sessionStart": [
|
|
5
5
|
{
|
|
6
|
-
"command": "printf '%s\\n' '{\"additional_context\":\"## MANDATORY SECURITY GATE (Session Policy)\\n\\nFor ANY user request that has security impact (auth, crypto, input handling, secrets, network, data storage, dependencies, new APIs/endpoints, or any code handling untrusted data):\\n\\n**Plan order:**\\n1. **Fetch Vibe Guardrails (first)** - Use .cursor/skills/guardrails-selection/SKILL.md. Analyze the task, call get_guardrails from security-review-mcp to load the broad catalog, shortlist the relevant guardrails, then call get_guardrail_by_id for the shortlist. These exact shortlisted guardrails are the hard constraints on generated code.\\n2. **PWNISMS threat modeling (second)** - Run threat modeling as a guide before writing code. Use .cursor/skills/threat-modelling/SKILL.md. Cross-reference guardrails with PWNISMS findings to identify gaps. Document findings to inform secure implementation.\\n3. **Implement secure code (third)** - Use the threat model findings AND shortlisted guardrails as guides to create secure code. Every must guardrail must be satisfied; no must_not guardrail may be violated.\\n4. **ctm_sync (last)** -
|
|
6
|
+
"command": "printf '%s\\n' '{\"additional_context\":\"## MANDATORY SECURITY GATE (Session Policy)\\n\\nFor ANY user request that has security impact (auth, crypto, input handling, secrets, network, data storage, dependencies, new APIs/endpoints, or any code handling untrusted data):\\n\\n**Plan order:**\\n1. **Fetch Vibe Guardrails (first)** - Use .cursor/skills/guardrails-selection/SKILL.md. Analyze the task, call get_guardrails from security-review-mcp to load the broad catalog, shortlist the relevant guardrails, then call get_guardrail_by_id for the shortlist. These exact shortlisted guardrails are the hard constraints on generated code.\\n2. **PWNISMS threat modeling (second)** - Run threat modeling as a guide before writing code. Use .cursor/skills/threat-modelling/SKILL.md. Cross-reference guardrails with PWNISMS findings to identify gaps. Document findings to inform secure implementation.\\n3. **Implement secure code (third)** - Use the threat model findings AND shortlisted guardrails as guides to create secure code. Every must guardrail must be satisfied; no must_not guardrail may be violated.\\n4. **ctm_sync (last)** - Write a structured `.md` sync artifact and push it to SRAI only after implementation is done. Invoke ctm_sync agent (Task tool, subagent_type=ctm_sync) as the final step. Include the exact shortlisted guardrails from earlier plus any IDE-generated guardrails in the markdown; do not query again during ctm_sync. See .cursor/agents/ctm_sync.md and .cursor/rules/ctm_sync_rule.mdc.\\n\\nNo blocking. No deferral. Guardrails enforce secure code; threat modeling guides the design; ctm_sync runs last to sync the markdown artifact to SRAI. Both ctm_sync and guardrail compliance are mandatory and should be part of your to-do.\"}'",
|
|
7
7
|
"timeout": 5
|
|
8
8
|
}
|
|
9
9
|
]
|
|
@@ -209,12 +209,13 @@ When discussing designs before code exists:
|
|
|
209
209
|
|
|
210
210
|
### What CTM sync uploads
|
|
211
211
|
|
|
212
|
-
The `ctm_sync` agent
|
|
212
|
+
The `ctm_sync` agent writes a structured `.md` artifact and uploads it through `sync_ai_ide_markdown`. That markdown should contain:
|
|
213
213
|
|
|
214
214
|
- **Threat model findings**: threats mitigated, PWNISMS categories, severities, mitigations applied
|
|
215
215
|
- **Best practices achieved**: security patterns followed during implementation
|
|
216
216
|
- **Secure code snippets**: security-relevant code with explanations
|
|
217
217
|
- **Guardrails applied**: all guardrails enforced during this session — both existing ones shortlisted earlier via `get_guardrails` + `get_guardrail_by_id` (`source: "existing"`) and new ones the IDE agent created on the fly (`source: "ide_generated"`), each with satisfaction status
|
|
218
|
+
- **Workflow metadata**: `chat_session_id`, `event_name` or `title`, required `summary`, and optional `workflow_name` / `workflow_description`
|
|
218
219
|
|
|
219
220
|
### How to invoke
|
|
220
221
|
|
|
@@ -223,7 +224,7 @@ Use the host's `ctm_sync` agent/workflow with:
|
|
|
223
224
|
- The `chat_session_id` for workflow routing
|
|
224
225
|
- Whether this is a new threat model or an update
|
|
225
226
|
|
|
226
|
-
See `{{CTM_SYNC_AGENT_PATH}}` for the full workflow and
|
|
227
|
+
See `{{CTM_SYNC_AGENT_PATH}}` for the full workflow and markdown schema.
|
|
227
228
|
|
|
228
229
|
---
|
|
229
230
|
|
|
@@ -23,7 +23,7 @@ function getCopilotSessionHookContent() {
|
|
|
23
23
|
'1. Fetch Vibe Guardrails first using .github/skills/guardrails-selection/SKILL.md. Resolve the project, call get_guardrails, shortlist relevant guardrails, then call get_guardrail_by_id for the shortlist.',
|
|
24
24
|
'2. Run PWNISMS threat modelling using .github/skills/threat-modelling/SKILL.md. Explicitly walk Product, Workload, Network, IAM, Secrets, Monitoring, and Supply Chain.',
|
|
25
25
|
'3. Implement secure code using both the hydrated guardrails and PWNISMS findings.',
|
|
26
|
-
'4. Run the ctm_sync custom agent using .github/agents/ctm_sync.agent.md after threat modelling or guardrail enforcement. Reuse the exact guardrail shortlist; do not re-query guardrails during CTM sync.',
|
|
26
|
+
'4. Run the ctm_sync custom agent using .github/agents/ctm_sync.agent.md after threat modelling or guardrail enforcement. Reuse the exact guardrail shortlist; do not re-query guardrails during CTM sync. The agent should write a structured .md sync artifact and upload it with sync_ai_ide_markdown.',
|
|
27
27
|
'',
|
|
28
28
|
'Do not use project-profile exploration tools during normal coding tasks. No blocking and no deferral: guardrails first, PWNISMS second, implementation third, ctm_sync last.',
|
|
29
29
|
].join('\n');
|
|
@@ -36,6 +36,14 @@ test('VS Code Copilot generator writes instructions, skills, agent, and hooks',
|
|
|
36
36
|
assert.match(threatSkill, /\.github\/agents\/ctm_sync\.agent\.md/);
|
|
37
37
|
assert.doesNotMatch(threatSkill, /get_project_profile_description/);
|
|
38
38
|
|
|
39
|
+
const agent = readFileSync(join(cwd, '.github/agents/ctm_sync.agent.md'), 'utf8');
|
|
40
|
+
assert.match(agent, /Configured SRAI project name: `SmokeProject`/);
|
|
41
|
+
assert.match(agent, /sync_ai_ide_markdown/);
|
|
42
|
+
assert.match(agent, /structured markdown artifact/i);
|
|
43
|
+
assert.match(agent, /OWASP Top 10 2025 Mappings/);
|
|
44
|
+
assert.match(agent, /vibereview\//);
|
|
45
|
+
assert.doesNotMatch(agent, /Call `create_ai_ide_event` with/i);
|
|
46
|
+
|
|
39
47
|
const hooks = JSON.parse(readFileSync(join(cwd, '.github/hooks/srai-session-policy.json'), 'utf8'));
|
|
40
48
|
assert.equal(hooks.hooks.SessionStart[0].type, 'command');
|
|
41
49
|
});
|