-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.js
More file actions
290 lines (265 loc) · 11.4 KB
/
config.js
File metadata and controls
290 lines (265 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/**
* Kill Chain Visualizer Configuration
*
* Central configuration file for colors, settings, and other parameters.
* Import this file in HTML pages to use consistent theming.
*/
const CONFIG = {
// Application info
version: '2.9.1',
changelogUrl: 'CHANGELOG.md',
// Framework source files (for extraction scripts)
sources: {
// CAPEC XML files
capec: {
domains: 'frameworks/CAPEC/DOMAINS.xml',
mechanisms: 'frameworks/CAPEC/MECHANISMS.xml'
},
// CWE XML files
cwe: {
hardware: 'frameworks/CWE/HARDWARE.xml',
software: 'frameworks/CWE/SOFTWARE.xml',
all: 'frameworks/CWE/ALL.xml'
},
// ATT&CK STIX bundles (v18.1 as of 01/2026)
attack: {
version: '18.1',
enterprise: 'frameworks/ATTCK/ENTERPRISE.json',
mobile: 'frameworks/ATTCK/MOBILE.json',
ics: 'frameworks/ATTCK/ICS.json'
}
},
// JSON sanitization paths (glob patterns, relative to project root)
sanitize: {
paths: [
'resources/**/*.json',
'frameworks/ATTCK/**/*.json'
]
},
// Phase colors (IN/THROUGH/OUT) - distinct from framework colors
phases: {
in: '#10b981', // Emerald green - entry/initial foothold
through: '#06b6d4', // Cyan - movement/propagation
out: '#ef4444' // Red - impact/action on objectives
},
// Framework colors (ATT&CK/CAPEC/CWE/Custom)
frameworks: {
attack: '#3b82f6', // Blue
capec: '#8b5cf6', // Purple
cwe: '#f59e0b', // Orange
custom: '#14b8a6' // Teal
},
// STIX 2.1 SDO types available for custom items
stixTypes: [
{ value: 'attack-pattern', label: 'Attack Pattern' },
{ value: 'campaign', label: 'Campaign' },
{ value: 'course-of-action', label: 'Course of Action' },
{ value: 'grouping', label: 'Grouping' },
{ value: 'identity', label: 'Identity' },
{ value: 'indicator', label: 'Indicator' },
{ value: 'infrastructure', label: 'Infrastructure' },
{ value: 'intrusion-set', label: 'Intrusion Set' },
{ value: 'location', label: 'Location' },
{ value: 'malware', label: 'Malware' },
{ value: 'malware-analysis', label: 'Malware Analysis' },
{ value: 'note', label: 'Note' },
{ value: 'observed-data', label: 'Observed Data' },
{ value: 'opinion', label: 'Opinion' },
{ value: 'report', label: 'Report' },
{ value: 'threat-actor', label: 'Threat Actor' },
{ value: 'tool', label: 'Tool' },
{ value: 'vulnerability', label: 'Vulnerability' },
{ value: 'x-custom', label: 'Custom' }
],
// UI colors (fallbacks, match default light theme)
ui: {
bgDark: '#f8fafc',
bgCard: '#ffffff',
bgPhase: '#f1f5f9',
textPrimary: '#0f172a',
textSecondary: '#475569',
borderColor: '#e2e8f0',
accent: '#94a3b8'
},
// Metadata icon colors (fallbacks)
metaIcons: {
defaultBg: 'rgba(255, 255, 255, 0.15)',
defaultFg: '#0f172a',
cveBg: 'rgba(239, 68, 68, 0.3)',
cveFg: '#fca5a5',
observableBg: 'rgba(59, 130, 246, 0.3)',
observableFg: '#93c5fd',
linkBg: 'rgba(139, 92, 246, 0.3)',
linkFg: '#c4b5fd',
commentBg: 'rgba(34, 197, 94, 0.3)',
commentFg: '#86efac',
confidenceBg: 'rgba(251, 191, 36, 0.3)',
confidenceFg: '#fcd34d',
brightness: 0.75
},
// Theme presets (light/dark) with optional schemes
themes: {
dark: {
default: {
ui: {
bgDark: '#1a1a1a',
bgCard: '#242424',
bgPhase: '#2d2d2d',
textPrimary: '#e5e5e5',
textSecondary: '#a3a3a3',
borderColor: '#404040',
accent: '#71717a'
},
metaIcons: {
defaultBg: 'rgba(255, 255, 255, 0.15)',
defaultFg: '#e5e5e5',
cveBg: 'rgba(239, 68, 68, 0.3)',
cveFg: '#fca5a5',
observableBg: 'rgba(59, 130, 246, 0.3)',
observableFg: '#93c5fd',
linkBg: 'rgba(139, 92, 246, 0.3)',
linkFg: '#c4b5fd',
commentBg: 'rgba(34, 197, 94, 0.3)',
commentFg: '#86efac',
confidenceBg: 'rgba(251, 191, 36, 0.3)',
confidenceFg: '#fcd34d',
brightness: 1
}
}
},
light: {
default: {
ui: {
bgDark: '#f8fafc',
bgCard: '#ffffff',
bgPhase: '#f1f5f9',
textPrimary: '#0f172a',
textSecondary: '#475569',
borderColor: '#e2e8f0',
accent: '#94a3b8'
},
metaIcons: {
defaultBg: 'rgba(15, 23, 42, 0.08)',
defaultFg: '#0f172a',
cveBg: 'rgba(239, 68, 68, 0.3)',
cveFg: '#fca5a5',
observableBg: 'rgba(59, 130, 246, 0.3)',
observableFg: '#93c5fd',
linkBg: 'rgba(139, 92, 246, 0.3)',
linkFg: '#c4b5fd',
commentBg: 'rgba(34, 197, 94, 0.3)',
commentFg: '#86efac',
confidenceBg: 'rgba(251, 191, 36, 0.3)',
confidenceFg: '#fcd34d',
brightness: 0.75
}
}
}
},
// Theme defaults
themeDefaults: {
mode: 'light',
scheme: 'default'
},
// Initial theme mode: 'light', 'dark', or 'auto' (OS preference)
themeMode: 'auto',
// Future config placeholders
display: {
maxNameLength: 200, // Max width for entity names in tags
maxDescLength: 800, // Max description length in detail panel
maxMitigations: 20, // Max mitigations to show
maxReferences: 3, // Max references to show
maxTitleLength: 200, // Max kill chain title length
maxCustomLabels: 20, // Max labels per custom STIX item
maxLabelLength: 50, // Max chars per label
maxCustomDescLength: 2000, // Max description length for custom items
maxKillChainDescLength: 2000 // Max kill chain description length
},
// Import behavior
imports: {
clearStixOnBundleImport: false, // Auto-clear STIX library before importing a STIX bundle
clearStixOnKillChainImport: true // Auto-clear STIX library before importing a kill chain
},
// Debugging controls
debugging: {
traceLocalIframeIPCLogs: false, // Enable full local iframe IPC trace logs in console
localIframeIPCRateLimit: {
enabled: true, // Apply request throttling for local iframe IPC request messages
refillPerSecond: 1, // Token refill rate per second
burst: 2 // Max burst per frame per request type
},
localIframeIPCBootstrap: {
timeoutMs: 1200, // Per-attempt bootstrap timeout in milliseconds
maxRetries: 3, // Total bootstrap attempts before terminal failure
retryBaseDelayMs: 250, // Base delay before retry attempts
retryBackoffMultiplier: 2, // Exponential backoff multiplier
maxRetryDelayMs: 2000, // Upper bound for retry delay
graceMs: 300 // Extra wait for child-side terminal-failure watch
}
},
// Local iframe IPC behavior
ConfigIframeIPC: {
enableLocalIframeIPC: false // Enable iframe IPC bridge only for file:// local mode
},
// Navigation behavior
navigation: {
confirmOnLeave: true, // Show confirmation dialog before leaving the page
showStixBuilder: true // Toggle STIX Composer view in navigation
},
// Visualizer behavior
visualizer: {
enabled: true // Disable to prevent visualizer resources from loading/executing
}
};
// Resolve a theme from mode/scheme and merge with defaults
function resolveTheme(mode = CONFIG.themeDefaults?.mode, scheme = CONFIG.themeDefaults?.scheme) {
const modeThemes = CONFIG.themes?.[mode] || CONFIG.themes?.dark || {};
const schemeTheme = modeThemes[scheme] || modeThemes.default || {};
return {
phases: { ...CONFIG.phases, ...(schemeTheme.phases || {}) },
frameworks: { ...CONFIG.frameworks, ...(schemeTheme.frameworks || {}) },
ui: { ...CONFIG.ui, ...(schemeTheme.ui || {}) },
metaIcons: { ...CONFIG.metaIcons, ...(schemeTheme.metaIcons || {}) }
};
}
// Apply config colors to CSS variables
function applyConfigColors(theme) {
const resolved = theme || resolveTheme();
const root = document.documentElement;
// Phase colors
root.style.setProperty('--phase-in', resolved.phases.in);
root.style.setProperty('--phase-through', resolved.phases.through);
root.style.setProperty('--phase-out', resolved.phases.out);
// Framework colors
root.style.setProperty('--attack-color', resolved.frameworks.attack);
root.style.setProperty('--capec-color', resolved.frameworks.capec);
root.style.setProperty('--cwe-color', resolved.frameworks.cwe);
root.style.setProperty('--custom-color', resolved.frameworks.custom);
// UI colors
root.style.setProperty('--bg-dark', resolved.ui.bgDark);
root.style.setProperty('--bg-card', resolved.ui.bgCard);
root.style.setProperty('--bg-phase', resolved.ui.bgPhase);
root.style.setProperty('--bg-panel', resolved.ui.bgPhase);
root.style.setProperty('--text-primary', resolved.ui.textPrimary);
root.style.setProperty('--text-secondary', resolved.ui.textSecondary);
root.style.setProperty('--border-color', resolved.ui.borderColor);
root.style.setProperty('--accent', resolved.ui.accent);
// Metadata icon colors
root.style.setProperty('--meta-default-bg', resolved.metaIcons.defaultBg);
root.style.setProperty('--meta-default-fg', resolved.metaIcons.defaultFg);
root.style.setProperty('--meta-cve-bg', resolved.metaIcons.cveBg);
root.style.setProperty('--meta-cve-fg', resolved.metaIcons.cveFg);
root.style.setProperty('--meta-observable-bg', resolved.metaIcons.observableBg);
root.style.setProperty('--meta-observable-fg', resolved.metaIcons.observableFg);
root.style.setProperty('--meta-link-bg', resolved.metaIcons.linkBg);
root.style.setProperty('--meta-link-fg', resolved.metaIcons.linkFg);
root.style.setProperty('--meta-comment-bg', resolved.metaIcons.commentBg);
root.style.setProperty('--meta-comment-fg', resolved.metaIcons.commentFg);
root.style.setProperty('--meta-confidence-bg', resolved.metaIcons.confidenceBg);
root.style.setProperty('--meta-confidence-fg', resolved.metaIcons.confidenceFg);
root.style.setProperty('--meta-icon-brightness', resolved.metaIcons.brightness);
}
// Export for module usage (if needed)
if (typeof module !== 'undefined' && module.exports) {
module.exports = { CONFIG, resolveTheme, applyConfigColors };
}