Merge pull request #632 from asger-semmle/pseudo-random-bytes

JS: add crypto.pseudoRandomBytes as source in InsecureRandomness.ql
This commit is contained in:
Max Schaefer
2018-12-13 08:14:40 +00:00
committed by GitHub
4 changed files with 11 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ module InsecureRandomness {
* A simple random number generator that is not cryptographically secure.
*/
class DefaultSource extends Source, DataFlow::ValueNode {
override CallExpr astNode;
override InvokeExpr astNode;
DefaultSource() {
exists(DataFlow::ModuleImportNode mod, string name | mod.getPath() = name |
@@ -98,6 +98,9 @@ module InsecureRandomness {
or
// (new require('chance')).<name>()
this = DataFlow::moduleImport("chance").getAnInstantiation().getAMemberInvocation(_)
or
// require('crypto').pseudoRandomBytes()
this = DataFlow::moduleMember("crypto", "pseudoRandomBytes").getAnInvocation()
}
}