@securityreviewai/securityreview-kit 0.1.49 → 0.1.51

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