File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
java/ql/lib/semmle/code/java Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ class TypeUrl extends RefType {
24
24
TypeUrl ( ) { this .hasQualifiedName ( "java.net" , "URL" ) }
25
25
}
26
26
27
+ /** The type `java.net.URLDecoder`. */
28
+ class TypeUrlDecoder extends RefType {
29
+ TypeUrlDecoder ( ) { this .hasQualifiedName ( "java.net" , "URLDecoder" ) }
30
+ }
31
+
27
32
/** The type `java.net.URI`. */
28
33
class TypeUri extends RefType {
29
34
TypeUri ( ) { this .hasQualifiedName ( "java.net" , "URI" ) }
@@ -157,6 +162,14 @@ class UrlOpenConnectionMethod extends Method {
157
162
}
158
163
}
159
164
165
+ /** The method `java.net.URLDecoder::decode`. */
166
+ class UrlDecodeMethod extends Method {
167
+ UrlDecodeMethod ( ) {
168
+ this .getDeclaringType ( ) instanceof TypeUrlDecoder and
169
+ this .getName ( ) = "decode"
170
+ }
171
+ }
172
+
160
173
/** The method `javax.net.SocketFactory::createSocket`. */
161
174
class CreateSocketMethod extends Method {
162
175
CreateSocketMethod ( ) {
Original file line number Diff line number Diff line change @@ -41,8 +41,6 @@ abstract class UrlForwardBarrier extends DataFlow::Node { }
41
41
42
42
private class PrimitiveBarrier extends UrlForwardBarrier instanceof SimpleTypeSanitizer { }
43
43
44
- // TODO: should this also take URL encoding/decoding into account?
45
- // TODO: and PathSanitization in general?
46
44
private class FollowsBarrierPrefix extends UrlForwardBarrier {
47
45
FollowsBarrierPrefix ( ) { this .asExpr ( ) = any ( BarrierPrefix fp ) .getAnAppendedExpression ( ) }
48
46
}
@@ -58,9 +56,8 @@ private class BarrierPrefix extends InterestingPrefix {
58
56
59
57
private class UrlPathBarrier extends UrlForwardBarrier instanceof PathInjectionSanitizer {
60
58
UrlPathBarrier ( ) {
61
- this instanceof ExactPathMatchSanitizer //TODO: still need a better solution for this edge case...
59
+ this instanceof ExactPathMatchSanitizer
62
60
or
63
- // TODO: these don't enforce order of checks and PathSanitization... make bypass test cases.
64
61
this instanceof NoEncodingBarrier
65
62
or
66
63
this instanceof FullyDecodesBarrier
@@ -71,7 +68,7 @@ abstract class UrlDecodeCall extends MethodCall { }
71
68
72
69
private class DefaultUrlDecodeCall extends UrlDecodeCall {
73
70
DefaultUrlDecodeCall ( ) {
74
- this .getMethod ( ) . hasQualifiedName ( "java.net" , "URLDecoder" , "decode" ) or // TODO: reuse existing class? Or make this a class?
71
+ this .getMethod ( ) instanceof UrlDecodeMethod or
75
72
this .getMethod ( ) .hasQualifiedName ( "org.eclipse.jetty.util.URIUtil" , "URIUtil" , "decodePath" )
76
73
}
77
74
}
You can’t perform that action at this time.
0 commit comments