Skip to content

Commit 3ca039b

Browse files
committed
Rename to InsecureRandomness
1 parent 6e70e6c commit 3ca039b

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

java/ql/lib/semmle/code/java/security/WeakRandomnessQuery.qll renamed to java/ql/lib/semmle/code/java/security/InsecureRandomnessQuery.qll

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** Provides classes and predicates for reasoning about weak randomness. */
1+
/** Provides classes and predicates for reasoning about insecure randomness. */
22

33
import java
44
private import semmle.code.java.frameworks.Servlets
@@ -9,13 +9,13 @@ private import semmle.code.java.dataflow.ExternalFlow
99
private import semmle.code.java.security.RandomQuery
1010

1111
/**
12-
* A node representing a source of weak randomness.
12+
* A node representing a source of insecure randomness.
1313
*
1414
* For example, use of `java.util.Random` or `java.lang.Math.random`.
1515
*/
16-
abstract class WeakRandomnessSource extends DataFlow::Node { }
16+
abstract class InsecureRandomnessSource extends DataFlow::Node { }
1717

18-
private class RandomMethodSource extends WeakRandomnessSource {
18+
private class RandomMethodSource extends InsecureRandomnessSource {
1919
RandomMethodSource() {
2020
exists(RandomDataSource s | this.asExpr() = s.getOutput() |
2121
not s.getQualifier().getType() instanceof SafeRandomImplementation
@@ -40,14 +40,14 @@ private class TypeHadoopOsSecureRandom extends SafeRandomImplementation {
4040
}
4141

4242
/**
43-
* A node representing an operation which should not use a weakly random value.
43+
* A node representing an operation which should not use a Insecurely random value.
4444
*/
45-
abstract class WeakRandomnessSink extends DataFlow::Node { }
45+
abstract class InsecureRandomnessSink extends DataFlow::Node { }
4646

4747
/**
4848
* A node which sets the value of a cookie.
4949
*/
50-
private class CookieSink extends WeakRandomnessSink {
50+
private class CookieSink extends InsecureRandomnessSink {
5151
CookieSink() {
5252
exists(Call c |
5353
c.(ClassInstanceExpr).getConstructedType() instanceof TypeCookie and
@@ -60,19 +60,19 @@ private class CookieSink extends WeakRandomnessSink {
6060
}
6161
}
6262

63-
private class SensitiveActionSink extends WeakRandomnessSink {
63+
private class SensitiveActionSink extends InsecureRandomnessSink {
6464
SensitiveActionSink() { this.asExpr() instanceof SensitiveExpr }
6565
}
6666

67-
private class CredentialsSink extends WeakRandomnessSink instanceof CredentialsSinkNode { }
67+
private class CredentialsSink extends InsecureRandomnessSink instanceof CredentialsSinkNode { }
6868

6969
/**
70-
* A taint-tracking configuration for weak randomness.
70+
* A taint-tracking configuration for Insecure randomness.
7171
*/
72-
module WeakRandomnessConfig implements DataFlow::ConfigSig {
73-
predicate isSource(DataFlow::Node src) { src instanceof WeakRandomnessSource }
72+
module InsecureRandomnessConfig implements DataFlow::ConfigSig {
73+
predicate isSource(DataFlow::Node src) { src instanceof InsecureRandomnessSource }
7474

75-
predicate isSink(DataFlow::Node sink) { sink instanceof WeakRandomnessSink }
75+
predicate isSink(DataFlow::Node sink) { sink instanceof InsecureRandomnessSink }
7676

7777
predicate isBarrierIn(DataFlow::Node n) { isSource(n) }
7878

@@ -92,6 +92,6 @@ module WeakRandomnessConfig implements DataFlow::ConfigSig {
9292
}
9393

9494
/**
95-
* Taint-tracking flow of a weakly random value into a sensitive sink.
95+
* Taint-tracking flow of a Insecurely random value into a sensitive sink.
9696
*/
97-
module WeakRandomnessFlow = TaintTracking::Global<WeakRandomnessConfig>;
97+
module InsecureRandomnessFlow = TaintTracking::Global<InsecureRandomnessConfig>;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @name Insecure randomness
3+
* @description Using a cryptographically Insecure pseudo-random number generator to generate a
4+
* security-sensitive value may allow an attacker to predict what value will
5+
* be generated.
6+
* @kind path-problem
7+
* @problem.severity warning
8+
* @security-severity 7.8
9+
* @precision high
10+
* @id java/insecure-randomness
11+
* @tags security
12+
* external/cwe/cwe-330
13+
* external/cwe/cwe-338
14+
*/
15+
16+
import java
17+
import semmle.code.java.security.InsecureRandomnessQuery
18+
import InsecureRandomnessFlow::PathGraph
19+
20+
from InsecureRandomnessFlow::PathNode source, InsecureRandomnessFlow::PathNode sink
21+
where InsecureRandomnessFlow::flowPath(source, sink)
22+
select sink.getNode(), source, sink, "Potential Insecure randomness due to a $@.", source.getNode(),
23+
"Insecure randomness source."

java/ql/src/Security/CWE/CWE-330/WeakRandomness.ql

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)