Skip to content

Commit 085286a

Browse files
authored
Merge pull request github#5135 from pwntester/guava_preconditions
Add support for the Preconditions Class in the Guava framework
2 parents 942ae7e + 645b021 commit 085286a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

java/ql/src/semmle/code/java/frameworks/guava/Guava.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
import java
66
import StringUtils
77
import Collections
8+
import Preconditions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/** Definitions of flow steps through the Preconditions class in the Guava framework. */
2+
3+
import java
4+
private import semmle.code.java.dataflow.FlowSteps
5+
6+
/**
7+
* The class `com.google.common.base.Preconditions`.
8+
*/
9+
class TypeGuavaPreconditions extends Class {
10+
TypeGuavaPreconditions() { this.hasQualifiedName("com.google.common.base", "Preconditions") }
11+
}
12+
13+
/**
14+
* A method that returns its argumnets.
15+
*/
16+
private class GuavaPreconditionsMethod extends TaintPreservingCallable {
17+
GuavaPreconditionsMethod() {
18+
this.getDeclaringType() instanceof TypeGuavaPreconditions and
19+
this.hasName("checkNotNull")
20+
}
21+
22+
override predicate returnsTaintFrom(int src) { src = 0 }
23+
}

0 commit comments

Comments
 (0)