mirror of
https://github.com/github/codeql.git
synced 2026-04-23 07:45:17 +02:00
autoformat ql
This commit is contained in:
@@ -447,14 +447,17 @@ private module ControlFlowGraphImpl {
|
||||
* Gets the `i`th `PatternCase` defined on `switch`, if one exists.
|
||||
*/
|
||||
private PatternCase getPatternCase(StmtParent switch, int i) {
|
||||
result = rank[i + 1](PatternCase pc, int caseIdx | pc = getCase(switch, caseIdx) | pc order by caseIdx asc)
|
||||
result =
|
||||
rank[i + 1](PatternCase pc, int caseIdx | pc = getCase(switch, caseIdx) | pc order by caseIdx)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PatternCase after pc, if one exists.
|
||||
*/
|
||||
private PatternCase getNextPatternCase(PatternCase pc) {
|
||||
exists(int idx, StmtParent switch | pc = getPatternCase(switch, idx) and result = getPatternCase(switch, idx + 1))
|
||||
exists(int idx, StmtParent switch |
|
||||
pc = getPatternCase(switch, idx) and result = getPatternCase(switch, idx + 1)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1558,9 +1558,7 @@ class SwitchExpr extends Expr, StmtParent, @switchexpr {
|
||||
/** An `instanceof` expression. */
|
||||
class InstanceOfExpr extends Expr, @instanceofexpr {
|
||||
/** Gets the expression on the left-hand side of the `instanceof` operator. */
|
||||
Expr getExpr() {
|
||||
result.isNthChildOf(this, 0)
|
||||
}
|
||||
Expr getExpr() { result.isNthChildOf(this, 0) }
|
||||
|
||||
/**
|
||||
* Gets the pattern of an `x instanceof T pattern` expression, if any.
|
||||
@@ -2558,7 +2556,5 @@ class RecordPatternExpr extends Expr, @recordpatternexpr {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "RecordPatternExpr" }
|
||||
|
||||
Pattern getSubPattern(int i) {
|
||||
result.isNthChildOf(this, i)
|
||||
}
|
||||
Pattern getSubPattern(int i) { result.isNthChildOf(this, i) }
|
||||
}
|
||||
|
||||
@@ -770,7 +770,9 @@ private class PpSwitchCase extends PpAst, SwitchCase {
|
||||
|
||||
private int lastConstCaseValueIndex() {
|
||||
result =
|
||||
1 + 2 * (max(int j | j = 0 or exists(this.(ConstCase).getValue(j))) + this.getCaseDefaultOffset())
|
||||
1 +
|
||||
2 *
|
||||
(max(int j | j = 0 or exists(this.(ConstCase).getValue(j))) + this.getCaseDefaultOffset())
|
||||
}
|
||||
|
||||
override PpAst getChild(int i) {
|
||||
|
||||
@@ -191,17 +191,11 @@ predicate simpleAstFlowStep(Expr e1, Expr e2) {
|
||||
or
|
||||
e2.(WhenExpr).getBranch(_).getAResult() = e1
|
||||
or
|
||||
exists(SwitchExpr se |
|
||||
e1 = se.getExpr() and e2 = se.getACase().(PatternCase).getPattern()
|
||||
)
|
||||
exists(SwitchExpr se | e1 = se.getExpr() and e2 = se.getACase().(PatternCase).getPattern())
|
||||
or
|
||||
exists(SwitchStmt ss |
|
||||
e1 = ss.getExpr() and e2 = ss.getACase().(PatternCase).getPattern()
|
||||
)
|
||||
exists(SwitchStmt ss | e1 = ss.getExpr() and e2 = ss.getACase().(PatternCase).getPattern())
|
||||
or
|
||||
exists(InstanceOfExpr ioe |
|
||||
e1 = ioe.getExpr() and e2 = ioe.getPattern()
|
||||
)
|
||||
exists(InstanceOfExpr ioe | e1 = ioe.getExpr() and e2 = ioe.getPattern())
|
||||
}
|
||||
|
||||
private predicate simpleLocalFlowStep0(Node node1, Node node2) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import java
|
||||
|
||||
import semmle.code.java.controlflow.Guards
|
||||
import semmle.code.java.dataflow.DataFlow
|
||||
|
||||
@@ -12,9 +11,13 @@ private predicate isSafe(Guard g, Expr checked, boolean branch) {
|
||||
}
|
||||
|
||||
module TestConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "source") }
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "source")
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument() }
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument()
|
||||
}
|
||||
|
||||
predicate isBarrier(DataFlow::Node node) {
|
||||
node = DataFlow::BarrierGuard<isSafe/3>::getABarrierNode()
|
||||
@@ -26,4 +29,3 @@ module Flow = DataFlow::Global<TestConfig>;
|
||||
from DataFlow::Node source, DataFlow::Node sink
|
||||
where Flow::flow(source, sink)
|
||||
select source, sink
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import java
|
||||
|
||||
import semmle.code.java.controlflow.Guards
|
||||
import semmle.code.java.dataflow.DataFlow
|
||||
|
||||
@@ -12,9 +11,13 @@ private predicate isSafe(Guard g, Expr checked, boolean branch) {
|
||||
}
|
||||
|
||||
module TestConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof StringLiteral or source.asParameter().getCallable().hasName("test") }
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr() instanceof StringLiteral or source.asParameter().getCallable().hasName("test")
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument() }
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument()
|
||||
}
|
||||
|
||||
predicate isBarrier(DataFlow::Node node) {
|
||||
node = DataFlow::BarrierGuard<isSafe/3>::getABarrierNode()
|
||||
@@ -26,4 +29,3 @@ module Flow = DataFlow::Global<TestConfig>;
|
||||
from DataFlow::Node source, DataFlow::Node sink
|
||||
where Flow::flow(source, sink)
|
||||
select source, sink
|
||||
|
||||
|
||||
Reference in New Issue
Block a user