Skip to content

Commit 2dec095

Browse files
committed
Binary/JVM: Autoformat.
1 parent 2f64978 commit 2dec095

File tree

20 files changed

+72
-85
lines changed

20 files changed

+72
-85
lines changed

binary/ql/lib/semmle/code/binary/ast/internal/JvmInstructions.qll

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -595,15 +595,13 @@ private string opcodeToMnemonic(int opcode) {
595595
// ============================================================================
596596
// Instruction Categories
597597
// ============================================================================
598-
599598
/** A no-operation instruction. */
600599
class JvmNop extends @jvm_nop, JvmInstruction { }
601600

602601
/** Pushes null onto the stack. */
603602
class JvmAconstNull extends @jvm_aconst_null, JvmLoadConstant { }
604603

605604
// Load local variable instructions (abstract base classes)
606-
607605
/** An instruction that loads a local variable onto the stack. */
608606
abstract class JvmLoadLocal extends JvmInstruction {
609607
abstract int getLocalVariableIndex();
@@ -998,11 +996,9 @@ class JvmLxor extends @jvm_lxor, JvmBitwiseInstruction { }
998996

999997
// iinc
1000998
class JvmIinc extends @jvm_iinc, JvmInstruction {
1001-
int getLocalVariableIndex() {
1002-
exists(int idx | jvm_operand_iinc(this, idx, _) | result = idx)
1003-
}
999+
int getLocalVariableIndex() { jvm_operand_iinc(this, result, _) }
10041000

1005-
int getIncrement() { exists(int inc | jvm_operand_iinc(this, _, inc) | result = inc) }
1001+
int getIncrement() { jvm_operand_iinc(this, _, result) }
10061002
}
10071003

10081004
// Type conversions (abstract hierarchy)
@@ -1185,15 +1181,11 @@ class JvmReturnVoid extends @jvm_return, JvmReturn { }
11851181
// Field access (abstract hierarchy)
11861182
/** An instruction that accesses a field. */
11871183
abstract class JvmFieldAccess extends JvmInstruction {
1188-
string getFieldClassName() {
1189-
exists(string cn | jvm_field_operand(this, cn, _, _) | result = cn)
1190-
}
1184+
string getFieldClassName() { jvm_field_operand(this, result, _, _) }
11911185

1192-
string getFieldName() { exists(string fn | jvm_field_operand(this, _, fn, _) | result = fn) }
1186+
string getFieldName() { jvm_field_operand(this, _, result, _) }
11931187

1194-
string getFieldDescriptor() {
1195-
exists(string fd | jvm_field_operand(this, _, _, fd) | result = fd)
1196-
}
1188+
string getFieldDescriptor() { jvm_field_operand(this, _, _, result) }
11971189

11981190
/** Holds if this is a static field access. */
11991191
predicate isStatic() { this instanceof JvmGetstatic or this instanceof JvmPutstatic }

binary/ql/lib/semmle/code/binary/ast/ir/internal/Consistency.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ module StagedConsistencyInput<InstructionSig Input> {
2929
not exists(i.getASuccessor())
3030
}
3131

32-
query predicate nonLocalSuccessor(Input::Function f1, Input::Function f2, Input::Instruction i, SuccessorType t) {
32+
query predicate nonLocalSuccessor(
33+
Input::Function f1, Input::Function f2, Input::Instruction i, SuccessorType t
34+
) {
3335
i.getEnclosingFunction() = f1 and
3436
i.getSuccessor(t).getEnclosingFunction() = f2 and
3537
f1 != f2
3638
}
3739

38-
query predicate successorMissingFunction(Input::Function f, Input::Instruction i1, Input::Instruction i2, SuccessorType t) {
40+
query predicate successorMissingFunction(
41+
Input::Function f, Input::Instruction i1, Input::Instruction i2, SuccessorType t
42+
) {
3943
i1.getEnclosingFunction() = f and
4044
i1.getSuccessor(t) = i2 and
4145
not exists(i2.getEnclosingFunction())

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/TranslatedFunction.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ class TranslatedX86Function extends TranslatedFunction, TTranslatedX86Function {
110110
else result = "Function_" + entry.getIndex()
111111
}
112112

113-
final override predicate isProgramEntryPoint() { entry instanceof Raw::X86ProgramEntryInstruction }
113+
final override predicate isProgramEntryPoint() {
114+
entry instanceof Raw::X86ProgramEntryInstruction
115+
}
114116

115117
final override predicate isPublic() { entry instanceof Raw::X86ExportedEntryInstruction }
116118

@@ -234,7 +236,6 @@ class TranslatedCilMethod extends TranslatedFunction, TTranslatedCilMethod {
234236
// ============================================================================
235237
// JVM Translated Elements
236238
// ============================================================================
237-
238239
class TranslatedJvmParameter extends TranslatedElement, TTranslatedJvmParameter {
239240
Raw::JvmParameter p;
240241

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/TranslatedInstruction.qll

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,6 @@ class TranslatedCilLoadField extends TranslatedCilInstruction, TTranslatedCilLoa
26832683
// ============================================================================
26842684
// JVM Translated Instructions
26852685
// ============================================================================
2686-
26872686
/**
26882687
* Base class for all translated JVM instructions.
26892688
*/
@@ -2773,9 +2772,7 @@ class TranslatedJvmInvoke extends TranslatedJvmInstruction, TTranslatedJvmInvoke
27732772
override Instruction getEntry() { result = this.getInstruction(JvmCallTargetTag()) }
27742773

27752774
override Variable getResultVariable() {
2776-
if instr.hasReturnValue()
2777-
then result = this.getTempVariable(JvmCallResultVarTag())
2778-
else none()
2775+
if instr.hasReturnValue() then result = this.getTempVariable(JvmCallResultVarTag()) else none()
27792776
}
27802777

27812778
final override Variable getStackElement(int i) {
@@ -2786,14 +2783,16 @@ class TranslatedJvmInvoke extends TranslatedJvmInstruction, TTranslatedJvmInvoke
27862783
or
27872784
// Rest of the stack has the arguments removed
27882785
i > 0 and
2789-
result = getTranslatedJvmInstruction(instr.getABackwardPredecessor())
2790-
.getStackElement(i - 1 + instr.getNumberOfArguments())
2786+
result =
2787+
getTranslatedJvmInstruction(instr.getABackwardPredecessor())
2788+
.getStackElement(i - 1 + instr.getNumberOfArguments())
27912789
or
27922790
// If no return value, shift the indices
27932791
i >= 0 and
27942792
not instr.hasReturnValue() and
2795-
result = getTranslatedJvmInstruction(instr.getABackwardPredecessor())
2796-
.getStackElement(i + instr.getNumberOfArguments())
2793+
result =
2794+
getTranslatedJvmInstruction(instr.getABackwardPredecessor())
2795+
.getStackElement(i + instr.getNumberOfArguments())
27972796
}
27982797
}
27992798

@@ -2873,7 +2872,9 @@ class TranslatedJvmLoadLocal extends TranslatedJvmInstruction, TTranslatedJvmLoa
28732872

28742873
override Instruction getEntry() { result = this.getInstruction(JvmLoadLocalTag()) }
28752874

2876-
override Variable getResultVariable() { result = this.getTempVariable(JvmLoadLocalResultVarTag()) }
2875+
override Variable getResultVariable() {
2876+
result = this.getTempVariable(JvmLoadLocalResultVarTag())
2877+
}
28772878

28782879
final override Variable getStackElement(int i) {
28792880
i = 0 and
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
private import Instruction2
22
import semmle.code.binary.ast.ir.internal.Consistency
3-
import StagedConsistencyInput<Instruction2>
3+
import StagedConsistencyInput<Instruction2>

binary/ql/lib/semmle/code/binary/ast/ir/internal/Tags.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ newtype LocalVariableTag =
99
X86RegisterTag(X86Register r) or
1010
StlocVarTag(int index) { any(CilStoreLocal stloc).getLocalVariableIndex() = index } or
1111
CilParameterVarTag(int index) { any(CilParameter p).getIndex() = index } or
12-
JvmLocalVarTag(int index) { any(JvmLoadLocal load).getLocalVariableIndex() = index or any(JvmStoreLocal store).getLocalVariableIndex() = index } or
12+
JvmLocalVarTag(int index) {
13+
any(JvmLoadLocal load).getLocalVariableIndex() = index or
14+
any(JvmStoreLocal store).getLocalVariableIndex() = index
15+
} or
1316
JvmParameterVarTag(int index) { any(JvmParameter p).getSlotIndex() = index }
1417

1518
string stringOfLocalVariableTag(LocalVariableTag tag) {

binary/ql/lib/semmle/code/binary/dataflow/DataFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ module DataFlow {
4444
predicate localFlow(Node::Node source, Node::Node sink) { localFlowStep*(source, sink) }
4545

4646
import DataFlowMake<Location, DataFlowImpl::BinaryDataFlow>
47-
}
47+
}

binary/ql/src/VulnerableCalls/VulnerableCalls.qll

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ Function getADirectlyVulnerableMethod(string id) {
5151
/**
5252
* Holds if `stub` is an iterator/async stub method and `stateMachine` is its
5353
* corresponding state machine implementation (the MoveNext method).
54-
*
54+
*
5555
* Iterator/async methods in C# are compiled to:
5656
* 1. A stub method that creates a state machine object
5757
* 2. A nested class with a MoveNext method containing the actual implementation
58-
*
59-
* The pattern is: method `Foo` in class `Bar` creates `Bar.<Foo>d__N`
58+
*
59+
* The pattern is: method `Foo` in class `Bar` creates `Bar.<Foo>d__N`
6060
* and the impl is in `Bar.<Foo>d__N.MoveNext`
6161
*/
6262
private predicate isStateMachineImplementation(Function stub, Function stateMachine) {
@@ -67,7 +67,7 @@ private predicate isStateMachineImplementation(Function stub, Function stateMach
6767
// The state machine type is nested in the same type as the stub
6868
// and named <MethodName>d__N
6969
stateMachineTypeName = stateMachine.getDeclaringType().getName() and
70-
stateMachineTypeName.matches("<" + stubName + ">d__%" ) and
70+
stateMachineTypeName.matches("<" + stubName + ">d__%") and
7171
// The state machine's declaring type's namespace should be the stub's type full name
7272
stateMachine.getDeclaringType().getNamespace() = stubType.getFullName()
7373
)
@@ -76,14 +76,12 @@ private predicate isStateMachineImplementation(Function stub, Function stateMach
7676
/**
7777
* Gets the state machine implementation for an iterator/async stub method.
7878
*/
79-
Function getStateMachineImplementation(Function stub) {
80-
isStateMachineImplementation(stub, result)
81-
}
79+
Function getStateMachineImplementation(Function stub) { isStateMachineImplementation(stub, result) }
8280

8381
/**
8482
* Gets a method that transitively calls a vulnerable method.
8583
* This computes the transitive closure of the call graph.
86-
*
84+
*
8785
* Also handles iterator/async methods by linking stub methods to their
8886
* state machine implementations.
8987
*/
@@ -105,7 +103,7 @@ Function getAVulnerableMethod(string id) {
105103
call.getStaticTarget() = getAVulnerableMethod(id)
106104
)
107105
or
108-
// Iterator/async: if a state machine's MoveNext is vulnerable,
106+
// Iterator/async: if a state machine's MoveNext is vulnerable,
109107
// the stub method that creates it is also vulnerable
110108
exists(Function stateMachine |
111109
stateMachine = getAVulnerableMethod(id) and

binary/ql/src/VulnerableCalls/VulnerableCallsSummarize.ql

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import semmle.code.binary.ast.ir.IR
1313
* Exports all methods that can reach vulnerable calls.
1414
* Output format matches the vulnerableCallModel extensible predicate for iterative analysis.
1515
*/
16-
query predicate vulnerableCallModel(
17-
string namespace, string className, string methodName, string id
18-
) {
16+
query predicate vulnerableCallModel(string namespace, string className, string methodName, string id) {
1917
ExportedVulnerableCalls::pathToVulnerableMethod(namespace, className, methodName, id)
2018
}
2119

@@ -32,14 +30,11 @@ query predicate publicVulnerableCallModel(
3230
* Lists the direct vulnerable call sites with their enclosing method context.
3331
*/
3432
query predicate vulnerableCallLocations(
35-
VulnerableMethodCall call,
36-
string callerNamespace,
37-
string callerClassName,
38-
string callerMethodName,
39-
string targetFqn,
40-
string id
33+
VulnerableMethodCall call, string callerNamespace, string callerClassName,
34+
string callerMethodName, string targetFqn, string id
4135
) {
4236
call.getVulnerabilityId() = id and
43-
call.getEnclosingFunction().hasFullyQualifiedName(callerNamespace, callerClassName, callerMethodName) and
37+
call.getEnclosingFunction()
38+
.hasFullyQualifiedName(callerNamespace, callerClassName, callerMethodName) and
4439
targetFqn = call.getTargetOperand().getAnyDef().(ExternalRefInstruction).getFullyQualifiedName()
4540
}

binary/ql/src/test.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import semmle.code.binary.ast.ir.IR
22

33
from Instruction i
4-
select i
4+
select i

0 commit comments

Comments
 (0)