Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e671832

Browse files
committed
Restore query-specific FunctionModels
MaD can't be used to introduce query-specific sumamries at the moment.
1 parent ed7f351 commit e671832

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

go/ql/lib/semmle/go/security/InsecureRandomnessCustomizations.qll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,33 @@ module InsecureRandomness {
8181
/** Gets a package that implements hash algorithms. */
8282
bindingset[result]
8383
private string getAHashPkg() { result.regexpMatch("crypto/(md5|sha(1|256|512)|rand)") }
84+
85+
/**
86+
* A function that hashes input, which is considered as a taint propagator for use of
87+
* cryptographically insecure random values.
88+
*/
89+
class HashAlgorithm extends TaintTracking::FunctionModel {
90+
HashAlgorithm() {
91+
exists(Method m | this = m |
92+
m.implements("hash", "Hash", "Sum")
93+
or
94+
m.implements("hash", "Hash32", "Sum32")
95+
or
96+
m.implements("hash", "Hash64", "Sum64")
97+
)
98+
or
99+
exists(string pkg, string name | this.hasQualifiedName(pkg, name) |
100+
pkg = getAHashPkg() and name.matches("Sum%")
101+
)
102+
}
103+
104+
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
105+
if this instanceof Method
106+
then (
107+
inp.isReceiver() and outp.isResult()
108+
) else (
109+
inp.isParameter(0) and outp.isResult()
110+
)
111+
}
112+
}
84113
}

0 commit comments

Comments
 (0)