cognium-dev 3.27.1 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +291 -246
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3261,6 +3261,7 @@ var parserInitialized = false;
|
|
|
3261
3261
|
var parserInitializing = null;
|
|
3262
3262
|
var loadedLanguages = new Map;
|
|
3263
3263
|
var loadingLanguages = new Map;
|
|
3264
|
+
var cachedParsers = new Map;
|
|
3264
3265
|
var configuredLanguagePaths = {};
|
|
3265
3266
|
var configuredLanguageModules = {};
|
|
3266
3267
|
async function initParser(options = {}) {
|
|
@@ -3330,9 +3331,14 @@ async function loadLanguage(language, wasmPath) {
|
|
|
3330
3331
|
return loadPromise;
|
|
3331
3332
|
}
|
|
3332
3333
|
async function createParser(language) {
|
|
3334
|
+
const cached = cachedParsers.get(language);
|
|
3335
|
+
if (cached) {
|
|
3336
|
+
return cached;
|
|
3337
|
+
}
|
|
3333
3338
|
const lang = await loadLanguage(language);
|
|
3334
3339
|
const parser = new Parser;
|
|
3335
3340
|
parser.setLanguage(lang);
|
|
3341
|
+
cachedParsers.set(language, parser);
|
|
3336
3342
|
return parser;
|
|
3337
3343
|
}
|
|
3338
3344
|
async function parse(code, language) {
|
|
@@ -3343,6 +3349,13 @@ async function parse(code, language) {
|
|
|
3343
3349
|
}
|
|
3344
3350
|
return tree;
|
|
3345
3351
|
}
|
|
3352
|
+
function disposeTree(tree) {
|
|
3353
|
+
if (!tree)
|
|
3354
|
+
return;
|
|
3355
|
+
try {
|
|
3356
|
+
tree.delete();
|
|
3357
|
+
} catch {}
|
|
3358
|
+
}
|
|
3346
3359
|
function walkTree(node, visitor) {
|
|
3347
3360
|
visitor(node);
|
|
3348
3361
|
for (let i2 = 0;i2 < node.childCount; i2++) {
|
|
@@ -8997,6 +9010,9 @@ var DEFAULT_SOURCES = [
|
|
|
8997
9010
|
{ method: "getContextPath", class: "HttpServletRequest", type: "http_path", severity: "medium", return_tainted: true },
|
|
8998
9011
|
{ method: "getRemoteHost", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
8999
9012
|
{ method: "getRemoteAddr", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
9013
|
+
{ method: "getPathWithinApplication", class: "WebUtils", type: "http_path", severity: "high", return_tainted: true },
|
|
9014
|
+
{ method: "getRequestUri", class: "WebUtils", type: "http_path", severity: "high", return_tainted: true },
|
|
9015
|
+
{ method: "decodeRequestString", class: "WebUtils", type: "http_path", severity: "high", return_tainted: true },
|
|
9000
9016
|
{ method: "getProtocol", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
9001
9017
|
{ method: "getScheme", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
9002
9018
|
{ method: "getAuthType", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
@@ -9294,7 +9310,6 @@ var DEFAULT_SINKS = [
|
|
|
9294
9310
|
{ method: "start", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [] },
|
|
9295
9311
|
{ method: "ProcessBuilder", class: "constructor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9296
9312
|
{ method: "command", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9297
|
-
{ method: "execute", class: "Executor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9298
9313
|
{ method: "execute", class: "DefaultExecutor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9299
9314
|
{ method: "CommandLine", class: "constructor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9300
9315
|
{ method: "parse", class: "CommandLine", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
@@ -9347,15 +9362,14 @@ var DEFAULT_SINKS = [
|
|
|
9347
9362
|
{ method: "fork", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9348
9363
|
{ method: "popen", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9349
9364
|
{ method: "system", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9350
|
-
{ method: "
|
|
9351
|
-
{ method: "setCommandline", class: "Executor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9365
|
+
{ method: "setCommandline", class: "DefaultExecutor", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9352
9366
|
{ method: "parse", class: "CommandLine", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9353
9367
|
{ method: "addArgument", class: "CommandLine", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9354
9368
|
{ method: "waitFor", class: "Process", type: "command_injection", cwe: "CWE-78", severity: "medium", arg_positions: [] },
|
|
9355
9369
|
{ method: "inheritIO", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "medium", arg_positions: [] },
|
|
9356
9370
|
{ method: "redirectOutput", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "medium", arg_positions: [0] },
|
|
9357
9371
|
{ method: "redirectInput", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "medium", arg_positions: [0] },
|
|
9358
|
-
{ method: "File", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9372
|
+
{ method: "File", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1] },
|
|
9359
9373
|
{ method: "FileInputStream", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9360
9374
|
{ method: "FileOutputStream", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9361
9375
|
{ method: "FileReader", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
@@ -9828,10 +9842,10 @@ var DEFAULT_SINKS = [
|
|
|
9828
9842
|
{ method: "spawn", class: "child_process", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9829
9843
|
{ method: "spawnSync", class: "child_process", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9830
9844
|
{ method: "exec", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0] },
|
|
9831
|
-
{ method: "execSync", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0] },
|
|
9832
|
-
{ method: "spawn", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0] },
|
|
9833
|
-
{ method: "spawnSync", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0] },
|
|
9834
|
-
{ method: "execFile", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0] },
|
|
9845
|
+
{ method: "execSync", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9846
|
+
{ method: "spawn", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9847
|
+
{ method: "spawnSync", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9848
|
+
{ method: "execFile", type: "command_injection", cwe: "CWE-78", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9835
9849
|
{ method: "readFile", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9836
9850
|
{ method: "readFileSync", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9837
9851
|
{ method: "writeFile", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
@@ -9842,17 +9856,17 @@ var DEFAULT_SINKS = [
|
|
|
9842
9856
|
{ method: "rmdir", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9843
9857
|
{ method: "createReadStream", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9844
9858
|
{ method: "createWriteStream", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9845
|
-
{ method: "query", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9846
|
-
{ method: "query", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9847
|
-
{ method: "query", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9848
|
-
{ method: "raw", type: "sql_injection", cwe: "CWE-89", severity: "high", arg_positions: [0] },
|
|
9859
|
+
{ method: "query", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9860
|
+
{ method: "query", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9861
|
+
{ method: "query", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9862
|
+
{ method: "raw", type: "sql_injection", cwe: "CWE-89", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9849
9863
|
{ method: "setAttribute", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [1] },
|
|
9850
9864
|
{ method: "send", class: "Response", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9851
9865
|
{ method: "write", class: "Response", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9852
9866
|
{ method: "end", class: "Response", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9853
9867
|
{ method: "html", class: "Response", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9854
9868
|
{ method: "render", class: "Response", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [1] },
|
|
9855
|
-
{ method: "eval", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
9869
|
+
{ method: "eval", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9856
9870
|
{ method: "Function", class: "constructor", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
9857
9871
|
{ method: "runInContext", class: "vm", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
9858
9872
|
{ method: "runInNewContext", class: "vm", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
@@ -9866,7 +9880,7 @@ var DEFAULT_SINKS = [
|
|
|
9866
9880
|
{ method: "get", class: "axios", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9867
9881
|
{ method: "post", class: "axios", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9868
9882
|
{ method: "request", class: "axios", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9869
|
-
{ method: "fetch", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9883
|
+
{ method: "fetch", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
9870
9884
|
{ method: "request", class: "http", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9871
9885
|
{ method: "get", class: "http", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9872
9886
|
{ method: "request", class: "https", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
@@ -9886,39 +9900,39 @@ var DEFAULT_SINKS = [
|
|
|
9886
9900
|
{ method: "check_output", class: "subprocess", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9887
9901
|
{ method: "check_call", class: "subprocess", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9888
9902
|
{ method: "Popen", class: "subprocess", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9889
|
-
{ method: "eval", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
9890
|
-
{ method: "exec", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
9891
|
-
{ method: "compile", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
9892
|
-
{ method: "__import__", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
9903
|
+
{ method: "eval", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
9904
|
+
{ method: "exec", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
9905
|
+
{ method: "compile", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9906
|
+
{ method: "__import__", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9893
9907
|
{ method: "loads", class: "pickle", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0] },
|
|
9894
9908
|
{ method: "load", class: "pickle", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0] },
|
|
9895
9909
|
{ method: "loads", class: "marshal", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0] },
|
|
9896
9910
|
{ method: "load", class: "yaml", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0] },
|
|
9897
9911
|
{ method: "loads", class: "yaml", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0] },
|
|
9898
|
-
{ method: "execute", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9899
|
-
{ method: "executemany", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9900
|
-
{ method: "raw", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9901
|
-
{ method: "extra", type: "sql_injection", cwe: "CWE-89", severity: "high", arg_positions: [0] },
|
|
9902
|
-
{ method: "open", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9912
|
+
{ method: "execute", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
9913
|
+
{ method: "executemany", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
9914
|
+
{ method: "raw", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
9915
|
+
{ method: "extra", type: "sql_injection", cwe: "CWE-89", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9916
|
+
{ method: "open", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9903
9917
|
{ method: "remove", class: "os", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9904
9918
|
{ method: "unlink", class: "os", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9905
9919
|
{ method: "rmdir", class: "os", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9906
9920
|
{ method: "rmtree", class: "shutil", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
9907
|
-
{ method: "send_file", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
9908
|
-
{ method: "render_template_string", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9909
|
-
{ method: "Markup", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9910
|
-
{ method: "mark_safe", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
9921
|
+
{ method: "send_file", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9922
|
+
{ method: "render_template_string", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9923
|
+
{ method: "Markup", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9924
|
+
{ method: "mark_safe", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9911
9925
|
{ method: "get", class: "requests", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9912
9926
|
{ method: "post", class: "requests", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9913
9927
|
{ method: "urlopen", class: "urllib.request", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
9914
|
-
{ method: "redirect", type: "open_redirect", cwe: "CWE-601", severity: "medium", arg_positions: [0] },
|
|
9915
|
-
{ method: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9928
|
+
{ method: "redirect", type: "open_redirect", cwe: "CWE-601", severity: "medium", arg_positions: [0], languages: ["python"] },
|
|
9929
|
+
{ method: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9916
9930
|
{ method: "find", class: "etree", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9917
9931
|
{ method: "findall", class: "etree", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9918
9932
|
{ method: "iterfind", class: "etree", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9919
9933
|
{ method: "XPath", class: "lxml", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9920
9934
|
{ method: "select", class: "elementpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [1] },
|
|
9921
|
-
{ method: "select", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9935
|
+
{ method: "select", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
9922
9936
|
{ method: "iter_select", class: "elementpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [1] },
|
|
9923
9937
|
{ method: "Selector", class: "elementpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
9924
9938
|
{ method: "parse", class: "etree", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
@@ -9984,33 +9998,33 @@ var DEFAULT_SINKS = [
|
|
|
9984
9998
|
{ method: "new", class: "Command", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9985
9999
|
{ method: "arg", class: "Command", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9986
10000
|
{ method: "args", class: "Command", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
9987
|
-
{ method: "query", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9988
|
-
{ method: "execute", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9989
|
-
{ method: "query", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9990
|
-
{ method: "execute", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9991
|
-
{ method: "sql_query", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9992
|
-
{ method: "raw_sql", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9993
|
-
{ method: "execute", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9994
|
-
{ method: "query_row", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9995
|
-
{ method: "prepare", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
10001
|
+
{ method: "query", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10002
|
+
{ method: "execute", class: "Client", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10003
|
+
{ method: "query", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10004
|
+
{ method: "execute", class: "Pool", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10005
|
+
{ method: "sql_query", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10006
|
+
{ method: "raw_sql", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10007
|
+
{ method: "execute", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10008
|
+
{ method: "query_row", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10009
|
+
{ method: "prepare", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
9996
10010
|
{ method: "query", class: "sqlx", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9997
|
-
{ method: "prepare", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9998
|
-
{ method: "execute", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
9999
|
-
{ method: "query_map", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
|
|
10011
|
+
{ method: "prepare", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10012
|
+
{ method: "execute", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10013
|
+
{ method: "query_map", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10000
10014
|
{ method: "open", class: "File", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10001
10015
|
{ method: "create", class: "File", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10002
|
-
{ method: "read_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10003
|
-
{ method: "remove_file", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10004
|
-
{ method: "remove_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10005
|
-
{ method: "remove_dir_all", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0] },
|
|
10006
|
-
{ method: "copy", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1] },
|
|
10007
|
-
{ method: "rename", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1] },
|
|
10008
|
-
{ method: "write", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10009
|
-
{ method: "read_to_string", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10010
|
-
{ method: "create_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10011
|
-
{ method: "create_dir_all", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10012
|
-
{ method: "metadata", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0] },
|
|
10013
|
-
{ method: "symlink_metadata", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0] },
|
|
10016
|
+
{ method: "read_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10017
|
+
{ method: "remove_file", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10018
|
+
{ method: "remove_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10019
|
+
{ method: "remove_dir_all", type: "path_traversal", cwe: "CWE-22", severity: "critical", arg_positions: [0], languages: ["rust"] },
|
|
10020
|
+
{ method: "copy", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1], languages: ["rust"] },
|
|
10021
|
+
{ method: "rename", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1], languages: ["rust"] },
|
|
10022
|
+
{ method: "write", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10023
|
+
{ method: "read_to_string", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10024
|
+
{ method: "create_dir", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10025
|
+
{ method: "create_dir_all", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0], languages: ["rust"] },
|
|
10026
|
+
{ method: "metadata", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0], languages: ["rust"] },
|
|
10027
|
+
{ method: "symlink_metadata", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0], languages: ["rust"] },
|
|
10014
10028
|
{ method: "read_to_string", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10015
10029
|
{ method: "write", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
10016
10030
|
{ method: "create_dir_all", class: "fs", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
|
|
@@ -10292,9 +10306,9 @@ var PYTHON_TAINTED_PATTERNS = [
|
|
|
10292
10306
|
{ pattern: /\brequest\.query_params\b/, sourceType: "http_param" },
|
|
10293
10307
|
{ pattern: /\brequest\.path_params\b/, sourceType: "http_param" }
|
|
10294
10308
|
];
|
|
10295
|
-
function analyzeTaint(calls, types, config = getDefaultConfig(), typeHierarchy) {
|
|
10309
|
+
function analyzeTaint(calls, types, config = getDefaultConfig(), typeHierarchy, language) {
|
|
10296
10310
|
const sources = findSources(calls, types, config.sources);
|
|
10297
|
-
const sinks = findSinks(calls, config.sinks, typeHierarchy);
|
|
10311
|
+
const sinks = findSinks(calls, config.sinks, typeHierarchy, language);
|
|
10298
10312
|
const sanitizers = findSanitizers(calls, types, config.sanitizers);
|
|
10299
10313
|
return { sources, sinks, sanitizers };
|
|
10300
10314
|
}
|
|
@@ -10541,11 +10555,11 @@ function isParameterizedQueryCall(call, pattern) {
|
|
|
10541
10555
|
}
|
|
10542
10556
|
return false;
|
|
10543
10557
|
}
|
|
10544
|
-
function findSinks(calls, patterns, typeHierarchy) {
|
|
10558
|
+
function findSinks(calls, patterns, typeHierarchy, language) {
|
|
10545
10559
|
const sinkMap = new Map;
|
|
10546
10560
|
for (const call of calls) {
|
|
10547
10561
|
for (const pattern of patterns) {
|
|
10548
|
-
if (matchesSinkPattern(call, pattern, typeHierarchy)) {
|
|
10562
|
+
if (matchesSinkPattern(call, pattern, typeHierarchy, language)) {
|
|
10549
10563
|
if (isParameterizedQueryCall(call, pattern)) {
|
|
10550
10564
|
continue;
|
|
10551
10565
|
}
|
|
@@ -10793,7 +10807,12 @@ function isKnownSafeReceiverForMethod(receiver, method, sinkType) {
|
|
|
10793
10807
|
}
|
|
10794
10808
|
return false;
|
|
10795
10809
|
}
|
|
10796
|
-
function matchesSinkPattern(call, pattern, typeHierarchy) {
|
|
10810
|
+
function matchesSinkPattern(call, pattern, typeHierarchy, language) {
|
|
10811
|
+
if (pattern.languages && pattern.languages.length > 0 && language !== undefined) {
|
|
10812
|
+
if (!pattern.languages.includes(language)) {
|
|
10813
|
+
return false;
|
|
10814
|
+
}
|
|
10815
|
+
}
|
|
10797
10816
|
const callMethodName = call.method_name;
|
|
10798
10817
|
const patternMethod = pattern.method;
|
|
10799
10818
|
let methodMatches = callMethodName === patternMethod;
|
|
@@ -10897,17 +10916,29 @@ function receiverMightBeClass(receiver, className) {
|
|
|
10897
10916
|
}
|
|
10898
10917
|
}
|
|
10899
10918
|
}
|
|
10900
|
-
|
|
10919
|
+
const ambiguousIdentifiers = new Set([
|
|
10920
|
+
"executor",
|
|
10921
|
+
"pool",
|
|
10922
|
+
"connection",
|
|
10923
|
+
"manager",
|
|
10924
|
+
"handler",
|
|
10925
|
+
"controller",
|
|
10926
|
+
"task",
|
|
10927
|
+
"thread",
|
|
10928
|
+
"job"
|
|
10929
|
+
]);
|
|
10930
|
+
const isAmbiguous = ambiguousIdentifiers.has(lowerReceiver);
|
|
10931
|
+
if (!isAmbiguous && lowerReceiver.length >= 3 && lowerClass.includes(lowerReceiver)) {
|
|
10901
10932
|
if (lowerReceiver.length >= 5 || lowerReceiver.length / lowerClass.length >= 0.4) {
|
|
10902
10933
|
return true;
|
|
10903
10934
|
}
|
|
10904
10935
|
}
|
|
10905
|
-
if (lowerReceiver.length >= 2) {
|
|
10936
|
+
if (!isAmbiguous && lowerReceiver.length >= 2) {
|
|
10906
10937
|
if (lowerClass.startsWith(lowerReceiver) || lowerClass.endsWith(lowerReceiver)) {
|
|
10907
10938
|
return true;
|
|
10908
10939
|
}
|
|
10909
10940
|
}
|
|
10910
|
-
if (lowerReceiver.length >= 3) {
|
|
10941
|
+
if (!isAmbiguous && lowerReceiver.length >= 3) {
|
|
10911
10942
|
const words = className.replace(/([a-z])([A-Z])/g, "$1\x00$2").toLowerCase().split("\x00");
|
|
10912
10943
|
for (const word of words) {
|
|
10913
10944
|
if (word.startsWith(lowerReceiver) && lowerReceiver.length / word.length >= 0.4) {
|
|
@@ -11738,6 +11769,9 @@ var ANTI_SANITIZER_METHODS = new Set([
|
|
|
11738
11769
|
"unescapeEcmaScript",
|
|
11739
11770
|
"unescapeJson",
|
|
11740
11771
|
"unescapeJava",
|
|
11772
|
+
"getPathWithinApplication",
|
|
11773
|
+
"getRequestUri",
|
|
11774
|
+
"decodeRequestString",
|
|
11741
11775
|
"unescape",
|
|
11742
11776
|
"decompress"
|
|
11743
11777
|
]);
|
|
@@ -11755,7 +11789,10 @@ var PROPAGATOR_METHODS = new Set([
|
|
|
11755
11789
|
"format",
|
|
11756
11790
|
"join",
|
|
11757
11791
|
"concat",
|
|
11758
|
-
"requireNonNull"
|
|
11792
|
+
"requireNonNull",
|
|
11793
|
+
"getPathWithinApplication",
|
|
11794
|
+
"getRequestUri",
|
|
11795
|
+
"decodeRequestString"
|
|
11759
11796
|
]);
|
|
11760
11797
|
|
|
11761
11798
|
// ../circle-ir/dist/analysis/constant-propagation/propagator.js
|
|
@@ -18301,7 +18338,7 @@ class TaintMatcherPass {
|
|
|
18301
18338
|
}
|
|
18302
18339
|
const hierarchy = createWithJdkTypes();
|
|
18303
18340
|
hierarchy.addFromIR(graph.ir, graph.ir.meta.file);
|
|
18304
|
-
const taint = analyzeTaint(calls, types, mergedConfig, hierarchy);
|
|
18341
|
+
const taint = analyzeTaint(calls, types, mergedConfig, hierarchy, language);
|
|
18305
18342
|
const sanitizerMethods = [];
|
|
18306
18343
|
for (const type of types) {
|
|
18307
18344
|
for (const method of type.methods) {
|
|
@@ -25761,194 +25798,202 @@ async function analyze(code, filePath, language, options = {}) {
|
|
|
25761
25798
|
}
|
|
25762
25799
|
logger.debug("Analyzing file", { filePath, language, codeLength: code.length });
|
|
25763
25800
|
const tree = await parse(code, language);
|
|
25764
|
-
|
|
25765
|
-
|
|
25766
|
-
|
|
25767
|
-
|
|
25768
|
-
|
|
25769
|
-
|
|
25770
|
-
|
|
25771
|
-
|
|
25772
|
-
|
|
25773
|
-
|
|
25774
|
-
|
|
25775
|
-
|
|
25776
|
-
|
|
25777
|
-
|
|
25778
|
-
|
|
25779
|
-
|
|
25780
|
-
|
|
25781
|
-
|
|
25782
|
-
|
|
25783
|
-
|
|
25784
|
-
|
|
25785
|
-
|
|
25786
|
-
|
|
25787
|
-
|
|
25788
|
-
|
|
25789
|
-
|
|
25790
|
-
|
|
25791
|
-
|
|
25792
|
-
|
|
25793
|
-
|
|
25794
|
-
|
|
25795
|
-
|
|
25796
|
-
|
|
25797
|
-
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
|
|
25801
|
-
|
|
25802
|
-
|
|
25803
|
-
|
|
25804
|
-
|
|
25805
|
-
|
|
25806
|
-
|
|
25807
|
-
|
|
25808
|
-
|
|
25809
|
-
|
|
25810
|
-
|
|
25811
|
-
|
|
25812
|
-
|
|
25813
|
-
|
|
25814
|
-
|
|
25815
|
-
|
|
25816
|
-
|
|
25817
|
-
|
|
25818
|
-
|
|
25819
|
-
|
|
25820
|
-
|
|
25821
|
-
|
|
25822
|
-
|
|
25823
|
-
|
|
25824
|
-
|
|
25825
|
-
|
|
25826
|
-
|
|
25827
|
-
|
|
25828
|
-
|
|
25829
|
-
|
|
25830
|
-
|
|
25831
|
-
|
|
25832
|
-
|
|
25833
|
-
|
|
25834
|
-
|
|
25835
|
-
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
|
|
25841
|
-
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
|
|
25845
|
-
|
|
25846
|
-
|
|
25847
|
-
|
|
25848
|
-
|
|
25849
|
-
|
|
25850
|
-
|
|
25851
|
-
|
|
25852
|
-
|
|
25853
|
-
|
|
25854
|
-
|
|
25855
|
-
|
|
25856
|
-
|
|
25857
|
-
|
|
25858
|
-
|
|
25859
|
-
|
|
25860
|
-
|
|
25861
|
-
|
|
25862
|
-
|
|
25863
|
-
|
|
25864
|
-
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
|
|
25868
|
-
|
|
25869
|
-
|
|
25870
|
-
|
|
25871
|
-
|
|
25872
|
-
|
|
25873
|
-
|
|
25874
|
-
|
|
25875
|
-
|
|
25876
|
-
|
|
25877
|
-
|
|
25878
|
-
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
|
|
25886
|
-
|
|
25887
|
-
|
|
25888
|
-
|
|
25889
|
-
|
|
25890
|
-
|
|
25891
|
-
|
|
25892
|
-
|
|
25893
|
-
|
|
25894
|
-
|
|
25895
|
-
|
|
25896
|
-
|
|
25897
|
-
|
|
25898
|
-
|
|
25899
|
-
|
|
25900
|
-
|
|
25801
|
+
try {
|
|
25802
|
+
logger.trace("Parsed AST", { rootNodeType: tree.rootNode.type });
|
|
25803
|
+
const nodeCache = collectAllNodes(tree.rootNode, getNodeTypesForLanguage(language));
|
|
25804
|
+
const meta = extractMeta(code, tree, filePath, language);
|
|
25805
|
+
const types = extractTypes(tree, nodeCache, language);
|
|
25806
|
+
const calls = extractCalls(tree, nodeCache, language);
|
|
25807
|
+
const imports = extractImports(tree, language);
|
|
25808
|
+
const exports = extractExports(types);
|
|
25809
|
+
const cfg = buildCFG(tree, language);
|
|
25810
|
+
const dfg = buildDFG(tree, nodeCache, language);
|
|
25811
|
+
const graph = new CodeGraph({
|
|
25812
|
+
meta,
|
|
25813
|
+
types,
|
|
25814
|
+
calls,
|
|
25815
|
+
cfg,
|
|
25816
|
+
dfg,
|
|
25817
|
+
taint: { sources: [], sinks: [], sanitizers: [] },
|
|
25818
|
+
imports,
|
|
25819
|
+
exports,
|
|
25820
|
+
unresolved: [],
|
|
25821
|
+
enriched: {}
|
|
25822
|
+
});
|
|
25823
|
+
const config = options.taintConfig ?? getDefaultConfig();
|
|
25824
|
+
const disabledPasses = new Set(options.disabledPasses ?? []);
|
|
25825
|
+
const passOpts = options.passOptions ?? {};
|
|
25826
|
+
const pipeline = new AnalysisPipeline;
|
|
25827
|
+
pipeline.add(new TaintMatcherPass);
|
|
25828
|
+
pipeline.add(new ConstantPropagationPass(tree));
|
|
25829
|
+
pipeline.add(new LanguageSourcesPass);
|
|
25830
|
+
pipeline.add(new SinkFilterPass);
|
|
25831
|
+
pipeline.add(new TaintPropagationPass);
|
|
25832
|
+
pipeline.add(new InterproceduralPass);
|
|
25833
|
+
if (!disabledPasses.has("scan-secrets"))
|
|
25834
|
+
pipeline.add(new ScanSecretsPass);
|
|
25835
|
+
if (!disabledPasses.has("dead-code"))
|
|
25836
|
+
pipeline.add(new DeadCodePass);
|
|
25837
|
+
if (!disabledPasses.has("missing-await"))
|
|
25838
|
+
pipeline.add(new MissingAwaitPass);
|
|
25839
|
+
if (!disabledPasses.has("n-plus-one"))
|
|
25840
|
+
pipeline.add(new NPlusOnePass);
|
|
25841
|
+
if (!disabledPasses.has("missing-public-doc"))
|
|
25842
|
+
pipeline.add(new MissingPublicDocPass);
|
|
25843
|
+
if (!disabledPasses.has("todo-in-prod"))
|
|
25844
|
+
pipeline.add(new TodoInProdPass);
|
|
25845
|
+
if (!disabledPasses.has("string-concat-loop"))
|
|
25846
|
+
pipeline.add(new StringConcatLoopPass);
|
|
25847
|
+
if (!disabledPasses.has("sync-io-async"))
|
|
25848
|
+
pipeline.add(new SyncIoAsyncPass);
|
|
25849
|
+
if (!disabledPasses.has("unchecked-return"))
|
|
25850
|
+
pipeline.add(new UncheckedReturnPass);
|
|
25851
|
+
if (!disabledPasses.has("null-deref"))
|
|
25852
|
+
pipeline.add(new NullDerefPass);
|
|
25853
|
+
if (!disabledPasses.has("resource-leak"))
|
|
25854
|
+
pipeline.add(new ResourceLeakPass);
|
|
25855
|
+
if (!disabledPasses.has("variable-shadowing"))
|
|
25856
|
+
pipeline.add(new VariableShadowingPass);
|
|
25857
|
+
if (!disabledPasses.has("leaked-global"))
|
|
25858
|
+
pipeline.add(new LeakedGlobalPass);
|
|
25859
|
+
if (!disabledPasses.has("unused-variable"))
|
|
25860
|
+
pipeline.add(new UnusedVariablePass);
|
|
25861
|
+
if (!disabledPasses.has("dependency-fan-out"))
|
|
25862
|
+
pipeline.add(new DependencyFanOutPass(passOpts.dependencyFanOut));
|
|
25863
|
+
if (!disabledPasses.has("stale-doc-ref"))
|
|
25864
|
+
pipeline.add(new StaleDocRefPass);
|
|
25865
|
+
if (!disabledPasses.has("infinite-loop"))
|
|
25866
|
+
pipeline.add(new InfiniteLoopPass);
|
|
25867
|
+
if (!disabledPasses.has("deep-inheritance"))
|
|
25868
|
+
pipeline.add(new DeepInheritancePass);
|
|
25869
|
+
if (!disabledPasses.has("redundant-loop-computation"))
|
|
25870
|
+
pipeline.add(new RedundantLoopPass);
|
|
25871
|
+
if (!disabledPasses.has("unbounded-collection"))
|
|
25872
|
+
pipeline.add(new UnboundedCollectionPass(passOpts.unboundedCollection));
|
|
25873
|
+
if (!disabledPasses.has("serial-await"))
|
|
25874
|
+
pipeline.add(new SerialAwaitPass);
|
|
25875
|
+
if (!disabledPasses.has("react-inline-jsx"))
|
|
25876
|
+
pipeline.add(new ReactInlineJsxPass);
|
|
25877
|
+
if (!disabledPasses.has("swallowed-exception"))
|
|
25878
|
+
pipeline.add(new SwallowedExceptionPass);
|
|
25879
|
+
if (!disabledPasses.has("broad-catch"))
|
|
25880
|
+
pipeline.add(new BroadCatchPass);
|
|
25881
|
+
if (!disabledPasses.has("unhandled-exception"))
|
|
25882
|
+
pipeline.add(new UnhandledExceptionPass);
|
|
25883
|
+
if (!disabledPasses.has("double-close"))
|
|
25884
|
+
pipeline.add(new DoubleClosePass);
|
|
25885
|
+
if (!disabledPasses.has("use-after-close"))
|
|
25886
|
+
pipeline.add(new UseAfterClosePass);
|
|
25887
|
+
if (!disabledPasses.has("cleanup-verify"))
|
|
25888
|
+
pipeline.add(new CleanupVerifyPass);
|
|
25889
|
+
if (!disabledPasses.has("missing-override"))
|
|
25890
|
+
pipeline.add(new MissingOverridePass);
|
|
25891
|
+
if (!disabledPasses.has("unused-interface-method"))
|
|
25892
|
+
pipeline.add(new UnusedInterfaceMethodPass);
|
|
25893
|
+
if (!disabledPasses.has("blocking-main-thread"))
|
|
25894
|
+
pipeline.add(new BlockingMainThreadPass);
|
|
25895
|
+
if (!disabledPasses.has("excessive-allocation"))
|
|
25896
|
+
pipeline.add(new ExcessiveAllocationPass);
|
|
25897
|
+
if (!disabledPasses.has("missing-stream"))
|
|
25898
|
+
pipeline.add(new MissingStreamPass);
|
|
25899
|
+
if (!disabledPasses.has("god-class"))
|
|
25900
|
+
pipeline.add(new GodClassPass);
|
|
25901
|
+
if (!disabledPasses.has("naming-convention"))
|
|
25902
|
+
pipeline.add(new NamingConventionPass(passOpts.namingConvention));
|
|
25903
|
+
if (!disabledPasses.has("security-headers"))
|
|
25904
|
+
pipeline.add(new SecurityHeadersPass(passOpts.securityHeaders));
|
|
25905
|
+
const { results, findings } = pipeline.run(graph, code, language, config);
|
|
25906
|
+
const sinkFilter = results.get("sink-filter");
|
|
25907
|
+
const interProc = results.get("interprocedural");
|
|
25908
|
+
const taint = {
|
|
25909
|
+
sources: sinkFilter.sources,
|
|
25910
|
+
sinks: [...sinkFilter.sinks, ...interProc.additionalSinks],
|
|
25911
|
+
sanitizers: sinkFilter.sanitizers,
|
|
25912
|
+
flows: interProc.additionalFlows,
|
|
25913
|
+
interprocedural: interProc.interprocedural
|
|
25914
|
+
};
|
|
25915
|
+
const unresolved = detectUnresolved(calls, types, dfg);
|
|
25916
|
+
const enriched = buildEnriched(types, calls, taint.sources, taint.sinks);
|
|
25917
|
+
const metricValues = new MetricRunner().run({ meta, types, calls, cfg, dfg, taint, imports, exports, unresolved, enriched }, code, language);
|
|
25918
|
+
logger.debug("Analysis complete", {
|
|
25919
|
+
filePath,
|
|
25920
|
+
finalSources: taint.sources.length,
|
|
25921
|
+
finalSinks: taint.sinks.length,
|
|
25922
|
+
flows: taint.flows?.length ?? 0,
|
|
25923
|
+
unresolvedItems: unresolved.length
|
|
25924
|
+
});
|
|
25925
|
+
return {
|
|
25926
|
+
meta,
|
|
25927
|
+
types,
|
|
25928
|
+
calls,
|
|
25929
|
+
cfg,
|
|
25930
|
+
dfg,
|
|
25931
|
+
taint,
|
|
25932
|
+
imports,
|
|
25933
|
+
exports,
|
|
25934
|
+
unresolved,
|
|
25935
|
+
enriched,
|
|
25936
|
+
findings: findings.length > 0 ? findings : undefined,
|
|
25937
|
+
metrics: { file: filePath, metrics: metricValues }
|
|
25938
|
+
};
|
|
25939
|
+
} finally {
|
|
25940
|
+
disposeTree(tree);
|
|
25941
|
+
}
|
|
25901
25942
|
}
|
|
25902
25943
|
async function analyzeHtmlFile(code, filePath, options) {
|
|
25903
25944
|
logger.debug("Analyzing HTML file", { filePath, codeLength: code.length });
|
|
25904
25945
|
const tree = await parse(code, "html");
|
|
25905
|
-
|
|
25906
|
-
|
|
25907
|
-
|
|
25908
|
-
|
|
25909
|
-
|
|
25910
|
-
|
|
25911
|
-
|
|
25912
|
-
|
|
25913
|
-
|
|
25914
|
-
|
|
25915
|
-
|
|
25916
|
-
|
|
25917
|
-
|
|
25918
|
-
|
|
25919
|
-
|
|
25920
|
-
|
|
25921
|
-
|
|
25922
|
-
|
|
25923
|
-
|
|
25924
|
-
|
|
25925
|
-
|
|
25926
|
-
|
|
25946
|
+
try {
|
|
25947
|
+
const meta = extractMeta(code, tree, filePath, "html");
|
|
25948
|
+
const { scriptBlocks, eventHandlers } = extractHtmlContent(tree.rootNode);
|
|
25949
|
+
logger.debug("HTML extraction", {
|
|
25950
|
+
filePath,
|
|
25951
|
+
inlineScripts: scriptBlocks.filter((b) => b.kind === "inline").length,
|
|
25952
|
+
externalScripts: scriptBlocks.filter((b) => b.kind === "external-src").length,
|
|
25953
|
+
eventHandlers: eventHandlers.length
|
|
25954
|
+
});
|
|
25955
|
+
const scriptResults = [];
|
|
25956
|
+
for (const block of scriptBlocks) {
|
|
25957
|
+
if (block.kind !== "inline" || !block.code.trim())
|
|
25958
|
+
continue;
|
|
25959
|
+
const scriptLang = block.scriptType === "ts" || block.scriptType === "typescript" || block.scriptType === "text/typescript" ? "typescript" : "javascript";
|
|
25960
|
+
try {
|
|
25961
|
+
const ir = await analyze(block.code, filePath, scriptLang, options);
|
|
25962
|
+
scriptResults.push({ ir, lineOffset: block.lineOffset });
|
|
25963
|
+
} catch (e) {
|
|
25964
|
+
logger.warn("Failed to analyze script block", {
|
|
25965
|
+
filePath,
|
|
25966
|
+
lineOffset: block.lineOffset,
|
|
25967
|
+
error: e instanceof Error ? e.message : String(e)
|
|
25968
|
+
});
|
|
25969
|
+
}
|
|
25927
25970
|
}
|
|
25928
|
-
|
|
25929
|
-
|
|
25930
|
-
|
|
25931
|
-
|
|
25932
|
-
|
|
25933
|
-
|
|
25934
|
-
|
|
25935
|
-
|
|
25936
|
-
|
|
25937
|
-
|
|
25938
|
-
|
|
25939
|
-
|
|
25940
|
-
}
|
|
25971
|
+
for (const handler of eventHandlers) {
|
|
25972
|
+
const wrappedCode = `function __${handler.eventName}_handler() { ${handler.code} }`;
|
|
25973
|
+
try {
|
|
25974
|
+
const ir = await analyze(wrappedCode, filePath, "javascript", options);
|
|
25975
|
+
scriptResults.push({ ir, lineOffset: handler.line });
|
|
25976
|
+
} catch (e) {
|
|
25977
|
+
logger.warn("Failed to analyze event handler", {
|
|
25978
|
+
filePath,
|
|
25979
|
+
eventName: handler.eventName,
|
|
25980
|
+
line: handler.line,
|
|
25981
|
+
error: e instanceof Error ? e.message : String(e)
|
|
25982
|
+
});
|
|
25983
|
+
}
|
|
25941
25984
|
}
|
|
25985
|
+
const attributeFindings = runHtmlAttributeSecurityChecks(tree.rootNode, filePath);
|
|
25986
|
+
const result = mergeHtmlResults(meta, scriptResults, attributeFindings);
|
|
25987
|
+
logger.debug("HTML analysis complete", {
|
|
25988
|
+
filePath,
|
|
25989
|
+
scriptBlocks: scriptResults.length,
|
|
25990
|
+
attributeFindings: attributeFindings.length,
|
|
25991
|
+
totalFindings: result.findings?.length ?? 0
|
|
25992
|
+
});
|
|
25993
|
+
return result;
|
|
25994
|
+
} finally {
|
|
25995
|
+
disposeTree(tree);
|
|
25942
25996
|
}
|
|
25943
|
-
const attributeFindings = runHtmlAttributeSecurityChecks(tree.rootNode, filePath);
|
|
25944
|
-
const result = mergeHtmlResults(meta, scriptResults, attributeFindings);
|
|
25945
|
-
logger.debug("HTML analysis complete", {
|
|
25946
|
-
filePath,
|
|
25947
|
-
scriptBlocks: scriptResults.length,
|
|
25948
|
-
attributeFindings: attributeFindings.length,
|
|
25949
|
-
totalFindings: result.findings?.length ?? 0
|
|
25950
|
-
});
|
|
25951
|
-
return result;
|
|
25952
25997
|
}
|
|
25953
25998
|
async function analyzeProject(files, options = {}) {
|
|
25954
25999
|
const fileAnalyses = [];
|
|
@@ -26038,7 +26083,7 @@ var colors = {
|
|
|
26038
26083
|
};
|
|
26039
26084
|
|
|
26040
26085
|
// src/version.ts
|
|
26041
|
-
var version = "3.
|
|
26086
|
+
var version = "3.30.0";
|
|
26042
26087
|
|
|
26043
26088
|
// src/formatters.ts
|
|
26044
26089
|
var SINK_SEVERITY = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0",
|
|
4
4
|
"description": "Static Application Security Testing CLI for detecting security vulnerabilities via taint tracking",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"registry": "https://registry.npmjs.org/"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"circle-ir": "^3.
|
|
68
|
+
"circle-ir": "^3.30.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.5.0",
|