@rigour-labs/core 5.0.1 → 5.1.1

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 (141) hide show
  1. package/README.md +9 -1
  2. package/dist/gates/agent-team.d.ts +0 -1
  3. package/dist/gates/agent-team.js +0 -1
  4. package/dist/gates/checkpoint.d.ts +0 -2
  5. package/dist/gates/checkpoint.js +0 -2
  6. package/dist/gates/context-window-artifacts.d.ts +6 -2
  7. package/dist/gates/context-window-artifacts.js +107 -31
  8. package/dist/gates/deep-analysis.d.ts +2 -0
  9. package/dist/gates/deep-analysis.js +41 -11
  10. package/dist/gates/dependency.d.ts +0 -2
  11. package/dist/gates/dependency.js +23 -5
  12. package/dist/gates/deprecated-apis.d.ts +0 -2
  13. package/dist/gates/deprecated-apis.js +33 -20
  14. package/dist/gates/duplication-drift/index.d.ts +61 -0
  15. package/dist/gates/duplication-drift/index.js +240 -0
  16. package/dist/gates/duplication-drift/similarity.d.ts +68 -0
  17. package/dist/gates/duplication-drift/similarity.js +177 -0
  18. package/dist/gates/duplication-drift/tokenizer.d.ts +55 -0
  19. package/dist/gates/duplication-drift/tokenizer.js +195 -0
  20. package/dist/gates/frontend-secret-exposure.d.ts +0 -3
  21. package/dist/gates/frontend-secret-exposure.js +1 -114
  22. package/dist/gates/frontend-secret-patterns.d.ts +33 -0
  23. package/dist/gates/frontend-secret-patterns.js +119 -0
  24. package/dist/gates/{hallucinated-imports.d.ts → hallucinated-imports/index.d.ts} +2 -29
  25. package/dist/gates/hallucinated-imports/index.js +174 -0
  26. package/dist/gates/hallucinated-imports/js-resolver.d.ts +45 -0
  27. package/dist/gates/hallucinated-imports/js-resolver.js +320 -0
  28. package/dist/gates/hallucinated-imports/manifest-discovery.d.ts +28 -0
  29. package/dist/gates/hallucinated-imports/manifest-discovery.js +114 -0
  30. package/dist/gates/hallucinated-imports/python-resolver.d.ts +24 -0
  31. package/dist/gates/hallucinated-imports/python-resolver.js +306 -0
  32. package/dist/gates/hallucinated-imports-lang.d.ts +2 -2
  33. package/dist/gates/hallucinated-imports-lang.js +269 -34
  34. package/dist/gates/hallucinated-imports.test.js +1 -2
  35. package/dist/gates/inconsistent-error-handling.d.ts +0 -5
  36. package/dist/gates/inconsistent-error-handling.js +15 -144
  37. package/dist/gates/language-adapters/csharp-adapter.d.ts +16 -0
  38. package/dist/gates/language-adapters/csharp-adapter.js +211 -0
  39. package/dist/gates/language-adapters/go-adapter.d.ts +26 -0
  40. package/dist/gates/language-adapters/go-adapter.js +195 -0
  41. package/dist/gates/language-adapters/index.d.ts +15 -0
  42. package/dist/gates/language-adapters/index.js +16 -0
  43. package/dist/gates/language-adapters/java-adapter.d.ts +16 -0
  44. package/dist/gates/language-adapters/java-adapter.js +237 -0
  45. package/dist/gates/language-adapters/js-adapter.d.ts +26 -0
  46. package/dist/gates/language-adapters/js-adapter.js +279 -0
  47. package/dist/gates/language-adapters/python-adapter.d.ts +25 -0
  48. package/dist/gates/language-adapters/python-adapter.js +183 -0
  49. package/dist/gates/language-adapters/registry.d.ts +26 -0
  50. package/dist/gates/language-adapters/registry.js +65 -0
  51. package/dist/gates/language-adapters/ruby-adapter.d.ts +25 -0
  52. package/dist/gates/language-adapters/ruby-adapter.js +217 -0
  53. package/dist/gates/language-adapters/rust-adapter.d.ts +27 -0
  54. package/dist/gates/language-adapters/rust-adapter.js +235 -0
  55. package/dist/gates/language-adapters/types.d.ts +60 -0
  56. package/dist/gates/language-adapters/types.js +22 -0
  57. package/dist/gates/logic-drift-extractors.d.ts +15 -0
  58. package/dist/gates/logic-drift-extractors.js +34 -0
  59. package/dist/gates/logic-drift.d.ts +0 -30
  60. package/dist/gates/logic-drift.js +39 -129
  61. package/dist/gates/phantom-apis.d.ts +0 -2
  62. package/dist/gates/phantom-apis.js +49 -20
  63. package/dist/gates/promise-safety.d.ts +0 -1
  64. package/dist/gates/promise-safety.js +14 -2
  65. package/dist/gates/runner.js +52 -23
  66. package/dist/gates/runner.test.js +1 -1
  67. package/dist/gates/security-patterns-data.d.ts +14 -0
  68. package/dist/gates/security-patterns-data.js +235 -0
  69. package/dist/gates/security-patterns.d.ts +17 -3
  70. package/dist/gates/security-patterns.js +80 -211
  71. package/dist/gates/side-effect-analysis/categorizer.d.ts +32 -0
  72. package/dist/gates/side-effect-analysis/categorizer.js +83 -0
  73. package/dist/gates/{side-effect-analysis.d.ts → side-effect-analysis/index.d.ts} +3 -5
  74. package/dist/gates/{side-effect-analysis.js → side-effect-analysis/index.js} +33 -45
  75. package/dist/gates/side-effect-analysis/scope-tracker.d.ts +37 -0
  76. package/dist/gates/side-effect-analysis/scope-tracker.js +40 -0
  77. package/dist/gates/side-effect-helpers/index.d.ts +4 -0
  78. package/dist/gates/side-effect-helpers/index.js +4 -0
  79. package/dist/gates/side-effect-helpers/pattern-detection.d.ts +123 -0
  80. package/dist/gates/{side-effect-helpers.js → side-effect-helpers/pattern-detection.js} +22 -468
  81. package/dist/gates/side-effect-helpers/resource-tracking.d.ts +80 -0
  82. package/dist/gates/side-effect-helpers/resource-tracking.js +281 -0
  83. package/dist/gates/side-effect-helpers/scope-analysis.d.ts +21 -0
  84. package/dist/gates/side-effect-helpers/scope-analysis.js +146 -0
  85. package/dist/gates/side-effect-helpers/types.d.ts +38 -0
  86. package/dist/gates/side-effect-helpers/types.js +41 -0
  87. package/dist/gates/side-effect-rules.d.ts +0 -1
  88. package/dist/gates/side-effect-rules.js +0 -1
  89. package/dist/gates/style-drift-rules.d.ts +86 -0
  90. package/dist/gates/style-drift-rules.js +103 -0
  91. package/dist/gates/style-drift.d.ts +7 -16
  92. package/dist/gates/style-drift.js +101 -119
  93. package/dist/gates/test-quality-matchers.d.ts +53 -0
  94. package/dist/gates/test-quality-matchers.js +86 -0
  95. package/dist/gates/test-quality.d.ts +0 -3
  96. package/dist/gates/test-quality.js +47 -44
  97. package/dist/hooks/checker.d.ts +0 -1
  98. package/dist/hooks/checker.js +0 -2
  99. package/dist/hooks/dlp-templates.d.ts +0 -1
  100. package/dist/hooks/dlp-templates.js +0 -4
  101. package/dist/hooks/index.d.ts +0 -2
  102. package/dist/hooks/index.js +0 -2
  103. package/dist/hooks/input-validator.d.ts +0 -1
  104. package/dist/hooks/input-validator.js +0 -1
  105. package/dist/hooks/input-validator.test.js +0 -1
  106. package/dist/hooks/standalone-checker.d.ts +0 -1
  107. package/dist/hooks/standalone-checker.js +0 -1
  108. package/dist/hooks/standalone-dlp-checker.d.ts +0 -1
  109. package/dist/hooks/standalone-dlp-checker.js +0 -1
  110. package/dist/hooks/templates.d.ts +0 -1
  111. package/dist/hooks/templates.js +0 -1
  112. package/dist/hooks/types.d.ts +0 -1
  113. package/dist/hooks/types.js +0 -1
  114. package/dist/index.d.ts +1 -1
  115. package/dist/index.js +1 -1
  116. package/dist/inference/index.js +1 -1
  117. package/dist/services/adaptive-thresholds.d.ts +0 -2
  118. package/dist/services/adaptive-thresholds.js +0 -2
  119. package/dist/services/filesystem-cache.d.ts +0 -1
  120. package/dist/services/filesystem-cache.js +0 -1
  121. package/dist/services/score-history.d.ts +0 -1
  122. package/dist/services/score-history.js +0 -1
  123. package/dist/services/temporal-drift.d.ts +1 -2
  124. package/dist/services/temporal-drift.js +7 -8
  125. package/dist/storage/db.d.ts +23 -7
  126. package/dist/storage/db.js +116 -55
  127. package/dist/storage/findings.d.ts +4 -3
  128. package/dist/storage/findings.js +13 -20
  129. package/dist/storage/local-memory.d.ts +4 -4
  130. package/dist/storage/local-memory.js +20 -22
  131. package/dist/storage/patterns.d.ts +5 -5
  132. package/dist/storage/patterns.js +20 -26
  133. package/dist/storage/scans.d.ts +6 -6
  134. package/dist/storage/scans.js +12 -21
  135. package/dist/types/index.d.ts +1 -0
  136. package/dist/utils/scanner.js +1 -1
  137. package/package.json +7 -8
  138. package/dist/gates/duplication-drift.d.ts +0 -128
  139. package/dist/gates/duplication-drift.js +0 -585
  140. package/dist/gates/hallucinated-imports.js +0 -641
  141. package/dist/gates/side-effect-helpers.d.ts +0 -260
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Scope and Context Tracking for Side-Effect Analysis
3
+ *
4
+ * Tracks scope boundaries, context tracking, and state during analysis.
5
+ */
6
+ import { findEnclosingFunction, extractLoopBody, extractFunctionDefs, isInUseEffectWithCleanup, isInsideCleanupContext, } from '../side-effect-helpers/index.js';
7
+ /**
8
+ * Finds the enclosing function scope for a given line index.
9
+ * Returns start and end line numbers of the scope.
10
+ */
11
+ export function findFunctionScope(lines, lineIndex, lang) {
12
+ return findEnclosingFunction(lines, lineIndex, lang);
13
+ }
14
+ /**
15
+ * Extracts the body of a loop or block starting at the given line.
16
+ * Handles scope-aware block detection (brace/indent tracking).
17
+ */
18
+ export function getBlockBody(lines, lineIndex, lang) {
19
+ return extractLoopBody(lines, lineIndex, lang);
20
+ }
21
+ /**
22
+ * Checks if a timer creation is in a React useEffect with cleanup return.
23
+ * Framework-aware pattern detection for safe side effects.
24
+ */
25
+ export function isInFrameworkCleanup(lines, lineIndex, lang) {
26
+ if ((lang === 'js' || lang === 'ts') && isInUseEffectWithCleanup(lines, lineIndex)) {
27
+ return true;
28
+ }
29
+ if (isInsideCleanupContext(lines, lineIndex, lang)) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Extracts all function definitions from the source code.
36
+ * Used for recursion analysis.
37
+ */
38
+ export function getAllFunctions(lines, lang) {
39
+ return extractFunctionDefs(lines, lang);
40
+ }
@@ -0,0 +1,4 @@
1
+ export * from './types.js';
2
+ export * from './scope-analysis.js';
3
+ export * from './resource-tracking.js';
4
+ export * from './pattern-detection.js';
@@ -0,0 +1,4 @@
1
+ export * from './types.js';
2
+ export * from './scope-analysis.js';
3
+ export * from './resource-tracking.js';
4
+ export * from './pattern-detection.js';
@@ -0,0 +1,123 @@
1
+ import { SideEffectLang } from './types.js';
2
+ /**
3
+ * Extract the path being watched from a file watcher call.
4
+ * Returns null if path cannot be determined.
5
+ *
6
+ * Handles:
7
+ * - fs.watch('./src', ...)
8
+ * - chokidar.watch(['./src', './lib'], ...)
9
+ * - Observer(path=...)
10
+ * - fsnotify.NewWatcher() + watcher.Add(path)
11
+ */
12
+ export declare function extractWatchedPath(line: string): string | null;
13
+ /**
14
+ * Extract write target path from a file write call.
15
+ * Returns null if path cannot be determined.
16
+ */
17
+ export declare function extractWritePath(line: string): string | null;
18
+ /**
19
+ * Check if a write path could trigger a file watcher.
20
+ *
21
+ * Smart matching:
22
+ * - "./src/output.js" is inside watched "./src"
23
+ * - "./dist/bundle.js" is NOT inside "./src"
24
+ * - If either path is a variable reference ($var), consider it suspicious
25
+ * - Exact matches always overlap
26
+ */
27
+ export declare function pathsOverlap(watchPath: string | null, writePath: string | null): boolean;
28
+ /**
29
+ * Extract loop body with correct scope tracking.
30
+ * Uses brace/indent matching (not just "next N lines").
31
+ */
32
+ export declare function extractLoopBody(lines: string[], loopLine: number, lang: SideEffectLang): {
33
+ body: string;
34
+ start: number;
35
+ end: number;
36
+ };
37
+ /**
38
+ * Extract all function definitions with their bodies.
39
+ * Used for recursion detection — need to check if function calls itself
40
+ * within its own extracted body (not just anywhere in the file).
41
+ */
42
+ export declare function extractFunctionDefs(lines: string[], lang: SideEffectLang): {
43
+ name: string;
44
+ start: number;
45
+ end: number;
46
+ params: string;
47
+ }[];
48
+ /**
49
+ * Check if a function has a base case (return/break before recursive call).
50
+ * Smart: actually checks that the base case comes BEFORE the recursive call,
51
+ * not just that both exist somewhere in the body.
52
+ */
53
+ export declare function hasBaseCase(bodyLines: string[], funcName: string): boolean;
54
+ /**
55
+ * Check if a function has a depth/limit parameter (implies bounded recursion).
56
+ * Smarter than just checking for the word "depth" anywhere — checks the
57
+ * function signature specifically.
58
+ */
59
+ export declare function hasDepthParameter(funcLine: string): boolean;
60
+ /**
61
+ * Check if a code block contains I/O operations.
62
+ * Language-aware: knows which stdlib calls are I/O.
63
+ */
64
+ export declare function containsIO(body: string, lang: SideEffectLang): boolean;
65
+ /**
66
+ * Check if a loop body or its preamble contains a retry limit.
67
+ *
68
+ * Smart: checks variable declarations before the loop AND inside the loop.
69
+ * Recognizes both explicit counters and library patterns.
70
+ */
71
+ export declare function hasRetryLimit(lines: string[], loopLine: number, bodyEnd: number): boolean;
72
+ /**
73
+ * Check if error handling inside a loop constitutes a retry pattern.
74
+ * Not just "catch exists" but "catch is followed by continue or the loop wraps the try".
75
+ */
76
+ export declare function hasCatchWithContinue(body: string, lang: SideEffectLang): boolean;
77
+ /**
78
+ * Check if a line contains a process spawn call.
79
+ */
80
+ export declare function isProcessSpawn(line: string, lang: SideEffectLang): RegExpMatchArray | null;
81
+ /**
82
+ * Check if a line contains a timer creation call.
83
+ * Returns the timer function name if matched.
84
+ */
85
+ export declare function isTimerCreation(line: string, lang: SideEffectLang): string | null;
86
+ /**
87
+ * Get cleanup patterns for timers (language-specific).
88
+ */
89
+ export declare function getTimerCleanupPatterns(lang: SideEffectLang): RegExp[];
90
+ /**
91
+ * Get cleanup patterns for spawned processes.
92
+ */
93
+ export declare function getProcessCleanupPatterns(lang: SideEffectLang): RegExp[];
94
+ /**
95
+ * Check if a line contains an unbounded loop construct.
96
+ */
97
+ export declare function isUnboundedLoop(line: string, lang: SideEffectLang): boolean;
98
+ /**
99
+ * Check if a line creates a file watcher.
100
+ * Returns the watcher function name if matched.
101
+ */
102
+ export declare function isFileWatcher(line: string, lang: SideEffectLang): string | null;
103
+ /**
104
+ * Check if a code body contains file write operations.
105
+ * Returns the first write call found, or null.
106
+ */
107
+ export declare function findWriteInBody(body: string, lang: SideEffectLang): string | null;
108
+ /**
109
+ * Check if a file watcher callback has debounce/throttle protection.
110
+ */
111
+ export declare function hasDebounceProtection(body: string): boolean;
112
+ /**
113
+ * Get resource open patterns for lifecycle checking.
114
+ */
115
+ export declare function isResourceOpen(line: string, lang: SideEffectLang): string | null;
116
+ /**
117
+ * Get resource close patterns.
118
+ */
119
+ export declare function getResourceClosePatterns(lang: SideEffectLang): RegExp[];
120
+ /**
121
+ * Check if an exit/signal handler respawns the process (auto-restart pattern).
122
+ */
123
+ export declare function isExitHandler(line: string, lang: SideEffectLang): boolean;