cognium-dev 3.123.0 → 3.124.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 +127 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -22617,6 +22617,15 @@ class LanguageSourcesPass {
|
|
|
22617
22617
|
ctx.addFinding(finding);
|
|
22618
22618
|
}
|
|
22619
22619
|
}
|
|
22620
|
+
if (language === "javascript" || language === "typescript" || language === "htmljs") {
|
|
22621
|
+
additionalSanitizers.push(...findJsSafeJsonParseSanitizers(code));
|
|
22622
|
+
additionalSanitizers.push(...findJsCryptoHashSanitizers(code));
|
|
22623
|
+
additionalSanitizers.push(...findJsCsvFormulaPrefixSanitizers(code));
|
|
22624
|
+
additionalSanitizers.push(...findJsWrapperFunctionSanitizers(code));
|
|
22625
|
+
}
|
|
22626
|
+
if (language === "java") {
|
|
22627
|
+
additionalSanitizers.push(...findJavaSafeJsonParseSanitizers(code));
|
|
22628
|
+
}
|
|
22620
22629
|
if (language === "python" || language === "javascript" || language === "typescript" || language === "go") {
|
|
22621
22630
|
const exfilFindings = findExternalSecretExfiltrationFindings(code, graph.ir.meta.file, language);
|
|
22622
22631
|
for (const finding of exfilFindings) {
|
|
@@ -24112,6 +24121,123 @@ function findRustCanonicalizeGuardSanitizers(code) {
|
|
|
24112
24121
|
}
|
|
24113
24122
|
return sanitizers;
|
|
24114
24123
|
}
|
|
24124
|
+
function findJavaSafeJsonParseSanitizers(code) {
|
|
24125
|
+
const sanitizers = [];
|
|
24126
|
+
const lines = code.split(`
|
|
24127
|
+
`);
|
|
24128
|
+
const safeParse = /\.(?:readValue|fromJson)\s*\(/;
|
|
24129
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24130
|
+
if (!safeParse.test(lines[i2]))
|
|
24131
|
+
continue;
|
|
24132
|
+
sanitizers.push({
|
|
24133
|
+
type: "java_safe_json_parse",
|
|
24134
|
+
method: "readValue",
|
|
24135
|
+
line: i2 + 1,
|
|
24136
|
+
sanitizes: ["external_taint_escape"]
|
|
24137
|
+
});
|
|
24138
|
+
}
|
|
24139
|
+
return sanitizers;
|
|
24140
|
+
}
|
|
24141
|
+
function findJsSafeJsonParseSanitizers(code) {
|
|
24142
|
+
const sanitizers = [];
|
|
24143
|
+
const lines = code.split(`
|
|
24144
|
+
`);
|
|
24145
|
+
const safeParse = /\bJSON\.parse\s*\(/;
|
|
24146
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24147
|
+
if (!safeParse.test(lines[i2]))
|
|
24148
|
+
continue;
|
|
24149
|
+
sanitizers.push({
|
|
24150
|
+
type: "js_safe_json_parse",
|
|
24151
|
+
method: "JSON.parse",
|
|
24152
|
+
line: i2 + 1,
|
|
24153
|
+
sanitizes: ["external_taint_escape"]
|
|
24154
|
+
});
|
|
24155
|
+
}
|
|
24156
|
+
return sanitizers;
|
|
24157
|
+
}
|
|
24158
|
+
function findJsCryptoHashSanitizers(code) {
|
|
24159
|
+
const sanitizers = [];
|
|
24160
|
+
const lines = code.split(`
|
|
24161
|
+
`);
|
|
24162
|
+
const hashCall = /\b(?:bcrypt|argon2)\s*\.\s*hash(?:Sync)?\s*\(|\bcrypto\s*\.\s*(?:scrypt(?:Sync)?|createHash)\s*\(|\.digest\s*\(/;
|
|
24163
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24164
|
+
if (!hashCall.test(lines[i2]))
|
|
24165
|
+
continue;
|
|
24166
|
+
sanitizers.push({
|
|
24167
|
+
type: "js_crypto_hash",
|
|
24168
|
+
method: "hash",
|
|
24169
|
+
line: i2 + 1,
|
|
24170
|
+
sanitizes: ["external_taint_escape"]
|
|
24171
|
+
});
|
|
24172
|
+
}
|
|
24173
|
+
return sanitizers;
|
|
24174
|
+
}
|
|
24175
|
+
function findJsCsvFormulaPrefixSanitizers(code) {
|
|
24176
|
+
const sanitizers = [];
|
|
24177
|
+
const lines = code.split(`
|
|
24178
|
+
`);
|
|
24179
|
+
const tickPrefix = /`'\$\{/;
|
|
24180
|
+
const concatPrefix = /["']\\?'["']\s*\+\s*[A-Za-z_]/;
|
|
24181
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24182
|
+
if (tickPrefix.test(lines[i2]) || concatPrefix.test(lines[i2])) {
|
|
24183
|
+
sanitizers.push({
|
|
24184
|
+
type: "js_csv_formula_prefix",
|
|
24185
|
+
method: "'-prefix",
|
|
24186
|
+
line: i2 + 1,
|
|
24187
|
+
sanitizes: ["external_taint_escape"]
|
|
24188
|
+
});
|
|
24189
|
+
}
|
|
24190
|
+
}
|
|
24191
|
+
return sanitizers;
|
|
24192
|
+
}
|
|
24193
|
+
function findJsWrapperFunctionSanitizers(code) {
|
|
24194
|
+
const sanitizers = [];
|
|
24195
|
+
const lines = code.split(`
|
|
24196
|
+
`);
|
|
24197
|
+
const wrappers = new Map;
|
|
24198
|
+
const fnDeclRe = /\bfunction\s+([A-Za-z_]\w*)\s*\(/;
|
|
24199
|
+
const arrowDeclRe = /\b(?:const|let|var)\s+([A-Za-z_]\w*)\s*=\s*(?:\([^)]*\)|[A-Za-z_]\w*)\s*=>/;
|
|
24200
|
+
const xssCharClass = /\.replace\s*\(\s*\/[^/]*[&<>"'][^/]*\//;
|
|
24201
|
+
const crlfCharClass = /\.replace\s*\(\s*\/[^/]*(?:\\r|\\n|\\t)[^/]*\//;
|
|
24202
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24203
|
+
const m = fnDeclRe.exec(lines[i2]) ?? arrowDeclRe.exec(lines[i2]);
|
|
24204
|
+
if (!m)
|
|
24205
|
+
continue;
|
|
24206
|
+
const name2 = m[1];
|
|
24207
|
+
const body2 = lines.slice(i2, Math.min(lines.length, i2 + 8)).join(`
|
|
24208
|
+
`);
|
|
24209
|
+
const kinds = new Set;
|
|
24210
|
+
if (xssCharClass.test(body2)) {
|
|
24211
|
+
kinds.add("xss");
|
|
24212
|
+
kinds.add("external_taint_escape");
|
|
24213
|
+
}
|
|
24214
|
+
if (crlfCharClass.test(body2)) {
|
|
24215
|
+
kinds.add("log_injection");
|
|
24216
|
+
kinds.add("external_taint_escape");
|
|
24217
|
+
}
|
|
24218
|
+
if (kinds.size > 0)
|
|
24219
|
+
wrappers.set(name2, kinds);
|
|
24220
|
+
}
|
|
24221
|
+
if (wrappers.size === 0)
|
|
24222
|
+
return sanitizers;
|
|
24223
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
24224
|
+
for (const [name2, kinds] of wrappers) {
|
|
24225
|
+
const declSelf = new RegExp(`\\b(?:function|const|let|var)\\s+${name2}\\b`);
|
|
24226
|
+
if (declSelf.test(lines[i2]))
|
|
24227
|
+
continue;
|
|
24228
|
+
const callRe = new RegExp(`\\b${name2}\\s*\\(`);
|
|
24229
|
+
if (!callRe.test(lines[i2]))
|
|
24230
|
+
continue;
|
|
24231
|
+
sanitizers.push({
|
|
24232
|
+
type: "js_wrapper_function",
|
|
24233
|
+
method: name2,
|
|
24234
|
+
line: i2 + 1,
|
|
24235
|
+
sanitizes: [...kinds]
|
|
24236
|
+
});
|
|
24237
|
+
}
|
|
24238
|
+
}
|
|
24239
|
+
return sanitizers;
|
|
24240
|
+
}
|
|
24115
24241
|
function collectEnvSecretVars(lines, language) {
|
|
24116
24242
|
const out2 = new Map;
|
|
24117
24243
|
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
@@ -37653,7 +37779,7 @@ var colors = {
|
|
|
37653
37779
|
};
|
|
37654
37780
|
|
|
37655
37781
|
// src/version.ts
|
|
37656
|
-
var version = "3.
|
|
37782
|
+
var version = "3.124.0";
|
|
37657
37783
|
|
|
37658
37784
|
// src/formatters.ts
|
|
37659
37785
|
var LIBRARY_API_SURFACE_TAG2 = "library-api-surface:caller-responsibility";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.124.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",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@cognium/project-profile-detect": "^1.1.0",
|
|
69
|
-
"circle-ir": "^3.
|
|
69
|
+
"circle-ir": "^3.124.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/node": "^25.5.0",
|