@nerviq/cli 1.10.0 → 1.12.0
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.
- package/README.md +176 -47
- package/bin/cli.js +842 -287
- package/package.json +2 -2
- package/src/activity.js +225 -59
- package/src/adoption-advisor.js +299 -0
- package/src/aider/freshness.js +28 -25
- package/src/aider/techniques.js +16 -11
- package/src/analyze.js +131 -1
- package/src/anti-patterns.js +17 -2
- package/src/audit.js +197 -96
- package/src/behavioral-drift.js +801 -0
- package/src/benchmark.js +15 -10
- package/src/continuous-ops.js +681 -0
- package/src/cost-tracking.js +61 -0
- package/src/cursor/techniques.js +17 -12
- package/src/deep-review.js +83 -0
- package/src/diff-only.js +280 -0
- package/src/doctor.js +118 -55
- package/src/governance.js +72 -50
- package/src/hook-validation.js +342 -0
- package/src/index.js +7 -1
- package/src/integrations.js +144 -60
- package/src/mcp-validation.js +337 -0
- package/src/opencode/techniques.js +12 -7
- package/src/operating-profile.js +574 -0
- package/src/org.js +97 -13
- package/src/permission-rules.js +218 -0
- package/src/plans.js +192 -8
- package/src/platform-change-manifest.js +86 -0
- package/src/policy-layers.js +210 -0
- package/src/profiles.js +4 -1
- package/src/prompt-injection.js +74 -0
- package/src/repo-archetype.js +386 -0
- package/src/secret-patterns.js +9 -0
- package/src/server.js +398 -3
- package/src/setup.js +36 -2
- package/src/source-urls.js +132 -132
- package/src/supplemental-checks.js +13 -12
- package/src/techniques/api.js +407 -0
- package/src/techniques/automation.js +316 -0
- package/src/techniques/compliance.js +257 -0
- package/src/techniques/hygiene.js +294 -0
- package/src/techniques/instructions.js +243 -0
- package/src/techniques/observability.js +226 -0
- package/src/techniques/optimization.js +142 -0
- package/src/techniques/quality.js +317 -0
- package/src/techniques/security.js +237 -0
- package/src/techniques/shared.js +443 -0
- package/src/techniques/stacks.js +2294 -0
- package/src/techniques/tools.js +106 -0
- package/src/techniques/workflow.js +413 -0
- package/src/techniques.js +78 -5611
- package/src/terminology.js +73 -0
- package/src/token-estimate.js +35 -0
- package/src/watch.js +18 -0
- package/src/windsurf/techniques.js +17 -12
- package/src/workspace.js +105 -8
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function unique(values) {
|
|
4
|
+
return [...new Set((values || []).filter(Boolean))];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function hasAny(set, values) {
|
|
8
|
+
return values.some((value) => set.has(value));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function humanizeMaturity(maturity) {
|
|
12
|
+
const labels = {
|
|
13
|
+
none: 'No governed baseline yet',
|
|
14
|
+
starter: 'Starter baseline',
|
|
15
|
+
developing: 'Developing baseline',
|
|
16
|
+
mature: 'Mature governed baseline',
|
|
17
|
+
};
|
|
18
|
+
return labels[maturity] || maturity;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function detectTopology(ctx, pkg) {
|
|
22
|
+
const signals = [];
|
|
23
|
+
const hasPackageWorkspaces = Array.isArray(pkg.workspaces) ||
|
|
24
|
+
Boolean(pkg.workspaces && Array.isArray(pkg.workspaces.packages));
|
|
25
|
+
|
|
26
|
+
if (hasPackageWorkspaces) signals.push('package.json workspaces');
|
|
27
|
+
if (ctx.fileContent('pnpm-workspace.yaml')) signals.push('pnpm-workspace.yaml');
|
|
28
|
+
if (ctx.fileContent('nx.json')) signals.push('nx.json');
|
|
29
|
+
if (ctx.fileContent('turbo.json')) signals.push('turbo.json');
|
|
30
|
+
if (ctx.fileContent('lerna.json')) signals.push('lerna.json');
|
|
31
|
+
if (ctx.hasDir('packages')) signals.push('packages/');
|
|
32
|
+
if (ctx.hasDir('apps')) signals.push('apps/');
|
|
33
|
+
|
|
34
|
+
if (signals.length > 0) {
|
|
35
|
+
return {
|
|
36
|
+
key: 'monorepo',
|
|
37
|
+
label: 'Monorepo',
|
|
38
|
+
rationale: 'Workspace or multi-package signals indicate a shared-root repo topology.',
|
|
39
|
+
signals,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const multiSurfaceSignals = [];
|
|
44
|
+
if (ctx.hasDir('app')) multiSurfaceSignals.push('app/');
|
|
45
|
+
if (ctx.hasDir('api')) multiSurfaceSignals.push('api/');
|
|
46
|
+
if (ctx.hasDir('services')) multiSurfaceSignals.push('services/');
|
|
47
|
+
if (ctx.hasDir('workers')) multiSurfaceSignals.push('workers/');
|
|
48
|
+
|
|
49
|
+
if (multiSurfaceSignals.length >= 2) {
|
|
50
|
+
return {
|
|
51
|
+
key: 'multi-surface',
|
|
52
|
+
label: 'Multi-surface repo',
|
|
53
|
+
rationale: 'Several product/service surfaces live in one repository even without formal workspace tooling.',
|
|
54
|
+
signals: multiSurfaceSignals,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
key: 'single-repo',
|
|
60
|
+
label: 'Single-repo',
|
|
61
|
+
rationale: 'No workspace or multi-package signals detected.',
|
|
62
|
+
signals: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function detectStackFamily(stackKeys, domainKeys, ctx) {
|
|
67
|
+
if (hasAny(stackKeys, ['flutter', 'swift', 'kotlin']) || domainKeys.has('mobile')) {
|
|
68
|
+
return { key: 'mobile', label: 'Mobile', rationale: 'Native or mobile-platform stacks dominate the repo.' };
|
|
69
|
+
}
|
|
70
|
+
if (domainKeys.has('infra-platform') || domainKeys.has('devops-cicd') || hasAny(stackKeys, ['terraform', 'kubernetes', 'docker'])) {
|
|
71
|
+
return { key: 'infra', label: 'Infrastructure / platform', rationale: 'Deployment, infrastructure, or CI surfaces are central.' };
|
|
72
|
+
}
|
|
73
|
+
if (domainKeys.has('ai-ml') || domainKeys.has('data-pipeline') || ctx.hasDir('experiments') || ctx.hasDir('notebooks')) {
|
|
74
|
+
return { key: 'data-ml', label: 'Data / AI / ML', rationale: 'Pipeline, experiment, or model workflow signals are present.' };
|
|
75
|
+
}
|
|
76
|
+
const hasFrontend = hasAny(stackKeys, ['react', 'nextjs', 'vue', 'angular', 'svelte']) || ctx.hasDir('components');
|
|
77
|
+
const hasBackend = hasAny(stackKeys, ['node', 'python', 'django', 'fastapi', 'go', 'rust', 'java', 'ruby', 'php', 'dotnet']) || ctx.hasDir('api') || ctx.hasDir('services');
|
|
78
|
+
if (hasFrontend && hasBackend) {
|
|
79
|
+
return { key: 'fullstack', label: 'Full-stack application', rationale: 'Both UI and service-layer signals are present.' };
|
|
80
|
+
}
|
|
81
|
+
if (hasFrontend) {
|
|
82
|
+
return { key: 'frontend', label: 'Frontend application', rationale: 'UI and component signals dominate the repo.' };
|
|
83
|
+
}
|
|
84
|
+
if (hasBackend) {
|
|
85
|
+
return { key: 'backend', label: 'Backend service', rationale: 'Service, API, or backend stack signals dominate the repo.' };
|
|
86
|
+
}
|
|
87
|
+
if (domainKeys.has('docs-content')) {
|
|
88
|
+
return { key: 'docs', label: 'Docs / content', rationale: 'Documentation and content workflow signals dominate the repo.' };
|
|
89
|
+
}
|
|
90
|
+
return { key: 'general', label: 'General codebase', rationale: 'No strong stack family dominates yet.' };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function detectRepoClass({ ctx, pkg, domainKeys, stackKeys, topology }) {
|
|
94
|
+
const signals = [];
|
|
95
|
+
const hasFrontend = hasAny(stackKeys, ['react', 'nextjs', 'vue', 'angular', 'svelte']) || ctx.hasDir('components') || ctx.hasDir('pages');
|
|
96
|
+
const hasBackend = hasAny(stackKeys, ['node', 'python', 'django', 'fastapi', 'go', 'rust', 'java', 'ruby', 'php', 'dotnet']) || ctx.hasDir('api') || ctx.hasDir('services') || ctx.hasDir('routes');
|
|
97
|
+
const isInfra = domainKeys.has('infra-platform') || domainKeys.has('devops-cicd') || hasAny(stackKeys, ['terraform', 'kubernetes', 'docker']) || ctx.hasDir('infra') || ctx.hasDir('deploy') || ctx.hasDir('helm');
|
|
98
|
+
const isMl = domainKeys.has('ai-ml') || domainKeys.has('data-pipeline') || ctx.hasDir('experiments') || ctx.hasDir('datasets') || ctx.hasDir('notebooks');
|
|
99
|
+
const isMobile = hasAny(stackKeys, ['flutter', 'swift', 'kotlin']) || domainKeys.has('mobile') || ctx.hasDir('ios') || ctx.hasDir('android');
|
|
100
|
+
const isLibrary = domainKeys.has('oss-library') || ((!hasFrontend && !hasBackend) && Boolean(pkg.main || pkg.module || pkg.exports || pkg.types));
|
|
101
|
+
const isCli = domainKeys.has('cli-tool') || Boolean(pkg.bin) || ctx.hasDir('bin');
|
|
102
|
+
|
|
103
|
+
if (topology.key === 'monorepo' && isInfra) {
|
|
104
|
+
signals.push('workspace topology', 'infra / deploy signals');
|
|
105
|
+
return {
|
|
106
|
+
key: 'platform-monorepo',
|
|
107
|
+
label: 'Platform monorepo',
|
|
108
|
+
rationale: 'Shared-root workspace plus infrastructure signals indicate a platform-style repo.',
|
|
109
|
+
signals,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (topology.key === 'monorepo' && (hasFrontend || hasBackend)) {
|
|
114
|
+
signals.push('workspace topology', hasFrontend ? 'frontend signals' : null, hasBackend ? 'backend signals' : null);
|
|
115
|
+
return {
|
|
116
|
+
key: 'application-monorepo',
|
|
117
|
+
label: 'Application monorepo',
|
|
118
|
+
rationale: 'Multiple app/service surfaces share one governed root.',
|
|
119
|
+
signals: unique(signals),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isInfra) {
|
|
124
|
+
signals.push('infra / deploy signals');
|
|
125
|
+
return {
|
|
126
|
+
key: 'infra-platform',
|
|
127
|
+
label: 'Infrastructure / platform repo',
|
|
128
|
+
rationale: 'Infrastructure or release-engineering surfaces define the repo.',
|
|
129
|
+
signals,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (isMobile) {
|
|
134
|
+
signals.push('mobile stack signals');
|
|
135
|
+
return {
|
|
136
|
+
key: 'mobile-app',
|
|
137
|
+
label: 'Mobile application',
|
|
138
|
+
rationale: 'Mobile-native directories or stacks define the repo.',
|
|
139
|
+
signals,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (isMl) {
|
|
144
|
+
signals.push('data / ML workflow signals');
|
|
145
|
+
return {
|
|
146
|
+
key: 'data-ml-system',
|
|
147
|
+
label: 'Data / AI system',
|
|
148
|
+
rationale: 'Pipelines, experiments, or model workflows are central.',
|
|
149
|
+
signals,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (isCli) {
|
|
154
|
+
signals.push('CLI distribution surface');
|
|
155
|
+
return {
|
|
156
|
+
key: 'developer-tool',
|
|
157
|
+
label: 'Developer tool',
|
|
158
|
+
rationale: 'Command-line packaging or tool UX is part of the product contract.',
|
|
159
|
+
signals,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (isLibrary) {
|
|
164
|
+
signals.push('package export surface');
|
|
165
|
+
return {
|
|
166
|
+
key: 'library-sdk',
|
|
167
|
+
label: 'Library / SDK',
|
|
168
|
+
rationale: 'The repo behaves like a reusable package rather than a deployed application.',
|
|
169
|
+
signals,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (hasFrontend && hasBackend) {
|
|
174
|
+
signals.push('frontend signals', 'backend signals');
|
|
175
|
+
return {
|
|
176
|
+
key: 'fullstack-product',
|
|
177
|
+
label: 'Full-stack product',
|
|
178
|
+
rationale: 'UI and service layers coexist as one application surface.',
|
|
179
|
+
signals,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (hasFrontend) {
|
|
184
|
+
signals.push('frontend signals');
|
|
185
|
+
return {
|
|
186
|
+
key: 'frontend-product',
|
|
187
|
+
label: 'Frontend product',
|
|
188
|
+
rationale: 'UI and component workflows dominate the repo.',
|
|
189
|
+
signals,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (hasBackend) {
|
|
194
|
+
signals.push('backend signals');
|
|
195
|
+
return {
|
|
196
|
+
key: 'backend-service',
|
|
197
|
+
label: 'Backend service',
|
|
198
|
+
rationale: 'API or service workflows dominate the repo.',
|
|
199
|
+
signals,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
key: 'general-codebase',
|
|
205
|
+
label: 'General codebase',
|
|
206
|
+
rationale: 'No stronger repo class dominates yet.',
|
|
207
|
+
signals: [],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function detectWorkflowTraits({ ctx, platform, assets, maturity, topology, domainKeys, recommendedMcpPacks = [] }) {
|
|
212
|
+
const traits = [];
|
|
213
|
+
const hasCi = ctx.hasDir('.github/workflows') || ctx.hasDir('.circleci') || Boolean(ctx.fileContent('.gitlab-ci.yml')) || Boolean(ctx.fileContent('Jenkinsfile'));
|
|
214
|
+
const hasMcp = (assets && assets.counts && assets.counts.mcpServers > 0) || (recommendedMcpPacks || []).length > 0;
|
|
215
|
+
const hasGovernanceSignals = domainKeys.has('enterprise-governed') || domainKeys.has('regulated-lite') || domainKeys.has('security-focused');
|
|
216
|
+
|
|
217
|
+
if (hasGovernanceSignals && hasCi) {
|
|
218
|
+
traits.push({
|
|
219
|
+
key: 'governed-rollout',
|
|
220
|
+
label: 'Governed rollout',
|
|
221
|
+
rationale: 'CI plus governance/regulatory signals suggest reviewable rollout discipline.',
|
|
222
|
+
signals: unique([
|
|
223
|
+
domainKeys.has('enterprise-governed') ? 'enterprise-governed pack' : null,
|
|
224
|
+
domainKeys.has('regulated-lite') ? 'regulated-lite pack' : null,
|
|
225
|
+
domainKeys.has('security-focused') ? 'security-focused pack' : null,
|
|
226
|
+
hasCi ? 'CI workflows' : null,
|
|
227
|
+
]),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (topology.key === 'monorepo') {
|
|
232
|
+
traits.push({
|
|
233
|
+
key: 'workspace-coordinated',
|
|
234
|
+
label: 'Workspace-coordinated',
|
|
235
|
+
rationale: 'The repo needs path-aware and package-aware workflow coordination.',
|
|
236
|
+
signals: ['workspace topology'],
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (hasCi) {
|
|
241
|
+
traits.push({
|
|
242
|
+
key: 'ci-driven',
|
|
243
|
+
label: 'CI-driven',
|
|
244
|
+
rationale: 'Automated CI surfaces are part of the normal engineering loop.',
|
|
245
|
+
signals: ['CI workflows'],
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (hasMcp) {
|
|
250
|
+
traits.push({
|
|
251
|
+
key: 'tool-enriched',
|
|
252
|
+
label: 'Tool-enriched',
|
|
253
|
+
rationale: 'Live MCP or external-context tooling is part of the intended workflow.',
|
|
254
|
+
signals: unique([
|
|
255
|
+
assets && assets.counts && assets.counts.mcpServers > 0 ? 'declared MCP servers' : null,
|
|
256
|
+
recommendedMcpPacks.length > 0 ? 'recommended MCP packs' : null,
|
|
257
|
+
]),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (maturity === 'mature' || maturity === 'developing') {
|
|
262
|
+
traits.push({
|
|
263
|
+
key: 'managed',
|
|
264
|
+
label: 'Managed baseline',
|
|
265
|
+
rationale: 'The repo already has enough governance assets that Nerviq should extend, not replace, the current baseline.',
|
|
266
|
+
signals: [humanizeMaturity(maturity)],
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (traits.length === 0) {
|
|
271
|
+
traits.push({
|
|
272
|
+
key: 'bootstrap-local',
|
|
273
|
+
label: 'Bootstrap local workflow',
|
|
274
|
+
rationale: 'The repo still looks early-stage and should start from a simple local baseline.',
|
|
275
|
+
signals: [humanizeMaturity(maturity)],
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return traits;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function detectRiskProfile({ ctx, platform, assets, domainKeys, maturity }) {
|
|
283
|
+
const reasons = [];
|
|
284
|
+
|
|
285
|
+
if (domainKeys.has('regulated-lite')) reasons.push('regulated-lite pack');
|
|
286
|
+
if (domainKeys.has('security-focused')) reasons.push('security-focused pack');
|
|
287
|
+
if (ctx.files.includes('SECURITY.md')) reasons.push('SECURITY.md');
|
|
288
|
+
if (ctx.files.includes('COMPLIANCE.md') || ctx.hasDir('compliance') || ctx.hasDir('policies')) reasons.push('compliance surface');
|
|
289
|
+
|
|
290
|
+
if (platform === 'codex' && assets && assets.trust) {
|
|
291
|
+
if (assets.trust.approvalPolicy === 'never') reasons.push('approval_policy=never');
|
|
292
|
+
if (assets.trust.sandboxMode === 'danger-full-access') reasons.push('sandbox_mode=danger-full-access');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (platform !== 'codex' && assets && assets.permissions) {
|
|
296
|
+
if (assets.permissions.defaultMode === 'bypassPermissions') reasons.push('bypassPermissions');
|
|
297
|
+
if (!assets.permissions.hasDenyRules) reasons.push('missing deny rules');
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (domainKeys.has('enterprise-governed')) reasons.push('enterprise-governed pack');
|
|
301
|
+
|
|
302
|
+
let key = 'standard';
|
|
303
|
+
let label = 'Standard';
|
|
304
|
+
let level = 'medium';
|
|
305
|
+
let rationale = 'No strong regulatory or unusually permissive-risk posture dominates the repo.';
|
|
306
|
+
|
|
307
|
+
if (reasons.some((reason) => /regulated|compliance|SECURITY|security-focused/i.test(reason))) {
|
|
308
|
+
key = 'regulated';
|
|
309
|
+
label = 'Regulated / security-sensitive';
|
|
310
|
+
level = 'high';
|
|
311
|
+
rationale = 'Compliance or security-sensitive signals mean recommendations should skew toward traceability and review.';
|
|
312
|
+
} else if (reasons.some((reason) => /bypassPermissions|danger-full-access|approval_policy=never/i.test(reason))) {
|
|
313
|
+
key = 'elevated';
|
|
314
|
+
label = 'Elevated operational risk';
|
|
315
|
+
level = 'high';
|
|
316
|
+
rationale = 'The repo is configured with permissive runtime posture that increases blast radius.';
|
|
317
|
+
} else if (maturity === 'none' || maturity === 'starter') {
|
|
318
|
+
key = 'bootstrap';
|
|
319
|
+
label = 'Bootstrap risk';
|
|
320
|
+
level = 'medium';
|
|
321
|
+
rationale = 'The main risk is missing baseline governance, not over-permissive automation.';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
key,
|
|
326
|
+
label,
|
|
327
|
+
level,
|
|
328
|
+
rationale,
|
|
329
|
+
reasons: unique(reasons),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function buildRepoArchetypeProfile(options) {
|
|
334
|
+
const {
|
|
335
|
+
ctx,
|
|
336
|
+
platform,
|
|
337
|
+
stacks = [],
|
|
338
|
+
assets,
|
|
339
|
+
recommendedDomainPacks = [],
|
|
340
|
+
recommendedMcpPacks = [],
|
|
341
|
+
maturity = 'none',
|
|
342
|
+
} = options || {};
|
|
343
|
+
|
|
344
|
+
const pkg = ctx && typeof ctx.jsonFile === 'function' ? (ctx.jsonFile('package.json') || {}) : {};
|
|
345
|
+
const stackKeys = new Set((stacks || []).map((stack) => stack.key));
|
|
346
|
+
const domainKeys = new Set((recommendedDomainPacks || []).map((pack) => pack.key));
|
|
347
|
+
|
|
348
|
+
const topology = detectTopology(ctx, pkg);
|
|
349
|
+
const stackFamily = detectStackFamily(stackKeys, domainKeys, ctx);
|
|
350
|
+
const repoClass = detectRepoClass({ ctx, pkg, domainKeys, stackKeys, topology });
|
|
351
|
+
const workflowTraits = detectWorkflowTraits({ ctx, platform, assets, maturity, topology, domainKeys, recommendedMcpPacks });
|
|
352
|
+
const primaryWorkflow = workflowTraits[0];
|
|
353
|
+
const riskProfile = detectRiskProfile({ ctx, platform, assets, domainKeys, maturity });
|
|
354
|
+
const signals = unique([
|
|
355
|
+
stackFamily.label,
|
|
356
|
+
...topology.signals,
|
|
357
|
+
...repoClass.signals,
|
|
358
|
+
...workflowTraits.flatMap((trait) => trait.signals || []),
|
|
359
|
+
...riskProfile.reasons,
|
|
360
|
+
...recommendedDomainPacks.slice(0, 3).map((pack) => pack.key),
|
|
361
|
+
]);
|
|
362
|
+
|
|
363
|
+
const confidence = signals.length >= 6 ? 'high' : signals.length >= 3 ? 'medium' : 'low';
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
key: `${topology.key}:${repoClass.key}`,
|
|
367
|
+
label: repoClass.label,
|
|
368
|
+
summary: `${repoClass.label} with ${topology.label.toLowerCase()} topology, ${primaryWorkflow.label.toLowerCase()} workflow, and ${riskProfile.label.toLowerCase()} posture.`,
|
|
369
|
+
confidence,
|
|
370
|
+
stackFamily,
|
|
371
|
+
topology,
|
|
372
|
+
maturity: {
|
|
373
|
+
key: maturity,
|
|
374
|
+
label: humanizeMaturity(maturity),
|
|
375
|
+
},
|
|
376
|
+
repoClass,
|
|
377
|
+
primaryWorkflow,
|
|
378
|
+
workflowTraits,
|
|
379
|
+
riskProfile,
|
|
380
|
+
signals: signals.slice(0, 8),
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
module.exports = {
|
|
385
|
+
buildRepoArchetypeProfile,
|
|
386
|
+
};
|
package/src/secret-patterns.js
CHANGED
|
@@ -5,6 +5,15 @@ const EMBEDDED_SECRET_PATTERNS = [
|
|
|
5
5
|
/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,
|
|
6
6
|
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
|
|
7
7
|
/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,
|
|
8
|
+
/\bAZURE(?:_[A-Z0-9]+){0,4}_(?:API_)?KEY\s*[:=]\s*['"]?[A-Za-z0-9+/=_-]{20,}['"]?/g,
|
|
9
|
+
/\bDefaultEndpointsProtocol=https;AccountName=[^;\s]+;AccountKey=[A-Za-z0-9+/=]{20,};EndpointSuffix=core\.windows\.net\b/gi,
|
|
10
|
+
/\bEndpoint=sb:\/\/[^\s;]+;SharedAccessKeyName=[^;\s]+;SharedAccessKey=[A-Za-z0-9+/=]{20,}\b/gi,
|
|
11
|
+
/\b(?:postgres(?:ql)?|mysql|mariadb|mongodb(?:\+srv)?|redis|rediss|amqp):\/\/[^:\s/]+:[^@\s]{4,}@[^/\s]+(?:\/[^\s'"]*)?/gi,
|
|
12
|
+
/\b(?:Server|Host|Data Source)\s*=\s*[^;\n]+;[^\n]*(?:Password|Pwd)\s*=\s*[^;\n]{4,}/gi,
|
|
13
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
|
|
14
|
+
/-----BEGIN (?:OPENSSH|RSA|DSA|EC) PRIVATE KEY-----[\s\S]{40,}?-----END (?:OPENSSH|RSA|DSA|EC) PRIVATE KEY-----/g,
|
|
15
|
+
/-----BEGIN PRIVATE KEY-----[\s\S]{40,}?-----END PRIVATE KEY-----/g,
|
|
16
|
+
/"type"\s*:\s*"service_account"[\s\S]{0,1200}?"client_email"\s*:\s*"[^\"]+@[^"]*gserviceaccount\.com"[\s\S]{0,1200}?"private_key"\s*:\s*"-----BEGIN PRIVATE KEY-----[\s\S]{20,}?-----END PRIVATE KEY-----\\n?"/g,
|
|
8
17
|
];
|
|
9
18
|
|
|
10
19
|
function containsEmbeddedSecret(text = '') {
|