@sikkuumiii/defuse 0.0.0-stage → 0.5.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 (236) hide show
  1. package/LICENSE +235 -0
  2. package/README.md +561 -2
  3. package/dist/src/cli.d.ts +20 -0
  4. package/dist/src/cli.js +619 -0
  5. package/dist/src/cli.js.map +1 -0
  6. package/dist/src/core/analyze.d.ts +178 -0
  7. package/dist/src/core/analyze.js +834 -0
  8. package/dist/src/core/analyze.js.map +1 -0
  9. package/dist/src/core/coverage.d.ts +87 -0
  10. package/dist/src/core/coverage.js +181 -0
  11. package/dist/src/core/coverage.js.map +1 -0
  12. package/dist/src/core/finding.d.ts +196 -0
  13. package/dist/src/core/finding.js +178 -0
  14. package/dist/src/core/finding.js.map +1 -0
  15. package/dist/src/core/licence.d.ts +50 -0
  16. package/dist/src/core/licence.js +56 -0
  17. package/dist/src/core/licence.js.map +1 -0
  18. package/dist/src/core/paths.d.ts +21 -0
  19. package/dist/src/core/paths.js +58 -0
  20. package/dist/src/core/paths.js.map +1 -0
  21. package/dist/src/core/score.d.ts +137 -0
  22. package/dist/src/core/score.js +232 -0
  23. package/dist/src/core/score.js.map +1 -0
  24. package/dist/src/dast/targets.d.ts +30 -0
  25. package/dist/src/dast/targets.js +79 -0
  26. package/dist/src/dast/targets.js.map +1 -0
  27. package/dist/src/dast/zap.d.ts +42 -0
  28. package/dist/src/dast/zap.js +184 -0
  29. package/dist/src/dast/zap.js.map +1 -0
  30. package/dist/src/engine/scan.d.ts +80 -0
  31. package/dist/src/engine/scan.js +129 -0
  32. package/dist/src/engine/scan.js.map +1 -0
  33. package/dist/src/engine/shapes.d.ts +47 -0
  34. package/dist/src/engine/shapes.js +328 -0
  35. package/dist/src/engine/shapes.js.map +1 -0
  36. package/dist/src/engine/walk.d.ts +60 -0
  37. package/dist/src/engine/walk.js +156 -0
  38. package/dist/src/engine/walk.js.map +1 -0
  39. package/dist/src/parse/astDump.d.ts +31 -0
  40. package/dist/src/parse/astDump.js +66 -0
  41. package/dist/src/parse/astDump.js.map +1 -0
  42. package/dist/src/parse/languages.d.ts +70 -0
  43. package/dist/src/parse/languages.js +174 -0
  44. package/dist/src/parse/languages.js.map +1 -0
  45. package/dist/src/parse/location.d.ts +17 -0
  46. package/dist/src/parse/location.js +38 -0
  47. package/dist/src/parse/location.js.map +1 -0
  48. package/dist/src/parse/node-grammars.d.ts +12 -0
  49. package/dist/src/parse/node-grammars.js +35 -0
  50. package/dist/src/parse/node-grammars.js.map +1 -0
  51. package/dist/src/parse/parser.d.ts +126 -0
  52. package/dist/src/parse/parser.js +202 -0
  53. package/dist/src/parse/parser.js.map +1 -0
  54. package/dist/src/parse/tree-store.d.ts +139 -0
  55. package/dist/src/parse/tree-store.js +236 -0
  56. package/dist/src/parse/tree-store.js.map +1 -0
  57. package/dist/src/platform/dependency-rule.d.ts +27 -0
  58. package/dist/src/platform/dependency-rule.js +21 -0
  59. package/dist/src/platform/dependency-rule.js.map +1 -0
  60. package/dist/src/platform/deps.d.ts +86 -0
  61. package/dist/src/platform/deps.js +304 -0
  62. package/dist/src/platform/deps.js.map +1 -0
  63. package/dist/src/platform/php-facts.d.ts +49 -0
  64. package/dist/src/platform/php-facts.js +67 -0
  65. package/dist/src/platform/php-facts.js.map +1 -0
  66. package/dist/src/platform/runtime-version.d.ts +78 -0
  67. package/dist/src/platform/runtime-version.js +573 -0
  68. package/dist/src/platform/runtime-version.js.map +1 -0
  69. package/dist/src/report/colors.d.ts +50 -0
  70. package/dist/src/report/colors.js +97 -0
  71. package/dist/src/report/colors.js.map +1 -0
  72. package/dist/src/report/coverage-table.d.ts +90 -0
  73. package/dist/src/report/coverage-table.js +291 -0
  74. package/dist/src/report/coverage-table.js.map +1 -0
  75. package/dist/src/report/html-report.d.ts +66 -0
  76. package/dist/src/report/html-report.js +489 -0
  77. package/dist/src/report/html-report.js.map +1 -0
  78. package/dist/src/report/human.d.ts +44 -0
  79. package/dist/src/report/human.js +575 -0
  80. package/dist/src/report/human.js.map +1 -0
  81. package/dist/src/report/json.d.ts +24 -0
  82. package/dist/src/report/json.js +178 -0
  83. package/dist/src/report/json.js.map +1 -0
  84. package/dist/src/report/mark.d.ts +17 -0
  85. package/dist/src/report/mark.js +39 -0
  86. package/dist/src/report/mark.js.map +1 -0
  87. package/dist/src/report/pricing.d.ts +33 -0
  88. package/dist/src/report/pricing.js +343 -0
  89. package/dist/src/report/pricing.js.map +1 -0
  90. package/dist/src/report/sarif.d.ts +39 -0
  91. package/dist/src/report/sarif.js +219 -0
  92. package/dist/src/report/sarif.js.map +1 -0
  93. package/dist/src/report/site.d.ts +87 -0
  94. package/dist/src/report/site.js +742 -0
  95. package/dist/src/report/site.js.map +1 -0
  96. package/dist/src/rules/code-injection.d.ts +47 -0
  97. package/dist/src/rules/code-injection.js +326 -0
  98. package/dist/src/rules/code-injection.js.map +1 -0
  99. package/dist/src/rules/command-injection.d.ts +30 -0
  100. package/dist/src/rules/command-injection.js +286 -0
  101. package/dist/src/rules/command-injection.js.map +1 -0
  102. package/dist/src/rules/contract.d.ts +198 -0
  103. package/dist/src/rules/contract.js +39 -0
  104. package/dist/src/rules/contract.js.map +1 -0
  105. package/dist/src/rules/format-string.d.ts +46 -0
  106. package/dist/src/rules/format-string.js +146 -0
  107. package/dist/src/rules/format-string.js.map +1 -0
  108. package/dist/src/rules/hardcoded-secret.d.ts +38 -0
  109. package/dist/src/rules/hardcoded-secret.js +440 -0
  110. package/dist/src/rules/hardcoded-secret.js.map +1 -0
  111. package/dist/src/rules/lib/guards.d.ts +168 -0
  112. package/dist/src/rules/lib/guards.js +1179 -0
  113. package/dist/src/rules/lib/guards.js.map +1 -0
  114. package/dist/src/rules/lib/html-safety.d.ts +75 -0
  115. package/dist/src/rules/lib/html-safety.js +755 -0
  116. package/dist/src/rules/lib/html-safety.js.map +1 -0
  117. package/dist/src/rules/lib/local-build.d.ts +59 -0
  118. package/dist/src/rules/lib/local-build.js +320 -0
  119. package/dist/src/rules/lib/local-build.js.map +1 -0
  120. package/dist/src/rules/lib/strings.d.ts +208 -0
  121. package/dist/src/rules/lib/strings.js +1970 -0
  122. package/dist/src/rules/lib/strings.js.map +1 -0
  123. package/dist/src/rules/path-traversal.d.ts +33 -0
  124. package/dist/src/rules/path-traversal.js +96 -0
  125. package/dist/src/rules/path-traversal.js.map +1 -0
  126. package/dist/src/rules/registry.d.ts +19 -0
  127. package/dist/src/rules/registry.js +77 -0
  128. package/dist/src/rules/registry.js.map +1 -0
  129. package/dist/src/rules/sql-injection.d.ts +36 -0
  130. package/dist/src/rules/sql-injection.js +299 -0
  131. package/dist/src/rules/sql-injection.js.map +1 -0
  132. package/dist/src/rules/ssrf.d.ts +39 -0
  133. package/dist/src/rules/ssrf.js +111 -0
  134. package/dist/src/rules/ssrf.js.map +1 -0
  135. package/dist/src/rules/unbounded-copy.d.ts +37 -0
  136. package/dist/src/rules/unbounded-copy.js +147 -0
  137. package/dist/src/rules/unbounded-copy.js.map +1 -0
  138. package/dist/src/rules/unsafe-deserialization.d.ts +43 -0
  139. package/dist/src/rules/unsafe-deserialization.js +276 -0
  140. package/dist/src/rules/unsafe-deserialization.js.map +1 -0
  141. package/dist/src/rules/weak-hash.d.ts +37 -0
  142. package/dist/src/rules/weak-hash.js +197 -0
  143. package/dist/src/rules/weak-hash.js.map +1 -0
  144. package/dist/src/rules/xss.d.ts +38 -0
  145. package/dist/src/rules/xss.js +527 -0
  146. package/dist/src/rules/xss.js.map +1 -0
  147. package/dist/src/taint/content-type.d.ts +19 -0
  148. package/dist/src/taint/content-type.js +20 -0
  149. package/dist/src/taint/content-type.js.map +1 -0
  150. package/dist/src/taint/dictionaries.d.ts +23 -0
  151. package/dist/src/taint/dictionaries.js +1778 -0
  152. package/dist/src/taint/dictionaries.js.map +1 -0
  153. package/dist/src/taint/fold.d.ts +59 -0
  154. package/dist/src/taint/fold.js +1177 -0
  155. package/dist/src/taint/fold.js.map +1 -0
  156. package/dist/src/taint/java-scope.d.ts +61 -0
  157. package/dist/src/taint/java-scope.js +212 -0
  158. package/dist/src/taint/java-scope.js.map +1 -0
  159. package/dist/src/taint/local-map.d.ts +79 -0
  160. package/dist/src/taint/local-map.js +603 -0
  161. package/dist/src/taint/local-map.js.map +1 -0
  162. package/dist/src/taint/project.d.ts +172 -0
  163. package/dist/src/taint/project.js +617 -0
  164. package/dist/src/taint/project.js.map +1 -0
  165. package/dist/src/taint/tracer.d.ts +265 -0
  166. package/dist/src/taint/tracer.js +3817 -0
  167. package/dist/src/taint/tracer.js.map +1 -0
  168. package/dist/src/taint/types.d.ts +484 -0
  169. package/dist/src/taint/types.js +47 -0
  170. package/dist/src/taint/types.js.map +1 -0
  171. package/dist/src/taint/visibility.d.ts +25 -0
  172. package/dist/src/taint/visibility.js +96 -0
  173. package/dist/src/taint/visibility.js.map +1 -0
  174. package/docs/examples/defuse.json +20 -0
  175. package/docs/examples/dvwa-urls.json +14 -0
  176. package/docs/examples/github-code-scanning.yml +54 -0
  177. package/docs/examples/tiny.js +4 -0
  178. package/package.json +73 -4
  179. package/src/cli.ts +747 -0
  180. package/src/core/analyze.ts +1072 -0
  181. package/src/core/coverage.ts +269 -0
  182. package/src/core/finding.ts +311 -0
  183. package/src/core/licence.ts +61 -0
  184. package/src/core/paths.ts +59 -0
  185. package/src/core/score.ts +353 -0
  186. package/src/dast/targets.ts +121 -0
  187. package/src/dast/zap.ts +246 -0
  188. package/src/engine/scan.ts +200 -0
  189. package/src/engine/shapes.ts +348 -0
  190. package/src/engine/walk.ts +196 -0
  191. package/src/parse/astDump.ts +85 -0
  192. package/src/parse/languages.ts +232 -0
  193. package/src/parse/location.ts +44 -0
  194. package/src/parse/node-grammars.ts +41 -0
  195. package/src/parse/parser.ts +262 -0
  196. package/src/parse/tree-store.ts +301 -0
  197. package/src/platform/dependency-rule.ts +33 -0
  198. package/src/platform/deps.ts +374 -0
  199. package/src/platform/php-facts.ts +85 -0
  200. package/src/platform/runtime-version.ts +710 -0
  201. package/src/report/colors.ts +107 -0
  202. package/src/report/coverage-table.ts +359 -0
  203. package/src/report/html-report.ts +601 -0
  204. package/src/report/human.ts +811 -0
  205. package/src/report/json.ts +189 -0
  206. package/src/report/mark.ts +47 -0
  207. package/src/report/pricing.ts +374 -0
  208. package/src/report/sarif.ts +235 -0
  209. package/src/report/site.ts +760 -0
  210. package/src/rules/code-injection.ts +346 -0
  211. package/src/rules/command-injection.ts +296 -0
  212. package/src/rules/contract.ts +220 -0
  213. package/src/rules/format-string.ts +158 -0
  214. package/src/rules/hardcoded-secret.ts +485 -0
  215. package/src/rules/lib/guards.ts +1235 -0
  216. package/src/rules/lib/html-safety.ts +793 -0
  217. package/src/rules/lib/local-build.ts +329 -0
  218. package/src/rules/lib/strings.ts +2034 -0
  219. package/src/rules/path-traversal.ts +101 -0
  220. package/src/rules/registry.ts +90 -0
  221. package/src/rules/sql-injection.ts +311 -0
  222. package/src/rules/ssrf.ts +118 -0
  223. package/src/rules/unbounded-copy.ts +162 -0
  224. package/src/rules/unsafe-deserialization.ts +291 -0
  225. package/src/rules/weak-hash.ts +226 -0
  226. package/src/rules/xss.ts +572 -0
  227. package/src/taint/content-type.ts +20 -0
  228. package/src/taint/dictionaries.ts +1855 -0
  229. package/src/taint/fold.ts +1206 -0
  230. package/src/taint/java-scope.ts +200 -0
  231. package/src/taint/local-map.ts +594 -0
  232. package/src/taint/project.ts +774 -0
  233. package/src/taint/tracer.ts +4298 -0
  234. package/src/taint/types.ts +511 -0
  235. package/src/taint/visibility.ts +100 -0
  236. package/tsconfig.json +61 -0
@@ -0,0 +1,617 @@
1
+ /**
2
+ * THE PROJECT INDEX (cross-file resolution)
3
+ * ==========================================
4
+ *
5
+ * Up to now the tracer could follow a value anywhere inside one file and no
6
+ * further. `helper(dirty)` where `helper` lives in `./helpers.js` was the end of
7
+ * the road, and on real code that is where most of the road is: applications put
8
+ * their database access in `db.js`, their escaping in `util/html.py`, their
9
+ * command runners in `Shell.java`.
10
+ *
11
+ * This module answers one question: **"file F calls a function named N - which
12
+ * file, if any, is that?"**
13
+ *
14
+ * THE RULE IT PLAYS BY: answer only when the answer is unambiguous.
15
+ *
16
+ * If two imported modules both define `sanitize`, we say nothing and record
17
+ * that we declined. Picking one at random would let the tool print a
18
+ * step-by-step "proof" through a function that never runs - which is worse than
19
+ * printing nothing, because it looks like evidence. The count of declined
20
+ * resolutions is reported in every scan.
21
+ *
22
+ * HOW IMPORTS ARE FOUND, per language:
23
+ *
24
+ * JS/TS `import x from './a'` and `require('./a')`, resolved relative to the
25
+ * importing file, trying the usual extensions and `/index`.
26
+ * Python `from .a import x`, `from pkg.a import x`, `import pkg.a` - resolved
27
+ * against the files actually present in the scan.
28
+ * Java `import com.x.Bar;` resolves to a file named `Bar.java`, PLUS every
29
+ * file in the same directory, because Java classes in the same
30
+ * package see each other with no import at all.
31
+ * Go every file in the same directory, because that is one package. Go
32
+ * imports name packages rather than files, and resolving those needs
33
+ * module metadata we do not read.
34
+ *
35
+ * WHAT IT DOES NOT DO, stated here and in the scan report:
36
+ * - It does not check that the function is actually EXPORTED. A module-private
37
+ * helper with the same name as an exported one could be entered.
38
+ * - It does not follow re-exports (`export * from './a'`).
39
+ * - It does not resolve node_modules, third-party packages, or aliases from
40
+ * tsconfig `paths` / webpack config.
41
+ * - Dynamic imports and computed requires are invisible.
42
+ */
43
+ import { basenameOf, dirnameOf, joinPath, resolveFrom, toPosix } from '../core/paths.js';
44
+ import { nodeAtRange } from '../parse/tree-store.js';
45
+ import { collectFunctions } from './tracer.js';
46
+ import { hasModifier } from './java-scope.js';
47
+ const JAVA_TYPE_DECLARATIONS = new Set([
48
+ 'class_declaration', 'interface_declaration', 'enum_declaration', 'record_declaration',
49
+ 'annotation_type_declaration',
50
+ ]);
51
+ export function javaTypeFacts(root) {
52
+ /*
53
+ * A dotted name read from its identifiers, not its text - so a comment
54
+ * between `import` and the name is not part of the name. A regex over the
55
+ * line missed such an import entirely, and the class it named lost to one in
56
+ * the same package that the import outranks (tests/probes/p08).
57
+ */
58
+ const dotted = (n) => {
59
+ const parts = [];
60
+ const visit = (x) => {
61
+ if (x.type === 'identifier')
62
+ parts.push(x.text ?? '');
63
+ for (const c of x.namedChildren)
64
+ if (c && c.type !== 'block_comment' && c.type !== 'line_comment')
65
+ visit(c);
66
+ };
67
+ if (n)
68
+ visit(n);
69
+ return parts.join('.');
70
+ };
71
+ let packageName = '';
72
+ const types = [];
73
+ const singleTypeImports = [];
74
+ const staticImports = [];
75
+ let staticOnDemand = false;
76
+ for (const child of root.namedChildren) {
77
+ if (!child)
78
+ continue;
79
+ if (child.type === 'package_declaration') {
80
+ packageName = dotted(child.namedChildren.find((c) => c?.type === 'scoped_identifier' || c?.type === 'identifier'));
81
+ }
82
+ else if (JAVA_TYPE_DECLARATIONS.has(child.type)) {
83
+ const name = child.childForFieldName('name')?.text;
84
+ if (name)
85
+ types.push({ name, kind: child.type });
86
+ }
87
+ else if (child.type === 'import_declaration') {
88
+ const isStatic = child.children.some((c) => c?.type === 'static');
89
+ const onDemand = child.namedChildren.some((c) => c?.type === 'asterisk');
90
+ const name = dotted(child.namedChildren.find((c) => c?.type === 'scoped_identifier' || c?.type === 'identifier'));
91
+ if (isStatic && onDemand)
92
+ staticOnDemand = true;
93
+ else if (isStatic)
94
+ staticImports.push(name.split('.').pop() ?? '');
95
+ else if (!onDemand && name)
96
+ singleTypeImports.push(name);
97
+ }
98
+ }
99
+ /*
100
+ * Nested types count for "is this type in the scan?": a superclass that is
101
+ * a nested class of this or another file is as able to supply members as a
102
+ * top-level one (tests/probes/j05, j06).
103
+ */
104
+ const allTypeNames = root
105
+ .descendantsOfType([...JAVA_TYPE_DECLARATIONS])
106
+ .map((n) => n?.childForFieldName('name')?.text ?? '')
107
+ .filter(Boolean);
108
+ return { packageName, types, singleTypeImports, staticImports, staticOnDemand, allTypeNames };
109
+ }
110
+ /** Turn a file's functions into coordinates, using the tracer's own definition. */
111
+ export function indexFunctions(root, language) {
112
+ const indexed = new Map();
113
+ for (const [name, fn] of collectFunctions(root, language)) {
114
+ indexed.set(name, {
115
+ name: fn.name,
116
+ params: fn.params,
117
+ minArgs: fn.minArgs,
118
+ maxArgs: fn.maxArgs,
119
+ bodyStart: fn.body.startIndex,
120
+ bodyEnd: fn.body.endIndex,
121
+ bodyType: fn.body.type,
122
+ });
123
+ }
124
+ return indexed;
125
+ }
126
+ /* -------------------------------------------------------------------------- *
127
+ * Import extraction - from the syntax tree, not from a text search, for the
128
+ * same reason the rules use the tree: a `require('./db')` inside a comment or a
129
+ * string is not an import.
130
+ * -------------------------------------------------------------------------- */
131
+ const IMPORT_NODES = {
132
+ javascript: ['import_statement', 'call_expression'],
133
+ typescript: ['import_statement', 'call_expression'],
134
+ python: ['import_statement', 'import_from_statement'],
135
+ /*
136
+ * `scoped_type_identifier` is here because an import statement is not the
137
+ * only way Java names another file.
138
+ *
139
+ * new org.owasp.benchmark.helpers.SeparateClassRequest(request)
140
+ *
141
+ * names a class as precisely as any import does and produces no
142
+ * import_declaration at all, so the edge was never built and the call was
143
+ * never followed.
144
+ *
145
+ * This was not a corner. It was EVERY ONE of the 69 cases the OWASP
146
+ * benchmark scored as a complete miss - 48 xss, 20 cmdi, 1 sqli, all of them
147
+ * a request wrapped in a helper class referenced by its full name. Proven by
148
+ * adding a single import line to one test case and changing nothing else,
149
+ * which turned a silent file into a finding.
150
+ *
151
+ * A complete miss is the only failure mode that gets somebody hacked, and
152
+ * this one was a hundred percent of ours.
153
+ */
154
+ java: ['import_declaration', 'scoped_type_identifier'],
155
+ go: [],
156
+ // PHP's require/include are function-like statements, and Composer autoloading
157
+ // resolves classes with no import line at all. Cross-file tracing in PHP is
158
+ // therefore NOT implemented - stated here rather than half-attempted.
159
+ php: [],
160
+ /*
161
+ * C and C++ resolve calls at LINK time, not through anything written in the
162
+ * source, and that is a harder problem than it first looks.
163
+ *
164
+ * `#include` brings in DECLARATIONS, not definitions - the body of the
165
+ * function lives in a .c file the header never names, chosen by a Makefile
166
+ * we do not read. So following an include would lead to a prototype and stop.
167
+ *
168
+ * Same-directory resolution, which is what makes Java and Go work above, is
169
+ * actively unsafe here: `static` gives a C function FILE scope, and every
170
+ * large C project has a dozen different `static int init(void)` definitions
171
+ * sitting in the same folder. Matching by name would let the tracer walk into
172
+ * a function the caller provably cannot see, and print a step-by-step proof
173
+ * through it. That is the exact failure this project exists to refuse, so
174
+ * cross-file tracing in the C family is NOT implemented and says so.
175
+ */
176
+ c: [],
177
+ cpp: [],
178
+ };
179
+ function unquote(raw) {
180
+ return raw.replace(/^[a-zA-Z]?["'`]/, '').replace(/["'`]$/, '');
181
+ }
182
+ /** The raw module specifiers this file mentions, e.g. "./db", "app.helpers". */
183
+ export function importSpecifiers(root, language) {
184
+ const wanted = new Set(IMPORT_NODES[language]);
185
+ if (wanted.size === 0)
186
+ return [];
187
+ const specifiers = [];
188
+ /*
189
+ * Six levels is enough for every language whose edges are declarations at
190
+ * the top of the file. Java's are not: a fully-qualified type reference sits
191
+ * inside a method body, which is twenty-odd levels down, so the walk stopped
192
+ * short of the very thing it needed to see.
193
+ *
194
+ * 48 is past any hand-written nesting and still far under the tracer's own
195
+ * MAX_AST_DEPTH of 400, and it applies only to Java - nothing else pays for
196
+ * it.
197
+ */
198
+ const maxDepth = language === 'java' ? 48 : 6;
199
+ const visit = (node, depth) => {
200
+ if (depth > maxDepth)
201
+ return;
202
+ if (wanted.has(node.type)) {
203
+ if (node.type === 'scoped_type_identifier') {
204
+ /*
205
+ * `a.b.C` parses as scoped_type_identifier nested inside
206
+ * scoped_type_identifier: the whole name, then `a.b`, then `a`. Only
207
+ * the outermost is the class being named; the inner ones are package
208
+ * fragments and would each try to resolve as a class of their own.
209
+ *
210
+ * The resolver below already requires exactly one file to match the
211
+ * final segment, so a fragment that matches nothing is harmless and a
212
+ * name that matches two files is declined rather than guessed. This
213
+ * check is about not asking the question, rather than about surviving
214
+ * the answer.
215
+ */
216
+ if (node.parent?.type !== 'scoped_type_identifier') {
217
+ specifiers.push((node.text ?? '').trim());
218
+ }
219
+ }
220
+ else if (node.type === 'call_expression') {
221
+ // require('./db') - only when the callee really is `require`.
222
+ const callee = node.childForFieldName('function');
223
+ if (callee?.text === 'require') {
224
+ const args = node.childForFieldName('arguments');
225
+ const first = args?.namedChildren.find((c) => c !== null);
226
+ if (first)
227
+ specifiers.push(unquote(first.text ?? ''));
228
+ }
229
+ }
230
+ else if (node.type === 'import_from_statement' &&
231
+ /^\.+$/.test(node.childForFieldName('module_name')?.text ?? '')) {
232
+ /*
233
+ * `from . import runner, shell` names no module in the `from` part: the
234
+ * imported NAMES are the modules (runner.py, shell/__init__.py). Read
235
+ * as just ".", it resolved to the package folder and never to a file -
236
+ * so every edge in a package written this way was lost. One specifier
237
+ * per name, `.runner`, resolves them like `from .runner import x`.
238
+ * ponytail: a name defined in the package's own __init__.py rather than
239
+ * a module of that name stays unresolved; add a fallback when it shows.
240
+ */
241
+ const dots = node.childForFieldName('module_name')?.text ?? '.';
242
+ const names = node.childrenForFieldName('name').filter((n) => n !== null);
243
+ if (names.length === 0)
244
+ specifiers.push(dots); // `from . import *`: the package itself
245
+ for (const name of names) {
246
+ const module = name.type === 'aliased_import' ? name.childForFieldName('name') : name;
247
+ if (module?.text)
248
+ specifiers.push(`${dots}${module.text}`);
249
+ }
250
+ }
251
+ else {
252
+ const source = node.childForFieldName('source') ??
253
+ node.childForFieldName('module_name') ??
254
+ node.childForFieldName('name') ??
255
+ null;
256
+ const raw = (source ?? node).text ?? '';
257
+ specifiers.push(unquote(raw.replace(/^import\s+|;$/g, '').trim()));
258
+ }
259
+ }
260
+ for (const child of node.namedChildren)
261
+ if (child)
262
+ visit(child, depth + 1);
263
+ };
264
+ visit(root, 0);
265
+ return specifiers.filter(Boolean);
266
+ }
267
+ const JS_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts'];
268
+ /** Turn a specifier into a path we actually have, or null. */
269
+ /*
270
+ * Every known path by its file name, built once per scan. Java resolves each
271
+ * `a.b.C` by looking for C.java, and BenchmarkJava names a class in full
272
+ * thousands of times - filtering all 2,766 paths for every one of those was
273
+ * the single largest cost in its scan.
274
+ */
275
+ const basenameIndex = new WeakMap();
276
+ function byBasename(known) {
277
+ let index = basenameIndex.get(known);
278
+ if (!index) {
279
+ index = new Map();
280
+ for (const p of known) {
281
+ const name = basenameOf(p);
282
+ const list = index.get(name);
283
+ if (list)
284
+ list.push(p);
285
+ else
286
+ index.set(name, [p]);
287
+ }
288
+ basenameIndex.set(known, index);
289
+ }
290
+ return index;
291
+ }
292
+ function resolveSpecifier(specifier, fromFile, known) {
293
+ const tryAll = (base) => {
294
+ if (known.has(base))
295
+ return base;
296
+ /**
297
+ * TypeScript's ESM convention: source says `import './languages.js'` but the
298
+ * file on disk is `languages.ts`. The compiler rewrites nothing, so a
299
+ * resolver that only tries the literal specifier finds nothing - which is
300
+ * exactly what happened the first time Defuse scanned its own source and
301
+ * reported zero import edges.
302
+ */
303
+ const rewritten = base.replace(/\.(js|mjs|cjs)$/, '');
304
+ if (rewritten !== base) {
305
+ for (const extension of JS_EXTENSIONS) {
306
+ if (known.has(rewritten + extension))
307
+ return rewritten + extension;
308
+ }
309
+ }
310
+ for (const extension of JS_EXTENSIONS) {
311
+ if (known.has(base + extension))
312
+ return base + extension;
313
+ if (known.has(joinPath(base, `index${extension}`))) {
314
+ return joinPath(base, `index${extension}`);
315
+ }
316
+ }
317
+ return null;
318
+ };
319
+ if (fromFile.language === 'javascript' || fromFile.language === 'typescript') {
320
+ // Only relative specifiers. A bare 'express' is a package, not our code.
321
+ if (!specifier.startsWith('.'))
322
+ return null;
323
+ return tryAll(resolveFrom(fromFile.directory, specifier));
324
+ }
325
+ if (fromFile.language === 'python') {
326
+ const leadingDots = /^\.+/.exec(specifier)?.[0].length ?? 0;
327
+ const body = specifier.slice(leadingDots).replace(/\./g, '/');
328
+ // A module is a file (`shell.py`) or a package folder (`shell/__init__.py`).
329
+ if (leadingDots > 0) {
330
+ let base = fromFile.directory;
331
+ for (let i = 1; i < leadingDots; i++)
332
+ base = dirnameOf(base);
333
+ const candidate = body ? joinPath(base, body) : base;
334
+ if (body && known.has(`${candidate}.py`))
335
+ return `${candidate}.py`;
336
+ return known.has(`${candidate}/__init__.py`) ? `${candidate}/__init__.py` : null;
337
+ }
338
+ // Absolute-ish: match any known file whose path ends with the module path.
339
+ const asFile = `${body}.py`;
340
+ const asPackage = `${body}/__init__.py`;
341
+ const matches = [...known].filter((p) => p === asFile || p === asPackage || p.endsWith(`/${asFile}`) || p.endsWith(`/${asPackage}`));
342
+ return matches.length === 1 ? (matches[0] ?? null) : null;
343
+ }
344
+ if (fromFile.language === 'java') {
345
+ // `com.example.Helper` -> a file called Helper.java, if there is exactly one.
346
+ const className = specifier.split('.').pop() ?? '';
347
+ if (!className || className === '*')
348
+ return null;
349
+ const matches = byBasename(known).get(`${className}.java`) ?? [];
350
+ return matches.length === 1 ? (matches[0] ?? null) : null;
351
+ }
352
+ return null;
353
+ }
354
+ /**
355
+ * @param files one record per scanned file, with functions and import
356
+ * specifiers ALREADY extracted from its tree.
357
+ * @param store where trees come from. Only touched when a resolution actually
358
+ * succeeds, which on real projects is a small fraction of files -
359
+ * the index itself is built without a single tree in hand.
360
+ */
361
+ export function buildProjectIndex(files, store) {
362
+ const byPath = new Map();
363
+ // Resolution happens in normalised space; lookups map back to the original.
364
+ const known = new Set(files.map((f) => toPosix(f.path)));
365
+ const originalOf = new Map(files.map((f) => [toPosix(f.path), f.path]));
366
+ for (const file of files) {
367
+ byPath.set(file.path, {
368
+ path: file.path,
369
+ posix: toPosix(file.path),
370
+ directory: dirnameOf(file.path),
371
+ language: file.language,
372
+ functions: file.functions,
373
+ imports: new Set(),
374
+ javaTypes: file.javaTypes,
375
+ });
376
+ }
377
+ // Second pass: resolve specifiers now that every path is known.
378
+ let importEdges = 0;
379
+ let importsUnresolved = 0;
380
+ for (const file of files) {
381
+ const entry = byPath.get(file.path);
382
+ if (!entry)
383
+ continue;
384
+ for (const specifier of file.importSpecifiers) {
385
+ const resolvedPosix = resolveSpecifier(specifier, entry, known);
386
+ const resolved = resolvedPosix ? originalOf.get(resolvedPosix) : undefined;
387
+ if (resolved && resolved !== file.path) {
388
+ entry.imports.add(resolved);
389
+ importEdges++;
390
+ }
391
+ else if (!/^[a-z@][\w@/.-]*$/i.test(specifier) || specifier.startsWith('.')) {
392
+ // A RELATIVE import that resolved to nothing means the file it names is
393
+ // outside the scan. A bare specifier (`express`, `@angular/core`) is a
394
+ // package and is expected not to resolve - counting those would drown
395
+ // the real signal in node_modules noise.
396
+ importsUnresolved++;
397
+ }
398
+ }
399
+ }
400
+ // Same-package visibility: Java and Go files in one directory see each other
401
+ // with no import statement at all, so the directory IS the import edge.
402
+ const byDirectory = new Map();
403
+ for (const entry of byPath.values()) {
404
+ if (entry.language !== 'java' && entry.language !== 'go')
405
+ continue;
406
+ const list = byDirectory.get(entry.directory) ?? [];
407
+ list.push(entry.path);
408
+ byDirectory.set(entry.directory, list);
409
+ }
410
+ /**
411
+ * Function name -> the files that define it.
412
+ *
413
+ * The first version of resolve() walked every sibling file in the directory
414
+ * looking for the name. That is fine for a normal package and catastrophic
415
+ * for OWASP's benchmark, which puts 2,766 Java files in ONE directory: every
416
+ * unresolved call scanned all 2,766 siblings, and a 12-second scan became 60.
417
+ *
418
+ * Indexing by name first turns that inner loop from "all files in the
419
+ * package" into "the handful of files that define this exact name".
420
+ */
421
+ const byFunctionName = new Map();
422
+ for (const entry of byPath.values()) {
423
+ for (const name of entry.functions.keys()) {
424
+ const list = byFunctionName.get(name);
425
+ if (list)
426
+ list.push(entry);
427
+ else
428
+ byFunctionName.set(name, [entry]);
429
+ }
430
+ }
431
+ /** Every Java type name declared in the scan, of every kind, nested ones included. */
432
+ const typeNames = new Set();
433
+ for (const entry of byPath.values())
434
+ for (const t of entry.javaTypes?.allTypeNames ?? [])
435
+ typeNames.add(t);
436
+ let resolved = 0;
437
+ let ambiguous = 0;
438
+ let relocationsFailed = 0;
439
+ let functionsIndexed = 0;
440
+ for (const entry of byPath.values())
441
+ functionsIndexed += entry.functions.size;
442
+ return {
443
+ resolve(fromPath, name) {
444
+ const from = byPath.get(fromPath);
445
+ if (!from)
446
+ return null;
447
+ // Start from "who defines this name at all", then keep only the ones
448
+ // this file can actually see.
449
+ const definers = byFunctionName.get(name);
450
+ if (!definers)
451
+ return null;
452
+ const samePackage = from.language === 'java' || from.language === 'go';
453
+ const hits = definers.filter((candidate) => candidate.path !== fromPath &&
454
+ candidate.language === from.language &&
455
+ (from.imports.has(candidate.path) ||
456
+ (samePackage && candidate.directory === from.directory)));
457
+ if (hits.length === 0)
458
+ return null;
459
+ if (hits.length > 1) {
460
+ ambiguous++;
461
+ return null; // several files define it - we do not guess.
462
+ }
463
+ const winner = hits[0];
464
+ const indexed = winner?.functions.get(name);
465
+ if (!winner || !indexed)
466
+ return null;
467
+ /* ---- materialise: coordinates back into a live syntax node ----
468
+ *
469
+ * This is the only place in the scan that can pull a tree back off disk,
470
+ * and it is deliberately the LAST thing that happens - after the file has
471
+ * been chosen and the ambiguity check has passed. Resolving first and
472
+ * parsing second means a project with thousands of files that never
473
+ * resolve into each other never re-parses anything.
474
+ *
475
+ * The pin lasts until the caller releases it, because the Node handed
476
+ * back here points into this tree's memory and nothing else keeps it
477
+ * alive. */
478
+ store.pin(winner.path);
479
+ const tree = store.get(winner.path);
480
+ const body = nodeAtRange(tree.rootNode, indexed.bodyStart, indexed.bodyEnd, indexed.bodyType);
481
+ if (!body) {
482
+ relocationsFailed++;
483
+ return null;
484
+ }
485
+ resolved++;
486
+ return {
487
+ path: winner.path,
488
+ fn: { name: indexed.name, params: indexed.params, minArgs: indexed.minArgs, maxArgs: indexed.maxArgs, body },
489
+ };
490
+ },
491
+ /*
492
+ * `Utils.getOSCommandString("echo")` - A STATIC CALL, NAMED THROUGH ITS CLASS.
493
+ *
494
+ * resolve() above answers by function NAME, which is right for the tracer:
495
+ * it only ever follows taint INTO a function, and entering the wrong one
496
+ * can at worst report a flow that looks odd. The constant proof asks the
497
+ * opposite question - "is what comes back fixed?" - and a wrong answer
498
+ * there deletes a finding. So this answers only when Java itself leaves no
499
+ * choice:
500
+ *
501
+ * - the receiver names a class: `a.b.Utils` by its full name - where
502
+ * `a` must look like a package and not a type - or `Utils` through a
503
+ * single-type import or, failing that, the caller's own package. An
504
+ * import-on-demand (`import a.b.*;`) is not followed;
505
+ * - exactly ONE file in the scan declares that package and a top-level
506
+ * class of that name - two copies is two candidates, and neither wins;
507
+ * - that class declares exactly one method of the name, and it is
508
+ * static. An overload is chosen by argument types, which nobody here
509
+ * reads; an inherited method lives in a class this does not look for.
510
+ *
511
+ * The caller's side - a local variable named `Utils` hides the class - is
512
+ * checked where the call is, in rules/lib/strings.ts.
513
+ */
514
+ staticMethod(fromPath, receiver, methodName, supertypes = [], allowInstance = false) {
515
+ const from = byPath.get(fromPath);
516
+ const facts = from?.javaTypes;
517
+ if (!from || from.language !== 'java' || !facts)
518
+ return null;
519
+ const dotted = receiver.replace(/\s+/g, '');
520
+ if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(dotted))
521
+ return null;
522
+ const segments = dotted.split('.');
523
+ const first = segments[0] ?? '';
524
+ const className = segments[segments.length - 1] ?? '';
525
+ /*
526
+ * Names that reach this file without a declaration in it: a static import
527
+ * of a member called `first` (a nested type or a field - tests/probes/p04,
528
+ * p05), any `import static a.b.C.*;`, and members inherited from a
529
+ * supertype declared in the scan (p06). Each could be what `first` means.
530
+ * A supertype from OUTSIDE the scan - HttpServlet, say - is not read; the
531
+ * SQL rule's limitations say so.
532
+ */
533
+ if (facts.staticOnDemand || facts.staticImports.includes(first))
534
+ return null;
535
+ if (supertypes.some((t) => t.split('.').some((part) => typeNames.has(part))))
536
+ return null;
537
+ let packageName;
538
+ if (segments.length > 1) {
539
+ /*
540
+ * `Wrapper.Inner` is a package Wrapper's class Inner ONLY if no type
541
+ * called Wrapper is in scope - a type outranks a package (JLS 6.5.2),
542
+ * and then Inner is Wrapper's nested class. Types in scope include
543
+ * library ones this scan never sees, so the first segment must look
544
+ * like a package: not capitalised (the convention every package
545
+ * follows), not a type of ANY kind anywhere in the scan (an interface
546
+ * called `app` - p07), not imported by name.
547
+ */
548
+ if (/^[A-Z]/.test(first) ||
549
+ typeNames.has(first) ||
550
+ facts.singleTypeImports.some((i) => i === first || i.endsWith(`.${first}`))) {
551
+ return null;
552
+ }
553
+ packageName = segments.slice(0, -1).join('.');
554
+ }
555
+ else {
556
+ const imported = facts.singleTypeImports.filter((i) => i.endsWith(`.${className}`));
557
+ if (imported.length > 1)
558
+ return null;
559
+ packageName = imported[0]
560
+ ? imported[0].slice(0, imported[0].length - className.length - 1)
561
+ : facts.packageName;
562
+ }
563
+ // Every kind of type counts as a candidate: a class and an interface
564
+ // with one full name are two candidates, and neither wins (p09).
565
+ const hits = [...byPath.values()].filter((f) => f.language === 'java' &&
566
+ f.javaTypes?.packageName === packageName &&
567
+ f.javaTypes.types.some((t) => t.name === className));
568
+ if (hits.length !== 1 || !hits[0])
569
+ return null;
570
+ const winner = hits[0];
571
+ const declared = winner.javaTypes?.types.filter((t) => t.name === className) ?? [];
572
+ if (declared.length !== 1 || declared[0]?.kind !== 'class_declaration')
573
+ return null;
574
+ store.pin(winner.path);
575
+ const root = store.get(winner.path).rootNode;
576
+ const klass = root.namedChildren.find((c) => c?.type === 'class_declaration' && c.childForFieldName('name')?.text === className);
577
+ if (!klass) {
578
+ relocationsFailed++;
579
+ return null;
580
+ }
581
+ /*
582
+ * A class that inherits from anything can inherit a method of this name
583
+ * - a more specific overload, or the only one that takes this many
584
+ * arguments - and that is the one that runs (p01, p02, p03).
585
+ */
586
+ if (klass.childForFieldName('superclass'))
587
+ return null;
588
+ // An instance method can also come from an interface's default method.
589
+ if (allowInstance && klass.childForFieldName('interfaces'))
590
+ return null;
591
+ const methods = (klass.childForFieldName('body')?.namedChildren ?? []).filter((m) => m?.type === 'method_declaration' && m.childForFieldName('name')?.text === methodName);
592
+ const method = methods.length === 1 ? methods[0] : undefined;
593
+ // Static - or, when the caller holds a `new X(...)` and so knows the
594
+ // object is exactly an X, an instance method (strings.ts, heldCreation).
595
+ if (!method || (!allowInstance && !hasModifier(method, 'static')))
596
+ return null;
597
+ // A private method cannot be called from another class at all.
598
+ if (winner.path !== fromPath && hasModifier(method, 'private'))
599
+ return null;
600
+ return { path: winner.path, method };
601
+ },
602
+ javaTypeInScan: (simpleName) => typeNames.has(simpleName),
603
+ noteAmbiguous() {
604
+ ambiguous++;
605
+ },
606
+ stats: () => ({
607
+ filesIndexed: byPath.size,
608
+ functionsIndexed,
609
+ importEdges,
610
+ importsUnresolved,
611
+ resolved,
612
+ ambiguous,
613
+ relocationsFailed,
614
+ }),
615
+ };
616
+ }
617
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/taint/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,WAAW,EAAkB,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA8D9C,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,mBAAmB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,oBAAoB;IACtF,6BAA6B;CAC9B,CAAC,CAAC;AAEH,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC;;;;;OAKG;IACH,MAAM,MAAM,GAAG,CAAC,CAA0B,EAAU,EAAE;QACpD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,CAAC,CAAO,EAAQ,EAAE;YAC9B,IAAI,CAAC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