File tree Expand file tree Collapse file tree 2 files changed +20
-23
lines changed
java/ql/lib/semmle/code/java Expand file tree Collapse file tree 2 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,17 @@ private predicate constantBooleanExpr(Expr e, boolean val) {
104
104
CalcConstants:: calculateBooleanValue ( e ) = val
105
105
}
106
106
107
+ pragma [ nomagic]
108
+ private predicate constantStringExpr ( Expr e , string val ) {
109
+ e .( CompileTimeConstantExpr ) .getStringValue ( ) = val
110
+ or
111
+ exists ( SsaExplicitUpdate v , Expr src |
112
+ e = v .getAUse ( ) and
113
+ src = v .getDefiningExpr ( ) .( VariableAssign ) .getSource ( ) and
114
+ constantStringExpr ( src , val )
115
+ )
116
+ }
117
+
107
118
private boolean getBoolValue ( Expr e ) { constantBooleanExpr ( e , result ) }
108
119
109
120
private int getIntValue ( Expr e ) { constantIntegerExpr ( e , result ) }
@@ -126,6 +137,14 @@ class ConstantBooleanExpr extends Expr {
126
137
boolean getBooleanValue ( ) { constantBooleanExpr ( this , result ) }
127
138
}
128
139
140
+ /** An expression that always has the same string value. */
141
+ class ConstantStringExpr extends Expr {
142
+ ConstantStringExpr ( ) { constantStringExpr ( this , _) }
143
+
144
+ /** Get the string value of this expression. */
145
+ string getStringValue ( ) { constantStringExpr ( this , result ) }
146
+ }
147
+
129
148
/**
130
149
* Gets an expression that equals `v - d`.
131
150
*/
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ import java
4
4
import semmle.code.java.dataflow.DataFlow
5
5
import semmle.code.java.dataflow.DataFlow2
6
6
import semmle.code.java.dataflow.DataFlow3
7
- import semmle.code.java.dataflow.DataFlow4
8
- import semmle.code.java.dataflow.DataFlow5
9
- private import semmle.code.java.dataflow.SSA
7
+ private import semmle.code.java.dataflow.RangeUtils
10
8
11
9
/*
12
10
* Various XML parsers in Java.
@@ -130,26 +128,6 @@ class DocumentBuilderFactoryConfig extends ParserConfig {
130
128
}
131
129
}
132
130
133
- private predicate constantStringExpr ( Expr e , string val ) {
134
- e .( CompileTimeConstantExpr ) .getStringValue ( ) = val
135
- or
136
- exists ( SsaExplicitUpdate v , Expr src |
137
- e = v .getAUse ( ) and
138
- src = v .getDefiningExpr ( ) .( VariableAssign ) .getSource ( ) and
139
- constantStringExpr ( src , val )
140
- )
141
- }
142
-
143
- /** An expression that always has the same string value. */
144
- private class ConstantStringExpr extends Expr {
145
- string value ;
146
-
147
- ConstantStringExpr ( ) { constantStringExpr ( this , value ) }
148
-
149
- /** Get the string value of this expression. */
150
- string getStringValue ( ) { result = value }
151
- }
152
-
153
131
/**
154
132
* A general configuration that is safe when enabled.
155
133
*/
You can’t perform that action at this time.
0 commit comments