@nahisaho/musubix-security 1.8.0 → 1.8.5

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 (186) hide show
  1. package/README.md +27 -0
  2. package/dist/analyzers/ai/index.d.ts +6 -0
  3. package/dist/analyzers/ai/index.d.ts.map +1 -0
  4. package/dist/analyzers/ai/index.js +6 -0
  5. package/dist/analyzers/ai/index.js.map +1 -0
  6. package/dist/analyzers/ai/prompt-injection-detector.d.ts +152 -0
  7. package/dist/analyzers/ai/prompt-injection-detector.d.ts.map +1 -0
  8. package/dist/analyzers/ai/prompt-injection-detector.js +468 -0
  9. package/dist/analyzers/ai/prompt-injection-detector.js.map +1 -0
  10. package/dist/analyzers/api/api-security-analyzer.d.ts +263 -0
  11. package/dist/analyzers/api/api-security-analyzer.d.ts.map +1 -0
  12. package/dist/analyzers/api/api-security-analyzer.js +581 -0
  13. package/dist/analyzers/api/api-security-analyzer.js.map +1 -0
  14. package/dist/analyzers/compliance/compliance-checker.d.ts +201 -0
  15. package/dist/analyzers/compliance/compliance-checker.d.ts.map +1 -0
  16. package/dist/analyzers/compliance/compliance-checker.js +772 -0
  17. package/dist/analyzers/compliance/compliance-checker.js.map +1 -0
  18. package/dist/analyzers/container/image-scanner.d.ts +163 -0
  19. package/dist/analyzers/container/image-scanner.d.ts.map +1 -0
  20. package/dist/analyzers/container/image-scanner.js +459 -0
  21. package/dist/analyzers/container/image-scanner.js.map +1 -0
  22. package/dist/analyzers/container/index.d.ts +6 -0
  23. package/dist/analyzers/container/index.d.ts.map +1 -0
  24. package/dist/analyzers/container/index.js +6 -0
  25. package/dist/analyzers/container/index.js.map +1 -0
  26. package/dist/analyzers/dashboard/security-dashboard.d.ts +286 -0
  27. package/dist/analyzers/dashboard/security-dashboard.d.ts.map +1 -0
  28. package/dist/analyzers/dashboard/security-dashboard.js +796 -0
  29. package/dist/analyzers/dashboard/security-dashboard.js.map +1 -0
  30. package/dist/analyzers/iac/iac-checker.d.ts +124 -0
  31. package/dist/analyzers/iac/iac-checker.d.ts.map +1 -0
  32. package/dist/analyzers/iac/iac-checker.js +755 -0
  33. package/dist/analyzers/iac/iac-checker.js.map +1 -0
  34. package/dist/analyzers/iac/index.d.ts +6 -0
  35. package/dist/analyzers/iac/index.d.ts.map +1 -0
  36. package/dist/analyzers/iac/index.js +6 -0
  37. package/dist/analyzers/iac/index.js.map +1 -0
  38. package/dist/analyzers/index.d.ts +9 -0
  39. package/dist/analyzers/index.d.ts.map +1 -0
  40. package/dist/analyzers/index.js +13 -0
  41. package/dist/analyzers/index.js.map +1 -0
  42. package/dist/analyzers/monitor/realtime-monitor.d.ts +216 -0
  43. package/dist/analyzers/monitor/realtime-monitor.d.ts.map +1 -0
  44. package/dist/analyzers/monitor/realtime-monitor.js +601 -0
  45. package/dist/analyzers/monitor/realtime-monitor.js.map +1 -0
  46. package/dist/analyzers/sast/index.d.ts +7 -0
  47. package/dist/analyzers/sast/index.d.ts.map +1 -0
  48. package/dist/analyzers/sast/index.js +7 -0
  49. package/dist/analyzers/sast/index.js.map +1 -0
  50. package/dist/analyzers/sast/interprocedural-analyzer.d.ts +276 -0
  51. package/dist/analyzers/sast/interprocedural-analyzer.d.ts.map +1 -0
  52. package/dist/analyzers/sast/interprocedural-analyzer.js +635 -0
  53. package/dist/analyzers/sast/interprocedural-analyzer.js.map +1 -0
  54. package/dist/analyzers/sast/zero-day-detector.d.ts +183 -0
  55. package/dist/analyzers/sast/zero-day-detector.d.ts.map +1 -0
  56. package/dist/analyzers/sast/zero-day-detector.js +593 -0
  57. package/dist/analyzers/sast/zero-day-detector.js.map +1 -0
  58. package/dist/analyzers/sca/dependency-scanner.d.ts +275 -0
  59. package/dist/analyzers/sca/dependency-scanner.d.ts.map +1 -0
  60. package/dist/analyzers/sca/dependency-scanner.js +642 -0
  61. package/dist/analyzers/sca/dependency-scanner.js.map +1 -0
  62. package/dist/core/index.d.ts +8 -0
  63. package/dist/core/index.d.ts.map +1 -0
  64. package/dist/core/index.js +10 -0
  65. package/dist/core/index.js.map +1 -0
  66. package/dist/core/pipeline-manager.d.ts +105 -0
  67. package/dist/core/pipeline-manager.d.ts.map +1 -0
  68. package/dist/core/pipeline-manager.js +449 -0
  69. package/dist/core/pipeline-manager.js.map +1 -0
  70. package/dist/core/result-aggregator.d.ts +96 -0
  71. package/dist/core/result-aggregator.d.ts.map +1 -0
  72. package/dist/core/result-aggregator.js +462 -0
  73. package/dist/core/result-aggregator.js.map +1 -0
  74. package/dist/index.d.ts +15 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +68 -0
  77. package/dist/index.js.map +1 -1
  78. package/dist/integrations/ci-integration.d.ts +227 -0
  79. package/dist/integrations/ci-integration.d.ts.map +1 -0
  80. package/dist/integrations/ci-integration.js +472 -0
  81. package/dist/integrations/ci-integration.js.map +1 -0
  82. package/dist/integrations/git-hooks.d.ts +155 -0
  83. package/dist/integrations/git-hooks.d.ts.map +1 -0
  84. package/dist/integrations/git-hooks.js +425 -0
  85. package/dist/integrations/git-hooks.js.map +1 -0
  86. package/dist/integrations/index.d.ts +9 -0
  87. package/dist/integrations/index.d.ts.map +1 -0
  88. package/dist/integrations/index.js +9 -0
  89. package/dist/integrations/index.js.map +1 -0
  90. package/dist/integrations/report-aggregator.d.ts +250 -0
  91. package/dist/integrations/report-aggregator.d.ts.map +1 -0
  92. package/dist/integrations/report-aggregator.js +488 -0
  93. package/dist/integrations/report-aggregator.js.map +1 -0
  94. package/dist/integrations/vscode-integration.d.ts +245 -0
  95. package/dist/integrations/vscode-integration.d.ts.map +1 -0
  96. package/dist/integrations/vscode-integration.js +449 -0
  97. package/dist/integrations/vscode-integration.js.map +1 -0
  98. package/dist/intelligence/attack-pattern-matcher.d.ts +217 -0
  99. package/dist/intelligence/attack-pattern-matcher.d.ts.map +1 -0
  100. package/dist/intelligence/attack-pattern-matcher.js +887 -0
  101. package/dist/intelligence/attack-pattern-matcher.js.map +1 -0
  102. package/dist/intelligence/index.d.ts +12 -0
  103. package/dist/intelligence/index.d.ts.map +1 -0
  104. package/dist/intelligence/index.js +18 -0
  105. package/dist/intelligence/index.js.map +1 -0
  106. package/dist/intelligence/neuro-symbolic-core.d.ts +88 -0
  107. package/dist/intelligence/neuro-symbolic-core.d.ts.map +1 -0
  108. package/dist/intelligence/neuro-symbolic-core.js +403 -0
  109. package/dist/intelligence/neuro-symbolic-core.js.map +1 -0
  110. package/dist/intelligence/predictive-analyzer.d.ts +317 -0
  111. package/dist/intelligence/predictive-analyzer.d.ts.map +1 -0
  112. package/dist/intelligence/predictive-analyzer.js +714 -0
  113. package/dist/intelligence/predictive-analyzer.js.map +1 -0
  114. package/dist/intelligence/risk-scorer.d.ts +333 -0
  115. package/dist/intelligence/risk-scorer.d.ts.map +1 -0
  116. package/dist/intelligence/risk-scorer.js +824 -0
  117. package/dist/intelligence/risk-scorer.js.map +1 -0
  118. package/dist/intelligence/security-analytics.d.ts +349 -0
  119. package/dist/intelligence/security-analytics.d.ts.map +1 -0
  120. package/dist/intelligence/security-analytics.js +813 -0
  121. package/dist/intelligence/security-analytics.js.map +1 -0
  122. package/dist/intelligence/threat-intelligence.d.ts +288 -0
  123. package/dist/intelligence/threat-intelligence.d.ts.map +1 -0
  124. package/dist/intelligence/threat-intelligence.js +639 -0
  125. package/dist/intelligence/threat-intelligence.js.map +1 -0
  126. package/dist/policy/index.d.ts +6 -0
  127. package/dist/policy/index.d.ts.map +1 -0
  128. package/dist/policy/index.js +6 -0
  129. package/dist/policy/index.js.map +1 -0
  130. package/dist/policy/policy-engine.d.ts +254 -0
  131. package/dist/policy/policy-engine.d.ts.map +1 -0
  132. package/dist/policy/policy-engine.js +651 -0
  133. package/dist/policy/policy-engine.js.map +1 -0
  134. package/dist/remediation/auto-fixer.d.ts +179 -0
  135. package/dist/remediation/auto-fixer.d.ts.map +1 -0
  136. package/dist/remediation/auto-fixer.js +540 -0
  137. package/dist/remediation/auto-fixer.js.map +1 -0
  138. package/dist/remediation/fix-validator.d.ts +195 -0
  139. package/dist/remediation/fix-validator.d.ts.map +1 -0
  140. package/dist/remediation/fix-validator.js +462 -0
  141. package/dist/remediation/fix-validator.js.map +1 -0
  142. package/dist/remediation/index.d.ts +10 -0
  143. package/dist/remediation/index.d.ts.map +1 -0
  144. package/dist/remediation/index.js +15 -0
  145. package/dist/remediation/index.js.map +1 -0
  146. package/dist/remediation/patch-generator.d.ts +203 -0
  147. package/dist/remediation/patch-generator.d.ts.map +1 -0
  148. package/dist/remediation/patch-generator.js +533 -0
  149. package/dist/remediation/patch-generator.js.map +1 -0
  150. package/dist/remediation/remediation-planner.d.ts +262 -0
  151. package/dist/remediation/remediation-planner.d.ts.map +1 -0
  152. package/dist/remediation/remediation-planner.js +531 -0
  153. package/dist/remediation/remediation-planner.js.map +1 -0
  154. package/dist/remediation/secure-code-transformer.d.ts +222 -0
  155. package/dist/remediation/secure-code-transformer.d.ts.map +1 -0
  156. package/dist/remediation/secure-code-transformer.js +625 -0
  157. package/dist/remediation/secure-code-transformer.js.map +1 -0
  158. package/dist/types/fix.d.ts +3 -1
  159. package/dist/types/fix.d.ts.map +1 -1
  160. package/dist/types/index.d.ts +6 -0
  161. package/dist/types/index.d.ts.map +1 -1
  162. package/dist/types/index.js +1 -0
  163. package/dist/types/index.js.map +1 -1
  164. package/dist/types/interprocedural.d.ts +203 -0
  165. package/dist/types/interprocedural.d.ts.map +1 -0
  166. package/dist/types/interprocedural.js +7 -0
  167. package/dist/types/interprocedural.js.map +1 -0
  168. package/dist/types/neuro-symbolic.d.ts +179 -0
  169. package/dist/types/neuro-symbolic.d.ts.map +1 -0
  170. package/dist/types/neuro-symbolic.js +7 -0
  171. package/dist/types/neuro-symbolic.js.map +1 -0
  172. package/dist/types/pipeline.d.ts +173 -0
  173. package/dist/types/pipeline.d.ts.map +1 -0
  174. package/dist/types/pipeline.js +7 -0
  175. package/dist/types/pipeline.js.map +1 -0
  176. package/dist/types/result.d.ts +134 -0
  177. package/dist/types/result.d.ts.map +1 -0
  178. package/dist/types/result.js +25 -0
  179. package/dist/types/result.js.map +1 -0
  180. package/dist/types/vulnerability.d.ts +2 -2
  181. package/dist/types/vulnerability.d.ts.map +1 -1
  182. package/dist/types/zero-day.d.ts +146 -0
  183. package/dist/types/zero-day.d.ts.map +1 -0
  184. package/dist/types/zero-day.js +7 -0
  185. package/dist/types/zero-day.js.map +1 -0
  186. package/package.json +2 -2
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @fileoverview VS Code Integration for Security Scanning
3
+ * @module @nahisaho/musubix-security/integrations/vscode-integration
4
+ *
5
+ * Provides API for VS Code extension integration with diagnostic
6
+ * and code action capabilities.
7
+ */
8
+ import type { ScanResult, Vulnerability, Severity, Fix } from '../types/index.js';
9
+ /**
10
+ * VS Code diagnostic severity (mirrors vscode.DiagnosticSeverity)
11
+ */
12
+ export declare enum DiagnosticSeverity {
13
+ Error = 0,
14
+ Warning = 1,
15
+ Information = 2,
16
+ Hint = 3
17
+ }
18
+ /**
19
+ * VS Code position
20
+ */
21
+ export interface Position {
22
+ line: number;
23
+ character: number;
24
+ }
25
+ /**
26
+ * VS Code range
27
+ */
28
+ export interface Range {
29
+ start: Position;
30
+ end: Position;
31
+ }
32
+ /**
33
+ * VS Code diagnostic
34
+ */
35
+ export interface Diagnostic {
36
+ /** Range where the diagnostic applies */
37
+ range: Range;
38
+ /** Human-readable message */
39
+ message: string;
40
+ /** Severity level */
41
+ severity: DiagnosticSeverity;
42
+ /** Diagnostic code */
43
+ code?: string | number;
44
+ /** Source of the diagnostic */
45
+ source: string;
46
+ /** Related information */
47
+ relatedInformation?: DiagnosticRelatedInformation[];
48
+ /** Tags for special handling */
49
+ tags?: DiagnosticTag[];
50
+ }
51
+ /**
52
+ * Diagnostic related information
53
+ */
54
+ export interface DiagnosticRelatedInformation {
55
+ location: {
56
+ uri: string;
57
+ range: Range;
58
+ };
59
+ message: string;
60
+ }
61
+ /**
62
+ * Diagnostic tag
63
+ */
64
+ export declare enum DiagnosticTag {
65
+ Unnecessary = 1,
66
+ Deprecated = 2
67
+ }
68
+ /**
69
+ * Code action
70
+ */
71
+ export interface CodeAction {
72
+ /** Title shown in UI */
73
+ title: string;
74
+ /** Kind of code action */
75
+ kind: CodeActionKind;
76
+ /** Diagnostics this action resolves */
77
+ diagnostics?: Diagnostic[];
78
+ /** Workspace edit to apply */
79
+ edit?: WorkspaceEdit;
80
+ /** Command to execute */
81
+ command?: Command;
82
+ /** Whether this is preferred action */
83
+ isPreferred?: boolean;
84
+ }
85
+ /**
86
+ * Code action kind
87
+ */
88
+ export type CodeActionKind = 'quickfix' | 'quickfix.security' | 'refactor' | 'refactor.security' | 'source' | 'source.fixAll.security';
89
+ /**
90
+ * Workspace edit
91
+ */
92
+ export interface WorkspaceEdit {
93
+ /** Map of URI to text edits */
94
+ changes: Map<string, TextEdit[]>;
95
+ }
96
+ /**
97
+ * Text edit
98
+ */
99
+ export interface TextEdit {
100
+ range: Range;
101
+ newText: string;
102
+ }
103
+ /**
104
+ * Command
105
+ */
106
+ export interface Command {
107
+ title: string;
108
+ command: string;
109
+ arguments?: unknown[];
110
+ }
111
+ /**
112
+ * Status bar item
113
+ */
114
+ export interface StatusBarItem {
115
+ text: string;
116
+ tooltip: string;
117
+ color?: string;
118
+ backgroundColor?: string;
119
+ command?: string;
120
+ }
121
+ /**
122
+ * Tree item for explorer view
123
+ */
124
+ export interface TreeItem {
125
+ label: string;
126
+ description?: string;
127
+ tooltip?: string;
128
+ iconPath?: string;
129
+ collapsibleState: 'none' | 'collapsed' | 'expanded';
130
+ children?: TreeItem[];
131
+ command?: Command;
132
+ contextValue?: string;
133
+ }
134
+ /**
135
+ * Hover content
136
+ */
137
+ export interface HoverContent {
138
+ contents: string[];
139
+ range?: Range;
140
+ }
141
+ /**
142
+ * Decoration
143
+ */
144
+ export interface Decoration {
145
+ range: Range;
146
+ renderOptions: {
147
+ after?: {
148
+ contentText: string;
149
+ color?: string;
150
+ backgroundColor?: string;
151
+ };
152
+ before?: {
153
+ contentText: string;
154
+ color?: string;
155
+ backgroundColor?: string;
156
+ };
157
+ };
158
+ }
159
+ /**
160
+ * VS Code integration options
161
+ */
162
+ export interface VSCodeIntegrationOptions {
163
+ /** Source name for diagnostics */
164
+ diagnosticSource?: string;
165
+ /** Collection name for diagnostics */
166
+ diagnosticCollection?: string;
167
+ /** Enable inline decorations */
168
+ enableDecorations?: boolean;
169
+ /** Enable code lens */
170
+ enableCodeLens?: boolean;
171
+ /** Severity mapping override */
172
+ severityMapping?: Partial<Record<Severity, DiagnosticSeverity>>;
173
+ }
174
+ /**
175
+ * VS Code integration adapter for security scanning
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const integration = createVSCodeIntegration();
180
+ *
181
+ * // Convert scan result to diagnostics
182
+ * const diagnostics = integration.toDiagnostics(scanResult);
183
+ *
184
+ * // Generate code actions for fixes
185
+ * const actions = integration.toCodeActions(vulnerability, fixes);
186
+ * ```
187
+ */
188
+ export declare class VSCodeIntegration {
189
+ private options;
190
+ private severityMap;
191
+ constructor(options?: VSCodeIntegrationOptions);
192
+ /**
193
+ * Convert vulnerability to VS Code diagnostic
194
+ */
195
+ toDiagnostic(vulnerability: Vulnerability): Diagnostic;
196
+ /**
197
+ * Convert scan result to VS Code diagnostics grouped by file
198
+ */
199
+ toDiagnostics(scanResult: ScanResult): Map<string, Diagnostic[]>;
200
+ /**
201
+ * Convert fix to VS Code code action
202
+ */
203
+ toCodeAction(vulnerability: Vulnerability, fix: Fix): CodeAction;
204
+ /**
205
+ * Convert multiple fixes to code actions
206
+ */
207
+ toCodeActions(vulnerability: Vulnerability, fixes: Fix[]): CodeAction[];
208
+ /**
209
+ * Generate "Fix All" code action
210
+ */
211
+ toFixAllAction(scanResult: ScanResult, fixes: Map<string, Fix[]>): CodeAction;
212
+ /**
213
+ * Generate status bar item
214
+ */
215
+ toStatusBarItem(scanResult: ScanResult): StatusBarItem;
216
+ /**
217
+ * Generate tree items for explorer view
218
+ */
219
+ toTreeItems(scanResult: ScanResult): TreeItem[];
220
+ /**
221
+ * Generate hover content for a vulnerability
222
+ */
223
+ toHoverContent(vulnerability: Vulnerability): HoverContent;
224
+ /**
225
+ * Generate inline decorations for vulnerabilities
226
+ */
227
+ toDecorations(vulnerabilities: Vulnerability[]): Decoration[];
228
+ /**
229
+ * Generate webview HTML content
230
+ */
231
+ toWebviewHTML(scanResult: ScanResult): string;
232
+ private locationToRange;
233
+ private formatDiagnosticMessage;
234
+ private getRelatedInformation;
235
+ private formatStatusTooltip;
236
+ private getSeverityIcon;
237
+ private getSeverityColor;
238
+ private getSeverityBadge;
239
+ private vulnerabilityToTreeItem;
240
+ }
241
+ /**
242
+ * Create VS Code integration instance
243
+ */
244
+ export declare function createVSCodeIntegration(options?: VSCodeIntegrationOptions): VSCodeIntegration;
245
+ //# sourceMappingURL=vscode-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode-integration.d.ts","sourceRoot":"","sources":["../../src/integrations/vscode-integration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAMlF;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,KAAK,IAAI;IACT,OAAO,IAAI;IACX,WAAW,IAAI;IACf,IAAI,IAAI;CACT;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,KAAK,EAAE,KAAK,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,sBAAsB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qB;IAgB7B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,uBAAuB;CAehC;AAMD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,iBAAiB,CAE7F"}
@@ -0,0 +1,449 @@
1
+ /**
2
+ * @fileoverview VS Code Integration for Security Scanning
3
+ * @module @nahisaho/musubix-security/integrations/vscode-integration
4
+ *
5
+ * Provides API for VS Code extension integration with diagnostic
6
+ * and code action capabilities.
7
+ */
8
+ // ============================================================================
9
+ // Types
10
+ // ============================================================================
11
+ /**
12
+ * VS Code diagnostic severity (mirrors vscode.DiagnosticSeverity)
13
+ */
14
+ export var DiagnosticSeverity;
15
+ (function (DiagnosticSeverity) {
16
+ DiagnosticSeverity[DiagnosticSeverity["Error"] = 0] = "Error";
17
+ DiagnosticSeverity[DiagnosticSeverity["Warning"] = 1] = "Warning";
18
+ DiagnosticSeverity[DiagnosticSeverity["Information"] = 2] = "Information";
19
+ DiagnosticSeverity[DiagnosticSeverity["Hint"] = 3] = "Hint";
20
+ })(DiagnosticSeverity || (DiagnosticSeverity = {}));
21
+ /**
22
+ * Diagnostic tag
23
+ */
24
+ export var DiagnosticTag;
25
+ (function (DiagnosticTag) {
26
+ DiagnosticTag[DiagnosticTag["Unnecessary"] = 1] = "Unnecessary";
27
+ DiagnosticTag[DiagnosticTag["Deprecated"] = 2] = "Deprecated";
28
+ })(DiagnosticTag || (DiagnosticTag = {}));
29
+ // ============================================================================
30
+ // VS Code Integration Class
31
+ // ============================================================================
32
+ /**
33
+ * VS Code integration adapter for security scanning
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const integration = createVSCodeIntegration();
38
+ *
39
+ * // Convert scan result to diagnostics
40
+ * const diagnostics = integration.toDiagnostics(scanResult);
41
+ *
42
+ * // Generate code actions for fixes
43
+ * const actions = integration.toCodeActions(vulnerability, fixes);
44
+ * ```
45
+ */
46
+ export class VSCodeIntegration {
47
+ options;
48
+ severityMap;
49
+ constructor(options = {}) {
50
+ this.options = {
51
+ diagnosticSource: options.diagnosticSource ?? 'MUSUBIX Security',
52
+ diagnosticCollection: options.diagnosticCollection ?? 'musubix-security',
53
+ enableDecorations: options.enableDecorations ?? true,
54
+ enableCodeLens: options.enableCodeLens ?? true,
55
+ severityMapping: options.severityMapping ?? {},
56
+ };
57
+ this.severityMap = {
58
+ critical: options.severityMapping?.critical ?? DiagnosticSeverity.Error,
59
+ high: options.severityMapping?.high ?? DiagnosticSeverity.Error,
60
+ medium: options.severityMapping?.medium ?? DiagnosticSeverity.Warning,
61
+ low: options.severityMapping?.low ?? DiagnosticSeverity.Information,
62
+ info: options.severityMapping?.info ?? DiagnosticSeverity.Hint,
63
+ };
64
+ }
65
+ /**
66
+ * Convert vulnerability to VS Code diagnostic
67
+ */
68
+ toDiagnostic(vulnerability) {
69
+ const range = this.locationToRange(vulnerability.location);
70
+ const diagnostic = {
71
+ range,
72
+ message: this.formatDiagnosticMessage(vulnerability),
73
+ severity: this.severityMap[vulnerability.severity],
74
+ code: vulnerability.ruleId,
75
+ source: this.options.diagnosticSource,
76
+ relatedInformation: this.getRelatedInformation(vulnerability),
77
+ };
78
+ return diagnostic;
79
+ }
80
+ /**
81
+ * Convert scan result to VS Code diagnostics grouped by file
82
+ */
83
+ toDiagnostics(scanResult) {
84
+ const diagnosticsMap = new Map();
85
+ for (const vuln of scanResult.vulnerabilities) {
86
+ const uri = vuln.location.file;
87
+ if (!diagnosticsMap.has(uri)) {
88
+ diagnosticsMap.set(uri, []);
89
+ }
90
+ diagnosticsMap.get(uri).push(this.toDiagnostic(vuln));
91
+ }
92
+ return diagnosticsMap;
93
+ }
94
+ /**
95
+ * Convert fix to VS Code code action
96
+ */
97
+ toCodeAction(vulnerability, fix) {
98
+ const diagnostic = this.toDiagnostic(vulnerability);
99
+ const action = {
100
+ title: fix.description,
101
+ kind: 'quickfix.security',
102
+ diagnostics: [diagnostic],
103
+ isPreferred: fix.confidence >= 0.8,
104
+ };
105
+ // Convert fix edits to workspace edit
106
+ if (fix.edits.length > 0) {
107
+ const changes = new Map();
108
+ for (const edit of fix.edits) {
109
+ const uri = vulnerability.location.file;
110
+ if (!changes.has(uri)) {
111
+ changes.set(uri, []);
112
+ }
113
+ changes.get(uri).push({
114
+ range: {
115
+ start: { line: edit.location.startLine - 1, character: edit.location.startColumn ?? 0 },
116
+ end: { line: edit.location.endLine - 1, character: edit.location.endColumn ?? 0 },
117
+ },
118
+ newText: edit.newCode ?? '',
119
+ });
120
+ }
121
+ action.edit = { changes };
122
+ }
123
+ return action;
124
+ }
125
+ /**
126
+ * Convert multiple fixes to code actions
127
+ */
128
+ toCodeActions(vulnerability, fixes) {
129
+ return fixes.map(fix => this.toCodeAction(vulnerability, fix));
130
+ }
131
+ /**
132
+ * Generate "Fix All" code action
133
+ */
134
+ toFixAllAction(scanResult, fixes) {
135
+ const allEdits = new Map();
136
+ let fixCount = 0;
137
+ for (const vuln of scanResult.vulnerabilities) {
138
+ const vulnFixes = fixes.get(vuln.id);
139
+ if (vulnFixes && vulnFixes.length > 0) {
140
+ const bestFix = vulnFixes[0];
141
+ for (const edit of bestFix.edits) {
142
+ const uri = vuln.location.file;
143
+ if (!allEdits.has(uri)) {
144
+ allEdits.set(uri, []);
145
+ }
146
+ allEdits.get(uri).push({
147
+ range: {
148
+ start: { line: edit.location.startLine - 1, character: edit.location.startColumn ?? 0 },
149
+ end: { line: edit.location.endLine - 1, character: edit.location.endColumn ?? 0 },
150
+ },
151
+ newText: edit.newCode ?? '',
152
+ });
153
+ fixCount++;
154
+ }
155
+ }
156
+ }
157
+ return {
158
+ title: `Fix all ${fixCount} security issues`,
159
+ kind: 'source.fixAll.security',
160
+ edit: { changes: allEdits },
161
+ };
162
+ }
163
+ /**
164
+ * Generate status bar item
165
+ */
166
+ toStatusBarItem(scanResult) {
167
+ const { critical, high, medium, low } = scanResult.summary;
168
+ const total = critical + high + medium + low;
169
+ let text;
170
+ let color;
171
+ let backgroundColor;
172
+ if (critical > 0) {
173
+ text = `$(shield) ${total} Security Issues (${critical} Critical)`;
174
+ color = '#ffffff';
175
+ backgroundColor = '#cc0000';
176
+ }
177
+ else if (high > 0) {
178
+ text = `$(shield) ${total} Security Issues (${high} High)`;
179
+ color = '#ffffff';
180
+ backgroundColor = '#ff8c00';
181
+ }
182
+ else if (total > 0) {
183
+ text = `$(shield) ${total} Security Issues`;
184
+ color = '#ffcc00';
185
+ }
186
+ else {
187
+ text = '$(shield) No Security Issues';
188
+ color = '#00cc00';
189
+ }
190
+ return {
191
+ text,
192
+ tooltip: this.formatStatusTooltip(scanResult),
193
+ color,
194
+ backgroundColor,
195
+ command: 'musubix-security.showReport',
196
+ };
197
+ }
198
+ /**
199
+ * Generate tree items for explorer view
200
+ */
201
+ toTreeItems(scanResult) {
202
+ const items = [];
203
+ // Group by severity
204
+ const bySeverity = new Map();
205
+ for (const vuln of scanResult.vulnerabilities) {
206
+ if (!bySeverity.has(vuln.severity)) {
207
+ bySeverity.set(vuln.severity, []);
208
+ }
209
+ bySeverity.get(vuln.severity).push(vuln);
210
+ }
211
+ // Create tree structure
212
+ for (const severity of ['critical', 'high', 'medium', 'low', 'info']) {
213
+ const vulns = bySeverity.get(severity) ?? [];
214
+ if (vulns.length === 0)
215
+ continue;
216
+ const severityItem = {
217
+ label: `${severity.toUpperCase()} (${vulns.length})`,
218
+ iconPath: this.getSeverityIcon(severity),
219
+ collapsibleState: severity === 'critical' || severity === 'high' ? 'expanded' : 'collapsed',
220
+ children: vulns.map(vuln => this.vulnerabilityToTreeItem(vuln)),
221
+ };
222
+ items.push(severityItem);
223
+ }
224
+ return items;
225
+ }
226
+ /**
227
+ * Generate hover content for a vulnerability
228
+ */
229
+ toHoverContent(vulnerability) {
230
+ const contents = [];
231
+ // Header
232
+ contents.push(`### 🔒 ${vulnerability.ruleId}`);
233
+ contents.push('');
234
+ // Severity badge
235
+ const badge = this.getSeverityBadge(vulnerability.severity);
236
+ contents.push(`**Severity:** ${badge}`);
237
+ contents.push('');
238
+ // Message
239
+ contents.push(`**Issue:** ${vulnerability.description}`);
240
+ contents.push('');
241
+ // OWASP/CWE
242
+ if (vulnerability.owasp || vulnerability.cwes) {
243
+ contents.push('**References:**');
244
+ if (vulnerability.owasp) {
245
+ contents.push(`- OWASP: ${vulnerability.owasp.join(', ')}`);
246
+ }
247
+ if (vulnerability.cwes && vulnerability.cwes.length > 0) {
248
+ contents.push(`- CWE: ${vulnerability.cwes.join(', ')}`);
249
+ }
250
+ contents.push('');
251
+ }
252
+ // Remediation (recommendation in the type)
253
+ if (vulnerability.recommendation) {
254
+ contents.push('**Remediation:**');
255
+ contents.push(vulnerability.recommendation);
256
+ }
257
+ return {
258
+ contents,
259
+ range: this.locationToRange(vulnerability.location),
260
+ };
261
+ }
262
+ /**
263
+ * Generate inline decorations for vulnerabilities
264
+ */
265
+ toDecorations(vulnerabilities) {
266
+ if (!this.options.enableDecorations)
267
+ return [];
268
+ return vulnerabilities.map(vuln => ({
269
+ range: this.locationToRange(vuln.location),
270
+ renderOptions: {
271
+ after: {
272
+ contentText: ` ⚠️ ${vuln.severity.toUpperCase()}: ${vuln.ruleId}`,
273
+ color: this.getSeverityColor(vuln.severity),
274
+ },
275
+ },
276
+ }));
277
+ }
278
+ /**
279
+ * Generate webview HTML content
280
+ */
281
+ toWebviewHTML(scanResult) {
282
+ const { critical, high, medium, low, info } = scanResult.summary;
283
+ return `
284
+ <!DOCTYPE html>
285
+ <html lang="en">
286
+ <head>
287
+ <meta charset="UTF-8">
288
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
289
+ <title>MUSUBIX Security Report</title>
290
+ <style>
291
+ body { font-family: var(--vscode-font-family); padding: 20px; }
292
+ .summary { display: flex; gap: 20px; margin-bottom: 20px; }
293
+ .stat { padding: 10px 20px; border-radius: 4px; text-align: center; }
294
+ .critical { background: #cc0000; color: white; }
295
+ .high { background: #ff8c00; color: white; }
296
+ .medium { background: #ffcc00; color: black; }
297
+ .low { background: #0066cc; color: white; }
298
+ .info { background: #666666; color: white; }
299
+ table { width: 100%; border-collapse: collapse; }
300
+ th, td { padding: 8px; text-align: left; border-bottom: 1px solid var(--vscode-panel-border); }
301
+ .severity-badge { padding: 2px 8px; border-radius: 4px; font-size: 12px; }
302
+ </style>
303
+ </head>
304
+ <body>
305
+ <h1>🔒 Security Scan Results</h1>
306
+
307
+ <div class="summary">
308
+ <div class="stat critical">Critical: ${critical}</div>
309
+ <div class="stat high">High: ${high}</div>
310
+ <div class="stat medium">Medium: ${medium}</div>
311
+ <div class="stat low">Low: ${low}</div>
312
+ <div class="stat info">Info: ${info}</div>
313
+ </div>
314
+
315
+ <table>
316
+ <thead>
317
+ <tr>
318
+ <th>Severity</th>
319
+ <th>Rule</th>
320
+ <th>File</th>
321
+ <th>Line</th>
322
+ <th>Message</th>
323
+ </tr>
324
+ </thead>
325
+ <tbody>
326
+ ${scanResult.vulnerabilities.map(v => `
327
+ <tr>
328
+ <td><span class="severity-badge ${v.severity}">${v.severity.toUpperCase()}</span></td>
329
+ <td>${v.ruleId}</td>
330
+ <td>${v.location.file}</td>
331
+ <td>${v.location.startLine}</td>
332
+ <td>${v.description}</td>
333
+ </tr>
334
+ `).join('')}
335
+ </tbody>
336
+ </table>
337
+ </body>
338
+ </html>
339
+ `;
340
+ }
341
+ // ============================================================================
342
+ // Private Methods
343
+ // ============================================================================
344
+ locationToRange(location) {
345
+ return {
346
+ start: {
347
+ line: location.startLine - 1,
348
+ character: location.startColumn ?? 0,
349
+ },
350
+ end: {
351
+ line: (location.endLine ?? location.startLine) - 1,
352
+ character: location.endColumn ?? 100,
353
+ },
354
+ };
355
+ }
356
+ formatDiagnosticMessage(vuln) {
357
+ let message = vuln.description;
358
+ if (vuln.owasp) {
359
+ message += ` [OWASP: ${vuln.owasp.join(', ')}]`;
360
+ }
361
+ if (vuln.cwes && vuln.cwes.length > 0) {
362
+ message += ` [CWE: ${vuln.cwes.join(', ')}]`;
363
+ }
364
+ return message;
365
+ }
366
+ getRelatedInformation(vuln) {
367
+ const info = [];
368
+ if (vuln.recommendation) {
369
+ info.push({
370
+ location: {
371
+ uri: vuln.location.file,
372
+ range: this.locationToRange(vuln.location),
373
+ },
374
+ message: `Remediation: ${vuln.recommendation}`,
375
+ });
376
+ }
377
+ return info;
378
+ }
379
+ formatStatusTooltip(scanResult) {
380
+ const { critical, high, medium, low, info } = scanResult.summary;
381
+ const lines = [
382
+ 'MUSUBIX Security Scan',
383
+ '─────────────────────',
384
+ `Critical: ${critical}`,
385
+ `High: ${high}`,
386
+ `Medium: ${medium}`,
387
+ `Low: ${low}`,
388
+ `Info: ${info}`,
389
+ '',
390
+ 'Click to view full report',
391
+ ];
392
+ return lines.join('\n');
393
+ }
394
+ getSeverityIcon(severity) {
395
+ const icons = {
396
+ critical: '$(error)',
397
+ high: '$(warning)',
398
+ medium: '$(info)',
399
+ low: '$(lightbulb)',
400
+ info: '$(note)',
401
+ };
402
+ return icons[severity];
403
+ }
404
+ getSeverityColor(severity) {
405
+ const colors = {
406
+ critical: '#cc0000',
407
+ high: '#ff8c00',
408
+ medium: '#ffcc00',
409
+ low: '#0066cc',
410
+ info: '#666666',
411
+ };
412
+ return colors[severity];
413
+ }
414
+ getSeverityBadge(severity) {
415
+ const emojis = {
416
+ critical: '🔴 CRITICAL',
417
+ high: '🟠 HIGH',
418
+ medium: '🟡 MEDIUM',
419
+ low: '🔵 LOW',
420
+ info: '⚪ INFO',
421
+ };
422
+ return emojis[severity];
423
+ }
424
+ vulnerabilityToTreeItem(vuln) {
425
+ return {
426
+ label: vuln.ruleId,
427
+ description: `${vuln.location.file}:${vuln.location.startLine}`,
428
+ tooltip: vuln.description,
429
+ iconPath: this.getSeverityIcon(vuln.severity),
430
+ collapsibleState: 'none',
431
+ command: {
432
+ title: 'Go to vulnerability',
433
+ command: 'musubix-security.goToVulnerability',
434
+ arguments: [vuln],
435
+ },
436
+ contextValue: 'vulnerability',
437
+ };
438
+ }
439
+ }
440
+ // ============================================================================
441
+ // Factory Functions
442
+ // ============================================================================
443
+ /**
444
+ * Create VS Code integration instance
445
+ */
446
+ export function createVSCodeIntegration(options) {
447
+ return new VSCodeIntegration(options);
448
+ }
449
+ //# sourceMappingURL=vscode-integration.js.map