hackmyagent 0.11.14 → 0.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.
Files changed (73) hide show
  1. package/README.md +35 -3
  2. package/dist/.integrity-manifest.json +1 -0
  3. package/dist/cli.js +79 -5
  4. package/dist/cli.js.map +1 -1
  5. package/dist/nanomind-core/analyzers/capability-analyzer.d.ts +40 -0
  6. package/dist/nanomind-core/analyzers/capability-analyzer.d.ts.map +1 -0
  7. package/dist/nanomind-core/analyzers/capability-analyzer.js +310 -0
  8. package/dist/nanomind-core/analyzers/capability-analyzer.js.map +1 -0
  9. package/dist/nanomind-core/analyzers/code-analyzer.d.ts +21 -0
  10. package/dist/nanomind-core/analyzers/code-analyzer.d.ts.map +1 -0
  11. package/dist/nanomind-core/analyzers/code-analyzer.js +350 -0
  12. package/dist/nanomind-core/analyzers/code-analyzer.js.map +1 -0
  13. package/dist/nanomind-core/analyzers/credential-analyzer.d.ts +20 -0
  14. package/dist/nanomind-core/analyzers/credential-analyzer.d.ts.map +1 -0
  15. package/dist/nanomind-core/analyzers/credential-analyzer.js +317 -0
  16. package/dist/nanomind-core/analyzers/credential-analyzer.js.map +1 -0
  17. package/dist/nanomind-core/analyzers/governance-analyzer.d.ts +22 -0
  18. package/dist/nanomind-core/analyzers/governance-analyzer.d.ts.map +1 -0
  19. package/dist/nanomind-core/analyzers/governance-analyzer.js +393 -0
  20. package/dist/nanomind-core/analyzers/governance-analyzer.js.map +1 -0
  21. package/dist/nanomind-core/analyzers/prompt-analyzer.d.ts +22 -0
  22. package/dist/nanomind-core/analyzers/prompt-analyzer.d.ts.map +1 -0
  23. package/dist/nanomind-core/analyzers/prompt-analyzer.js +486 -0
  24. package/dist/nanomind-core/analyzers/prompt-analyzer.js.map +1 -0
  25. package/dist/nanomind-core/analyzers/scope-analyzer.d.ts +20 -0
  26. package/dist/nanomind-core/analyzers/scope-analyzer.d.ts.map +1 -0
  27. package/dist/nanomind-core/analyzers/scope-analyzer.js +326 -0
  28. package/dist/nanomind-core/analyzers/scope-analyzer.js.map +1 -0
  29. package/dist/nanomind-core/compiler/semantic-compiler.d.ts +41 -0
  30. package/dist/nanomind-core/compiler/semantic-compiler.d.ts.map +1 -0
  31. package/dist/nanomind-core/compiler/semantic-compiler.js +490 -0
  32. package/dist/nanomind-core/compiler/semantic-compiler.js.map +1 -0
  33. package/dist/nanomind-core/index.d.ts +30 -0
  34. package/dist/nanomind-core/index.d.ts.map +1 -0
  35. package/dist/nanomind-core/index.js +45 -0
  36. package/dist/nanomind-core/index.js.map +1 -0
  37. package/dist/nanomind-core/ingestion/artifact-parser.d.ts +48 -0
  38. package/dist/nanomind-core/ingestion/artifact-parser.d.ts.map +1 -0
  39. package/dist/nanomind-core/ingestion/artifact-parser.js +203 -0
  40. package/dist/nanomind-core/ingestion/artifact-parser.js.map +1 -0
  41. package/dist/nanomind-core/ingestion/input-sanitizer.d.ts +49 -0
  42. package/dist/nanomind-core/ingestion/input-sanitizer.d.ts.map +1 -0
  43. package/dist/nanomind-core/ingestion/input-sanitizer.js +80 -0
  44. package/dist/nanomind-core/ingestion/input-sanitizer.js.map +1 -0
  45. package/dist/nanomind-core/scanner-bridge.d.ts +49 -0
  46. package/dist/nanomind-core/scanner-bridge.d.ts.map +1 -0
  47. package/dist/nanomind-core/scanner-bridge.js +317 -0
  48. package/dist/nanomind-core/scanner-bridge.js.map +1 -0
  49. package/dist/nanomind-core/security/defense-in-depth.d.ts +99 -0
  50. package/dist/nanomind-core/security/defense-in-depth.d.ts.map +1 -0
  51. package/dist/nanomind-core/security/defense-in-depth.js +206 -0
  52. package/dist/nanomind-core/security/defense-in-depth.js.map +1 -0
  53. package/dist/nanomind-core/security/integrity-verifier.d.ts +132 -0
  54. package/dist/nanomind-core/security/integrity-verifier.d.ts.map +1 -0
  55. package/dist/nanomind-core/security/integrity-verifier.js +437 -0
  56. package/dist/nanomind-core/security/integrity-verifier.js.map +1 -0
  57. package/dist/nanomind-core/types.d.ts +125 -0
  58. package/dist/nanomind-core/types.d.ts.map +1 -0
  59. package/dist/nanomind-core/types.js +22 -0
  60. package/dist/nanomind-core/types.js.map +1 -0
  61. package/dist/semantic/index.d.ts +2 -0
  62. package/dist/semantic/index.d.ts.map +1 -1
  63. package/dist/semantic/index.js +6 -2
  64. package/dist/semantic/index.js.map +1 -1
  65. package/dist/semantic/nanomind-enhancer.d.ts +50 -0
  66. package/dist/semantic/nanomind-enhancer.d.ts.map +1 -0
  67. package/dist/semantic/nanomind-enhancer.js +203 -0
  68. package/dist/semantic/nanomind-enhancer.js.map +1 -0
  69. package/dist/skills/builder.d.ts +55 -0
  70. package/dist/skills/builder.d.ts.map +1 -0
  71. package/dist/skills/builder.js +282 -0
  72. package/dist/skills/builder.js.map +1 -0
  73. package/package.json +2 -2
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ /**
3
+ * Credential Analyzer -- AST-based AST-CRED-* checks
4
+ *
5
+ * Queries the SecurityAST for credential exposure patterns instead of
6
+ * regex-matching raw text. Understands data flow through AST.declaredDataAccess
7
+ * and distinguishes real credentials from test fixtures and documentation.
8
+ *
9
+ * Checks:
10
+ * AST-CRED-001: Credentials in non-environment contexts
11
+ * AST-CRED-002: Credential forwarding to external destinations
12
+ * AST-CRED-003: Hardcoded secrets in artifact content
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.analyzeCredentials = analyzeCredentials;
16
+ const defense_in_depth_js_1 = require("../security/defense-in-depth.js");
17
+ // ============================================================================
18
+ // Public API
19
+ // ============================================================================
20
+ /**
21
+ * Analyze a SecurityAST for credential-related security issues.
22
+ * Verifies AST integrity before processing.
23
+ */
24
+ function analyzeCredentials(ast, verifier) {
25
+ (0, defense_in_depth_js_1.assertASTIntegrity)(ast, verifier);
26
+ const findings = [];
27
+ findings.push(...checkCredentialsInNonEnvContext(ast));
28
+ findings.push(...checkCredentialForwarding(ast));
29
+ findings.push(...checkHardcodedSecrets(ast));
30
+ return findings;
31
+ }
32
+ // ============================================================================
33
+ // AST-CRED-001: Credentials in non-environment contexts
34
+ // ============================================================================
35
+ /**
36
+ * Detects credential data access patterns that occur outside of proper
37
+ * environment variable / secret manager contexts. Skills and configs
38
+ * should reference credentials via env vars, not inline.
39
+ *
40
+ * Uses AST.declaredDataAccess to find credential-type data patterns
41
+ * and checks whether the artifact type is an appropriate context.
42
+ */
43
+ function checkCredentialsInNonEnvContext(ast) {
44
+ const findings = [];
45
+ // Env files and credential files are expected to contain credentials
46
+ const safeContextTypes = new Set(['env_file', 'credential_file']);
47
+ if (safeContextTypes.has(ast.artifactType)) {
48
+ return findings;
49
+ }
50
+ const credentialAccess = ast.declaredDataAccess.filter(d => d.dataType === 'credentials');
51
+ if (credentialAccess.length === 0) {
52
+ return findings;
53
+ }
54
+ // Check if evidence spans suggest these are documentation examples or test fixtures
55
+ const isDocOrTest = isDocumentationOrTestContext(ast);
56
+ for (const access of credentialAccess) {
57
+ // Credential reads in skills/configs/source code are suspicious
58
+ // unless the artifact is clearly documentation or test fixture
59
+ if (isDocOrTest) {
60
+ continue;
61
+ }
62
+ const severity = deriveSeverity(access, ast);
63
+ findings.push({
64
+ checkId: 'AST-CRED-001',
65
+ name: 'Credentials in Non-Environment Context',
66
+ description: `Credential data (${access.accessMode}) detected in a ${ast.artifactType} artifact. ` +
67
+ 'Credentials should only be referenced via environment variables or secret managers, ' +
68
+ 'never embedded in skills, configs, or source code.',
69
+ category: 'Credential Security',
70
+ severity,
71
+ passed: false,
72
+ message: `Credential ${access.accessMode} in ${ast.artifactType} context`,
73
+ fixable: true,
74
+ file: ast.artifactPath,
75
+ fix: 'Replace inline credentials with environment variable references (e.g., $API_KEY or process.env.API_KEY). ' +
76
+ 'Use a secret manager for production deployments.',
77
+ guidance: 'Credentials embedded in non-env artifacts can be leaked through version control, ' +
78
+ 'logs, or prompt injection attacks that extract artifact content.',
79
+ attackClass: 'CRED-EXPOSURE',
80
+ confidence: isDocOrTest ? 0.3 : 0.8,
81
+ });
82
+ }
83
+ return findings;
84
+ }
85
+ // ============================================================================
86
+ // AST-CRED-002: Credential forwarding patterns
87
+ // ============================================================================
88
+ /**
89
+ * Detects credentials being transmitted to external destinations.
90
+ * Cross-references AST.declaredDataAccess (transmit mode) with
91
+ * credential data types to find forwarding patterns.
92
+ */
93
+ function checkCredentialForwarding(ast) {
94
+ const findings = [];
95
+ // Find credential data that is transmitted externally
96
+ // Direct: credentials type with transmit mode
97
+ const directCredTransmit = ast.declaredDataAccess.filter(d => d.dataType === 'credentials' && d.accessMode === 'transmit');
98
+ // Indirect: credentials type (read) combined with any transmit pattern
99
+ const hasCredentialAccess = ast.declaredDataAccess.some(d => d.dataType === 'credentials');
100
+ const hasExternalTransmit = ast.declaredDataAccess.some(d => d.accessMode === 'transmit');
101
+ const hasExfilRisk = ast.inferredRiskSurface.some(r => r.attackClass === 'SKILL-EXFIL' || r.attackClass === 'DATA-EXFIL');
102
+ // Combine direct transmissions with indirect patterns
103
+ const credentialTransmissions = [];
104
+ for (const d of directCredTransmit) {
105
+ credentialTransmissions.push({ destination: d.destination ?? 'unknown endpoint' });
106
+ }
107
+ // If credentials are accessed AND there's external transmission, flag it
108
+ if (directCredTransmit.length === 0 && hasCredentialAccess && hasExternalTransmit) {
109
+ credentialTransmissions.push({ destination: 'external endpoint' });
110
+ }
111
+ // If credentials are accessed AND there's an exfiltration risk surface
112
+ if (directCredTransmit.length === 0 && credentialTransmissions.length === 0 && hasCredentialAccess && hasExfilRisk) {
113
+ credentialTransmissions.push({ destination: 'external (inferred from exfiltration risk)' });
114
+ }
115
+ for (const transmission of credentialTransmissions) {
116
+ const destination = transmission.destination;
117
+ // Cross-check with risk surfaces for corroboration
118
+ const corroboratingRisk = ast.inferredRiskSurface.find(r => r.attackClass === 'CRED-HARVEST' || r.attackClass === 'SKILL-EXFIL');
119
+ const confidence = corroboratingRisk
120
+ ? Math.max(corroboratingRisk.confidence, 0.8)
121
+ : 0.7;
122
+ findings.push({
123
+ checkId: 'AST-CRED-002',
124
+ name: 'Credential Forwarding Detected',
125
+ description: `Credentials are being transmitted to ${destination}. ` +
126
+ 'Credential forwarding is a primary exfiltration vector. ' +
127
+ 'Even legitimate logging must never include credential values.',
128
+ category: 'Credential Security',
129
+ severity: 'critical',
130
+ passed: false,
131
+ message: `Credential forwarding to ${destination}`,
132
+ fixable: true,
133
+ file: ast.artifactPath,
134
+ fix: `Remove credential transmission to ${destination}. ` +
135
+ 'If external auth is needed, use OAuth token exchange or a credential broker. ' +
136
+ 'Never forward raw credentials.',
137
+ guidance: 'Credential forwarding enables account takeover. Even forwarding to "trusted" ' +
138
+ 'endpoints is risky because the destination can be compromised or spoofed.',
139
+ attackClass: 'CRED-EXFIL',
140
+ confidence,
141
+ evidence: corroboratingRisk?.evidence,
142
+ });
143
+ }
144
+ // Also check: capabilities that imply credential forwarding
145
+ const forwardingCaps = ast.inferredCapabilities.filter(c => c.name.includes('send') || c.name.includes('transmit') || c.name.includes('forward'));
146
+ for (const cap of forwardingCaps) {
147
+ const mentionsCredentials = cap.evidence?.toLowerCase().includes('credential') ||
148
+ cap.evidence?.toLowerCase().includes('token') ||
149
+ cap.evidence?.toLowerCase().includes('secret') ||
150
+ cap.evidence?.toLowerCase().includes('password');
151
+ if (mentionsCredentials) {
152
+ // Avoid duplicates -- only add if we didn't already find a direct transmission
153
+ if (credentialTransmissions.length === 0) {
154
+ findings.push({
155
+ checkId: 'AST-CRED-002',
156
+ name: 'Credential Forwarding Detected',
157
+ description: `Inferred capability "${cap.name}" involves credential data. ` +
158
+ 'This pattern suggests credentials may be forwarded externally.',
159
+ category: 'Credential Security',
160
+ severity: 'high',
161
+ passed: false,
162
+ message: `Inferred credential forwarding via ${cap.name}`,
163
+ fixable: true,
164
+ file: ast.artifactPath,
165
+ fix: 'Remove or restrict the capability that forwards credential data. ' +
166
+ 'Use environment variable references instead of passing credential values.',
167
+ attackClass: 'CRED-EXFIL',
168
+ confidence: 0.6,
169
+ evidence: cap.evidence,
170
+ });
171
+ }
172
+ }
173
+ }
174
+ return findings;
175
+ }
176
+ // ============================================================================
177
+ // AST-CRED-003: Hardcoded secrets in artifact content
178
+ // ============================================================================
179
+ /**
180
+ * Detects evidence of hardcoded secrets in the artifact by examining
181
+ * evidence spans and risk surfaces for credential patterns.
182
+ * Distinguishes real secrets from test fixtures (containing "FAKE",
183
+ * "EXAMPLE", "test", "placeholder") and documentation examples.
184
+ */
185
+ function checkHardcodedSecrets(ast) {
186
+ const findings = [];
187
+ // Look for evidence spans that support credential exposure
188
+ const credentialEvidence = ast.evidenceSpans.filter(e => e.supports === 'CRED-HARVEST' ||
189
+ e.supports === 'CRED-EXFIL' ||
190
+ e.supports === 'credential_exposure');
191
+ // Check risk surfaces for credential patterns
192
+ const credentialRisks = ast.inferredRiskSurface.filter(r => r.attackClass === 'CRED-HARVEST');
193
+ // Combine signals
194
+ const hasCredentialSignals = credentialEvidence.length > 0 || credentialRisks.length > 0;
195
+ if (!hasCredentialSignals) {
196
+ return findings;
197
+ }
198
+ // Filter out defensive constraint contexts: if the artifact has constraints
199
+ // about credential management (e.g., "must never store credentials"), the
200
+ // CRED-HARVEST signal is from the constraint text, not actual harvesting.
201
+ const hasDefensiveCredConstraint = ast.declaredConstraints.some(c => c.domain === 'credential_management' && c.enforceability >= 0.6);
202
+ if (hasDefensiveCredConstraint && credentialEvidence.length === 0) {
203
+ // The credential signal is likely from the constraint text, not from
204
+ // actual credential harvesting patterns. Only risk surfaces exist,
205
+ // and they were triggered by the constraint's mention of credentials.
206
+ return findings;
207
+ }
208
+ // Filter out test fixtures and documentation
209
+ const isTestOrDoc = isDocumentationOrTestContext(ast);
210
+ const evidenceTexts = credentialEvidence.map(e => e.text);
211
+ const allTestFixtures = evidenceTexts.every(t => isTestFixtureCredential(t));
212
+ if (isTestOrDoc && allTestFixtures) {
213
+ return findings;
214
+ }
215
+ // Determine severity based on artifact type and evidence strength
216
+ const maxConfidence = Math.max(...credentialEvidence.map(e => e.confidence), ...credentialRisks.map(r => r.confidence), 0);
217
+ const severity = maxConfidence >= 0.8 ? 'critical' : maxConfidence >= 0.5 ? 'high' : 'medium';
218
+ const evidenceSummary = credentialEvidence.length > 0
219
+ ? credentialEvidence[0].text.slice(0, 120)
220
+ : credentialRisks[0]?.evidence ?? 'Credential pattern detected';
221
+ findings.push({
222
+ checkId: 'AST-CRED-003',
223
+ name: 'Hardcoded Secret Detected',
224
+ description: 'The artifact contains patterns consistent with hardcoded secrets. ' +
225
+ 'Hardcoded credentials are exposed in version control, build artifacts, ' +
226
+ 'and prompt injection attacks that extract artifact content.',
227
+ category: 'Credential Security',
228
+ severity,
229
+ passed: false,
230
+ message: `Hardcoded secret: ${evidenceSummary.slice(0, 80)}`,
231
+ fixable: true,
232
+ file: ast.artifactPath,
233
+ fix: 'Move all secrets to environment variables or a secret manager. ' +
234
+ 'Replace hardcoded values with references: $SECRET_NAME or process.env.SECRET_NAME. ' +
235
+ 'Rotate any credentials that were committed to version control.',
236
+ guidance: 'After removing hardcoded credentials, rotate them immediately. ' +
237
+ 'The old values may already be in git history or build caches.',
238
+ attackClass: 'CRED-HARDCODED',
239
+ confidence: allTestFixtures ? 0.3 : maxConfidence,
240
+ evidence: evidenceSummary,
241
+ });
242
+ return findings;
243
+ }
244
+ // ============================================================================
245
+ // Helpers
246
+ // ============================================================================
247
+ /**
248
+ * Determine if the artifact is a documentation example or test fixture.
249
+ * Test fixtures contain "FAKE", "EXAMPLE", "placeholder", etc.
250
+ * Documentation contexts reference credentials for illustration only.
251
+ */
252
+ function isDocumentationOrTestContext(ast) {
253
+ const path = (ast.artifactPath ?? '').toLowerCase();
254
+ // Test fixtures
255
+ if (path.includes('test/') ||
256
+ path.includes('__tests__/') ||
257
+ path.includes('fixture') ||
258
+ path.includes('example') ||
259
+ path.includes('.example')) {
260
+ return true;
261
+ }
262
+ // Documentation (but not .skill.md, .soul.md, or CLAUDE.md which are functional)
263
+ if ((path.endsWith('.md') &&
264
+ !path.endsWith('.skill.md') &&
265
+ !path.endsWith('.soul.md') &&
266
+ !path.endsWith('claude.md')) ||
267
+ path.includes('doc/') ||
268
+ path.includes('docs/') ||
269
+ path.includes('readme')) {
270
+ return true;
271
+ }
272
+ // Check declared purpose for test/doc language
273
+ const purpose = ast.declaredPurpose.toLowerCase();
274
+ if (purpose.includes('test') ||
275
+ purpose.includes('example') ||
276
+ purpose.includes('documentation') ||
277
+ purpose.includes('fixture') ||
278
+ purpose.includes('demo')) {
279
+ return true;
280
+ }
281
+ return false;
282
+ }
283
+ /**
284
+ * Check if a credential-like string is a test fixture (contains markers
285
+ * like FAKE, EXAMPLE, placeholder, etc.)
286
+ */
287
+ function isTestFixtureCredential(text) {
288
+ const upper = text.toUpperCase();
289
+ return (upper.includes('FAKE') ||
290
+ upper.includes('EXAMPLE') ||
291
+ upper.includes('PLACEHOLDER') ||
292
+ upper.includes('TEST') ||
293
+ upper.includes('DUMMY') ||
294
+ upper.includes('SAMPLE') ||
295
+ upper.includes('XXX') ||
296
+ upper.includes('YOUR_') ||
297
+ upper.includes('<YOUR'));
298
+ }
299
+ /**
300
+ * Derive severity from data access pattern and artifact context.
301
+ */
302
+ function deriveSeverity(access, ast) {
303
+ // Transmitting credentials is always critical
304
+ if (access.accessMode === 'transmit')
305
+ return 'critical';
306
+ // Writing credentials outside env context is high
307
+ if (access.accessMode === 'write')
308
+ return 'high';
309
+ // Reading credentials in a skill is medium (might be legitimate env var ref)
310
+ if (ast.artifactType === 'skill' || ast.artifactType === 'system_prompt')
311
+ return 'medium';
312
+ // Source code with credential access is high
313
+ if (ast.artifactType === 'source_code')
314
+ return 'high';
315
+ return 'medium';
316
+ }
317
+ //# sourceMappingURL=credential-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-analyzer.js","sourceRoot":"","sources":["../../../src/nanomind-core/analyzers/credential-analyzer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAcH,gDAaC;AAvBD,yEAAqE;AAErE,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;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AC,OAAO,CAAC;QACvB,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACxB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QACvB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CACxB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CACrB,MAAyB,EACzB,GAAgB;IAEhB,8CAA8C;IAC9C,IAAI,MAAM,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC;IACxD,kDAAkD;IAClD,IAAI,MAAM,CAAC,UAAU,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IACjD,6EAA6E;IAC7E,IAAI,GAAG,CAAC,YAAY,KAAK,OAAO,IAAI,GAAG,CAAC,YAAY,KAAK,eAAe;QAAE,OAAO,QAAQ,CAAC;IAC1F,6CAA6C;IAC7C,IAAI,GAAG,CAAC,YAAY,KAAK,aAAa;QAAE,OAAO,MAAM,CAAC;IACtD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Governance Analyzer -- AST-based AST-GOV-* checks
3
+ *
4
+ * Queries the SecurityAST for governance and SOUL gaps. Evaluates
5
+ * constraint coverage, enforceability, and override resistance using
6
+ * the structured AST.declaredConstraints instead of raw text matching.
7
+ *
8
+ * Checks:
9
+ * AST-GOV-001: Constraint domain coverage gaps (9 domains)
10
+ * AST-GOV-002: Weak constraint enforceability
11
+ * AST-GOV-003: Missing governance for capabilities
12
+ * AST-GOV-004: Override resistance gaps
13
+ * AST-GOV-005: Governance-capability ratio imbalance
14
+ */
15
+ import type { SecurityAST } from '../types.js';
16
+ import type { ASTFinding } from './capability-analyzer.js';
17
+ /**
18
+ * Analyze a SecurityAST for governance and SOUL-related issues.
19
+ * Verifies AST integrity before processing.
20
+ */
21
+ export declare function analyzeGovernance(ast: SecurityAST, verifier: (ast: SecurityAST) => boolean): ASTFinding[];
22
+ //# sourceMappingURL=governance-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-analyzer.d.ts","sourceRoot":"","sources":["../../../src/nanomind-core/analyzers/governance-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA4C,MAAM,aAAa,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAqD3D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,GACtC,UAAU,EAAE,CAYd"}