mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
docs: rename ql-training-rst > ql-training
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import java
|
||||
|
||||
class StringConcat extends AddExpr {
|
||||
StringConcat() { getType() instanceof TypeString }
|
||||
}
|
||||
|
||||
from MethodAccess ma
|
||||
where
|
||||
ma.getMethod().getName().matches("sparql%Query") and
|
||||
ma.getArgument(0) instanceof StringConcat
|
||||
select ma, "SPARQL query vulnerable to injection."
|
||||
@@ -0,0 +1,8 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.DataFlow::DataFlow
|
||||
|
||||
from MethodAccess ma, StringConcat stringConcat
|
||||
where
|
||||
ma.getMethod().getName().matches("sparql%Query") and
|
||||
localFlow(exprNode(stringConcat), exprNode(ma.getArgument(0)))
|
||||
select ma, "SPARQL query vulnerable to injection."
|
||||
@@ -0,0 +1,12 @@
|
||||
import java
|
||||
|
||||
class EmptyBlock extends Block {
|
||||
EmptyBlock() {
|
||||
this.getNumStmt() = 0
|
||||
|
||||
}
|
||||
|
||||
from IfStmt ifstmt
|
||||
where ifstmt.getThen() instanceof
|
||||
EmptyBlock
|
||||
select ifstmt
|
||||
@@ -0,0 +1,11 @@
|
||||
import java
|
||||
|
||||
class EmptyBlock extends Block {
|
||||
EmptyBlock() { this.getNumStmt() = 0 }
|
||||
}
|
||||
|
||||
from IfStmt ifstmt
|
||||
where
|
||||
ifstmt.getThen() instanceof EmptyBlock and
|
||||
not exists(ifstmt.getElse())
|
||||
select ifstmt, "This if-statement is redundant."
|
||||
@@ -0,0 +1,9 @@
|
||||
import java
|
||||
|
||||
predicate isEmpty(Block block) {
|
||||
block.getNumStmt() = 0
|
||||
}
|
||||
|
||||
from IfStmt ifstmt
|
||||
where isEmpty(ifstmt.getThen())
|
||||
select ifstmt
|
||||
@@ -0,0 +1,7 @@
|
||||
import java
|
||||
|
||||
from IfStmt ifstmt, Block block
|
||||
where
|
||||
block = ifstmt.getThen() and
|
||||
block.getNumStmt() = 0
|
||||
select ifstmt, "This if-statement is redundant."
|
||||
@@ -0,0 +1,14 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.TaintTracking
|
||||
|
||||
class TaintedOGNLConfig extends TaintTracking::Configuration {
|
||||
TaintedOGNLConfig() { this = "TaintedOGNLConfig" }
|
||||
override predicate isSource(DataFlow::Node source) { /* TBD */ }
|
||||
override predicate isSink(DataFlow::Node sink) { /* TBD */ }
|
||||
}
|
||||
|
||||
from TaintedOGNLConfig cfg, DataFlow::Node source, DataFlow::Node sink
|
||||
where cfg.hasFlow(source, sink)
|
||||
select source,
|
||||
"This untrusted input is evaluated as an OGNL expression $@.",
|
||||
sink, "here"
|
||||
@@ -0,0 +1,7 @@
|
||||
import java
|
||||
|
||||
from Method m, MethodAccess ma
|
||||
where
|
||||
m.getName().matches("sparql%Query") and
|
||||
ma.getMethod() = m
|
||||
select ma, m
|
||||
@@ -0,0 +1,8 @@
|
||||
import java
|
||||
|
||||
from Method m, MethodAccess ma
|
||||
where
|
||||
m.getName().matches("sparql%Query") and
|
||||
ma.getMethod() = m and
|
||||
isStringConcat(ma.getArgument(0))
|
||||
select ma, m
|
||||
@@ -0,0 +1,12 @@
|
||||
import java
|
||||
|
||||
predicate isStringConcat(AddExpr ae) {
|
||||
ae.getType() instanceof TypeString
|
||||
}
|
||||
|
||||
from Method m, MethodAccess ma
|
||||
where
|
||||
m.getName().matches("sparql%Query") and
|
||||
ma.getMethod() = m and
|
||||
isStringConcat(ma.getArgument(0))
|
||||
select ma, "SPARQL query vulnerable to injection."
|
||||
Reference in New Issue
Block a user