Skip to content

Commit c6814fc

Browse files
committed
merge duplicate module into a module file
1 parent 701e3d7 commit c6814fc

File tree

3 files changed

+47
-90
lines changed

3 files changed

+47
-90
lines changed

java/ql/src/experimental/Security/CWE/CWE-347/Auth0NoVerifier.ql

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,7 @@
1212

1313
import java
1414
import semmle.code.java.dataflow.FlowSources
15-
16-
module JwtAuth0 {
17-
class PayloadType extends RefType {
18-
PayloadType() { this.hasQualifiedName("com.auth0.jwt.interfaces", "Payload") }
19-
}
20-
21-
class JwtType extends RefType {
22-
JwtType() { this.hasQualifiedName("com.auth0.jwt", "JWT") }
23-
}
24-
25-
class JwtVerifierType extends RefType {
26-
JwtVerifierType() { this.hasQualifiedName("com.auth0.jwt", "JWTVerifier") }
27-
}
28-
29-
/**
30-
* A Method that returns a Decoded Claim of JWT
31-
*/
32-
class GetPayload extends MethodCall {
33-
GetPayload() {
34-
this.getCallee().getDeclaringType() instanceof PayloadType and
35-
this.getCallee().hasName(["getClaim", "getIssuedAt"])
36-
}
37-
}
38-
39-
/**
40-
* A Method that Decode JWT without signature verification
41-
*/
42-
class Decode extends MethodCall {
43-
Decode() {
44-
this.getCallee().getDeclaringType() instanceof JwtType and
45-
this.getCallee().hasName("decode")
46-
}
47-
}
48-
49-
/**
50-
* A Method that Decode JWT with signature verification
51-
*/
52-
class Verify extends MethodCall {
53-
Verify() {
54-
this.getCallee().getDeclaringType() instanceof JwtVerifierType and
55-
this.getCallee().hasName("verify")
56-
}
57-
}
58-
}
15+
import JwtAuth0 as JwtAuth0
5916

6017
module JwtDecodeConfig implements DataFlow::ConfigSig {
6118
predicate isSource(DataFlow::Node source) {

java/ql/src/experimental/Security/CWE/CWE-347/Auth0NoVerifierLocalSource.ql

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,11 @@
1212

1313
import java
1414
import semmle.code.java.dataflow.FlowSources
15+
import JwtAuth0 as JwtAuth0
1516

16-
module JwtAuth0 {
17-
class PayloadType extends RefType {
18-
PayloadType() { this.hasQualifiedName("com.auth0.jwt.interfaces", "Payload") }
19-
}
20-
21-
class JwtType extends RefType {
22-
JwtType() { this.hasQualifiedName("com.auth0.jwt", "JWT") }
23-
}
24-
25-
class JwtVerifierType extends RefType {
26-
JwtVerifierType() { this.hasQualifiedName("com.auth0.jwt", "JWTVerifier") }
27-
}
28-
29-
/**
30-
* A Method that returns a Decoded Claim of JWT
31-
*/
32-
class GetPayload extends MethodCall {
33-
GetPayload() {
34-
this.getCallee().getDeclaringType() instanceof PayloadType and
35-
this.getCallee().hasName(["getClaim", "getIssuedAt"])
36-
}
37-
}
38-
39-
/**
40-
* A Method that Decode JWT without signature verification
41-
*/
42-
class Decode extends MethodCall {
43-
Decode() {
44-
this.getCallee().getDeclaringType() instanceof JwtType and
45-
this.getCallee().hasName("decode")
46-
}
47-
}
48-
49-
/**
50-
* A Method that Decode JWT with signature verification
51-
*/
52-
class Verify extends MethodCall {
53-
Verify() {
54-
this.getCallee().getDeclaringType() instanceof JwtVerifierType and
55-
this.getCallee().hasName("verify")
56-
}
57-
}
58-
}
5917

6018
module JwtDecodeConfig implements DataFlow::ConfigSig {
6119
predicate isSource(DataFlow::Node source) {
62-
6320
exists(Variable v |
6421
source.asExpr() = v.getInitializer() and
6522
v.getType().hasName("String")
@@ -89,11 +46,11 @@ module JwtDecodeConfig implements DataFlow::ConfigSig {
8946
}
9047

9148
module FlowToJwtVerifyConfig implements DataFlow::ConfigSig {
92-
predicate isSource(DataFlow::Node source) {
49+
predicate isSource(DataFlow::Node source) {
9350
exists(Variable v |
9451
source.asExpr() = v.getInitializer() and
9552
v.getType().hasName("String")
96-
)
53+
)
9754
}
9855

9956
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(JwtAuth0::Verify a).getArgument(0) }
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import java
2+
3+
class PayloadType extends RefType {
4+
PayloadType() { this.hasQualifiedName("com.auth0.jwt.interfaces", "Payload") }
5+
}
6+
7+
class JwtType extends RefType {
8+
JwtType() { this.hasQualifiedName("com.auth0.jwt", "JWT") }
9+
}
10+
11+
class JwtVerifierType extends RefType {
12+
JwtVerifierType() { this.hasQualifiedName("com.auth0.jwt", "JWTVerifier") }
13+
}
14+
15+
/**
16+
* A Method that returns a Decoded Claim of JWT
17+
*/
18+
class GetPayload extends MethodCall {
19+
GetPayload() {
20+
this.getCallee().getDeclaringType() instanceof PayloadType and
21+
this.getCallee().hasName(["getClaim", "getIssuedAt"])
22+
}
23+
}
24+
25+
/**
26+
* A Method that Decode JWT without signature verification
27+
*/
28+
class Decode extends MethodCall {
29+
Decode() {
30+
this.getCallee().getDeclaringType() instanceof JwtType and
31+
this.getCallee().hasName("decode")
32+
}
33+
}
34+
35+
/**
36+
* A Method that Decode JWT with signature verification
37+
*/
38+
class Verify extends MethodCall {
39+
Verify() {
40+
this.getCallee().getDeclaringType() instanceof JwtVerifierType and
41+
this.getCallee().hasName("verify")
42+
}
43+
}

0 commit comments

Comments
 (0)