@securityreviewai/securityreview-kit 0.1.51 → 0.1.52

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.
Files changed (78) hide show
  1. package/README.md +105 -0
  2. package/bin/securityreview-kit.js +5 -0
  3. package/package.json +30 -24
  4. package/src/cli.js +109 -0
  5. package/src/commands/init.js +851 -0
  6. package/src/commands/status.js +99 -0
  7. package/src/commands/switch-project.js +207 -0
  8. package/src/generators/mcp/claude.js +85 -0
  9. package/src/generators/mcp/claude.test.js +64 -0
  10. package/src/generators/mcp/codex.js +70 -0
  11. package/src/generators/mcp/codex.test.js +43 -0
  12. package/src/generators/mcp/cursor.js +29 -0
  13. package/src/generators/mcp/cursor.test.js +50 -0
  14. package/src/generators/mcp/gemini.js +28 -0
  15. package/src/generators/mcp/vscode.js +29 -0
  16. package/src/generators/mcp/windsurf.js +27 -0
  17. package/src/generators/rules/antigravity.js +22 -0
  18. package/src/generators/rules/claude.js +87 -0
  19. package/src/generators/rules/claude.test.js +60 -0
  20. package/src/generators/rules/codex.js +141 -0
  21. package/src/generators/rules/codex.test.js +59 -0
  22. package/src/generators/rules/content.js +110 -0
  23. package/{templates/shared → src/generators/rules}/content.md +6 -9
  24. package/src/generators/rules/cursor.js +128 -0
  25. package/src/generators/rules/gemini.js +13 -0
  26. package/src/generators/rules/guardrails-init-profile.md +56 -0
  27. package/src/generators/rules/guardrails-profiler/SKILL.md +130 -0
  28. package/src/generators/rules/guardrails-profiler/references/signal-registry.json +514 -0
  29. package/{templates/shared/guardrails-selection.md → src/generators/rules/guardrails-selection/SKILL.md} +12 -10
  30. package/src/generators/rules/guardrails-selection/references/category-threat-map.md +232 -0
  31. package/src/generators/rules/guardrails_rule.md +94 -0
  32. package/src/generators/rules/hooks.json +11 -0
  33. package/{templates/shared/threat-modelling.md → src/generators/rules/skill.md} +11 -14
  34. package/src/generators/rules/srai-profile.md +32 -0
  35. package/{templates/shared → src/generators/rules}/vibereview-sync/SKILL.md +12 -15
  36. package/src/generators/rules/vscode.js +101 -0
  37. package/src/generators/rules/vscode.test.js +54 -0
  38. package/src/generators/rules/windsurf.js +13 -0
  39. package/src/utils/constants.js +95 -0
  40. package/src/utils/cursor-agent-path.js +67 -0
  41. package/src/utils/cursor-cli-permissions.js +28 -0
  42. package/src/utils/detect.js +27 -0
  43. package/src/utils/fs-helpers.js +82 -0
  44. package/src/utils/guardrails-profiler-bundle.js +84 -0
  45. package/src/utils/ide-cli-install.js +138 -0
  46. package/src/utils/profiler-agent.js +446 -0
  47. package/src/utils/profiler-agent.test.js +81 -0
  48. package/src/utils/srai.js +252 -0
  49. package/dist/api.js +0 -44
  50. package/dist/commands/guardrails.js +0 -13
  51. package/dist/commands/init.js +0 -88
  52. package/dist/commands/profile.js +0 -14
  53. package/dist/commands/status.js +0 -27
  54. package/dist/commands/sync.js +0 -6
  55. package/dist/config.js +0 -18
  56. package/dist/fs.js +0 -43
  57. package/dist/index.js +0 -44
  58. package/dist/profile.js +0 -113
  59. package/dist/scaffold/claude-code.js +0 -43
  60. package/dist/scaffold/codex.js +0 -41
  61. package/dist/scaffold/cursor.js +0 -45
  62. package/dist/scaffold/gemini.js +0 -10
  63. package/dist/scaffold/index.js +0 -22
  64. package/dist/scaffold/mcp.js +0 -15
  65. package/dist/scaffold/rules.js +0 -191
  66. package/dist/scaffold/vibreview.js +0 -30
  67. package/dist/scaffold/vscode.js +0 -28
  68. package/dist/scaffold/windsurf.js +0 -10
  69. package/dist/sync/index.js +0 -34
  70. package/dist/sync/payload.js +0 -23
  71. package/dist/sync/state.js +0 -12
  72. package/dist/types.js +0 -1
  73. package/templates/claude/CLAUDE.md +0 -13
  74. package/templates/claude/agents/guardrail_profiler.md +0 -12
  75. package/templates/claude/agents/threat_modeler.md +0 -5
  76. package/templates/claude/skills/vibreview/SKILL.md +0 -21
  77. package/templates/claude/skills/vibreview/guardrail_patterns.md +0 -12
  78. package/templates/cursor/rules/vibreview-security.mdc +0 -8
@@ -0,0 +1,232 @@
1
+ # Guardrail Selection Threat Map
2
+
3
+ Use this file when deciding which guardrail categories apply to the current task and which threat families should influence the shortlist.
4
+
5
+ The intent is not to produce a full threat model here. The intent is to make sure likely exploit paths influence which guardrails are fetched by id and enforced during implementation.
6
+
7
+ ## How to use this map
8
+
9
+ 1. Start from the feature or code change.
10
+ 2. Infer the categories involved in the implementation.
11
+ 3. Use the mappings below to identify likely threat families.
12
+ 4. Shortlist guardrails that directly or adjacently mitigate those threats.
13
+ 5. Fetch those guardrails with `get_guardrail_by_id`.
14
+
15
+ ## STRIDE-style mappings for guardrail selection
16
+
17
+ ### Spoofing
18
+
19
+ Usually maps to authentication and session-related controls.
20
+
21
+ Threat patterns to consider:
22
+
23
+ - identity-related attacks
24
+ - session and token attacks
25
+ - business-logic attacks leading to authentication bypass
26
+ - injection attacks leading to authentication bypass
27
+ - serialization attacks leading to authentication bypass
28
+ - cryptographic attacks leading to authentication bypass
29
+ - lapses in logging leading to authentication bypass
30
+ - client-side trust leading to authentication bypass
31
+
32
+ Categories commonly shortlisted:
33
+
34
+ - `authentication`
35
+ - `session_management`
36
+ - `cryptography`
37
+ - `logging`
38
+ - `client_side`
39
+ - `business_logic`
40
+ - `input_validation`
41
+ - `deserialization`
42
+
43
+ ### Tampering
44
+
45
+ Usually maps to authorization, integrity, and unsafe state change controls.
46
+
47
+ Threat patterns to consider:
48
+
49
+ - broken object level access control patterns
50
+ - broken functional level access control patterns
51
+ - injection-driven authorization bypass
52
+ - serialization-driven authorization bypass
53
+ - business-logic-driven authorization bypass
54
+ - client-side trust leading to unauthorized state changes
55
+
56
+ Categories commonly shortlisted:
57
+
58
+ - `authorization`
59
+ - `tenant_isolation`
60
+ - `data_access`
61
+ - `business_logic`
62
+ - `logging`
63
+ - `input_validation`
64
+ - `deserialization`
65
+ - `client_side`
66
+
67
+ ### Repudiation
68
+
69
+ Usually appears when spoofing and tampering are possible but the system cannot prove what happened.
70
+
71
+ Threat patterns to consider:
72
+
73
+ - weak or missing audit trails for auth and authorization decisions
74
+ - missing actor attribution on sensitive state changes
75
+ - mutable or incomplete event records
76
+ - inability to correlate session, actor, and resource changes
77
+
78
+ Categories commonly shortlisted:
79
+
80
+ - `logging`
81
+ - `monitoring`
82
+ - `authentication`
83
+ - `authorization`
84
+ - `admin_workflows`
85
+
86
+ ### Information Disclosure
87
+
88
+ Usually maps to authorization, data exposure, logging, and unsafe client-side trust.
89
+
90
+ Threat patterns to consider:
91
+
92
+ - broken object level access control patterns
93
+ - broken functional level access control patterns
94
+ - injection-driven information disclosure
95
+ - serialization-driven information disclosure
96
+ - business-logic-driven information disclosure
97
+ - lapses in logging leading to disclosure
98
+ - client-side trust causing exposure of protected data
99
+
100
+ Categories commonly shortlisted:
101
+
102
+ - `authorization`
103
+ - `tenant_isolation`
104
+ - `data_access`
105
+ - `logging`
106
+ - `input_validation`
107
+ - `deserialization`
108
+ - `client_side`
109
+ - `output_encoding`
110
+
111
+ ### Denial of Service
112
+
113
+ Usually maps to workload protection, parsing safety, quota controls, and expensive query behavior.
114
+
115
+ Threat patterns to consider:
116
+
117
+ - broken access control patterns that expose heavy operations
118
+ - injection or data-access paths that amplify resource consumption
119
+ - serialization-driven memory or parser exhaustion
120
+ - business-logic-driven abuse of expensive workflows
121
+ - logging lapses that hide repeated abuse
122
+
123
+ Categories commonly shortlisted:
124
+
125
+ - `rate_limiting`
126
+ - `input_validation`
127
+ - `file_uploads`
128
+ - `deserialization`
129
+ - `data_access`
130
+ - `network`
131
+ - `monitoring`
132
+ - `logging`
133
+ - `business_logic`
134
+
135
+ ### Elevation of Privilege
136
+
137
+ Usually maps to authorization, role boundaries, trust decisions, and privileged workflow controls.
138
+
139
+ Threat patterns to consider:
140
+
141
+ - access control bypasses from broken object or function level access
142
+ - injection-based privilege escalation
143
+ - client-side induced privilege escalation
144
+ - serialization-induced privilege escalation
145
+ - business-logic-triggered privilege escalation
146
+ - logging lapses that conceal privilege abuse
147
+
148
+ Categories commonly shortlisted:
149
+
150
+ - `authorization`
151
+ - `tenant_isolation`
152
+ - `admin_workflows`
153
+ - `business_logic`
154
+ - `client_side`
155
+ - `input_validation`
156
+ - `deserialization`
157
+ - `logging`
158
+
159
+ ## Fast examples
160
+
161
+ ### Add password reset flow
162
+
163
+ Likely categories:
164
+
165
+ - `authentication`
166
+ - `session_management`
167
+ - `cryptography`
168
+ - `logging`
169
+ - `rate_limiting`
170
+
171
+ Likely threat families:
172
+
173
+ - spoofing
174
+ - repudiation
175
+ - information disclosure
176
+
177
+ ### Add admin endpoint to change user role
178
+
179
+ Likely categories:
180
+
181
+ - `authorization`
182
+ - `tenant_isolation`
183
+ - `admin_workflows`
184
+ - `logging`
185
+ - `business_logic`
186
+
187
+ Likely threat families:
188
+
189
+ - tampering
190
+ - repudiation
191
+ - elevation of privilege
192
+ - information disclosure
193
+
194
+ ### Add bulk import endpoint
195
+
196
+ Likely categories:
197
+
198
+ - `input_validation`
199
+ - `file_uploads`
200
+ - `deserialization`
201
+ - `data_access`
202
+ - `logging`
203
+ - `rate_limiting`
204
+
205
+ Likely threat families:
206
+
207
+ - tampering
208
+ - information disclosure
209
+ - denial of service
210
+
211
+ ### Move entitlement checks to the frontend
212
+
213
+ Likely categories:
214
+
215
+ - `authorization`
216
+ - `client_side`
217
+ - `tenant_isolation`
218
+ - `logging`
219
+
220
+ Likely threat families:
221
+
222
+ - tampering
223
+ - information disclosure
224
+ - elevation of privilege
225
+
226
+ ## Selection reminders
227
+
228
+ - A feature can require guardrails from multiple categories.
229
+ - Shortlist for exploit chains, not isolated weaknesses.
230
+ - Logging often matters because poor auditability can turn spoofing, tampering, or privilege abuse into repudiation.
231
+ - Client-side logic often needs server-side guardrails even if the visible change is in the UI.
232
+ - If no existing guardrail covers a realistic recurring threat, create an `ide_generated` guardrail and carry it into the final VibeReview markdown sync.
@@ -0,0 +1,94 @@
1
+ # Vibe Guardrails — Secure by Code
2
+
3
+ **Enforce project-specific security guardrails during every code-generation task.**
4
+
5
+ This rule complements the PWNISMS threat model ("secure by design") with concrete, project-level coding dos and don'ts ("secure by code"). Guardrails are maintained in SRAI and fetched via `security-review-mcp`.
6
+
7
+ ---
8
+
9
+ ## When this rule applies
10
+
11
+ This rule is **active for every code-generation or code-modification task** — including:
12
+
13
+ - Implementing new features or endpoints
14
+ - Fixing bugs that touch security-relevant code
15
+ - Refactoring code that handles auth, input, secrets, data storage, or network
16
+ - Generating boilerplate, scaffolding, or templates that will run in production
17
+
18
+ ### When to skip
19
+
20
+ Skip guardrail enforcement for tasks with **no code output** (documentation, Q&A, formatting, renaming).
21
+
22
+ ---
23
+
24
+ ## Required behavior
25
+
26
+ ### 1. Use the guardrails-selection skill at the start of every code task
27
+
28
+ Before writing or modifying code, you must read and follow `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.
29
+
30
+ That skill is mandatory because the IDE must not leave guardrail selection to chance. The required workflow is:
31
+
32
+ - **Analyze the task first** — infer what the user is actually building, what components are touched, what categories are involved, and what threats might occur.
33
+ - **Resolve the project** — use `find_project_by_name` with `name="<SRAI_PROJECT_NAME>"` to obtain `project_id`.
34
+ - **Load the broad catalog** — call `get_guardrails` with `project_id`.
35
+ - **Shortlist intentionally** — choose only the guardrails that mitigate the categories and likely threats for the current task.
36
+ - **Hydrate the exact shortlist** — call `get_guardrail_by_id` for the shortlisted guardrail ids so implementation uses the exact selected guardrails, not a vague reading of the full catalog.
37
+ - **Preserve the shortlist** — keep the selected existing guardrails in context so the final VibeReview markdown can include the same guardrails later without re-querying.
38
+
39
+ The broad `get_guardrails` result is only the candidate catalog. The active implementation guardrails must come from the shortlisted `get_guardrail_by_id` result.
40
+
41
+ Each guardrail used for implementation should preserve these fields:
42
+
43
+ | Field | Description |
44
+ |---|---|
45
+ | `id` | Stable guardrail identifier used with `get_guardrail_by_id` |
46
+ | `title` | Short name of the guardrail |
47
+ | `rule_type` | `must` (mandatory) or `must_not` (prohibition) |
48
+ | `category` | Grouping label (e.g. `authentication`, `input_validation`, `secrets`) or `null` |
49
+ | `instruction` | The actionable coding directive |
50
+
51
+ If `get_guardrails` returns additional metadata such as `source_ref`, use it as supporting context during selection.
52
+
53
+ ### 2. Apply guardrails during code generation
54
+
55
+ - **`must` rules (DOs):** Treat as mandatory implementation requirements. Every line of generated code must satisfy all applicable `must` guardrails.
56
+ - **`must_not` rules (DON'Ts):** Treat as hard prohibitions. Generated code must never violate a `must_not` guardrail.
57
+ - If a guardrail conflicts with the user's explicit instruction, **flag the conflict** to the user and ask for confirmation before proceeding.
58
+ - If no guardrails are returned (empty list), proceed normally using baseline PWNISMS controls.
59
+
60
+ ### 3. Cross-reference with PWNISMS
61
+
62
+ Guardrails and PWNISMS are complementary:
63
+
64
+ - Guardrails provide **project-specific, concrete rules** derived from prior threat reviews, compliance requirements, and team decisions.
65
+ - PWNISMS provides **universal threat-category coverage** to catch gaps that guardrails may not yet cover.
66
+ - When PWNISMS analysis reveals a gap not covered by any existing guardrail, **create a new guardrail on the fly** and apply it immediately (marked `source: "ide_generated"` in the VibeReview markdown).
67
+
68
+ ### 4. Report guardrail compliance
69
+
70
+ After code generation, include a brief guardrails compliance summary:
71
+
72
+ - List which guardrails were applied (by title), distinguishing existing vs IDE-generated.
73
+ - Flag any guardrails that could not be fully satisfied and explain why.
74
+ - Do not drop shortlisted existing guardrails from session context. The final VibeReview markdown must include the same shortlist, including any unsatisfied items with notes.
75
+
76
+ ---
77
+
78
+ ## Guardrail lifecycle — updates and new guardrails
79
+
80
+ Guardrails are living artifacts. The IDE agent can create, apply, and update them:
81
+
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 in the final VibeReview markdown with `source: "ide_generated"`.
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 — must be preserved in the VibeReview markdown under a single `Guardrails Applied` section that the server can normalize into `guardrails_applied`.
85
+
86
+ ---
87
+
88
+ ## Tool Reference
89
+
90
+ | Tool | Purpose |
91
+ |---|---|
92
+ | `get_guardrails` | Fetch the broad project guardrails catalog (requires `project_id`) |
93
+ | `get_guardrail_by_id` | Fetch the exact shortlisted guardrails that will govern implementation |
94
+ | `find_project_by_name` | Resolve project by name to get `project_id` |
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "sessionStart": [
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. **VibeReview sync (last)** - Read .cursor/skills/vibereview-sync/SKILL.md. The main agent must write a structured `.md` artifact under `vibereview/`, must not read sibling markdown files there just to infer format, must validate that all required metadata and sections are present, and must call `sync_ai_ide_markdown` directly after implementation is done. Include the exact shortlisted guardrails from earlier plus any IDE-generated guardrails in the markdown; do not query guardrails again during sync.\\n\\nNo blocking. No deferral. Guardrails enforce secure code; threat modeling guides the design; the main agent owns the final markdown sync to SRAI. Both sync and guardrail compliance are mandatory and should be part of your to-do.\"}'",
7
+ "timeout": 5
8
+ }
9
+ ]
10
+ }
11
+ }
@@ -1,13 +1,12 @@
1
1
  ---
2
2
  name: PWNISMS Threat Modelling
3
- description: Security-first threat modelling workflow for code and architecture tasks. Walks all 7 PWNISMS categories, enforces vibe guardrails (secure by code), and synchronizes findings via a direct VibeReview markdown sync. Use after guardrail selection and before implementation.
3
+ description: Security-first threat modelling workflow for code and architecture tasks. Walks all 7 PWNISMS categories, enforces vibe guardrails (secure by code), and synchronizes findings via a direct VibeReview markdown sync. Use before, during, and after implementation.
4
4
  ---
5
5
 
6
6
  # PWNISMS — Security-First Threat Modelling
7
7
 
8
8
  For EVERY security-relevant task (feature, bug fix, refactor, infra change, architecture design), run a threat model with PWNISMS.
9
9
 
10
- - This is a pre-implementation gate. Do not write, edit, patch, or generate implementation code until guardrail selection has completed and this PWNISMS pass has been completed.
11
10
  - Walk through all 7 categories explicitly.
12
11
  - If a category is not applicable, state it briefly and move on.
13
12
  - Anchor analysis to linked files, diffs, PRs, API specs, and diagrams whenever available.
@@ -21,7 +20,7 @@ Before deep analysis, ensure the project-specific guardrail shortlist exists:
21
20
 
22
21
  1. Use `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.
23
22
  2. Resolve the project with `find_project_by_name` using `name="<SRAI_PROJECT_NAME>"`.
24
- 3. Call `get_guardrails`, shortlist intentionally for this task, then preserve the exact returned guardrail records in context.
23
+ 3. Call `get_guardrails`, shortlist intentionally for this task, then hydrate the exact shortlist with `get_guardrail_by_id`.
25
24
  4. Keep the shortlisted existing guardrails in context for implementation and the final VibeReview markdown sync.
26
25
 
27
26
  Do not perform project-profile exploration as part of PWNISMS. The old profile tools are not part of this workflow. Ground the threat model in the user request, repository code, diffs, architecture docs the user provides, and the shortlisted guardrails.
@@ -155,7 +154,7 @@ Dependency and delivery threats:
155
154
 
156
155
  After completing the PWNISMS analysis and before writing code:
157
156
 
158
- 1. **Review the exact shortlisted guardrails** produced by `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.
157
+ 1. **Review the shortlisted hydrated guardrails** produced by `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.
159
158
  2. **Classify applicability** — For each shortlisted guardrail, determine if it applies to the current task.
160
159
  3. **Apply during code generation:**
161
160
  - `must` rules → mandatory implementation requirements. Every applicable `must` guardrail must be satisfied.
@@ -200,7 +199,7 @@ When discussing designs before code exists:
200
199
 
201
200
  ## Phase 5 — VibeReview Sync (Post Threat Modelling)
202
201
 
203
- **MANDATORY:** After every threat modeling step that produces or modifies threat content, the main agent must update the `.vibreview/scans/*.md` artifact and call `sync_ai_ide_markdown` directly with raw markdown content.
202
+ **MANDATORY:** After every threat modeling step that produces or modifies threat content, the main agent must update the `vibereview/*.md` artifact and call `sync_ai_ide_markdown` directly.
204
203
 
205
204
  ### What triggers the VibeReview sync
206
205
 
@@ -208,22 +207,20 @@ When discussing designs before code exists:
208
207
  - Existing threat model updated or extended (new threats, refined mitigations, additional components)
209
208
  - Guardrails applied during a code-generation task (existing or IDE-generated)
210
209
 
211
- Do not call sync before implementation is complete unless the user explicitly asked only for threat modelling/design output. For coding tasks, the order is guardrail selection, PWNISMS, implementation, markdown sync.
212
-
213
210
  ### What the VibeReview markdown must contain
214
211
 
215
- The main agent writes a structured `.md` artifact under `.vibreview/scans/` and uploads the raw markdown string through `sync_ai_ide_markdown`. That markdown should contain:
212
+ The main agent writes a structured `.md` artifact under `vibereview/` and uploads it through `sync_ai_ide_markdown`. That markdown should contain:
216
213
 
217
214
  - **Threat model findings**: threats mitigated, PWNISMS categories, severities, mitigations applied
218
215
  - **Best practices achieved**: structured practice entries with `practice_name`, `description`, and `category`
219
216
  - **Secure code snippets**: security-relevant code with explanations
220
- - **Guardrails applied**: all guardrails enforced during this session — both existing ones shortlisted earlier via `get_guardrails` (`source: "existing"`) and new ones the IDE agent created on the fly (`source: "ide_generated"`), each with satisfaction status
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
221
218
  - **Workflow metadata**: `chat_session_id`, `event_name` or `title`, required `summary`, and optional `workflow_name` / `workflow_description`
222
219
 
223
220
  ### How to sync
224
221
 
225
222
  1. Read and follow `{{VIBEREVIEW_SYNC_SKILL_DIR}}/SKILL.md`.
226
- 2. Write or update a file under `.vibreview/scans/`, ideally `.vibreview/scans/<chat_session_id>-<slugified-title-or-event-name>.md`.
223
+ 2. Write or update a file under `vibereview/`, ideally `vibereview/<chat_session_id>-<slugified-title-or-event-name>.md`.
227
224
  3. Put `chat_session_id`, `summary`, and either `title` or `event_name` in frontmatter.
228
225
  4. Include the required sections:
229
226
  - `Best Practices Achieved`
@@ -237,9 +234,9 @@ The main agent writes a structured `.md` artifact under `.vibreview/scans/` and
237
234
  - every guardrail includes `title`, `rule_type`, `source`, and `satisfied`
238
235
  - OWASP mappings use exact IDs and names
239
236
  - snippets are grounded in actual code, not invented text
240
- - no sibling `.md` files in `.vibreview/scans/` were read just to infer format or content
241
- 6. Call `sync_ai_ide_markdown` directly with the finished raw markdown content. Do not pass JSON, extracted event objects, or summaries as the markdown.
242
- 7. If sync fails, leave the artifact in `.vibreview/scans/` and report the failure clearly.
237
+ - no sibling `.md` files in `vibereview/` were read just to infer format or content
238
+ 6. Call `sync_ai_ide_markdown` directly with the finished markdown artifact.
239
+ 7. If sync fails, leave the artifact in `vibereview/` and report the failure clearly.
243
240
 
244
241
  ---
245
242
 
@@ -254,6 +251,6 @@ Before finalizing output, confirm:
254
251
  - [ ] Residual risk and follow-up actions are stated.
255
252
  - [ ] Vibe guardrails were fetched and enforced (all applicable `must`/`must_not` rules satisfied).
256
253
  - [ ] Guardrail compliance summary is included in the response (existing + IDE-generated).
257
- - [ ] The VibeReview markdown was written under `.vibreview/scans/` and `sync_ai_ide_markdown` was called successfully with raw markdown content.
254
+ - [ ] The VibeReview markdown was written under `vibereview/` and `sync_ai_ide_markdown` was called successfully.
258
255
 
259
256
  If ANY box cannot be checked, you MUST flag the gap to the user with a specific remediation recommendation before finalizing the code.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: srai-profile
3
+ description: Create and upload a SecurityReviewAI code profile using security-review-mcp
4
+ ---
5
+
6
+ # SRAI Profile Uploader
7
+
8
+ Create a code profile from the current request and upload it to SRAI using `security-review-mcp`.
9
+
10
+ Configured SRAI project name: `<SRAI_PROJECT_NAME>`
11
+
12
+ ## Steps
13
+
14
+ 1. Determine scope from the user prompt.
15
+ - If the request is about a specific capability/module/endpoint, produce a **Feature Code Profile**.
16
+ - If the request is broad, exploratory, or architecture-level, produce a **Codebase Code Profile**.
17
+ 2. Build detailed profile content before any upload call.
18
+ - Include purpose, boundaries, entry points, sensitive data, trust boundaries, integrations, threats, controls, and open risks.
19
+ 3. Resolve the SRAI project.
20
+ - Use the configured project name by default; if it is missing or ambiguous, ask the user to confirm it.
21
+ - Call `find_project_by_name` with `name="<SRAI_PROJECT_NAME>"`.
22
+ - If missing, call `list_projects`; if still missing, call `create_project` with `name="<SRAI_PROJECT_NAME>"`.
23
+ 4. Upload generated markdown content with tool 11: `upload_document`.
24
+ - Use this for raw markdown/text generated in the chat.
25
+ - Use a clear document name such as `feature-code-profile-<feature>.md` or `codebase-code-profile-<repo>.md`.
26
+ 5. Upload files/diagrams with tool 10: `upload_document` when needed.
27
+ - Provide base64 file content and file name.
28
+ - Set `document_type` to `Component Diagram` for architecture diagrams.
29
+ - Set `document_type` to `Uploaded Knowledgebase doc` for other document uploads.
30
+ 6. Confirm the result.
31
+ - Report project name, upload tool used, document name, and that processing is asynchronous.
32
+ - If upload fails, return exact error details and next retry step.
@@ -1,6 +1,6 @@
1
1
  ---
2
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.
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
4
  ---
5
5
 
6
6
  # VibeReview Markdown Sync
@@ -9,20 +9,18 @@ Configured SRAI project name: `<SRAI_PROJECT_NAME>`
9
9
 
10
10
  Use this skill whenever threat modelling output exists or security guardrail compliance must be synchronized to SRAI.
11
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.
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.
15
13
 
16
14
  ## Core Rules
17
15
 
18
- 1. Write the artifact under `.vibreview/scans/`.
16
+ 1. Write the artifact under `vibereview/`.
19
17
  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.
18
+ 3. Do not read other `.md` files in `vibereview/` to infer structure, copy content, or merge state.
21
19
  4. If the current session file path is already known, update that one file directly.
22
20
  5. If the current session file does not exist yet, create a new file using a stable name such as:
23
21
 
24
22
  ```text
25
- .vibreview/scans/<chat_session_id>-<slugified-title-or-event-name>.md
23
+ vibereview/<chat_session_id>-<slugified-title-or-event-name>.md
26
24
  ```
27
25
 
28
26
  6. Validate the markdown before calling `sync_ai_ide_markdown`.
@@ -30,7 +28,7 @@ For coding tasks, do not use this skill until the required sequence is complete:
30
28
 
31
29
  ## Why You Must Not Read Sibling Files
32
30
 
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.
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.
34
32
 
35
33
  Treat each VibeReview artifact as self-contained. The current artifact must be fully authorable from:
36
34
 
@@ -352,8 +350,8 @@ Allowed values:
352
350
 
353
351
  Before calling `sync_ai_ide_markdown`, verify all of the following:
354
352
 
355
- - The file is under `.vibreview/scans/`.
356
- - You did not read sibling markdown files in `.vibreview/scans/`.
353
+ - The file is under `vibereview/`.
354
+ - You did not read sibling markdown files in `vibereview/`.
357
355
  - `chat_session_id` exists in frontmatter.
358
356
  - `summary` exists in frontmatter.
359
357
  - `event_name` or `title` exists in frontmatter.
@@ -374,8 +372,7 @@ Before calling `sync_ai_ide_markdown`, verify all of the following:
374
372
 
375
373
  After validation:
376
374
 
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.
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.
@@ -0,0 +1,101 @@
1
+ import { existsSync, unlinkSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import {
4
+ GUARDRAILS_SELECTION_SKILL_REL_DIR,
5
+ THREAT_MODELLING_SKILL_REL_DIR,
6
+ VIBEREVIEW_SYNC_SKILL_REL_DIR,
7
+ } from '../../utils/constants.js';
8
+ import { upsertSentinelBlock, writeText } from '../../utils/fs-helpers.js';
9
+ import { getRuleContent, getThreatModellingSkillContent, getVibeReviewSyncSkillContent } from './content.js';
10
+
11
+ function writeGeneratedText(filePath, content) {
12
+ const action = existsSync(filePath) ? 'updated' : 'created';
13
+ writeText(filePath, content);
14
+ return { filePath, action };
15
+ }
16
+
17
+ function removeGeneratedText(filePath) {
18
+ if (existsSync(filePath)) {
19
+ unlinkSync(filePath);
20
+ return { filePath, action: 'deleted' };
21
+ }
22
+ return null;
23
+ }
24
+
25
+ function getCopilotSessionHookContent() {
26
+ const additionalContext = [
27
+ '## MANDATORY SECURITY GATE (Session Policy)',
28
+ '',
29
+ 'For any request with security impact (auth, authorization, crypto, input handling, secrets, network, data storage, dependencies, new APIs/endpoints, infrastructure, or code handling untrusted data), follow this order:',
30
+ '',
31
+ '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.',
32
+ '2. Run PWNISMS threat modelling using .github/skills/threat-modelling/SKILL.md. Explicitly walk Product, Workload, Network, IAM, Secrets, Monitoring, and Supply Chain.',
33
+ '3. Implement secure code using both the hydrated guardrails and PWNISMS findings.',
34
+ '4. Read .github/skills/vibereview-sync/SKILL.md. Write a structured .md artifact under vibereview/, do not read sibling markdown files there just to infer format, validate it, and call sync_ai_ide_markdown directly after threat modelling or guardrail enforcement. Reuse the exact guardrail shortlist; do not re-query guardrails during the final sync.',
35
+ '',
36
+ 'Do not use project-profile exploration tools during normal coding tasks. No blocking and no deferral: guardrails first, PWNISMS second, implementation third, VibeReview sync last.',
37
+ ].join('\n');
38
+
39
+ const commandPayload = JSON.stringify({
40
+ hookSpecificOutput: {
41
+ hookEventName: 'SessionStart',
42
+ additionalContext,
43
+ },
44
+ });
45
+
46
+ return JSON.stringify(
47
+ {
48
+ hooks: {
49
+ SessionStart: [
50
+ {
51
+ type: 'command',
52
+ command: `printf '%s\\n' '${commandPayload.replaceAll("'", "'\\''")}'`,
53
+ timeout: 5,
54
+ },
55
+ ],
56
+ },
57
+ },
58
+ null,
59
+ 2,
60
+ ) + '\n';
61
+ }
62
+
63
+ /**
64
+ * Generate VS Code Copilot instructions — appends to .github/copilot-instructions.md
65
+ */
66
+ export function generate(cwd, options = {}) {
67
+ const optionsWithSkillDirs = {
68
+ ...options,
69
+ guardrailsSelectionSkillDir: GUARDRAILS_SELECTION_SKILL_REL_DIR.vscode,
70
+ threatModellingSkillDir: THREAT_MODELLING_SKILL_REL_DIR.vscode,
71
+ vibereviewSyncSkillDir: VIBEREVIEW_SYNC_SKILL_REL_DIR.vscode,
72
+ };
73
+ const filePath = join(cwd, '.github', 'copilot-instructions.md');
74
+ const content = getRuleContent(optionsWithSkillDirs);
75
+ const action = upsertSentinelBlock(filePath, content);
76
+
77
+ const threatSkillPath = join(cwd, THREAT_MODELLING_SKILL_REL_DIR.vscode, 'SKILL.md');
78
+ const threatSkill = writeGeneratedText(
79
+ threatSkillPath,
80
+ getThreatModellingSkillContent(optionsWithSkillDirs),
81
+ );
82
+
83
+ const vibereviewSyncSkillPath = join(cwd, VIBEREVIEW_SYNC_SKILL_REL_DIR.vscode, 'SKILL.md');
84
+ const vibereviewSyncSkill = writeGeneratedText(
85
+ vibereviewSyncSkillPath,
86
+ getVibeReviewSyncSkillContent(optionsWithSkillDirs),
87
+ );
88
+
89
+ const deletedLegacyAgent = removeGeneratedText(join(cwd, '.github', 'agents', 'ctm_sync.agent.md'));
90
+
91
+ const hooksPath = join(cwd, '.github', 'hooks', 'srai-session-policy.json');
92
+ const hooks = writeGeneratedText(hooksPath, getCopilotSessionHookContent());
93
+
94
+ return [
95
+ { filePath, action, kind: 'rule' },
96
+ { ...threatSkill, kind: 'skill' },
97
+ { ...vibereviewSyncSkill, kind: 'skill' },
98
+ { ...hooks, kind: 'hooks' },
99
+ ...(deletedLegacyAgent ? [{ ...deletedLegacyAgent, kind: 'cleanup' }] : []),
100
+ ];
101
+ }