api-tests-coverage 1.0.16 → 1.0.17

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 (56) hide show
  1. package/dist/dashboard/dist/index.html +1 -1
  2. package/dist/src/discovery/fileClassifier.d.ts.map +1 -1
  3. package/dist/src/discovery/fileClassifier.js +15 -16
  4. package/dist/src/discovery/projectDiscovery.d.ts.map +1 -1
  5. package/dist/src/discovery/projectDiscovery.js +4 -1
  6. package/dist/src/languages/java/semanticBuilder.d.ts.map +1 -1
  7. package/dist/src/languages/java/semanticBuilder.js +69 -12
  8. package/dist/src/languages/javascript/angularDetector.d.ts.map +1 -1
  9. package/dist/src/languages/javascript/angularDetector.js +50 -17
  10. package/dist/src/languages/javascript/assertionResolver.js +6 -4
  11. package/dist/src/languages/javascript/hapiDetector.d.ts.map +1 -1
  12. package/dist/src/languages/javascript/hapiDetector.js +48 -5
  13. package/dist/src/languages/javascript/vueDetector.d.ts +2 -0
  14. package/dist/src/languages/javascript/vueDetector.d.ts.map +1 -1
  15. package/dist/src/languages/javascript/vueDetector.js +22 -0
  16. package/dist/src/languages/python/index.d.ts +1 -1
  17. package/dist/src/languages/python/index.d.ts.map +1 -1
  18. package/dist/src/languages/python/index.js +33 -3
  19. package/dist/src/pipeline/confidence.d.ts +6 -1
  20. package/dist/src/pipeline/confidence.d.ts.map +1 -1
  21. package/dist/src/pipeline/confidence.js +8 -3
  22. package/dist/src/pipeline/graph.d.ts.map +1 -1
  23. package/dist/src/pipeline/graph.js +16 -4
  24. package/dist/src/pipeline/stages/ast/astStage.d.ts.map +1 -1
  25. package/dist/src/pipeline/stages/ast/astStage.js +46 -2
  26. package/dist/src/pipeline/stages/ast/baseUrlComposer.d.ts.map +1 -1
  27. package/dist/src/pipeline/stages/ast/baseUrlComposer.js +18 -4
  28. package/dist/src/pipeline/stages/ast/crossFileResolver.js +29 -0
  29. package/dist/src/pipeline/stages/ast/graphBuilder.d.ts.map +1 -1
  30. package/dist/src/pipeline/stages/ast/graphBuilder.js +81 -0
  31. package/dist/src/pipeline/stages/ast/optionalAuthUnifier.d.ts +3 -1
  32. package/dist/src/pipeline/stages/ast/optionalAuthUnifier.d.ts.map +1 -1
  33. package/dist/src/pipeline/stages/ast/optionalAuthUnifier.js +34 -14
  34. package/dist/src/pipeline/stages/ast/resolvers/angularInjectionResolver.d.ts.map +1 -1
  35. package/dist/src/pipeline/stages/ast/resolvers/angularInjectionResolver.js +22 -3
  36. package/dist/src/pipeline/stages/ast/resolvers/dddLayerResolver.d.ts.map +1 -1
  37. package/dist/src/pipeline/stages/ast/resolvers/dddLayerResolver.js +104 -28
  38. package/dist/src/pipeline/stages/ast/resolvers/mybatisResolver.d.ts.map +1 -1
  39. package/dist/src/pipeline/stages/ast/resolvers/mybatisResolver.js +56 -0
  40. package/dist/src/pipeline/stages/ast/resolvers/vuexActionResolver.d.ts.map +1 -1
  41. package/dist/src/pipeline/stages/ast/resolvers/vuexActionResolver.js +43 -18
  42. package/dist/src/pipeline/stages/ast/rulesEnforcer.d.ts.map +1 -1
  43. package/dist/src/pipeline/stages/ast/rulesEnforcer.js +336 -45
  44. package/dist/src/pipeline/stages/merge/conflictDetector.d.ts +2 -0
  45. package/dist/src/pipeline/stages/merge/conflictDetector.d.ts.map +1 -1
  46. package/dist/src/pipeline/stages/merge/conflictDetector.js +54 -2
  47. package/dist/src/pipeline/stages/merge/coverageMappingBuilder.d.ts.map +1 -1
  48. package/dist/src/pipeline/stages/merge/coverageMappingBuilder.js +67 -3
  49. package/dist/src/pipeline/stages/tia/mockBoundaryDetector.d.ts.map +1 -1
  50. package/dist/src/pipeline/stages/tia/mockBoundaryDetector.js +8 -1
  51. package/dist/src/pipeline/stages/tia/parameterizedTestExpander.js +8 -4
  52. package/dist/src/pipeline/stages/tia/testLayerClassifier.d.ts.map +1 -1
  53. package/dist/src/pipeline/stages/tia/testLayerClassifier.js +36 -10
  54. package/dist/src/pipeline/types.d.ts +1 -1
  55. package/dist/src/pipeline/types.d.ts.map +1 -1
  56. package/package.json +3 -3
@@ -14,47 +14,25 @@ function enforceStructureAgnosticRules(symbolTable, projectRoot) {
14
14
  const violations = [];
15
15
  let rulesChecked = 0;
16
16
  let rulesPassed = 0;
17
- // RULE-SA01: No endpoint nodes classified based on directory name alone
18
- rulesChecked++;
19
- const sa01Violations = checkRuleSA01(symbolTable, projectRoot);
20
- violations.push(...sa01Violations);
21
- if (sa01Violations.length === 0)
22
- rulesPassed++;
23
- // RULE-SA02: All endpoint nodes must have fully resolved URLs
24
- rulesChecked++;
25
- const sa02Violations = checkRuleSA02(symbolTable);
26
- violations.push(...sa02Violations);
27
- if (sa02Violations.length === 0)
28
- rulesPassed++;
29
- // RULE-SA03: Service/repository nodes detected without framework annotations
30
- rulesChecked++;
31
- // This is a capability check, not a violation check — always passes if detection code exists
32
- rulesPassed++;
33
- // RULE-SA04: Optional auth distinguished from public
34
- rulesChecked++;
35
- const sa04Violations = checkRuleSA04(symbolTable);
36
- violations.push(...sa04Violations);
37
- if (sa04Violations.length === 0)
38
- rulesPassed++;
39
- // RULE-SA05: @Mapper interfaces linked to XML
40
- rulesChecked++;
41
- // Checked by mybatisResolver — passes if no unresolved mappers
42
- rulesPassed++;
43
- // RULE-SA06: .graphqls files parsed as first-class
44
- rulesChecked++;
45
- rulesPassed++;
46
- // RULE-SA07: Angular HttpClient in services followed through injection
47
- rulesChecked++;
48
- rulesPassed++;
49
- // RULE-SA08: Vuex dispatch linked to actions
50
- rulesChecked++;
51
- rulesPassed++;
52
- // RULE-SA09: Functional Angular guards detected
53
- rulesChecked++;
54
- rulesPassed++;
55
- // RULE-SA10: webtest/TestApp detected as API test evidence
56
- rulesChecked++;
57
- rulesPassed++;
17
+ const checks = [
18
+ { id: 'SA01', fn: () => checkRuleSA01(symbolTable, projectRoot) },
19
+ { id: 'SA02', fn: () => checkRuleSA02(symbolTable) },
20
+ { id: 'SA03', fn: () => checkRuleSA03(symbolTable) },
21
+ { id: 'SA04', fn: () => checkRuleSA04(symbolTable) },
22
+ { id: 'SA05', fn: () => checkRuleSA05(symbolTable) },
23
+ { id: 'SA06', fn: () => checkRuleSA06(symbolTable) },
24
+ { id: 'SA07', fn: () => checkRuleSA07(symbolTable) },
25
+ { id: 'SA08', fn: () => checkRuleSA08(symbolTable) },
26
+ { id: 'SA09', fn: () => checkRuleSA09(symbolTable) },
27
+ { id: 'SA10', fn: () => checkRuleSA10(symbolTable) },
28
+ ];
29
+ for (const check of checks) {
30
+ rulesChecked++;
31
+ const ruleViolations = check.fn();
32
+ violations.push(...ruleViolations);
33
+ if (ruleViolations.length === 0)
34
+ rulesPassed++;
35
+ }
58
36
  return { violations, rulesChecked, rulesPassed };
59
37
  }
60
38
  /**
@@ -62,10 +40,26 @@ function enforceStructureAgnosticRules(symbolTable, projectRoot) {
62
40
  * Checks that route registrations have content-based evidence, not just path-based.
63
41
  */
64
42
  function checkRuleSA01(symbolTable, projectRoot) {
65
- // This rule is enforced by design: all our detectors use content analysis (AST/regex),
66
- // not directory-based classification. We verify no router mounts were added with
67
- // directory-only evidence.
68
- return [];
43
+ const violations = [];
44
+ // Check route registrations for directory-only evidence
45
+ for (const [filePath, model] of symbolTable.models) {
46
+ if (!model.routeRegistrations)
47
+ continue;
48
+ for (const reg of model.routeRegistrations) {
49
+ // A route with no registrar (no decorator, no app.route, no router.METHOD)
50
+ // that was classified solely from its directory path is a violation
51
+ if (!reg.registrarName && !reg.methods && !reg.security) {
52
+ violations.push({
53
+ ruleId: 'SA01',
54
+ severity: 'error',
55
+ message: `Route '${reg.path}' in ${filePath} appears to lack content-based evidence`,
56
+ filePath,
57
+ line: reg.line,
58
+ });
59
+ }
60
+ }
61
+ }
62
+ return violations;
69
63
  }
70
64
  /**
71
65
  * RULE-SA02: All endpoint nodes must have fully resolved URLs.
@@ -91,6 +85,39 @@ function checkRuleSA02(symbolTable) {
91
85
  }
92
86
  return violations;
93
87
  }
88
+ /**
89
+ * RULE-SA03: Service/repository nodes must be detected without requiring framework annotations.
90
+ * Checks that interface implementations exist in the symbol table for projects that have
91
+ * classes following DDD patterns (Repository, Store, Gateway naming or method patterns).
92
+ */
93
+ function checkRuleSA03(symbolTable) {
94
+ const violations = [];
95
+ // Find classes that look like repositories by naming convention
96
+ const repoLikeClasses = [];
97
+ for (const [className, classDecl] of symbolTable.classes) {
98
+ if (/(?:Repository|Repo|Store|Gateway)$/i.test(className)) {
99
+ repoLikeClasses.push(className);
100
+ }
101
+ }
102
+ // If there are repository-like classes, check that at least some have interface implementations resolved
103
+ if (repoLikeClasses.length > 0) {
104
+ let hasAnyImpl = false;
105
+ for (const [, impls] of symbolTable.interfaceImplementations) {
106
+ if (impls.length > 0) {
107
+ hasAnyImpl = true;
108
+ break;
109
+ }
110
+ }
111
+ if (!hasAnyImpl && repoLikeClasses.length >= 2) {
112
+ violations.push({
113
+ ruleId: 'SA03',
114
+ severity: 'warning',
115
+ message: `Found ${repoLikeClasses.length} repository-like class(es) but no interface→implementation mappings resolved`,
116
+ });
117
+ }
118
+ }
119
+ return violations;
120
+ }
94
121
  /**
95
122
  * RULE-SA04: Optional auth must be distinguished from public.
96
123
  * Checks that models with route registrations having security classifications
@@ -118,3 +145,267 @@ function checkRuleSA04(symbolTable) {
118
145
  }
119
146
  return violations;
120
147
  }
148
+ /**
149
+ * RULE-SA05: @Mapper interfaces must be linked to their XML mapper files.
150
+ * Checks that all interface implementations with MyBatis naming have corresponding XML bindings.
151
+ */
152
+ function checkRuleSA05(symbolTable) {
153
+ const violations = [];
154
+ // Find @Mapper-like classes (by naming convention or annotations)
155
+ for (const [className, classDecl] of symbolTable.classes) {
156
+ if (!className.endsWith('Mapper'))
157
+ continue;
158
+ // Check if this mapper has a corresponding interface implementation (XML binding)
159
+ let hasBinding = false;
160
+ for (const [, impls] of symbolTable.interfaceImplementations) {
161
+ if (impls.some((impl) => impl.interfaceName === className || impl.implName.includes(className))) {
162
+ hasBinding = true;
163
+ break;
164
+ }
165
+ }
166
+ // Check if there are any models with MyBatis-related content
167
+ const model = symbolTable.models.get(classDecl.filePath);
168
+ if (model && !hasBinding) {
169
+ // Only warn if the project appears to use MyBatis (has XML-linked implementations)
170
+ let projectUsesMyBatis = false;
171
+ for (const [, impls] of symbolTable.interfaceImplementations) {
172
+ if (impls.some((impl) => impl.implName.includes('XmlMapper'))) {
173
+ projectUsesMyBatis = true;
174
+ break;
175
+ }
176
+ }
177
+ if (projectUsesMyBatis) {
178
+ violations.push({
179
+ ruleId: 'SA05',
180
+ severity: 'warning',
181
+ message: `@Mapper interface '${className}' in ${classDecl.filePath} has no linked XML mapper`,
182
+ filePath: classDecl.filePath,
183
+ line: classDecl.line,
184
+ });
185
+ }
186
+ }
187
+ }
188
+ return violations;
189
+ }
190
+ /**
191
+ * RULE-SA06: .graphqls schema files must be parsed as first-class endpoint definitions.
192
+ * Checks that GraphQL schemas produce endpoint nodes when present.
193
+ */
194
+ function checkRuleSA06(symbolTable) {
195
+ const violations = [];
196
+ // Check if there are any .graphqls or .graphql files in the models that lack route registrations
197
+ for (const [filePath, model] of symbolTable.models) {
198
+ if (!filePath.endsWith('.graphqls') && !filePath.endsWith('.graphql'))
199
+ continue;
200
+ // GraphQL schema files should produce route registrations
201
+ if (!model.routeRegistrations || model.routeRegistrations.length === 0) {
202
+ violations.push({
203
+ ruleId: 'SA06',
204
+ severity: 'warning',
205
+ message: `GraphQL schema file '${filePath}' was not parsed into endpoint definitions`,
206
+ filePath,
207
+ });
208
+ }
209
+ }
210
+ return violations;
211
+ }
212
+ /**
213
+ * RULE-SA07: Angular HttpClient calls in @Injectable services must be followed through injection.
214
+ * Checks that services with HTTP calls have injection chains linking them to consumers.
215
+ */
216
+ function checkRuleSA07(symbolTable) {
217
+ var _a, _b;
218
+ const violations = [];
219
+ // Find services with HTTP calls that have no injection chain consumers
220
+ for (const [className, classDecl] of symbolTable.classes) {
221
+ const model = symbolTable.models.get(classDecl.filePath);
222
+ if (!model)
223
+ continue;
224
+ // Check if this class has methods with HTTP calls
225
+ let hasHttpCalls = false;
226
+ for (const [, func] of model.functions) {
227
+ if (func.bodyHttpCalls.length > 0) {
228
+ hasHttpCalls = true;
229
+ break;
230
+ }
231
+ }
232
+ if (!hasHttpCalls)
233
+ continue;
234
+ // Content-based check: is this an Angular @Injectable service?
235
+ // (RULE-SA01 compliant — no filename convention used)
236
+ const hasInjectableMarker = ((_b = (_a = model.decoratorStacks) === null || _a === void 0 ? void 0 : _a.some((ds) => ds.decorators.some((d) => d.name === 'Injectable' || d.name.includes('Injectable')))) !== null && _b !== void 0 ? _b : false) ||
237
+ Array.from(model.functions.values()).some((f) => { var _a; return (_a = f.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => a === 'Injectable' || a === '@Injectable'); });
238
+ if (!hasInjectableMarker)
239
+ continue;
240
+ // Check if any injection chains reference this service
241
+ let hasConsumer = false;
242
+ for (const [, chains] of symbolTable.injectionChains) {
243
+ if (chains.some((c) => c.serviceClass === className)) {
244
+ hasConsumer = true;
245
+ break;
246
+ }
247
+ }
248
+ if (!hasConsumer) {
249
+ violations.push({
250
+ ruleId: 'SA07',
251
+ severity: 'info',
252
+ message: `Angular service '${className}' in ${classDecl.filePath} has HTTP calls but no resolved injection consumers`,
253
+ filePath: classDecl.filePath,
254
+ line: classDecl.line,
255
+ });
256
+ }
257
+ }
258
+ return violations;
259
+ }
260
+ /**
261
+ * RULE-SA08: Vuex dispatch calls must be linked to store action definitions.
262
+ * Checks that dispatch calls have corresponding injection chain entries.
263
+ */
264
+ function checkRuleSA08(symbolTable) {
265
+ const violations = [];
266
+ // Find models with dispatch calls that have no injection chain linking
267
+ for (const [filePath, model] of symbolTable.models) {
268
+ let hasDispatch = false;
269
+ for (const [, func] of model.functions) {
270
+ if (func.calledFunctions.some((f) => f.includes('dispatch'))) {
271
+ hasDispatch = true;
272
+ break;
273
+ }
274
+ }
275
+ if (!hasDispatch)
276
+ continue;
277
+ // Check if there's an injection chain linking this file to a store
278
+ const chains = symbolTable.injectionChains.get(filePath);
279
+ if (!chains || chains.length === 0) {
280
+ // Only warn if the project has Vuex store files (files with both actions and HTTP calls)
281
+ let hasStoreFiles = false;
282
+ for (const [otherFile, otherModel] of symbolTable.models) {
283
+ if (otherFile === filePath)
284
+ continue;
285
+ for (const [, func] of otherModel.functions) {
286
+ if (func.bodyHttpCalls.length > 0) {
287
+ hasStoreFiles = true;
288
+ break;
289
+ }
290
+ }
291
+ if (hasStoreFiles)
292
+ break;
293
+ }
294
+ if (hasStoreFiles) {
295
+ violations.push({
296
+ ruleId: 'SA08',
297
+ severity: 'info',
298
+ message: `File '${filePath}' dispatches Vuex actions but no dispatch→action links were resolved`,
299
+ filePath,
300
+ });
301
+ }
302
+ }
303
+ }
304
+ return violations;
305
+ }
306
+ /**
307
+ * RULE-SA09: Functional Angular guards (CanActivateFn) must be detected.
308
+ * Checks that guard files are recognized and linked to routes.
309
+ */
310
+ function checkRuleSA09(symbolTable) {
311
+ var _a, _b;
312
+ const violations = [];
313
+ // Find files with Angular guard-related content (content-based, not filename-based)
314
+ for (const [filePath, model] of symbolTable.models) {
315
+ // Content-based check: does this file have guard-related types or implementations?
316
+ // (RULE-SA01 compliant — no filename convention used)
317
+ let hasGuardContent = false;
318
+ // Check function annotations for guard type markers (CanActivateFn, etc.)
319
+ const guardTypeAnnotations = [
320
+ 'CanActivateFn',
321
+ 'CanActivateChildFn',
322
+ 'CanDeactivateFn',
323
+ 'ResolveFn',
324
+ 'CanMatchFn',
325
+ ];
326
+ for (const [, func] of model.functions) {
327
+ if ((_a = func.annotations) === null || _a === void 0 ? void 0 : _a.some((a) => guardTypeAnnotations.includes(a))) {
328
+ hasGuardContent = true;
329
+ break;
330
+ }
331
+ }
332
+ // Check if any class in this file implements guard interfaces
333
+ if (!hasGuardContent) {
334
+ const guardInterfaces = [
335
+ 'CanActivate',
336
+ 'CanActivateChild',
337
+ 'CanDeactivate',
338
+ 'Resolve',
339
+ 'CanMatch',
340
+ ];
341
+ for (const [, classDecl] of symbolTable.classes) {
342
+ if (classDecl.filePath === filePath &&
343
+ ((_b = classDecl.implementsInterfaces) === null || _b === void 0 ? void 0 : _b.some((i) => guardInterfaces.includes(i)))) {
344
+ hasGuardContent = true;
345
+ break;
346
+ }
347
+ }
348
+ }
349
+ // Check function names for guard-related patterns as content heuristic
350
+ if (!hasGuardContent) {
351
+ for (const [funcName] of model.functions) {
352
+ if (/guard|canActivate|canDeactivate|canMatch/i.test(funcName)) {
353
+ hasGuardContent = true;
354
+ break;
355
+ }
356
+ }
357
+ }
358
+ if (!hasGuardContent)
359
+ continue;
360
+ // Check if this guard has any route registrations or middleware entries
361
+ let isLinked = false;
362
+ for (const [, middleware] of symbolTable.middlewareInheritance) {
363
+ if (middleware.some((m) => m.sourceFile === filePath || m.name.includes('guard'))) {
364
+ isLinked = true;
365
+ break;
366
+ }
367
+ }
368
+ if (!isLinked) {
369
+ // Check if there's at least a function export that looks like a guard
370
+ let hasGuardFunction = false;
371
+ for (const [funcName] of model.functions) {
372
+ if (/guard|canActivate|canDeactivate|canMatch/i.test(funcName)) {
373
+ hasGuardFunction = true;
374
+ break;
375
+ }
376
+ }
377
+ if (hasGuardFunction) {
378
+ violations.push({
379
+ ruleId: 'SA09',
380
+ severity: 'info',
381
+ message: `Angular guard in '${filePath}' has guard functions but is not linked to any route`,
382
+ filePath,
383
+ });
384
+ }
385
+ }
386
+ }
387
+ return violations;
388
+ }
389
+ /**
390
+ * RULE-SA10: webtest/TestApp must be detected as API test evidence.
391
+ * Checks that files using webtest patterns have their HTTP calls extracted.
392
+ */
393
+ function checkRuleSA10(symbolTable) {
394
+ const violations = [];
395
+ for (const [filePath, model] of symbolTable.models) {
396
+ // Check if this model has webtest-detected calls (via the __webtest_calls__ synthetic function)
397
+ const webtestFunc = model.functions.get('__webtest_calls__');
398
+ if (!webtestFunc)
399
+ continue;
400
+ // Verify the webtest calls actually produced HTTP call entries
401
+ if (webtestFunc.bodyHttpCalls.length === 0) {
402
+ violations.push({
403
+ ruleId: 'SA10',
404
+ severity: 'warning',
405
+ message: `File '${filePath}' has webtest detection but produced no HTTP call entries`,
406
+ filePath,
407
+ });
408
+ }
409
+ }
410
+ return violations;
411
+ }
@@ -4,6 +4,8 @@
4
4
  *
5
5
  * Detects:
6
6
  * - Runtime-unconfirmed: AST+TIA say covered, but IAST/DAST disagree
7
+ * - DAST-unreachable: DAST probed an endpoint but could not reach it
8
+ * - Undeclared-endpoint: DAST discovered endpoints not found by static analysis
7
9
  * - Stage disagreement: Two stages assign different types to the same node
8
10
  */
9
11
  import type { ConflictNode } from '../../types';
@@ -1 +1 @@
1
- {"version":3,"file":"conflictDetector.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/merge/conflictDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,sBAAsB,EAC7B,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,YAAY,EAAE,CA0ChB"}
1
+ {"version":3,"file":"conflictDetector.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/merge/conflictDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,sBAAsB,EAC7B,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,YAAY,EAAE,CAmGhB"}
@@ -5,6 +5,8 @@
5
5
  *
6
6
  * Detects:
7
7
  * - Runtime-unconfirmed: AST+TIA say covered, but IAST/DAST disagree
8
+ * - DAST-unreachable: DAST probed an endpoint but could not reach it
9
+ * - Undeclared-endpoint: DAST discovered endpoints not found by static analysis
8
10
  * - Stage disagreement: Two stages assign different types to the same node
9
11
  */
10
12
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -13,7 +15,7 @@ exports.detectConflicts = detectConflicts;
13
15
  * Detect conflicts across all stages.
14
16
  */
15
17
  function detectConflicts(graph, iastOutput, dastOutput) {
16
- var _a, _b, _c, _d, _e;
18
+ var _a, _b, _c, _d, _e, _f, _g;
17
19
  const conflicts = [];
18
20
  // 1. Runtime-unconfirmed: endpoints that AST found but neither IAST nor DAST confirmed
19
21
  const endpointNodes = graph.getNodesByType('endpoint');
@@ -46,7 +48,57 @@ function detectConflicts(graph, iastOutput, dastOutput) {
46
48
  }
47
49
  }
48
50
  }
49
- // 2. Stage disagreement: same node ID added by multiple stages with different types
51
+ // 2. DAST-unreachable: endpoints that DAST explicitly could not reach
52
+ if (dastOutput) {
53
+ for (const endpointId of dastUnreachable) {
54
+ const node = graph.getNode(endpointId);
55
+ const label = (_f = node === null || node === void 0 ? void 0 : node.label) !== null && _f !== void 0 ? _f : endpointId;
56
+ conflicts.push({
57
+ conflictId: `conflict:dast-unreachable:${endpointId}`,
58
+ nodeId: endpointId,
59
+ type: 'dast-unreachable',
60
+ stages: ['dast'],
61
+ stageOutputs: {
62
+ dast: 'unreachable',
63
+ },
64
+ detail: `${label} was probed by DAST but could not be reached.`,
65
+ suggestedAction: 'Verify the endpoint is deployed and accessible. Check authentication requirements and network configuration for the DAST scanner.',
66
+ severity: 'warning',
67
+ });
68
+ }
69
+ }
70
+ // 3. Undeclared-endpoint: DAST discovered endpoints not found by static analysis
71
+ if (dastOutput) {
72
+ const staticEndpointIds = new Set(endpointNodes
73
+ .filter((n) => n.sourceStage !== 'dast')
74
+ .map((n) => n.id));
75
+ for (const result of dastOutput.results) {
76
+ if (!result.reachable)
77
+ continue;
78
+ const endpointPath = (_g = result.normalizedPath) !== null && _g !== void 0 ? _g : result.path;
79
+ const endpointId = `endpoint:${result.method.toUpperCase()}:${endpointPath}`;
80
+ if (!staticEndpointIds.has(endpointId)) {
81
+ // Avoid duplicate conflicts for the same endpoint
82
+ const conflictId = `conflict:undeclared-endpoint:${endpointId}`;
83
+ if (conflicts.some((c) => c.conflictId === conflictId))
84
+ continue;
85
+ conflicts.push({
86
+ conflictId,
87
+ nodeId: endpointId,
88
+ type: 'undeclared-endpoint',
89
+ stages: ['dast'],
90
+ stageOutputs: {
91
+ dast: 'discovered',
92
+ ast: 'not-declared',
93
+ },
94
+ detail: `${result.method.toUpperCase()} ${endpointPath} was discovered by DAST but not found by static analysis.`,
95
+ suggestedAction: 'Review the endpoint source. It may be dynamically registered, generated by a framework, or missing from the scanned codebase.',
96
+ severity: 'warning',
97
+ });
98
+ }
99
+ }
100
+ }
101
+ // 4. Stage disagreement: same node ID added by multiple stages with different types
50
102
  // (This is handled by the graph merge(), which already returns ConflictNode[])
51
103
  return conflicts;
52
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coverageMappingBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/merge/coverageMappingBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EAMhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,sBAAsB,EAC7B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,gBAAgB,EAAE,OAAO,GACxB,eAAe,EAAE,CAuJnB"}
1
+ {"version":3,"file":"coverageMappingBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/merge/coverageMappingBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EAOhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoBhD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,sBAAsB,EAC7B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,gBAAgB,EAAE,OAAO,GACxB,eAAe,EAAE,CAyNnB"}
@@ -8,6 +8,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.buildCoverageMappings = buildCoverageMappings;
9
9
  const confidence_1 = require("../../confidence");
10
10
  const mergeRules_1 = require("./mergeRules");
11
+ /** Rank test layers so deeper coverage layers win when comparing. */
12
+ const TEST_LAYER_RANK = {
13
+ e2e: 6,
14
+ api: 5,
15
+ integration: 4,
16
+ component: 3,
17
+ unit: 2,
18
+ security: 1,
19
+ performance: 1,
20
+ };
21
+ function testLayerRank(layer) {
22
+ var _a;
23
+ if (!layer)
24
+ return 0;
25
+ return (_a = TEST_LAYER_RANK[layer]) !== null && _a !== void 0 ? _a : 0;
26
+ }
11
27
  /**
12
28
  * Build coverage mappings for all endpoint-type nodes in the graph.
13
29
  */
@@ -59,9 +75,9 @@ function buildCoverageMappings(graph, tiaOutput, iastOutput, dastOutput, isStati
59
75
  assertionConfirmed = true;
60
76
  assertionSource = 'direct';
61
77
  }
62
- // Check test layer
78
+ // Check test layer — only replace if the new layer has a higher rank
63
79
  const layer = testLayerLookup.get(testFilePath);
64
- if (layer) {
80
+ if (layer && testLayerRank(layer) > testLayerRank(bestTestLayer)) {
65
81
  bestTestLayer = layer;
66
82
  }
67
83
  // Check for mock boundaries on this test file
@@ -98,7 +114,7 @@ function buildCoverageMappings(graph, tiaOutput, iastOutput, dastOutput, isStati
98
114
  const pathNodeIds = [endpoint.id, ...linkedTests.map((t) => `file:${t}`)];
99
115
  const mockBoundaryOnPath = hasMockBoundary;
100
116
  // Build confidence evidence
101
- const evidence = (0, confidence_1.buildConfidenceEvidence)(graph, pathNodeIds, isStaticOnlyMode);
117
+ const evidence = (0, confidence_1.buildConfidenceEvidence)(graph, pathNodeIds, isStaticOnlyMode, iastConfirmed.has(endpoint.id), dastConfirmed.has(endpoint.id));
102
118
  // Compute confidence
103
119
  const confidence = (0, confidence_1.computeConfidence)(evidence);
104
120
  // Determine coverage class
@@ -137,5 +153,53 @@ function buildCoverageMappings(graph, tiaOutput, iastOutput, dastOutput, isStati
137
153
  traversalDepth,
138
154
  });
139
155
  }
156
+ // ─── Secondary mappings: service, error-branch, repository ────────────────
157
+ const secondaryNodeTypes = [
158
+ { nodeType: 'service', itemType: 'service' },
159
+ { nodeType: 'exception-branch', itemType: 'error-branch' },
160
+ { nodeType: 'repository', itemType: 'repository' },
161
+ ];
162
+ for (const { nodeType, itemType } of secondaryNodeTypes) {
163
+ const nodes = graph.getNodesByType(nodeType);
164
+ for (const node of nodes) {
165
+ const incomingEdges = graph.getEdgesTo(node.id);
166
+ const testEdges = incomingEdges.filter((e) => e.type === 'tests' || e.type === 'asserts');
167
+ const linkedTests = [];
168
+ const sourceStages = new Set([node.sourceStage]);
169
+ let assertionConfirmed = false;
170
+ let assertionSource = 'unresolved';
171
+ for (const edge of testEdges) {
172
+ const testFilePath = edge.sourceNodeId.replace(/^file:/, '');
173
+ if (!linkedTests.includes(testFilePath)) {
174
+ linkedTests.push(testFilePath);
175
+ }
176
+ sourceStages.add(edge.sourceStage);
177
+ if (edge.type === 'asserts') {
178
+ assertionConfirmed = true;
179
+ assertionSource = 'direct';
180
+ }
181
+ }
182
+ const pathNodeIds = [node.id, ...linkedTests.map((t) => `file:${t}`)];
183
+ const evidence = (0, confidence_1.buildConfidenceEvidence)(graph, pathNodeIds, isStaticOnlyMode, false, false);
184
+ const confidence = (0, confidence_1.computeConfidence)(evidence);
185
+ const coverageClass = linkedTests.length > 0 ? 'unit-covered' : 'uncovered';
186
+ mappings.push({
187
+ itemId: node.id,
188
+ itemType,
189
+ linkedTests,
190
+ sourceStages: Array.from(sourceStages),
191
+ confidence,
192
+ coverageClass,
193
+ mockBoundaries: [],
194
+ assertionSource,
195
+ assertionConfirmed,
196
+ dastReachable: 'not-probed',
197
+ runtimeConfirmed: false,
198
+ urlResolution: 'unresolved',
199
+ conflicts: [],
200
+ traversalDepth: 0,
201
+ });
202
+ }
203
+ }
140
204
  return mappings;
141
205
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mockBoundaryDetector.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/tia/mockBoundaryDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmEpD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,oBAAoB,EAAE,CA8CxB"}
1
+ {"version":3,"file":"mockBoundaryDetector.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/tia/mockBoundaryDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmEpD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,oBAAoB,EAAE,CAwDxB"}
@@ -102,7 +102,14 @@ function detectMockBoundaries(filePath, content, language) {
102
102
  if (pattern.regex.test(line)) {
103
103
  // Extract mocked target (heuristic: argument in parentheses)
104
104
  const targetMatch = /[\(][\s]*['"`]?([a-zA-Z0-9_./@]+)['"`]?/.exec(line);
105
- const mockedTarget = (_a = targetMatch === null || targetMatch === void 0 ? void 0 : targetMatch[1]) !== null && _a !== void 0 ? _a : 'unknown';
105
+ let mockedTarget = (_a = targetMatch === null || targetMatch === void 0 ? void 0 : targetMatch[1]) !== null && _a !== void 0 ? _a : 'unknown';
106
+ // Secondary extraction for Java/Kotlin annotation-style mocks (e.g. @Mock private UserService userService;)
107
+ if (mockedTarget === 'unknown') {
108
+ const annotationTypeMatch = line.match(/(?:private|protected|public)?\s*(\w+)\s+\w+\s*;/);
109
+ if (annotationTypeMatch) {
110
+ mockedTarget = annotationTypeMatch[1];
111
+ }
112
+ }
106
113
  boundaries.push({
107
114
  testFilePath: filePath,
108
115
  mockingLibrary: pattern.library,
@@ -102,9 +102,10 @@ function expandJavaKotlinParameterized(filePath, content) {
102
102
  }
103
103
  // ─── Jest Parameterized ─────────────────────────────────────────────────────
104
104
  function expandJestParameterized(filePath, content) {
105
- var _a;
105
+ var _a, _b;
106
106
  const results = [];
107
107
  const lines = content.split('\n');
108
+ let lineStartOffset = 0;
108
109
  for (let i = 0; i < lines.length; i++) {
109
110
  const line = lines[i];
110
111
  // test.each([...])('name', ...)
@@ -113,11 +114,13 @@ function expandJestParameterized(filePath, content) {
113
114
  const eachMatch = /(?:test|it|describe)\.each\s*\(\s*\[/.exec(line);
114
115
  if (eachMatch) {
115
116
  // Try to extract the array and count items
116
- const arrayContent = extractBalancedBrackets(content, content.indexOf(eachMatch[0], i > 0 ? content.indexOf(lines[i]) : 0));
117
+ const matchOffset = lineStartOffset + ((_a = eachMatch.index) !== null && _a !== void 0 ? _a : 0);
118
+ const bracketStart = content.indexOf('[', matchOffset);
119
+ const arrayContent = extractBalancedBrackets(content, bracketStart);
117
120
  const variantCount = arrayContent ? countArrayElements(arrayContent) : 'unresolvable';
118
121
  // Extract test name from the next argument
119
- const nameMatch = /\)\s*\(\s*['"`]([^'"`]+)['"`]/.exec(content.substring(content.indexOf(eachMatch[0])));
120
- const testName = (_a = nameMatch === null || nameMatch === void 0 ? void 0 : nameMatch[1]) !== null && _a !== void 0 ? _a : 'parameterized test';
122
+ const nameMatch = /\)\s*\(\s*['"`]([^'"`]+)['"`]/.exec(content.substring(matchOffset));
123
+ const testName = (_b = nameMatch === null || nameMatch === void 0 ? void 0 : nameMatch[1]) !== null && _b !== void 0 ? _b : 'parameterized test';
121
124
  results.push({
122
125
  testFilePath: filePath,
123
126
  testName,
@@ -146,6 +149,7 @@ function expandJestParameterized(filePath, content) {
146
149
  line: i + 1,
147
150
  });
148
151
  }
152
+ lineStartOffset += lines[i].length + 1; // +1 for newline
149
153
  }
150
154
  return results;
151
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"testLayerClassifier.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/tia/testLayerClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8GlD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,kBAAkB,CA0DpB"}
1
+ {"version":3,"file":"testLayerClassifier.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/stages/tia/testLayerClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8GlD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,kBAAkB,CAqFpB"}