Skip to content

Commit

Permalink
Make imports private
Browse files Browse the repository at this point in the history
  • Loading branch information
egregius313 committed Aug 2, 2023
1 parent b0014f6 commit 3d51f62
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions java/ql/lib/semmle/code/java/security/WeakRandomnessQuery.qll
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/** Provides classes and predicates for reasoning about weak randomness. */

import java
import semmle.code.java.frameworks.Servlets
import semmle.code.java.security.SensitiveActions
import semmle.code.java.dataflow.TaintTracking
import semmle.code.java.dataflow.ExternalFlow
import semmle.code.java.security.RandomQuery
private import semmle.code.java.frameworks.Servlets
private import semmle.code.java.security.SensitiveActions
private import semmle.code.java.dataflow.TaintTracking
private import semmle.code.java.dataflow.ExternalFlow
private import semmle.code.java.security.RandomQuery

/**
* The `java.util.Random` class.
Expand All @@ -25,23 +25,31 @@ abstract class WeakRandomnessSource extends DataFlow::Node { }
* A node representing a call to a constructor of `java.util.Random`.
*/
private class JavaRandomSource extends WeakRandomnessSource {
JavaRandomSource() {
this.asExpr().(ConstructorCall).getType() instanceof TypeRandom
}
JavaRandomSource() { this.asExpr().(ConstructorCall).getType() instanceof TypeRandom }
}

/**
* A node representing a call to one of the methods of `org.apache.commons.lang.RandomStringUtils`.
*/
private class ApacheRandomStringUtilsMethodAccessSource extends WeakRandomnessSource {
ApacheRandomStringUtilsMethodAccessSource() {
this.asExpr().(MethodAccess).getMethod().hasQualifiedName("org.apache.commons.lang", "RandomStringUtils", ["random", "randomAlphabetic", "randomAlphanumeric", "randomAscii", "randomGraph", "randomNumeric", "randomPrint"])
this.asExpr()
.(MethodAccess)
.getMethod()
.hasQualifiedName("org.apache.commons.lang", "RandomStringUtils",
[
"random", "randomAlphabetic", "randomAlphanumeric", "randomAscii", "randomGraph",
"randomNumeric", "randomPrint"
])
}
}

private class ThreadLocalRandomSource extends WeakRandomnessSource {
ThreadLocalRandomSource() {
this.asExpr().(MethodAccess).getMethod().hasQualifiedName("java.util.concurrent", "ThreadLocalRandom", "current")
this.asExpr()
.(MethodAccess)
.getMethod()
.hasQualifiedName("java.util.concurrent", "ThreadLocalRandom", "current")
}
}

Expand Down

0 comments on commit 3d51f62

Please sign in to comment.