@securityreviewai/securityreview-kit 0.1.49 → 0.1.50

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.
@@ -0,0 +1,378 @@
1
+ ---
2
+ name: vibereview-sync
3
+ description: Write and synchronize a structured VibeReview markdown artifact under vibereview/ for the current security-relevant session. Use after threat modelling or guardrail-enforced implementation.
4
+ ---
5
+
6
+ # VibeReview Markdown Sync
7
+
8
+ Configured SRAI project name: `<SRAI_PROJECT_NAME>`
9
+
10
+ Use this skill whenever threat modelling output exists or security guardrail compliance must be synchronized to SRAI.
11
+
12
+ This skill exists to make the markdown deterministic, grounded, and parseable without depending on a separate subagent. The same agent that performed the work should author the markdown and call `sync_ai_ide_markdown` directly.
13
+
14
+ ## Core Rules
15
+
16
+ 1. Write the artifact under `vibereview/`.
17
+ 2. Author the markdown from the current task context only.
18
+ 3. Do not read other `.md` files in `vibereview/` to infer structure, copy content, or merge state.
19
+ 4. If the current session file path is already known, update that one file directly.
20
+ 5. If the current session file does not exist yet, create a new file using a stable name such as:
21
+
22
+ ```text
23
+ vibereview/<chat_session_id>-<slugified-title-or-event-name>.md
24
+ ```
25
+
26
+ 6. Validate the markdown before calling `sync_ai_ide_markdown`.
27
+ 7. If sync fails, leave the file on disk and report the failure clearly.
28
+
29
+ ## Why You Must Not Read Sibling Files
30
+
31
+ Other markdown files in `vibereview/` may belong to different sessions, different workflows, or partially complete work. Reading them introduces drift and causes downstream extraction failures.
32
+
33
+ Treat each VibeReview artifact as self-contained. The current artifact must be fully authorable from:
34
+
35
+ - the current user request
36
+ - the current session context
37
+ - the threat model produced in this task
38
+ - the exact guardrail shortlist preserved in context
39
+ - the real code snippets touched in this task
40
+
41
+ ## Required Authoring Workflow
42
+
43
+ ### Step 1: Collect the required inputs
44
+
45
+ Before writing the markdown, confirm you have:
46
+
47
+ - a stable `chat_session_id`
48
+ - a concise `summary`
49
+ - either `title` or `event_name`
50
+ - the exact existing guardrails shortlisted earlier
51
+ - any `ide_generated` guardrails created during this task
52
+ - grounded threat entries
53
+ - grounded code snippets from actual files
54
+ - exact OWASP Top 10 2025 mappings when applicable
55
+
56
+ If any required field is missing, resolve it from current context before writing. Do not invent data.
57
+
58
+ ### Step 2: Write YAML frontmatter
59
+
60
+ The frontmatter should use this shape:
61
+
62
+ ```yaml
63
+ ---
64
+ chat_session_id: "cursor-chat-7f3b2f44-8c4d-4d4a-9f1e-2b6a4c91b201"
65
+ workflow_name: "User Auth Hardening"
66
+ workflow_description: "Security improvements for auth flow handling in the current IDE session"
67
+ event_name: "Hardened AI IDE sync ingestion and workflow reuse"
68
+ summary: "This change moved AI IDE sync handling to the server so workflow resolution and event creation happen deterministically after markdown upload. We enforced stable session identity, validated required event fields, and added structured extraction for threats, guardrails, secure code snippets, and OWASP mappings. The endpoint now accepts markdown, returns immediately, and continues processing in the background."
69
+ external_id: "ai-ide-sync-2026-04-21-001"
70
+ ---
71
+ ```
72
+
73
+ ### Frontmatter rules
74
+
75
+ - `chat_session_id` is required.
76
+ - `summary` is required.
77
+ - At least one of `event_name` or `title` is required.
78
+ - `workflow_name` is optional.
79
+ - `workflow_description` is optional.
80
+ - `external_id` is optional.
81
+ - If `workflow_name` is omitted, the server may derive it from the title.
82
+ - Do not rely on `developer_name` or `developer_email` in markdown. The server ignores them when authenticated API identity exists.
83
+
84
+ ## Required Markdown Structure
85
+
86
+ Use this top-level shape:
87
+
88
+ ```md
89
+ # AI IDE Sync Event
90
+
91
+ ## Event Identity
92
+ ...
93
+
94
+ ## Summary
95
+ ...
96
+
97
+ # Threats Mitigated
98
+ ...
99
+
100
+ # Best Practices Achieved
101
+ ...
102
+
103
+ # Secure Code Snippets
104
+ ...
105
+
106
+ # Guardrails Applied
107
+ ...
108
+
109
+ # OWASP Top 10 2025 Mappings
110
+ ...
111
+ ```
112
+
113
+ The exact heading levels may vary slightly, but the section names should stay stable and obvious.
114
+
115
+ ## Event Identity Section
116
+
117
+ Preferred structure:
118
+
119
+ ```md
120
+ ## Event Identity
121
+
122
+ - chat_session_id: `cursor-chat-7f3b2f44-8c4d-4d4a-9f1e-2b6a4c91b201`
123
+ - workflow_name: `User Auth Hardening`
124
+ - event_name: `Hardened AI IDE sync ingestion and workflow reuse`
125
+ - external_id: `ai-ide-sync-2026-04-21-001`
126
+ ```
127
+
128
+ ## Summary Section
129
+
130
+ Repeat the summary in prose under `## Summary`.
131
+
132
+ ## Threats Mitigated Section
133
+
134
+ Each threat entry must include:
135
+
136
+ - `threat_name`
137
+ - `pwnisms_category`
138
+ - `severity`
139
+ - `mitigation_applied`
140
+
141
+ When code exists, include a `### Code Snippet` subsection with:
142
+
143
+ - `file_path`
144
+ - `language`
145
+ - `explanation`
146
+ - a fenced code block containing real code
147
+
148
+ Preferred example:
149
+
150
+ ````md
151
+ # Threats Mitigated
152
+
153
+ ## Threat 1
154
+
155
+ - threat_name: Missing session identity can attach events to the wrong workflow
156
+ - pwnisms_category: IAM
157
+ - severity: High
158
+ - mitigation_applied: The server now requires a stable `chat_session_id` and uses it to resolve or create the workflow before persisting the event.
159
+
160
+ ### Code Snippet
161
+
162
+ - file_path: `app/api/external_ai_ide.py`
163
+ - language: `python`
164
+ - explanation: This prevents ambiguous workflow association and ensures repeated syncs from the same IDE chat session map to the same workflow.
165
+
166
+ ```python
167
+ chat_session_id = str(
168
+ frontmatter.get("chat_session_id")
169
+ or extracted.chat_session_id
170
+ or ""
171
+ ).strip()
172
+
173
+ if not chat_session_id:
174
+ raise ValueError("chat_session_id could not be resolved from markdown content")
175
+ ```
176
+ ````
177
+
178
+ ### Threat authoring rules
179
+
180
+ - Keep each threat clearly separated.
181
+ - Do not collapse multiple threats into one malformed block.
182
+ - Always close fenced code blocks.
183
+ - Never let prose spill into the next threat entry.
184
+ - PWNISMS categories must be one of:
185
+ - `Product`
186
+ - `Workload`
187
+ - `Network`
188
+ - `IAM`
189
+ - `Secrets`
190
+ - `Monitoring`
191
+ - `Supply Chain`
192
+ - Severity should be one of:
193
+ - `Critical`
194
+ - `High`
195
+ - `Medium`
196
+ - `Low`
197
+
198
+ ## Best Practices Achieved Section
199
+
200
+ Use structured practice entries, not plain bullet-only lists.
201
+
202
+ ````md
203
+ # Best Practices Achieved
204
+
205
+ ## Practice 1
206
+ - practice_name: Stable workflow correlation
207
+ - description: Used a stable chat session identifier to ensure repeated syncs map to the same workflow.
208
+ - category: identity
209
+
210
+ ## Practice 2
211
+ - practice_name: Server-side workflow orchestration
212
+ - description: Kept workflow and event creation on the server instead of relying on IDE-side orchestration.
213
+ - category: design
214
+
215
+ ## Practice 3
216
+ - practice_name: Required field validation
217
+ - description: Validated required event identity fields before persisting security review data.
218
+ - category: validation
219
+ ````
220
+
221
+ ### Best practice rules
222
+
223
+ - Each entry should be introduced with a stable heading such as `## Practice 1`, `## Practice 2`, and so on.
224
+ - Each entry must include:
225
+ - `practice_name`
226
+ - `description`
227
+ - `category`
228
+ - Keep the values concise and grounded in the actual work completed.
229
+ - Do not turn this section into freeform paragraphs.
230
+ - Do not reduce this section to plain bullet statements without field names.
231
+
232
+ ## Secure Code Snippets Section
233
+
234
+ Each snippet entry should include:
235
+
236
+ - `file_path`
237
+ - `language`
238
+ - `explanation`
239
+ - a fenced code block with real code
240
+
241
+ Preferred example:
242
+
243
+ ````md
244
+ # Secure Code Snippets
245
+
246
+ ## Snippet 1
247
+
248
+ - file_path: `app/api/external_ai_ide.py`
249
+ - language: `python`
250
+ - explanation: This is security-relevant because it isolates background processing from the request lifecycle and ensures the authenticated developer identity is propagated server-side.
251
+
252
+ ```python
253
+ async def _process_ai_ide_markdown_ingestion(
254
+ *,
255
+ project_id: int,
256
+ ingestion_id: str,
257
+ filename: str,
258
+ markdown_text: str,
259
+ developer_name: str,
260
+ developer_email: str,
261
+ ) -> None:
262
+ logger.info(
263
+ "Starting AI IDE markdown ingestion %s for project %s",
264
+ ingestion_id,
265
+ project_id,
266
+ )
267
+ ```
268
+ ````
269
+
270
+ ### Secure snippet rules
271
+
272
+ - Snippets must be real code, not invented examples.
273
+ - Prefer snippets already cited in threat mitigations when they are strongly relevant.
274
+ - Use fenced code blocks.
275
+ - Keep snippets focused and bounded.
276
+
277
+ ## Guardrails Applied Section
278
+
279
+ Each guardrail entry must include:
280
+
281
+ - `title`
282
+ - `rule_type`
283
+ - `category`
284
+ - `instruction`
285
+ - `source`
286
+ - `satisfied`
287
+ - `notes`
288
+
289
+ Preferred example:
290
+
291
+ ```md
292
+ # Guardrails Applied
293
+
294
+ ## Guardrail 1
295
+
296
+ - title: Require stable AI IDE session identity
297
+ - rule_type: must
298
+ - category: Identity
299
+ - instruction: Every AI IDE sync markdown must include a stable chat_session_id so workflow association is deterministic.
300
+ - source: existing
301
+ - satisfied: true
302
+ - notes: Enforced during markdown ingestion before workflow lookup or workflow creation.
303
+ ```
304
+
305
+ ### Guardrail rules
306
+
307
+ - `rule_type` must be `must` or `must_not`.
308
+ - `source` must be `existing` or `ide_generated`.
309
+ - `satisfied` must be `true` or `false`.
310
+ - Do not drop shortlisted existing guardrails even when unsatisfied.
311
+ - If a guardrail was not fully satisfied, keep it and explain why in `notes`.
312
+
313
+ ## OWASP Top 10 2025 Mappings Section
314
+
315
+ Use exact IDs and names. Preferred structures:
316
+
317
+ ```md
318
+ # OWASP Top 10 2025 Mappings
319
+
320
+ - A07: Authentication Failures
321
+ - A06: Insecure Design
322
+ - A10: Mishandling of Exceptional Conditions
323
+ ```
324
+
325
+ or
326
+
327
+ ```md
328
+ # OWASP Top 10 2025 Mappings
329
+
330
+ - category_id: A07
331
+ category_name: Authentication Failures
332
+ - category_id: A06
333
+ category_name: Insecure Design
334
+ ```
335
+
336
+ Allowed values:
337
+
338
+ - `A01` Broken Access Control
339
+ - `A02` Security Misconfiguration
340
+ - `A03` Software Supply Chain Failures
341
+ - `A04` Cryptographic Failures
342
+ - `A05` Injection
343
+ - `A06` Insecure Design
344
+ - `A07` Authentication Failures
345
+ - `A08` Software or Data Integrity Failures
346
+ - `A09` Security Logging and Alerting Failures
347
+ - `A10` Mishandling of Exceptional Conditions
348
+
349
+ ## Validation Checklist Before Sync
350
+
351
+ Before calling `sync_ai_ide_markdown`, verify all of the following:
352
+
353
+ - The file is under `vibereview/`.
354
+ - You did not read sibling markdown files in `vibereview/`.
355
+ - `chat_session_id` exists in frontmatter.
356
+ - `summary` exists in frontmatter.
357
+ - `event_name` or `title` exists in frontmatter.
358
+ - The `Event Identity` section exists.
359
+ - The `Summary` section exists.
360
+ - The `Threats Mitigated` section exists.
361
+ - The `Best Practices Achieved` section exists.
362
+ - The `Secure Code Snippets` section exists.
363
+ - The `Guardrails Applied` section exists.
364
+ - The `OWASP Top 10 2025 Mappings` section exists.
365
+ - Every threat entry is structurally complete.
366
+ - Every code fence is closed.
367
+ - Every snippet is grounded in real code.
368
+ - Every guardrail entry is structurally complete.
369
+ - OWASP IDs and names are exact.
370
+
371
+ ## Final Step
372
+
373
+ After validation:
374
+
375
+ 1. Save the markdown artifact under `vibereview/`.
376
+ 2. Call `sync_ai_ide_markdown` directly with that file's contents or path, depending on the tool interface exposed by the host.
377
+ 3. If sync succeeds, report success briefly.
378
+ 4. If sync fails, report failure clearly and leave the markdown artifact intact for retry.