Skip to content

Commit 3ef5f30

Browse files
committed
small change
1 parent 4980948 commit 3ef5f30

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

javascript/ql/lib/semmle/javascript/frameworks/CryptoLibraries.qll

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private module NodeJSCrypto {
276276
*/
277277
private module CryptoJS {
278278
private class InstantiatedAlgorithm extends DataFlow::CallNode {
279-
CryptographicAlgorithm algorithm; // non-functional
279+
private string algorithmName;
280280

281281
InstantiatedAlgorithm() {
282282
/*
@@ -295,11 +295,25 @@ private module CryptoJS {
295295
mod = DataFlow::moduleImport("crypto-js") and
296296
propRead = mod.getAPropertyRead("algo").getAPropertyRead() and
297297
this = propRead.getAMemberCall("create") and
298-
not isStrongPasswordHashingAlgorithm(propRead.getPropertyName())
298+
algorithmName = propRead.getPropertyName() and
299+
not isStrongPasswordHashingAlgorithm(algorithmName)
299300
)
300301
}
301302

302-
CryptographicAlgorithm getAlgorithm() { result = algorithm }
303+
CryptographicAlgorithm getAlgorithm() { result.matchesName(algorithmName) }
304+
305+
private BlockMode getExplicitBlockMode() { result.matchesString(algorithmName) }
306+
307+
BlockMode getBlockMode() {
308+
isBlockEncryptionAlgorithm(this.getAlgorithm()) and
309+
(
310+
if exists(this.getExplicitBlockMode())
311+
then result = this.getExplicitBlockMode()
312+
else
313+
// CBC is the default if not explicitly specified
314+
result = "CBC"
315+
)
316+
}
303317
}
304318

305319

0 commit comments

Comments
 (0)