Skip to content

Commit adc3882

Browse files
committed
C#: Some minor extra fixes.
1 parent e6b62f1 commit adc3882

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

csharp/ql/campaigns/Solorigate/src/ModifiedFnvFunctionDetection.ql

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@ import experimental.code.csharp.Cryptography.NonCryptographicHashes
1616
from Variable v, Literal l, LoopStmt loop, Expr additional_xor
1717
where
1818
maybeUsedInFnvFunction(v, _, _, loop) and
19-
(
20-
exists(BitwiseXorExpr xor2 | xor2.getAnOperand() = l and additional_xor = xor2 |
21-
loop.getAControlFlowExitNode().getASuccessor*() = xor2.getAControlFlowNode() and
22-
xor2.getAnOperand() = v.getAnAccess()
23-
)
24-
or
25-
exists(AssignXorExpr xor2 | xor2.getAnOperand() = l and additional_xor = xor2 |
26-
loop.getAControlFlowExitNode().getASuccessor*() = xor2.getAControlFlowNode() and
27-
xor2.getAnOperand() = v.getAnAccess()
28-
)
19+
exists(BitwiseXorOperation xor2 | xor2.getAnOperand() = l and additional_xor = xor2 |
20+
loop.getAControlFlowExitNode().getASuccessor*() = xor2.getAControlFlowNode() and
21+
xor2.getAnOperand() = v.getAnAccess()
2922
)
3023
select l, "This literal is used in an $@ after an FNV-like hash calculation with variable $@.",
3124
additional_xor, "additional xor", v, v.toString()

csharp/ql/lib/semmle/code/csharp/commons/Strings.qll

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,9 @@ class ImplicitToStringExpr extends Expr {
4949
this = add.getOtherOperand(o).stripImplicit()
5050
)
5151
or
52-
// s1 += s2 for where the left hand side is a string, call an operator +(string, object)
53-
exists(AssignAddExpr add, Operator o, Parameter p0, Parameter p1 |
54-
o = add.getTarget() and
55-
o.getName() = "+" and
56-
p0 = o.getParameter(0) and
57-
p1 = o.getParameter(1) and
58-
p0.getType() instanceof StringType and
59-
this = getAnAssignedArgumentOrParam(p1).stripImplicit()
52+
exists(AssignAddExpr add, Expr o | o = add.getLeftOperand() |
53+
o.stripImplicit().getType() instanceof StringType and
54+
this = add.getRightOperand().stripImplicit()
6055
)
6156
or
6257
this = any(InterpolatedStringExpr ise).getAnInsert().stripImplicit()

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ private module GuardsInput implements
119119
class AndExpr extends BinExpr {
120120
AndExpr() {
121121
this instanceof LogicalAndExpr or
122-
this instanceof BitwiseAndExpr
122+
this instanceof BitwiseAndOperation
123123
}
124124
}
125125

126126
class OrExpr extends BinExpr {
127127
OrExpr() {
128128
this instanceof LogicalOrExpr or
129-
this instanceof BitwiseOrExpr
129+
this instanceof BitwiseOrOperation
130130
}
131131
}
132132

csharp/ql/lib/semmle/code/csharp/frameworks/system/Xml.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class SystemXmlSchemaXmlSchemaValidationFlags extends EnumConstant {
131131
}
132132
}
133133

134-
private Expr getBitwiseOrOperand(Expr e) { result = e.(BitwiseOrExpr).getAnOperand() }
134+
private Expr getBitwiseOrOperand(Expr e) { result = e.(BitwiseOrOperation).getAnOperand() }
135135

136136
/** A creation of an instance of `System.Xml.XmlReaderSettings`. */
137137
class XmlReaderSettingsCreation extends ObjectCreation {

csharp/ql/src/Likely Bugs/PossibleLossOfPrecision.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ predicate convertedToFloatOrDecimal(Expr e, Type t) {
2727
t instanceof DecimalType
2828
)
2929
or
30-
exists(BinaryArithmeticOperation op |
30+
exists(BinaryOperation op |
3131
op.getAnOperand() = e and
3232
convertedToFloatOrDecimal(op, t)
3333
|
34-
op instanceof AddExpr or
35-
op instanceof SubExpr or
36-
op instanceof MulExpr
34+
op instanceof AddOperation or
35+
op instanceof SubOperation or
36+
op instanceof MulOperation
3737
)
3838
}
3939

0 commit comments

Comments
 (0)