Skip to content

Commit 4499048

Browse files
committed
better query quality thanks to owen
1 parent 877605d commit 4499048

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

go/ql/src/experimental/CWE-321-V2/HardCodedKeys.ql

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,16 @@ module JwtParseWithConstantKeyConfig implements DataFlow::ConfigSig {
2020
// Find a node that has flow to a key Function argument
2121
// then find the first result node of this Function which is the secret key
2222
exists(FuncDef fd, DataFlow::Node n, DataFlow::ResultNode rn |
23+
fd = n.asExpr()
24+
or
25+
n = fd.(FuncDecl).getFunction().getARead()
26+
|
2327
GolangJwtKeyFunc::flow(n, _) and
2428
sink = rn and
25-
fd = n.asExpr() and
2629
rn.getRoot() = fd and
2730
rn.getIndex() = 0
2831
)
2932
or
30-
exists(Function f, DataFlow::ResultNode rn |
31-
GolangJwtKeyFunc::flow(f.getARead(), _) and
32-
// sink is result of a method
33-
sink = rn and
34-
// the method is belong to a function in which is used as a JWT function key
35-
rn.getRoot() = f.getFuncDecl() and
36-
rn.getIndex() = 0
37-
)
38-
or
3933
// second part is the JWT Parsing Functions that get a string or byte as an argument
4034
sink = any(JwtParse jp).getKeyArg()
4135
}

0 commit comments

Comments
 (0)