cognium-dev 3.71.0 → 3.73.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 +283 -22
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -11116,6 +11116,29 @@ var DEFAULT_SINKS = [
|
|
|
11116
11116
|
{ method: "debug", class: "console", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2, 3], languages: ["javascript", "typescript"] },
|
|
11117
11117
|
{ method: "trace", class: "console", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2, 3], languages: ["javascript", "typescript"] },
|
|
11118
11118
|
{ method: "redirect", type: "open_redirect", cwe: "CWE-601", severity: "medium", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11119
|
+
{ method: "search", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [1, 2], languages: ["javascript", "typescript"] },
|
|
11120
|
+
{ method: "searchSync", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [1, 2], languages: ["javascript", "typescript"] },
|
|
11121
|
+
{ method: "search", class: "ldapjs", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [1, 2], languages: ["javascript", "typescript"] },
|
|
11122
|
+
{ method: "searchSync", class: "ldapjs", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [1, 2], languages: ["javascript", "typescript"] },
|
|
11123
|
+
{ method: "select", class: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11124
|
+
{ method: "select1", class: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11125
|
+
{ method: "evaluate", class: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11126
|
+
{ method: "parse", class: "xpath", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11127
|
+
{ method: "parseXml", class: "libxml", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11128
|
+
{ method: "parseXmlString", class: "libxml", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11129
|
+
{ method: "parseXml", class: "libxmljs", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11130
|
+
{ method: "parseXmlString", class: "libxmljs", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11131
|
+
{ method: "parseFromString", class: "DOMParser", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11132
|
+
{ method: "parseFromString", class: "xmldom", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11133
|
+
{ method: "render", class: "ejs", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11134
|
+
{ method: "compile", class: "ejs", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11135
|
+
{ method: "render", class: "handlebars", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11136
|
+
{ method: "compile", class: "handlebars", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11137
|
+
{ method: "render", class: "pug", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11138
|
+
{ method: "compile", class: "pug", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11139
|
+
{ method: "render", class: "mustache", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11140
|
+
{ method: "render", class: "nunjucks", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11141
|
+
{ method: "renderString", class: "nunjucks", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
11119
11142
|
{ method: "system", class: "os", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
11120
11143
|
{ method: "popen", class: "os", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
11121
11144
|
{ method: "run", class: "subprocess", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
@@ -11192,6 +11215,13 @@ var DEFAULT_SINKS = [
|
|
|
11192
11215
|
{ method: "delete_one", class: "Collection", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0] },
|
|
11193
11216
|
{ method: "delete_many", class: "Collection", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0] },
|
|
11194
11217
|
{ method: "aggregate", class: "Collection", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0] },
|
|
11218
|
+
{ method: "find_one", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
11219
|
+
{ method: "update_one", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0, 1], languages: ["python"] },
|
|
11220
|
+
{ method: "update_many", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0, 1], languages: ["python"] },
|
|
11221
|
+
{ method: "delete_one", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
11222
|
+
{ method: "delete_many", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
11223
|
+
{ method: "replace_one", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0, 1], languages: ["python"] },
|
|
11224
|
+
{ method: "count_documents", type: "nosql_injection", cwe: "CWE-943", severity: "critical", arg_positions: [0], languages: ["python"] },
|
|
11195
11225
|
{ method: "from_string", class: "Template", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
11196
11226
|
{ method: "Template", class: "jinja2", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
11197
11227
|
{ method: "Template", class: "mako", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
@@ -11200,6 +11230,13 @@ var DEFAULT_SINKS = [
|
|
|
11200
11230
|
{ method: "error", class: "logger", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11201
11231
|
{ method: "debug", class: "logger", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11202
11232
|
{ method: "critical", class: "logger", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11233
|
+
{ method: "info", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11234
|
+
{ method: "warning", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11235
|
+
{ method: "error", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11236
|
+
{ method: "debug", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11237
|
+
{ method: "critical", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11238
|
+
{ method: "log", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [1] },
|
|
11239
|
+
{ method: "exception", class: "logging", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0] },
|
|
11203
11240
|
{ method: "command", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
11204
11241
|
{ method: "inheritIO", class: "ProcessBuilder", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [] },
|
|
11205
11242
|
{ method: "step", class: "StepExecution", type: "command_injection", cwe: "CWE-78", severity: "critical", arg_positions: [0] },
|
|
@@ -11828,6 +11865,17 @@ function findSources(calls, types, patterns, sourceLines, language) {
|
|
|
11828
11865
|
s.variable = m[1];
|
|
11829
11866
|
}
|
|
11830
11867
|
}
|
|
11868
|
+
if (language === "go" && sourceLines) {
|
|
11869
|
+
const GO_ASSIGN_LHS = /^\s*(?:var\s+)?([A-Za-z_]\w*)(?:\s*,\s*[A-Za-z_]\w*)*\s*(?::\s*[A-Za-z_][\w.]*\s*)?(?::?=)(?!=)/;
|
|
11870
|
+
for (const s of result) {
|
|
11871
|
+
if (s.variable && s.variable.length > 0)
|
|
11872
|
+
continue;
|
|
11873
|
+
const lineText = sourceLines[s.line - 1] ?? "";
|
|
11874
|
+
const m = GO_ASSIGN_LHS.exec(lineText);
|
|
11875
|
+
if (m)
|
|
11876
|
+
s.variable = m[1];
|
|
11877
|
+
}
|
|
11878
|
+
}
|
|
11831
11879
|
return result;
|
|
11832
11880
|
}
|
|
11833
11881
|
function isInterproceduralTaintableType(typeName) {
|
|
@@ -15192,6 +15240,9 @@ function isFalsePositive(result, sinkLine, taintedVar) {
|
|
|
15192
15240
|
if (varValue && varValue.type !== "unknown" && !result.tainted.has(taintedVar)) {
|
|
15193
15241
|
return { isFalsePositive: true, reason: `variable_is_constant: ${varValue.value}` };
|
|
15194
15242
|
}
|
|
15243
|
+
if (taintedVar.startsWith("self.") || taintedVar.startsWith("this.")) {
|
|
15244
|
+
return { isFalsePositive: false, reason: null };
|
|
15245
|
+
}
|
|
15195
15246
|
if (result.symbols.has(taintedVar) && !result.tainted.has(taintedVar)) {
|
|
15196
15247
|
return { isFalsePositive: true, reason: "variable_not_tainted" };
|
|
15197
15248
|
}
|
|
@@ -17823,7 +17874,7 @@ class GoPlugin extends BaseLanguagePlugin {
|
|
|
17823
17874
|
type: "command_injection",
|
|
17824
17875
|
cwe: "CWE-78",
|
|
17825
17876
|
severity: "critical",
|
|
17826
|
-
argPositions: [
|
|
17877
|
+
argPositions: []
|
|
17827
17878
|
},
|
|
17828
17879
|
{
|
|
17829
17880
|
method: "CommandContext",
|
|
@@ -17831,7 +17882,7 @@ class GoPlugin extends BaseLanguagePlugin {
|
|
|
17831
17882
|
type: "command_injection",
|
|
17832
17883
|
cwe: "CWE-78",
|
|
17833
17884
|
severity: "critical",
|
|
17834
|
-
argPositions: [
|
|
17885
|
+
argPositions: []
|
|
17835
17886
|
},
|
|
17836
17887
|
{
|
|
17837
17888
|
method: "Open",
|
|
@@ -17920,6 +17971,110 @@ class GoPlugin extends BaseLanguagePlugin {
|
|
|
17920
17971
|
cwe: "CWE-502",
|
|
17921
17972
|
severity: "medium",
|
|
17922
17973
|
argPositions: [0]
|
|
17974
|
+
},
|
|
17975
|
+
{
|
|
17976
|
+
method: "Print",
|
|
17977
|
+
class: "log",
|
|
17978
|
+
type: "log_injection",
|
|
17979
|
+
cwe: "CWE-117",
|
|
17980
|
+
severity: "medium",
|
|
17981
|
+
argPositions: []
|
|
17982
|
+
},
|
|
17983
|
+
{
|
|
17984
|
+
method: "Println",
|
|
17985
|
+
class: "log",
|
|
17986
|
+
type: "log_injection",
|
|
17987
|
+
cwe: "CWE-117",
|
|
17988
|
+
severity: "medium",
|
|
17989
|
+
argPositions: []
|
|
17990
|
+
},
|
|
17991
|
+
{
|
|
17992
|
+
method: "Printf",
|
|
17993
|
+
class: "log",
|
|
17994
|
+
type: "log_injection",
|
|
17995
|
+
cwe: "CWE-117",
|
|
17996
|
+
severity: "medium",
|
|
17997
|
+
argPositions: []
|
|
17998
|
+
},
|
|
17999
|
+
{
|
|
18000
|
+
method: "Fatal",
|
|
18001
|
+
class: "log",
|
|
18002
|
+
type: "log_injection",
|
|
18003
|
+
cwe: "CWE-117",
|
|
18004
|
+
severity: "medium",
|
|
18005
|
+
argPositions: []
|
|
18006
|
+
},
|
|
18007
|
+
{
|
|
18008
|
+
method: "Fatalln",
|
|
18009
|
+
class: "log",
|
|
18010
|
+
type: "log_injection",
|
|
18011
|
+
cwe: "CWE-117",
|
|
18012
|
+
severity: "medium",
|
|
18013
|
+
argPositions: []
|
|
18014
|
+
},
|
|
18015
|
+
{
|
|
18016
|
+
method: "Fatalf",
|
|
18017
|
+
class: "log",
|
|
18018
|
+
type: "log_injection",
|
|
18019
|
+
cwe: "CWE-117",
|
|
18020
|
+
severity: "medium",
|
|
18021
|
+
argPositions: []
|
|
18022
|
+
},
|
|
18023
|
+
{
|
|
18024
|
+
method: "Panic",
|
|
18025
|
+
class: "log",
|
|
18026
|
+
type: "log_injection",
|
|
18027
|
+
cwe: "CWE-117",
|
|
18028
|
+
severity: "medium",
|
|
18029
|
+
argPositions: []
|
|
18030
|
+
},
|
|
18031
|
+
{
|
|
18032
|
+
method: "Panicln",
|
|
18033
|
+
class: "log",
|
|
18034
|
+
type: "log_injection",
|
|
18035
|
+
cwe: "CWE-117",
|
|
18036
|
+
severity: "medium",
|
|
18037
|
+
argPositions: []
|
|
18038
|
+
},
|
|
18039
|
+
{
|
|
18040
|
+
method: "Panicf",
|
|
18041
|
+
class: "log",
|
|
18042
|
+
type: "log_injection",
|
|
18043
|
+
cwe: "CWE-117",
|
|
18044
|
+
severity: "medium",
|
|
18045
|
+
argPositions: []
|
|
18046
|
+
},
|
|
18047
|
+
{
|
|
18048
|
+
method: "Parse",
|
|
18049
|
+
class: "Template",
|
|
18050
|
+
type: "code_injection",
|
|
18051
|
+
cwe: "CWE-94",
|
|
18052
|
+
severity: "high",
|
|
18053
|
+
argPositions: [0]
|
|
18054
|
+
},
|
|
18055
|
+
{
|
|
18056
|
+
method: "ParseFiles",
|
|
18057
|
+
class: "template",
|
|
18058
|
+
type: "code_injection",
|
|
18059
|
+
cwe: "CWE-94",
|
|
18060
|
+
severity: "high",
|
|
18061
|
+
argPositions: []
|
|
18062
|
+
},
|
|
18063
|
+
{
|
|
18064
|
+
method: "ParseGlob",
|
|
18065
|
+
class: "template",
|
|
18066
|
+
type: "code_injection",
|
|
18067
|
+
cwe: "CWE-94",
|
|
18068
|
+
severity: "high",
|
|
18069
|
+
argPositions: [0]
|
|
18070
|
+
},
|
|
18071
|
+
{
|
|
18072
|
+
method: "ParseFS",
|
|
18073
|
+
class: "template",
|
|
18074
|
+
type: "code_injection",
|
|
18075
|
+
cwe: "CWE-94",
|
|
18076
|
+
severity: "high",
|
|
18077
|
+
argPositions: []
|
|
17923
18078
|
}
|
|
17924
18079
|
];
|
|
17925
18080
|
}
|
|
@@ -21084,6 +21239,7 @@ class LanguageSourcesPass {
|
|
|
21084
21239
|
ctx.addFinding(finding);
|
|
21085
21240
|
}
|
|
21086
21241
|
additionalSanitizers.push(...findBashRegexAllowlistSanitizers(code));
|
|
21242
|
+
additionalSanitizers.push(...findBashRealpathPrefixGuardSanitizers(code));
|
|
21087
21243
|
}
|
|
21088
21244
|
attachSourceLineCode(additionalSources, additionalSinks, code);
|
|
21089
21245
|
return { additionalSources, additionalSinks, additionalSanitizers, pyTaintedVars, pySanitizedVars, jsTaintedVars };
|
|
@@ -21139,15 +21295,18 @@ function findGetterSources(types, instanceFieldTaint, _sourceCode) {
|
|
|
21139
21295
|
return sources;
|
|
21140
21296
|
}
|
|
21141
21297
|
function findOopFieldReadSources(types, sourceCode, language) {
|
|
21142
|
-
if (language !== "java" && language !== "python")
|
|
21298
|
+
if (language !== "java" && language !== "python" && language !== "javascript" && language !== "typescript")
|
|
21143
21299
|
return [];
|
|
21144
21300
|
const sources = [];
|
|
21145
21301
|
const lines = sourceCode.split(`
|
|
21146
21302
|
`);
|
|
21147
21303
|
const isPython = language === "python";
|
|
21304
|
+
const isJs = language === "javascript" || language === "typescript";
|
|
21305
|
+
const isJava = language === "java";
|
|
21148
21306
|
const SELF = isPython ? "self" : "this";
|
|
21149
21307
|
const javaHttpPattern = /\b(?:req|request|httpRequest|servletRequest|httpServletRequest)\.(?:getParameter|getParameterValues|getParameterMap|getHeader|getHeaders|getCookies|getQueryString|getPathInfo|getRequestURI|getRequestURL|getInputStream|getReader)\b/;
|
|
21150
21308
|
const fieldAssignRe = new RegExp(`^\\s*${SELF}\\.([A-Za-z_]\\w*)\\s*=\\s*(.+?)(?:;\\s*)?$`);
|
|
21309
|
+
const fieldAssignReG = new RegExp(`${SELF}\\.([A-Za-z_]\\w*)\\s*=\\s*([^;}\\n]+)`, "g");
|
|
21151
21310
|
const commentPrefix = isPython ? "#" : "//";
|
|
21152
21311
|
for (const type of types) {
|
|
21153
21312
|
if (type.kind !== "class")
|
|
@@ -21161,7 +21320,12 @@ function findOopFieldReadSources(types, sourceCode, language) {
|
|
|
21161
21320
|
ctor = m;
|
|
21162
21321
|
break;
|
|
21163
21322
|
}
|
|
21164
|
-
} else {
|
|
21323
|
+
} else if (isJs) {
|
|
21324
|
+
if (m.name === "constructor") {
|
|
21325
|
+
ctor = m;
|
|
21326
|
+
break;
|
|
21327
|
+
}
|
|
21328
|
+
} else if (isJava) {
|
|
21165
21329
|
if (m.name === type.name) {
|
|
21166
21330
|
ctor = m;
|
|
21167
21331
|
break;
|
|
@@ -21183,26 +21347,44 @@ function findOopFieldReadSources(types, sourceCode, language) {
|
|
|
21183
21347
|
const line = lines[i2] ?? "";
|
|
21184
21348
|
if (line.trim().startsWith(commentPrefix))
|
|
21185
21349
|
continue;
|
|
21186
|
-
const
|
|
21187
|
-
|
|
21350
|
+
const pairs = [];
|
|
21351
|
+
const anchored = line.match(fieldAssignRe);
|
|
21352
|
+
if (anchored)
|
|
21353
|
+
pairs.push({ field: anchored[1], rhs: anchored[2].trim().replace(/;\s*$/, "") });
|
|
21354
|
+
if (isJs) {
|
|
21355
|
+
for (const m of line.matchAll(fieldAssignReG)) {
|
|
21356
|
+
const field = m[1];
|
|
21357
|
+
const rhs = m[2].trim().replace(/;\s*$/, "");
|
|
21358
|
+
if (!pairs.some((p) => p.field === field))
|
|
21359
|
+
pairs.push({ field, rhs });
|
|
21360
|
+
}
|
|
21361
|
+
}
|
|
21362
|
+
if (pairs.length === 0)
|
|
21188
21363
|
continue;
|
|
21189
|
-
const fieldName
|
|
21190
|
-
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
|
|
21196
|
-
|
|
21197
|
-
|
|
21198
|
-
|
|
21199
|
-
|
|
21200
|
-
|
|
21364
|
+
for (const { field: fieldName, rhs } of pairs) {
|
|
21365
|
+
let sourceType = null;
|
|
21366
|
+
if (paramNames.has(rhs)) {
|
|
21367
|
+
sourceType = "interprocedural_param";
|
|
21368
|
+
} else if (isJava && javaHttpPattern.test(rhs)) {
|
|
21369
|
+
sourceType = "http_param";
|
|
21370
|
+
} else if (isPython) {
|
|
21371
|
+
for (const { pattern, type: type2 } of PYTHON_TAINTED_PATTERNS2) {
|
|
21372
|
+
if (pattern.test(rhs)) {
|
|
21373
|
+
sourceType = type2;
|
|
21374
|
+
break;
|
|
21375
|
+
}
|
|
21376
|
+
}
|
|
21377
|
+
} else if (isJs) {
|
|
21378
|
+
for (const { pattern, type: type2 } of JS_TAINTED_PATTERNS) {
|
|
21379
|
+
if (pattern.test(rhs)) {
|
|
21380
|
+
sourceType = type2;
|
|
21381
|
+
break;
|
|
21382
|
+
}
|
|
21201
21383
|
}
|
|
21202
21384
|
}
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21385
|
+
if (sourceType) {
|
|
21386
|
+
fieldTaint.set(fieldName, { line: i2 + 1, type: sourceType });
|
|
21387
|
+
}
|
|
21206
21388
|
}
|
|
21207
21389
|
}
|
|
21208
21390
|
if (fieldTaint.size === 0)
|
|
@@ -22027,6 +22209,76 @@ function isSafeBashAllowlistRegex(literal) {
|
|
|
22027
22209
|
}
|
|
22028
22210
|
return consumed === body2.length;
|
|
22029
22211
|
}
|
|
22212
|
+
function findBashRealpathPrefixGuardSanitizers(code) {
|
|
22213
|
+
const sanitizers = [];
|
|
22214
|
+
const lines = code.split(`
|
|
22215
|
+
`);
|
|
22216
|
+
const caseOpen = /^\s*case\s+"?\$\{?\w+\}?"?\s+in\b/;
|
|
22217
|
+
const esacClose = /^\s*esac\b/;
|
|
22218
|
+
const armOpener = /^\s*([^)\s][^)]*?)\)/;
|
|
22219
|
+
const prefixArm = /^(?:"\$\{?\w+\}?"|"[^"]*"|\/[\w\-./]+|\$\{?\w+\}?|[\w\-./]+)(?:\/|\*)/;
|
|
22220
|
+
const catchAllArm = /^(?:\*|\\\*)$/;
|
|
22221
|
+
let i2 = 0;
|
|
22222
|
+
while (i2 < lines.length) {
|
|
22223
|
+
if (!caseOpen.test(lines[i2])) {
|
|
22224
|
+
i2++;
|
|
22225
|
+
continue;
|
|
22226
|
+
}
|
|
22227
|
+
let caseEnd = -1;
|
|
22228
|
+
for (let j = i2 + 1;j < lines.length; j++) {
|
|
22229
|
+
if (esacClose.test(lines[j])) {
|
|
22230
|
+
caseEnd = j;
|
|
22231
|
+
break;
|
|
22232
|
+
}
|
|
22233
|
+
}
|
|
22234
|
+
if (caseEnd === -1) {
|
|
22235
|
+
i2++;
|
|
22236
|
+
continue;
|
|
22237
|
+
}
|
|
22238
|
+
let hasPrefixArm = false;
|
|
22239
|
+
let hasTerminalCatchAll = false;
|
|
22240
|
+
for (let j = i2 + 1;j < caseEnd; j++) {
|
|
22241
|
+
const armMatch = armOpener.exec(lines[j]);
|
|
22242
|
+
if (!armMatch)
|
|
22243
|
+
continue;
|
|
22244
|
+
const pattern = armMatch[1].trim();
|
|
22245
|
+
if (catchAllArm.test(pattern)) {
|
|
22246
|
+
let bodyEnd = caseEnd;
|
|
22247
|
+
for (let k = j + 1;k < caseEnd; k++) {
|
|
22248
|
+
if (armOpener.test(lines[k])) {
|
|
22249
|
+
bodyEnd = k;
|
|
22250
|
+
break;
|
|
22251
|
+
}
|
|
22252
|
+
}
|
|
22253
|
+
const armBody = lines.slice(j, bodyEnd).join(" ");
|
|
22254
|
+
if (/\b(exit|return|die)\b/.test(armBody)) {
|
|
22255
|
+
hasTerminalCatchAll = true;
|
|
22256
|
+
}
|
|
22257
|
+
} else if (prefixArm.test(pattern)) {
|
|
22258
|
+
hasPrefixArm = true;
|
|
22259
|
+
}
|
|
22260
|
+
}
|
|
22261
|
+
if (hasPrefixArm && hasTerminalCatchAll) {
|
|
22262
|
+
for (let l = i2 + 1;l <= caseEnd + 1; l++) {
|
|
22263
|
+
sanitizers.push({
|
|
22264
|
+
type: "realpath_prefix_guard",
|
|
22265
|
+
method: "case",
|
|
22266
|
+
line: l,
|
|
22267
|
+
sanitizes: [
|
|
22268
|
+
"path_traversal",
|
|
22269
|
+
"command_injection",
|
|
22270
|
+
"code_injection",
|
|
22271
|
+
"ssrf",
|
|
22272
|
+
"open_redirect",
|
|
22273
|
+
"log_injection"
|
|
22274
|
+
]
|
|
22275
|
+
});
|
|
22276
|
+
}
|
|
22277
|
+
}
|
|
22278
|
+
i2 = caseEnd + 1;
|
|
22279
|
+
}
|
|
22280
|
+
return sanitizers;
|
|
22281
|
+
}
|
|
22030
22282
|
|
|
22031
22283
|
// ../circle-ir/dist/analysis/passes/sink-filter-pass.js
|
|
22032
22284
|
var JS_XSS_SANITIZERS = [
|
|
@@ -22075,11 +22327,20 @@ class SinkFilterPass {
|
|
|
22075
22327
|
const { pyTaintedVars, pySanitizedVars } = langSources;
|
|
22076
22328
|
const sourceLines = ctx.code.split(`
|
|
22077
22329
|
`);
|
|
22330
|
+
const oopFieldVars = new Set;
|
|
22331
|
+
for (const s of sources) {
|
|
22332
|
+
if (s.variable && s.variable.startsWith("self.")) {
|
|
22333
|
+
oopFieldVars.add(s.variable);
|
|
22334
|
+
}
|
|
22335
|
+
}
|
|
22078
22336
|
filtered = filtered.filter((sink) => {
|
|
22079
22337
|
if (sink.type !== "xpath_injection")
|
|
22080
22338
|
return true;
|
|
22081
22339
|
const sinkLineText = sourceLines[sink.line - 1] ?? "";
|
|
22082
22340
|
const taintedVarOnLine = [...pyTaintedVars.keys()].find((v) => new RegExp(`\\b${v}\\b`).test(sinkLineText));
|
|
22341
|
+
const oopVarOnLine = [...oopFieldVars].find((v) => sinkLineText.includes(v));
|
|
22342
|
+
if (oopVarOnLine)
|
|
22343
|
+
return true;
|
|
22083
22344
|
if (!taintedVarOnLine)
|
|
22084
22345
|
return false;
|
|
22085
22346
|
if (pySanitizedVars.has(taintedVarOnLine))
|
|
@@ -32001,7 +32262,7 @@ var colors = {
|
|
|
32001
32262
|
};
|
|
32002
32263
|
|
|
32003
32264
|
// src/version.ts
|
|
32004
|
-
var version = "3.
|
|
32265
|
+
var version = "3.73.0";
|
|
32005
32266
|
|
|
32006
32267
|
// src/formatters.ts
|
|
32007
32268
|
var SINK_SEVERITY = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.73.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.73.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.5.0",
|