Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 79002b0

Browse files
author
dilanbhalla
committed
pr fixes
1 parent 2ee654d commit 79002b0

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

ql/src/experimental/CWE-327/BrokenCryptoAlgorithmCustomizations.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ module BrokenCryptoAlgorithm {
4949
class Configuration extends TaintTracking::Configuration {
5050
Configuration() { this = "BrokenCryptoAlgorithm" }
5151

52-
override predicate isSource(DataFlow::Node source) { source instanceof SensitiveSource }
52+
override predicate isSource(DataFlow::Node source) { source instanceof Source }
5353

54-
override predicate isSink(DataFlow::Node sink) {
55-
sink instanceof WeakCryptographicOperationSink
56-
}
54+
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
5755

5856
override predicate isSanitizer(DataFlow::Node node) {
5957
super.isSanitizer(node) or

ql/src/experimental/CWE-327/CryptoLibraries.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ private module AlgorithmNames {
4040
name = "RIPEMD" or
4141
name = "RIPEMD128" or
4242
name = "RIPEMD256" or
43-
name = "RIPEMD160" or
4443
name = "RIPEMD320" or
4544
name = "SHA0" or
4645
name = "SHA1"
@@ -122,7 +121,8 @@ abstract class CryptographicAlgorithm extends TCryptographicAlgorithm {
122121
*/
123122
bindingset[name]
124123
predicate matchesName(string name) {
125-
name.toUpperCase().regexpReplaceAll("[-_ ]", "").regexpMatch(".*" + getName() + ".*")
124+
exists(name.regexpReplaceAll("[-_]", "").regexpFind("(?i)\\Q" + getName() + "\\E", _, _))
125+
// name.toUpperCase().regexpReplaceAll("[-_ ]", "").regexpMatch(".*" + getName() + ".*")
126126
}
127127

128128
/**
@@ -188,6 +188,10 @@ abstract class CryptographicOperation extends Expr {
188188
abstract CryptographicAlgorithm getAlgorithm();
189189
}
190190

191+
/**
192+
* Below are the cryptographic functions that have been implemented so far for this library.
193+
* Class that checks for use of Md5 package.
194+
*/
191195
class Md5 extends CryptographicOperation {
192196
Expr input;
193197
CryptographicAlgorithm algorithm;
@@ -207,16 +211,20 @@ class Md5 extends CryptographicOperation {
207211
override CryptographicAlgorithm getAlgorithm() { result = algorithm }
208212
}
209213

214+
/**
215+
* Class that checks for use of Des package.
216+
*/
210217
class Des extends CryptographicOperation {
211218
Expr input;
212219
CryptographicAlgorithm algorithm;
213-
CallExpr call;
214220
SelectorExpr sel;
221+
CallExpr call;
215222

216223
Des() {
217224
this = call and
218-
algorithm.matchesName(call.getCalleeName()) and
225+
algorithm.matchesName(sel.getBase().toString()) and
219226
algorithm.matchesName("DES") and
227+
sel.getSelector().toString() = call.getCalleeName().toString() and
220228
call.getArgument(0) = input
221229
}
222230

0 commit comments

Comments
 (0)