mirror of
https://github.com/github/codeql.git
synced 2026-04-12 02:24:00 +02:00
C#: Deprecate get[L|R]Value predicates.
This commit is contained in:
@@ -77,7 +77,7 @@ predicate missedAllOpportunity(ForeachStmtGenericEnumerable fes) {
|
||||
// The then case of the if assigns false to something and breaks out of the loop.
|
||||
exists(Assignment a, BoolLiteral bl |
|
||||
a = is.getThen().getAChild*() and
|
||||
bl = a.getRValue() and
|
||||
bl = a.getRightOperand() and
|
||||
bl.toString() = "false"
|
||||
) and
|
||||
is.getThen().getAChild*() instanceof BreakStmt
|
||||
|
||||
@@ -96,7 +96,7 @@ private class MethodUse extends Use, QualifiableExpr {
|
||||
private class AccessUse extends Access, Use {
|
||||
AccessUse() {
|
||||
not this.getTarget().(Parameter).getCallable() instanceof Accessor and
|
||||
not this = any(LocalVariableDeclAndInitExpr d).getLValue() and
|
||||
not this = any(LocalVariableDeclAndInitExpr d).getLeftOperand() and
|
||||
not this.isImplicit() and
|
||||
not this instanceof MethodAccess and // handled by `MethodUse`
|
||||
not this instanceof TypeAccess and // handled by `TypeMentionUse`
|
||||
|
||||
@@ -235,7 +235,7 @@ private class RefArg extends AssignableAccess {
|
||||
module AssignableInternal {
|
||||
private predicate tupleAssignmentDefinition(AssignExpr ae, Expr leaf) {
|
||||
exists(TupleExpr te |
|
||||
ae.getLValue() = te and
|
||||
ae.getLeftOperand() = te and
|
||||
te.getAnArgument+() = leaf and
|
||||
// `leaf` is either an assignable access or a local variable declaration
|
||||
not leaf instanceof TupleExpr
|
||||
@@ -249,8 +249,8 @@ module AssignableInternal {
|
||||
*/
|
||||
private predicate tupleAssignmentPair(AssignExpr ae, Expr left, Expr right) {
|
||||
tupleAssignmentDefinition(ae, _) and
|
||||
left = ae.getLValue() and
|
||||
right = ae.getRValue()
|
||||
left = ae.getLeftOperand() and
|
||||
right = ae.getRightOperand()
|
||||
or
|
||||
exists(TupleExpr l, TupleExpr r, int i | tupleAssignmentPair(ae, l, r) |
|
||||
left = l.getArgument(i) and
|
||||
@@ -291,7 +291,7 @@ module AssignableInternal {
|
||||
cached
|
||||
newtype TAssignableDefinition =
|
||||
TAssignmentDefinition(Assignment a) {
|
||||
not a.getLValue() instanceof TupleExpr and
|
||||
not a.getLeftOperand() instanceof TupleExpr and
|
||||
not a instanceof AssignCallOperation and
|
||||
not a instanceof AssignCoalesceExpr
|
||||
} or
|
||||
@@ -358,7 +358,7 @@ module AssignableInternal {
|
||||
// Not defined by dispatch in order to avoid too conservative negative recursion error
|
||||
cached
|
||||
AssignableAccess getTargetAccess(AssignableDefinition def) {
|
||||
def = TAssignmentDefinition(any(Assignment a | a.getLValue() = result))
|
||||
def = TAssignmentDefinition(any(Assignment a | a.getLeftOperand() = result))
|
||||
or
|
||||
def = TTupleAssignmentDefinition(_, result)
|
||||
or
|
||||
@@ -381,8 +381,8 @@ module AssignableInternal {
|
||||
tupleAssignmentPair(ae, ac, result)
|
||||
)
|
||||
or
|
||||
exists(Assignment ass | ac = ass.getLValue() |
|
||||
result = ass.getRValue() and
|
||||
exists(Assignment ass | ac = ass.getLeftOperand() |
|
||||
result = ass.getRightOperand() and
|
||||
not ass instanceof AssignOperation
|
||||
)
|
||||
or
|
||||
@@ -527,7 +527,7 @@ module AssignableDefinitions {
|
||||
Assignment getAssignment() { result = a }
|
||||
|
||||
override Expr getSource() {
|
||||
result = a.getRValue() and
|
||||
result = a.getRightOperand() and
|
||||
not a instanceof AddOrRemoveEventExpr
|
||||
}
|
||||
|
||||
|
||||
@@ -343,10 +343,10 @@ final class AssignmentNode extends ControlFlowElementNode {
|
||||
result.(TypeMentionNode).getTarget() = controlFlowElement
|
||||
or
|
||||
childIndex = 0 and
|
||||
result.(ElementNode).getElement() = assignment.getLValue()
|
||||
result.(ElementNode).getElement() = assignment.getLeftOperand()
|
||||
or
|
||||
childIndex = 1 and
|
||||
result.(ElementNode).getElement() = assignment.getRValue()
|
||||
result.(ElementNode).getElement() = assignment.getRightOperand()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -535,8 +535,8 @@ class Setter extends Accessor, @setter {
|
||||
exists(AssignExpr assign |
|
||||
this.getStatementBody().getNumberOfStmts() = 1 and
|
||||
assign.getParent() = this.getStatementBody().getAChild() and
|
||||
assign.getLValue() = result.getAnAccess() and
|
||||
assign.getRValue() = accessToValue()
|
||||
assign.getLeftOperand() = result.getAnAccess() and
|
||||
assign.getRightOperand() = accessToValue()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ private module GuardsInput implements
|
||||
IdExpr() { this instanceof AssignExpr or this instanceof CastExpr }
|
||||
|
||||
Expr getEqualChildExpr() {
|
||||
result = this.(AssignExpr).getRValue()
|
||||
result = this.(AssignExpr).getRightOperand()
|
||||
or
|
||||
result = this.(CastExpr).getExpr()
|
||||
}
|
||||
@@ -836,7 +836,7 @@ module Internal {
|
||||
|
||||
/** Holds if expression `e2` is a `null` value whenever `e1` is. */
|
||||
predicate nullValueImpliedUnary(Expr e1, Expr e2) {
|
||||
e1 = e2.(AssignExpr).getRValue()
|
||||
e1 = e2.(AssignExpr).getRightOperand()
|
||||
or
|
||||
e1 = e2.(Cast).getExpr()
|
||||
or
|
||||
@@ -923,7 +923,7 @@ module Internal {
|
||||
/** Holds if expression `e2` is a non-`null` value whenever `e1` is. */
|
||||
predicate nonNullValueImpliedUnary(Expr e1, Expr e2) {
|
||||
e1 = e2.(CastExpr).getExpr() or
|
||||
e1 = e2.(AssignExpr).getRValue() or
|
||||
e1 = e2.(AssignExpr).getRightOperand() or
|
||||
e1 = e2.(NullCoalescingOperation).getAnOperand()
|
||||
}
|
||||
|
||||
|
||||
@@ -521,7 +521,7 @@ module Expressions {
|
||||
// ```
|
||||
// need special treatment, because the accesses `[0]`, `[1]`, and `[2]`
|
||||
// have no qualifier.
|
||||
this = any(MemberInitializer mi).getLValue()
|
||||
this = any(MemberInitializer mi).getLeftOperand()
|
||||
) and
|
||||
not exists(AssignableDefinitions::OutRefDefinition def | def.getTargetAccess() = this)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ private Expr maybeNullExpr(Expr reason) {
|
||||
or
|
||||
result instanceof AsExpr and reason = result
|
||||
or
|
||||
result.(AssignExpr).getRValue() = maybeNullExpr(reason)
|
||||
result.(AssignExpr).getRightOperand() = maybeNullExpr(reason)
|
||||
or
|
||||
result.(CastExpr).getExpr() = maybeNullExpr(reason)
|
||||
or
|
||||
|
||||
@@ -528,7 +528,7 @@ module LocalFlow {
|
||||
e2 =
|
||||
any(AssignExpr ae |
|
||||
ae.getParent() = any(ControlFlowElement cfe | not cfe instanceof ExprStmt) and
|
||||
e1 = ae.getRValue()
|
||||
e1 = ae.getRightOperand()
|
||||
)
|
||||
or
|
||||
e1 = e2.(ObjectCreation).getInitializer()
|
||||
@@ -554,7 +554,7 @@ module LocalFlow {
|
||||
e2 = we
|
||||
)
|
||||
or
|
||||
exists(AssignExpr ae | ae.getLValue().(TupleExpr) = e2 and ae.getRValue() = e1)
|
||||
exists(AssignExpr ae | ae.getLeftOperand().(TupleExpr) = e2 and ae.getRightOperand() = e1)
|
||||
or
|
||||
exists(ControlFlowElement cfe | cfe = e2.(TupleExpr).(PatternExpr).getPatternMatch() |
|
||||
cfe.(IsExpr).getExpr() = e1
|
||||
@@ -795,7 +795,7 @@ private predicate fieldOrPropertyStore(ContentSet c, Expr src, Expr q, boolean p
|
||||
q = we and
|
||||
mi = we.getInitializer().getAMemberInitializer() and
|
||||
f = mi.getInitializedMember() and
|
||||
src = mi.getRValue() and
|
||||
src = mi.getRightOperand() and
|
||||
postUpdate = false
|
||||
)
|
||||
or
|
||||
@@ -804,7 +804,7 @@ private predicate fieldOrPropertyStore(ContentSet c, Expr src, Expr q, boolean p
|
||||
mi = q.(ObjectInitializer).getAMemberInitializer() and
|
||||
q.getParent() instanceof ObjectCreation and
|
||||
f = mi.getInitializedMember() and
|
||||
src = mi.getRValue() and
|
||||
src = mi.getRightOperand() and
|
||||
postUpdate = false
|
||||
)
|
||||
or
|
||||
@@ -879,8 +879,8 @@ private predicate arrayStore(Expr src, Expr a, boolean postUpdate) {
|
||||
// Member initializer, `new C { Array = { [i] = src } }`
|
||||
exists(MemberInitializer mi |
|
||||
mi = a.(ObjectInitializer).getAMemberInitializer() and
|
||||
mi.getLValue() instanceof ArrayAccess and
|
||||
mi.getRValue() = src and
|
||||
mi.getLeftOperand() instanceof ArrayAccess and
|
||||
mi.getRightOperand() = src and
|
||||
postUpdate = false
|
||||
)
|
||||
}
|
||||
@@ -2582,7 +2582,7 @@ module PostUpdateNodes {
|
||||
call.getExpr() = init.(CollectionInitializer).getAnElementInitializer()
|
||||
or
|
||||
// E.g. `new Dictionary<int, string>() { [0] = "a", [1] = "b" }`
|
||||
call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLValue()
|
||||
call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLeftOperand()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2795,7 +2795,7 @@ predicate additionalLambdaFlowStep(Node nodeFrom, Node nodeTo, boolean preserves
|
||||
preservesValue = true
|
||||
or
|
||||
exists(AddEventExpr aee |
|
||||
nodeFrom.asExpr() = aee.getRValue() and
|
||||
nodeFrom.asExpr() = aee.getRightOperand() and
|
||||
nodeTo.asExpr().(EventRead).getTarget() = aee.getTarget() and
|
||||
preservesValue = false
|
||||
)
|
||||
|
||||
@@ -337,7 +337,7 @@ private module CallGraph {
|
||||
pred = succ.(DelegateCreation).getArgument()
|
||||
or
|
||||
exists(AddEventExpr ae | succ.(EventAccess).getTarget() = ae.getTarget() |
|
||||
pred = ae.getRValue()
|
||||
pred = ae.getRightOperand()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ private module Impl {
|
||||
/** Holds if SSA definition `def` equals `e + delta`. */
|
||||
predicate ssaUpdateStep(ExplicitDefinition def, ExprNode e, int delta) {
|
||||
exists(ControlFlow::Node cfn | cfn = def.getControlFlowNode() |
|
||||
e = cfn.(ExprNode::Assignment).getRValue() and
|
||||
e = cfn.(ExprNode::Assignment).getRightOperand() and
|
||||
delta = 0 and
|
||||
not cfn instanceof ExprNode::AssignOperation
|
||||
or
|
||||
@@ -39,7 +39,7 @@ private module Impl {
|
||||
|
||||
/** Holds if `e1 + delta` equals `e2`. */
|
||||
predicate valueFlowStep(ExprNode e2, ExprNode e1, int delta) {
|
||||
e2.(ExprNode::AssignExpr).getRValue() = e1 and delta = 0
|
||||
e2.(ExprNode::AssignExpr).getRightOperand() = e1 and delta = 0
|
||||
or
|
||||
e2.(ExprNode::UnaryPlusExpr).getOperand() = e1 and delta = 0
|
||||
or
|
||||
@@ -207,13 +207,13 @@ module ExprNode {
|
||||
override CS::Assignment e;
|
||||
|
||||
/** Gets the left operand of this assignment. */
|
||||
ExprNode getLValue() {
|
||||
result = unique(ExprNode res | hasChild(e, e.getLValue(), this, res) | res)
|
||||
ExprNode getLeftOperand() {
|
||||
result = unique(ExprNode res | hasChild(e, e.getLeftOperand(), this, res) | res)
|
||||
}
|
||||
|
||||
/** Gets the right operand of this assignment. */
|
||||
ExprNode getRValue() {
|
||||
result = unique(ExprNode res | hasChild(e, e.getRValue(), this, res) | res)
|
||||
ExprNode getRightOperand() {
|
||||
result = unique(ExprNode res | hasChild(e, e.getRightOperand(), this, res) | res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +225,10 @@ module ExprNode {
|
||||
/** A compound assignment operation. */
|
||||
class AssignOperation extends Assignment, BinaryOperation {
|
||||
override CS::AssignOperation e;
|
||||
|
||||
override ExprNode getLeftOperand() { result = Assignment.super.getLeftOperand() }
|
||||
|
||||
override ExprNode getRightOperand() { result = Assignment.super.getRightOperand() }
|
||||
}
|
||||
|
||||
/** A unary operation. */
|
||||
|
||||
@@ -168,7 +168,7 @@ private module Impl {
|
||||
/** Returned an expression that is assigned to `f`. */
|
||||
ExprNode getAssignedValueToField(Field f) {
|
||||
result.getExpr() in [
|
||||
f.getAnAssignedValue(), any(AssignOperation a | a.getLValue() = f.getAnAccess())
|
||||
f.getAnAssignedValue(), any(AssignOperation a | a.getLeftOperand() = f.getAnAccess())
|
||||
]
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ private module Impl {
|
||||
/** Returns a sub expression of `e` for expression types where the sign depends on the child. */
|
||||
ExprNode getASubExprWithSameSign(ExprNode e) {
|
||||
exists(Expr e_, Expr child | hasChild(e_, child, e, result) |
|
||||
child = e_.(AssignExpr).getRValue() or
|
||||
child = e_.(AssignExpr).getRightOperand() or
|
||||
child = e_.(UnaryPlusExpr).getOperand() or
|
||||
child = e_.(PostIncrExpr).getOperand() or
|
||||
child = e_.(PostDecrExpr).getOperand() or
|
||||
|
||||
@@ -55,5 +55,5 @@ ExprNode ssaRead(Definition v, int delta) {
|
||||
or
|
||||
v.(ExplicitDefinition).getControlFlowNode().(ExprNode::Assignment) = result and delta = 0
|
||||
or
|
||||
result.(ExprNode::AssignExpr).getRValue() = ssaRead(v, delta)
|
||||
result.(ExprNode::AssignExpr).getRightOperand() = ssaRead(v, delta)
|
||||
}
|
||||
|
||||
@@ -1348,7 +1348,7 @@ private module Internal {
|
||||
any(DynamicMemberAccess dma | this = TDispatchDynamicEventAccess(_, dma, _)).getQualifier()
|
||||
}
|
||||
|
||||
override Expr getArgument(int i) { i = 0 and result = this.getCall().getRValue() }
|
||||
override Expr getArgument(int i) { i = 0 and result = this.getCall().getRightOperand() }
|
||||
}
|
||||
|
||||
/** A call to a constructor using dynamic types. */
|
||||
|
||||
@@ -112,7 +112,7 @@ class BaseAccess extends Access, @base_access_expr {
|
||||
class MemberAccess extends Access, QualifiableExpr, @member_access_expr {
|
||||
override predicate hasImplicitThisQualifier() {
|
||||
QualifiableExpr.super.hasImplicitThisQualifier() and
|
||||
not exists(MemberInitializer mi | mi.getLValue() = this)
|
||||
not exists(MemberInitializer mi | mi.getLeftOperand() = this)
|
||||
}
|
||||
|
||||
override Member getQualifiedDeclaration() { result = this.getTarget() }
|
||||
|
||||
@@ -20,14 +20,22 @@ class Assignment extends BinaryOperation, @assign_expr {
|
||||
expr_parent(_, 1, this)
|
||||
}
|
||||
|
||||
/** Gets the left operand of this assignment. */
|
||||
Expr getLValue() { result = this.getLeftOperand() }
|
||||
/**
|
||||
* DEPRECATED: Use `getLeftOperand` instead.
|
||||
*
|
||||
* Gets the left operand of this assignment.
|
||||
*/
|
||||
deprecated Expr getLValue() { result = this.getLeftOperand() }
|
||||
|
||||
/** Gets the right operand of this assignment. */
|
||||
Expr getRValue() { result = this.getRightOperand() }
|
||||
/**
|
||||
* DEPRECATED: Use `getRightOperand` instead.
|
||||
*
|
||||
* Gets the right operand of this assignment.
|
||||
*/
|
||||
deprecated Expr getRValue() { result = this.getRightOperand() }
|
||||
|
||||
/** Gets the variable being assigned to, if any. */
|
||||
Variable getTargetVariable() { result.getAnAccess() = this.getLValue() }
|
||||
Variable getTargetVariable() { result.getAnAccess() = this.getLeftOperand() }
|
||||
|
||||
override string getOperator() { none() }
|
||||
}
|
||||
@@ -40,7 +48,12 @@ class LocalVariableDeclAndInitExpr extends LocalVariableDeclExpr, Assignment {
|
||||
|
||||
override LocalVariable getTargetVariable() { result = this.getVariable() }
|
||||
|
||||
override LocalVariableAccess getLValue() { result = Assignment.super.getLValue() }
|
||||
/**
|
||||
* DEPRECATED: Use `getLeftOperand` instead.
|
||||
*/
|
||||
deprecated override LocalVariableAccess getLValue() { result = this.getLeftOperand() }
|
||||
|
||||
override LocalVariableAccess getLeftOperand() { result = Assignment.super.getLeftOperand() }
|
||||
|
||||
override string toString() { result = LocalVariableDeclExpr.super.toString() + " = ..." }
|
||||
|
||||
@@ -223,9 +236,12 @@ deprecated class AssignUnsighedRightShiftExpr = AssignUnsignedRightShiftExpr;
|
||||
*/
|
||||
class AddOrRemoveEventExpr extends AssignOperation, @assign_event_expr {
|
||||
/** Gets the event targeted by this event assignment. */
|
||||
Event getTarget() { result = this.getLValue().getTarget() }
|
||||
Event getTarget() { result = this.getLeftOperand().getTarget() }
|
||||
|
||||
override EventAccess getLValue() { result = this.getChild(0) }
|
||||
/**
|
||||
* DEPRECATED: Use `getLeftOperand` instead.
|
||||
*/
|
||||
deprecated override EventAccess getLValue() { result = this.getLeftOperand() }
|
||||
|
||||
override EventAccess getLeftOperand() { result = this.getChild(0) }
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ class EventCall extends AccessorCall, EventAccessExpr {
|
||||
override EventAccessor getTarget() {
|
||||
exists(Event e, AddOrRemoveEventExpr aoree |
|
||||
e = this.getEvent() and
|
||||
aoree.getLValue() = this
|
||||
aoree.getLeftOperand() = this
|
||||
|
|
||||
aoree instanceof AddEventExpr and result = e.getAddEventAccessor()
|
||||
or
|
||||
@@ -784,8 +784,8 @@ class EventCall extends AccessorCall, EventAccessExpr {
|
||||
override Expr getArgument(int i) {
|
||||
i = 0 and
|
||||
exists(AddOrRemoveEventExpr aoree |
|
||||
aoree.getLValue() = this and
|
||||
result = aoree.getRValue()
|
||||
aoree.getLeftOperand() = this and
|
||||
result = aoree.getRightOperand()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class MemberInitializer extends AssignExpr {
|
||||
MemberInitializer() { this.getParent() instanceof ObjectInitializer }
|
||||
|
||||
/** Gets the initialized member. */
|
||||
Member getInitializedMember() { result.getAnAccess() = this.getLValue() }
|
||||
Member getInitializedMember() { result.getAnAccess() = this.getLeftOperand() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "MemberInitializer" }
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ class QualifiableExpr extends Expr, @qualifiable_expr {
|
||||
}
|
||||
|
||||
private Expr getAnAssignOrForeachChild() {
|
||||
result = any(AssignExpr e).getLValue()
|
||||
result = any(AssignExpr e).getLeftOperand()
|
||||
or
|
||||
result = any(ForeachStmt fs).getVariableDeclTuple()
|
||||
or
|
||||
|
||||
@@ -41,6 +41,6 @@ class ReturnedByMockObject extends ObjectCreation {
|
||||
* Gets a value used to initialize a member of this object creation.
|
||||
*/
|
||||
Expr getAMemberInitializationValue() {
|
||||
result = this.getInitializer().(ObjectInitializer).getAMemberInitializer().getRValue()
|
||||
result = this.getInitializer().(ObjectInitializer).getAMemberInitializer().getRightOperand()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ abstract class SqlExpr extends Expr {
|
||||
class CommandTextAssignmentSqlExpr extends SqlExpr, AssignExpr {
|
||||
CommandTextAssignmentSqlExpr() {
|
||||
exists(Property p, SystemDataIDbCommandInterface i, Property text |
|
||||
p = this.getLValue().(PropertyAccess).getTarget() and
|
||||
p = this.getLeftOperand().(PropertyAccess).getTarget() and
|
||||
text = i.getCommandTextProperty()
|
||||
|
|
||||
p.overridesOrImplementsOrEquals(text)
|
||||
)
|
||||
}
|
||||
|
||||
override Expr getSql() { result = this.getRValue() }
|
||||
override Expr getSql() { result = this.getRightOperand() }
|
||||
}
|
||||
|
||||
/** A construction of an unknown `IDbCommand` object. */
|
||||
|
||||
@@ -100,20 +100,20 @@ Expr getAValueForCookiePolicyProp(string prop) {
|
||||
Expr getAValueForProp(ObjectCreation create, Assignment a, string prop) {
|
||||
// values set in object init
|
||||
exists(MemberInitializer init, Expr src, PropertyAccess pa |
|
||||
a.getLValue() = pa and
|
||||
a.getLeftOperand() = pa and
|
||||
pa.getTarget().hasName(prop) and
|
||||
init = create.getInitializer().(ObjectInitializer).getAMemberInitializer() and
|
||||
init.getLValue() = pa and
|
||||
DataFlow::localExprFlow(src, init.getRValue()) and
|
||||
init.getLeftOperand() = pa and
|
||||
DataFlow::localExprFlow(src, init.getRightOperand()) and
|
||||
result = src
|
||||
)
|
||||
or
|
||||
// values set on var that create is assigned to
|
||||
exists(Expr src, PropertyAccess pa |
|
||||
a.getLValue() = pa and
|
||||
a.getLeftOperand() = pa and
|
||||
pa.getTarget().hasName(prop) and
|
||||
DataFlow::localExprFlow(create, pa.getQualifier()) and
|
||||
DataFlow::localExprFlow(src, a.getRValue()) and
|
||||
DataFlow::localExprFlow(src, a.getRightOperand()) and
|
||||
result = src
|
||||
)
|
||||
}
|
||||
@@ -138,15 +138,15 @@ private module OnAppendCookieTrackingConfig<propertyName/0 getPropertyName> impl
|
||||
exists(PropertyWrite pw, Assignment delegateAssign, Callable c |
|
||||
pw.getProperty().getName() = "OnAppendCookie" and
|
||||
pw.getProperty().getDeclaringType() instanceof MicrosoftAspNetCoreBuilderCookiePolicyOptions and
|
||||
delegateAssign.getLValue() = pw and
|
||||
delegateAssign.getLeftOperand() = pw and
|
||||
(
|
||||
exists(LambdaExpr lambda |
|
||||
delegateAssign.getRValue() = lambda and
|
||||
delegateAssign.getRightOperand() = lambda and
|
||||
lambda = c
|
||||
)
|
||||
or
|
||||
exists(DelegateCreation delegate |
|
||||
delegateAssign.getRValue() = delegate and
|
||||
delegateAssign.getRightOperand() = delegate and
|
||||
delegate.getArgument().(CallableAccess).getTarget() = c
|
||||
)
|
||||
) and
|
||||
@@ -159,9 +159,9 @@ private module OnAppendCookieTrackingConfig<propertyName/0 getPropertyName> impl
|
||||
exists(PropertyWrite pw, Assignment a |
|
||||
pw.getProperty().getDeclaringType() instanceof MicrosoftAspNetCoreHttpCookieOptions and
|
||||
pw.getProperty().getName() = getPropertyName() and
|
||||
a.getLValue() = pw and
|
||||
a.getLeftOperand() = pw and
|
||||
exists(Expr val |
|
||||
DataFlow::localExprFlow(val, a.getRValue()) and
|
||||
DataFlow::localExprFlow(val, a.getRightOperand()) and
|
||||
val.getValue() = "true"
|
||||
) and
|
||||
sink.asExpr() = pw.getQualifier()
|
||||
|
||||
@@ -126,16 +126,16 @@ private module TypeNameTrackingConfig implements DataFlow::ConfigSig {
|
||||
or
|
||||
node1.getType() instanceof TypeNameHandlingEnum and
|
||||
exists(PropertyWrite pw, Property p, Assignment a |
|
||||
a.getLValue() = pw and
|
||||
a.getLeftOperand() = pw and
|
||||
pw.getProperty() = p and
|
||||
p.getDeclaringType() instanceof JsonSerializerSettingsClass and
|
||||
p.hasName("TypeNameHandling") and
|
||||
(
|
||||
node1.asExpr() = a.getRValue() and
|
||||
node1.asExpr() = a.getRightOperand() and
|
||||
node2.asExpr() = pw.getQualifier()
|
||||
or
|
||||
exists(ObjectInitializer oi |
|
||||
node1.asExpr() = oi.getAMemberInitializer().getRValue() and
|
||||
node1.asExpr() = oi.getAMemberInitializer().getRightOperand() and
|
||||
node2.asExpr() = oi
|
||||
)
|
||||
)
|
||||
|
||||
@@ -84,15 +84,15 @@ private Expr getAValueForProp(ObjectCreation create, string prop) {
|
||||
// values set in object init
|
||||
exists(MemberInitializer init |
|
||||
init = create.getInitializer().(ObjectInitializer).getAMemberInitializer() and
|
||||
init.getLValue().(PropertyAccess).getTarget().hasName(prop) and
|
||||
result = init.getRValue()
|
||||
init.getLeftOperand().(PropertyAccess).getTarget().hasName(prop) and
|
||||
result = init.getRightOperand()
|
||||
)
|
||||
or
|
||||
// values set on var that create is assigned to
|
||||
exists(Assignment propAssign |
|
||||
DataFlow::localExprFlow(create, propAssign.getLValue().(PropertyAccess).getQualifier()) and
|
||||
propAssign.getLValue().(PropertyAccess).getTarget().hasName(prop) and
|
||||
result = propAssign.getRValue()
|
||||
DataFlow::localExprFlow(create, propAssign.getLeftOperand().(PropertyAccess).getQualifier()) and
|
||||
propAssign.getLeftOperand().(PropertyAccess).getTarget().hasName(prop) and
|
||||
result = propAssign.getRightOperand()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +84,9 @@ where
|
||||
not f.getDeclaringType() instanceof Enum and
|
||||
not f.getType() instanceof Struct and
|
||||
not exists(Assignment ae, Field g |
|
||||
ae.getLValue().(FieldAccess).getTarget() = g and
|
||||
ae.getLeftOperand().(FieldAccess).getTarget() = g and
|
||||
g.getUnboundDeclaration() = f and
|
||||
not ae.getRValue() instanceof NullLiteral
|
||||
not ae.getRightOperand() instanceof NullLiteral
|
||||
) and
|
||||
not exists(MethodCall mc, int i, Field g |
|
||||
exists(Parameter p | mc.getTarget().getParameter(i) = p | p.isOut() or p.isRef()) and
|
||||
@@ -101,7 +101,7 @@ where
|
||||
not init instanceof NullLiteral
|
||||
) and
|
||||
not exists(AssignOperation ua, Field g |
|
||||
ua.getLValue().(FieldAccess).getTarget() = g and
|
||||
ua.getLeftOperand().(FieldAccess).getTarget() = g and
|
||||
g.getUnboundDeclaration() = f
|
||||
) and
|
||||
not exists(MutatorOperation op |
|
||||
|
||||
@@ -60,16 +60,16 @@ module LambdaDataFlow {
|
||||
}
|
||||
|
||||
Element getAssignmentTarget(Expr e) {
|
||||
exists(Assignment a | a.getRValue() = e |
|
||||
result = a.getLValue().(PropertyAccess).getTarget() or
|
||||
result = a.getLValue().(FieldAccess).getTarget() or
|
||||
result = a.getLValue().(LocalVariableAccess).getTarget() or
|
||||
result = a.getLValue().(EventAccess).getTarget()
|
||||
exists(Assignment a | a.getRightOperand() = e |
|
||||
result = a.getLeftOperand().(PropertyAccess).getTarget() or
|
||||
result = a.getLeftOperand().(FieldAccess).getTarget() or
|
||||
result = a.getLeftOperand().(LocalVariableAccess).getTarget() or
|
||||
result = a.getLeftOperand().(EventAccess).getTarget()
|
||||
)
|
||||
or
|
||||
exists(AddEventExpr aee |
|
||||
e = aee.getRValue() and
|
||||
result = aee.getLValue().getTarget()
|
||||
e = aee.getRightOperand() and
|
||||
result = aee.getLeftOperand().getTarget()
|
||||
)
|
||||
or
|
||||
result = getCollectionAssignmentTarget(e)
|
||||
@@ -97,8 +97,8 @@ Element getCollectionAssignmentTarget(Expr e) {
|
||||
// Store values using indexer
|
||||
exists(IndexerAccess ia, AssignExpr ae |
|
||||
ia.getQualifier() = result.(Variable).getAnAccess() and
|
||||
ia = ae.getLValue() and
|
||||
e = ae.getRValue()
|
||||
ia = ae.getLeftOperand() and
|
||||
e = ae.getRightOperand()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import csharp
|
||||
import semmle.code.csharp.commons.StructuralComparison
|
||||
|
||||
private Expr getAssignedExpr(Stmt stmt) {
|
||||
result = stmt.stripSingletonBlocks().(ExprStmt).getExpr().(AssignExpr).getLValue()
|
||||
result = stmt.stripSingletonBlocks().(ExprStmt).getExpr().(AssignExpr).getLeftOperand()
|
||||
}
|
||||
|
||||
from IfStmt is, string what
|
||||
|
||||
@@ -23,9 +23,10 @@ where
|
||||
) and
|
||||
forex(Access a | a = v.getAnAccess() |
|
||||
a = any(ModifierMethodCall m).getQualifier() or
|
||||
a = any(AssignExpr ass | ass.getRValue() instanceof ObjectCreation).getLValue() or
|
||||
a = any(AssignExpr ass | ass.getRightOperand() instanceof ObjectCreation).getLeftOperand() or
|
||||
a =
|
||||
any(LocalVariableDeclAndInitExpr ass | ass.getRValue() instanceof ObjectCreation).getLValue()
|
||||
any(LocalVariableDeclAndInitExpr ass | ass.getRightOperand() instanceof ObjectCreation)
|
||||
.getLeftOperand()
|
||||
) and
|
||||
not v = any(ForeachStmt fs).getVariable() and
|
||||
not v = any(BindingPatternExpr vpe).getVariableDeclExpr().getVariable() and
|
||||
|
||||
@@ -19,7 +19,7 @@ private predicate candidate(AssignExpr ae) {
|
||||
not ae instanceof MemberInitializer and
|
||||
// Enum field initializers are never self assignments. `enum E { A = 42 }`
|
||||
not ae.getParent().(Field).getDeclaringType() instanceof Enum and
|
||||
forall(Expr e | e = ae.getLValue().getAChildExpr*() |
|
||||
forall(Expr e | e = ae.getLeftOperand().getAChildExpr*() |
|
||||
// Non-trivial property accesses may have side-effects,
|
||||
// so these are not considered
|
||||
e instanceof PropertyAccess implies e instanceof TrivialPropertyAccess
|
||||
@@ -28,7 +28,7 @@ private predicate candidate(AssignExpr ae) {
|
||||
|
||||
private predicate selfAssignExpr(AssignExpr ae) {
|
||||
candidate(ae) and
|
||||
sameGvn(ae.getLValue(), ae.getRValue())
|
||||
sameGvn(ae.getLeftOperand(), ae.getRightOperand())
|
||||
}
|
||||
|
||||
private Declaration getDeclaration(Expr e) {
|
||||
@@ -40,5 +40,5 @@ private Declaration getDeclaration(Expr e) {
|
||||
}
|
||||
|
||||
from AssignExpr ae, Declaration target
|
||||
where selfAssignExpr(ae) and target = getDeclaration(ae.getLValue())
|
||||
where selfAssignExpr(ae) and target = getDeclaration(ae.getLeftOperand())
|
||||
select ae, "This assignment assigns $@ to itself.", target, target.getName()
|
||||
|
||||
@@ -50,7 +50,7 @@ predicate potentiallyConsumingAccess(VariableAccess va) {
|
||||
Expr sequenceSource(IEnumerableSequence seq) {
|
||||
result = seq.getInitializer()
|
||||
or
|
||||
exists(Assignment a | a.getLValue() = seq.getAnAccess() and result = a.getRValue())
|
||||
exists(Assignment a | a.getLeftOperand() = seq.getAnAccess() and result = a.getRightOperand())
|
||||
}
|
||||
|
||||
from IEnumerableSequence seq, VariableAccess va
|
||||
|
||||
@@ -24,7 +24,7 @@ class StringCat extends AddExpr {
|
||||
*/
|
||||
predicate isSelfConcatAssignExpr(AssignExpr e, Variable v) {
|
||||
exists(VariableAccess use |
|
||||
stringCatContains(e.getRValue(), use) and
|
||||
stringCatContains(e.getRightOperand(), use) and
|
||||
use.getTarget() = e.getTargetVariable() and
|
||||
v = use.getTarget()
|
||||
)
|
||||
@@ -41,7 +41,7 @@ predicate stringCatContains(StringCat expr, Expr child) {
|
||||
* where `v` is a simple variable (and not, for example, a property).
|
||||
*/
|
||||
predicate isConcatExpr(AssignAddExpr e, Variable v) {
|
||||
e.getLValue().getType() instanceof StringType and
|
||||
e.getLeftOperand().getType() instanceof StringType and
|
||||
v = e.getTargetVariable()
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ predicate cookieAppendHttpOnlyByDefault() {
|
||||
|
||||
predicate httpOnlyFalse(ObjectCreation oc) {
|
||||
exists(Assignment a |
|
||||
getAValueForProp(oc, a, "HttpOnly") = a.getRValue() and
|
||||
a.getRValue().getValue() = "false"
|
||||
getAValueForProp(oc, a, "HttpOnly") = a.getRightOperand() and
|
||||
a.getRightOperand().getValue() = "false"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ predicate nonHttpOnlyCookieBuilderAssignment(Assignment a, Expr val) {
|
||||
MicrosoftAspNetCoreAuthenticationCookiesCookieAuthenticationOptions
|
||||
) and
|
||||
pw.getProperty().getName() = "HttpOnly" and
|
||||
a.getLValue() = pw and
|
||||
DataFlow::localExprFlow(val, a.getRValue())
|
||||
a.getLeftOperand() = pw and
|
||||
DataFlow::localExprFlow(val, a.getRightOperand())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ where
|
||||
nonHttpOnlyCookieCall(httpOnlySink)
|
||||
or
|
||||
exists(Assignment a |
|
||||
httpOnlySink = a.getRValue() and
|
||||
httpOnlySink = a.getRightOperand() and
|
||||
nonHttpOnlyCookieBuilderAssignment(a, _)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -35,8 +35,8 @@ module InsecureSqlConnectionConfig implements DataFlow::ConfigSig {
|
||||
) and
|
||||
not exists(MemberInitializer mi |
|
||||
mi = oc.getInitializer().(ObjectInitializer).getAMemberInitializer() and
|
||||
mi.getLValue().(PropertyAccess).getTarget().getName() = "Encrypt" and
|
||||
mi.getRValue().(BoolLiteral).getValue() = "true"
|
||||
mi.getLeftOperand().(PropertyAccess).getTarget().getName() = "Encrypt" and
|
||||
mi.getRightOperand().(BoolLiteral).getValue() = "true"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ predicate cookieAppendSecureByDefault() {
|
||||
|
||||
predicate secureFalse(ObjectCreation oc) {
|
||||
exists(Assignment a |
|
||||
getAValueForProp(oc, a, "Secure") = a.getRValue() and
|
||||
a.getRValue().getValue() = "false"
|
||||
getAValueForProp(oc, a, "Secure") = a.getRightOperand() and
|
||||
a.getRightOperand().getValue() = "false"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ predicate insecureSecurePolicyAssignment(Assignment a, Expr val) {
|
||||
MicrosoftAspNetCoreAuthenticationCookiesCookieAuthenticationOptions
|
||||
) and
|
||||
pw.getProperty().getName() = "SecurePolicy" and
|
||||
a.getLValue() = pw and
|
||||
DataFlow::localExprFlow(val, a.getRValue()) and
|
||||
a.getLeftOperand() = pw and
|
||||
DataFlow::localExprFlow(val, a.getRightOperand()) and
|
||||
val.getValue() = "2" // None
|
||||
)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ where
|
||||
insecureCookieCall(secureSink)
|
||||
or
|
||||
exists(Assignment a |
|
||||
secureSink = a.getRValue() and
|
||||
secureSink = a.getRightOperand() and
|
||||
insecureSecurePolicyAssignment(a, _)
|
||||
)
|
||||
select secureSink, "Cookie attribute 'Secure' is not set to true."
|
||||
|
||||
@@ -14,11 +14,11 @@ import csharp
|
||||
|
||||
from Assignment a, PropertyAccess pa
|
||||
where
|
||||
a.getLValue() = pa and
|
||||
a.getLeftOperand() = pa and
|
||||
pa.getTarget().hasName("Domain") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
(
|
||||
a.getRValue().getValue().regexpReplaceAll("[^.]", "").length() < 2 or
|
||||
a.getRValue().getValue().matches(".%")
|
||||
a.getRightOperand().getValue().regexpReplaceAll("[^.]", "").length() < 2 or
|
||||
a.getRightOperand().getValue().matches(".%")
|
||||
)
|
||||
select a, "Overly broad domain for cookie."
|
||||
|
||||
@@ -14,8 +14,8 @@ import csharp
|
||||
|
||||
from Assignment a, PropertyAccess pa
|
||||
where
|
||||
a.getLValue() = pa and
|
||||
a.getLeftOperand() = pa and
|
||||
pa.getTarget().hasName("Path") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
a.getRValue().getValue() = "/"
|
||||
a.getRightOperand().getValue() = "/"
|
||||
select a, "Overly broad path for cookie."
|
||||
|
||||
@@ -17,12 +17,12 @@ from Element l
|
||||
where
|
||||
// header checking is disabled programmatically in the code
|
||||
exists(Assignment a, PropertyAccess pa |
|
||||
a.getLValue() = pa and
|
||||
a.getLeftOperand() = pa and
|
||||
pa.getTarget().hasName("EnableHeaderChecking") and
|
||||
pa.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasFullyQualifiedName("System.Web.Configuration", "HttpRuntimeSection") and
|
||||
a.getRValue().getValue() = "false" and
|
||||
a.getRightOperand().getValue() = "false" and
|
||||
a = l
|
||||
)
|
||||
or
|
||||
|
||||
@@ -89,10 +89,10 @@ module Random {
|
||||
e = any(SensitiveLibraryParameter v).getAnAssignedArgument()
|
||||
or
|
||||
// Assignment operation, e.g. += or similar
|
||||
exists(AssignOperation ao | ao.getRValue() = e |
|
||||
ao.getLValue() = any(SensitiveVariable v).getAnAccess() or
|
||||
ao.getLValue() = any(SensitiveProperty v).getAnAccess() or
|
||||
ao.getLValue() = any(SensitiveLibraryParameter v).getAnAccess()
|
||||
exists(AssignOperation ao | ao.getRightOperand() = e |
|
||||
ao.getLeftOperand() = any(SensitiveVariable v).getAnAccess() or
|
||||
ao.getLeftOperand() = any(SensitiveProperty v).getAnAccess() or
|
||||
ao.getLeftOperand() = any(SensitiveLibraryParameter v).getAnAccess()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ predicate incorrectUseOfRC2(Assignment e, string msg) {
|
||||
.getDeclaringType()
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "RC2CryptoServiceProvider")
|
||||
) and
|
||||
e.getRValue().getValue().toInt() < 128 and
|
||||
e.getRightOperand().getValue().toInt() < 128 and
|
||||
msg = "Key size should be at least 128 bits for RC2 encryption."
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ class FutureDateExpr extends MethodCall {
|
||||
|
||||
from Assignment a, PropertyAccess pa, FutureDateExpr fde
|
||||
where
|
||||
a.getLValue() = pa and
|
||||
a.getRValue() = fde and
|
||||
a.getLeftOperand() = pa and
|
||||
a.getRightOperand() = fde and
|
||||
pa.getTarget().hasName("Expires") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
(fde.timeIsNotClear() or fde.getTimeInSecond() > 300) // 5 minutes max
|
||||
|
||||
@@ -27,7 +27,7 @@ module CallTargetStats implements StatsSig {
|
||||
p = c.getProperty() and
|
||||
not p.getAnAccessor() instanceof Setter and
|
||||
assign = c.getParent() and
|
||||
assign.getLValue() = c and
|
||||
assign.getLeftOperand() = c and
|
||||
assign.getParent() instanceof Property
|
||||
)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ module CallTargetStats implements StatsSig {
|
||||
exists(Property p, AssignExpr assign |
|
||||
p = c.getProperty() and
|
||||
assign = c.getParent() and
|
||||
assign.getLValue() = c and
|
||||
assign.getLeftOperand() = c and
|
||||
assign.getParent() instanceof ObjectInitializer and
|
||||
assign.getParent().getParent() instanceof AnonymousObjectCreation
|
||||
)
|
||||
@@ -46,8 +46,8 @@ module CallTargetStats implements StatsSig {
|
||||
exists(Property p, AssignExpr assign |
|
||||
p = c.getProperty() and
|
||||
assign = c.getParent() and
|
||||
assign.getLValue() = c and
|
||||
assign.getRValue() instanceof ObjectOrCollectionInitializer
|
||||
assign.getLeftOperand() = c and
|
||||
assign.getRightOperand() instanceof ObjectOrCollectionInitializer
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -187,10 +187,10 @@ module HashWithoutSaltConfig implements DataFlow::ConfigSig {
|
||||
or
|
||||
// a salt or key is included in subclasses of `KeyedHashAlgorithm`
|
||||
exists(MethodCall mc, Assignment a, ObjectCreation oc |
|
||||
a.getRValue() = oc and
|
||||
a.getRightOperand() = oc and
|
||||
oc.getObjectType().getABaseType+() instanceof KeyedHashAlgorithm and
|
||||
mc.getTarget() instanceof HashMethod and
|
||||
a.getLValue() = mc.getQualifier().(VariableAccess).getTarget().getAnAccess() and
|
||||
a.getLeftOperand() = mc.getQualifier().(VariableAccess).getTarget().getAnAccess() and
|
||||
mc.getArgument(0) = node.asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import csharp
|
||||
|
||||
from AssignOperation ao
|
||||
select ao, ao.getLValue(), ao.getRValue()
|
||||
select ao, ao.getLeftOperand(), ao.getRightOperand()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import csharp
|
||||
|
||||
from Assignment a
|
||||
select a.getLocation(), a.getLValue().getType().toString(), a.getRValue().getType().toString(),
|
||||
a.getRValue().toString()
|
||||
select a.getLocation(), a.getLeftOperand().getType().toString(),
|
||||
a.getRightOperand().getType().toString(), a.getRightOperand().toString()
|
||||
|
||||
@@ -3,7 +3,7 @@ import csharp
|
||||
private predicate getLambda(
|
||||
LocalVariableDeclAndInitExpr e, string type, LocalVariable v, LambdaExpr lexp
|
||||
) {
|
||||
lexp = e.getRValue() and
|
||||
lexp = e.getRightOperand() and
|
||||
v = e.getTargetVariable() and
|
||||
type = e.getType().toStringWithTypes()
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ query predicate assignbitwise(
|
||||
AssignBitwiseOperation op, Expr left, Expr right, string name, string qlclass
|
||||
) {
|
||||
op.getFile().getStem() = "Operators" and
|
||||
left = op.getLValue() and
|
||||
right = op.getRValue() and
|
||||
left = op.getLeftOperand() and
|
||||
right = op.getRightOperand() and
|
||||
name = op.getOperator() and
|
||||
qlclass = op.getAPrimaryQlClass()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ query predicate indexerCalls(IndexerCall indexer, int arg, Expr value) {
|
||||
query predicate elementAssignments(
|
||||
ElementWrite write, Assignment assignment, int index, Expr indexer
|
||||
) {
|
||||
write = assignment.getLValue() and indexer = write.getIndex(index)
|
||||
write = assignment.getLeftOperand() and indexer = write.getIndex(index)
|
||||
}
|
||||
|
||||
query predicate arrayQualifiers(ElementAccess access, Expr qualifier) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Expr e
|
||||
where
|
||||
exists(Assignment a | a.getRValue() = e |
|
||||
exists(Assignment a | a.getRightOperand() = e |
|
||||
a.getParent().(Field).getDeclaringType() instanceof Enum
|
||||
)
|
||||
select e, e.getValue()
|
||||
|
||||
@@ -9,5 +9,5 @@ where
|
||||
c.hasName("LoginDialog") and
|
||||
e.getEnclosingCallable() = c and
|
||||
e.getTarget().hasName("Click") and
|
||||
e.getLValue().getQualifier().(FieldAccess).getTarget().hasName("OkButton")
|
||||
e.getLeftOperand().getQualifier().(FieldAccess).getTarget().hasName("OkButton")
|
||||
select c, e
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousMethodExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f7") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f7") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getParameter(0).getType() instanceof IntType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousMethodExpr e, Parameter p, ParameterAccess pa
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f7") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f7") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
p = e.getParameter(0) and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousMethodExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f7") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f7") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getType().(DelegateType).getReturnType() instanceof IntType
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousMethodExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f8") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f8") and
|
||||
e.getParent+() = assign and
|
||||
e.hasNoParameters()
|
||||
select e, e
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousMethodExpr e, LocalVariableAccess va
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f8") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f8") and
|
||||
e.getParent+() = assign and
|
||||
e.hasNoParameters() and
|
||||
va.getEnclosingStmt().getParent+() = e.getBody() and
|
||||
|
||||
@@ -6,11 +6,11 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousObjectCreation o, Assignment a, Property p
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("list2") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("list2") and
|
||||
o.getParent+() = assign and
|
||||
o.getInitializer().getMemberInitializer(0) = a and
|
||||
a.getRValue().getValue() = "2" and
|
||||
p = a.getLValue().(PropertyAccess).getTarget() and
|
||||
a.getRightOperand().getValue() = "2" and
|
||||
p = a.getLeftOperand().(PropertyAccess).getTarget() and
|
||||
p.hasName("i") and
|
||||
p.getDeclaringType() = o.getObjectType()
|
||||
select o
|
||||
|
||||
@@ -6,11 +6,11 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousObjectCreation o, Assignment a, Property p
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
o.getParent+() = assign and
|
||||
o.getInitializer().getMemberInitializer(0) = a and
|
||||
a.getRValue().getValue() = "Chris Smith" and
|
||||
p = a.getLValue().(PropertyAccess).getTarget() and
|
||||
a.getRightOperand().getValue() = "Chris Smith" and
|
||||
p = a.getLeftOperand().(PropertyAccess).getTarget() and
|
||||
p.hasName("Name") and
|
||||
p.getDeclaringType() = o.getObjectType()
|
||||
select o, p.getType().toString()
|
||||
|
||||
@@ -6,11 +6,11 @@ import csharp
|
||||
|
||||
from Assignment assign, AnonymousObjectCreation o, Assignment a, Property p
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
o.getParent+() = assign and
|
||||
o.getInitializer().getMemberInitializer(1) = a and
|
||||
a.getRValue() instanceof ArrayCreation and
|
||||
p = a.getLValue().(PropertyAccess).getTarget() and
|
||||
a.getRightOperand() instanceof ArrayCreation and
|
||||
p = a.getLeftOperand().(PropertyAccess).getTarget() and
|
||||
p.hasName("PhoneNumbers") and
|
||||
p.getDeclaringType() = o.getObjectType()
|
||||
select o, p.getType().getName()
|
||||
|
||||
@@ -8,7 +8,7 @@ from
|
||||
Assignment assign, AnonymousObjectCreation o, Assignment a, AnonymousObjectCreation p,
|
||||
Assignment b
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
o.getParent+() = assign and
|
||||
o.getInitializer().getMemberInitializer(1) = a and
|
||||
p.getParent+() = assign and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e, ArrayInitializer i
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is1") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is1") and
|
||||
e = a.getRightOperand() and
|
||||
not e.isImplicitlyTyped() and
|
||||
i = e.getInitializer() and
|
||||
e.isImplicitlySized() and
|
||||
|
||||
@@ -6,9 +6,9 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e, CastExpr cast
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("os") and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("os") and
|
||||
e.getEnclosingCallable().hasName("MainElementAccess") and
|
||||
e = a.getRValue() and
|
||||
e = a.getRightOperand() and
|
||||
not e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e, ArrayInitializer i
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is2") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is2") and
|
||||
e = a.getRightOperand() and
|
||||
not e.isImplicitlyTyped() and
|
||||
i = e.getInitializer() and
|
||||
e.getNumberOfLengthArguments() = 2 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is3") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is3") and
|
||||
e = a.getRightOperand() and
|
||||
not e.isImplicitlyTyped() and
|
||||
not e.hasInitializer() and
|
||||
e.getNumberOfLengthArguments() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is4") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is4") and
|
||||
e = a.getRightOperand() and
|
||||
not e.isImplicitlyTyped() and
|
||||
not e.hasInitializer() and
|
||||
e.getNumberOfLengthArguments() = 2 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e, int i
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is5") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is5") and
|
||||
e = a.getRightOperand() and
|
||||
e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is6") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is6") and
|
||||
e = a.getRightOperand() and
|
||||
e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("is7") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("is7") and
|
||||
e = a.getRightOperand() and
|
||||
e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("contacts2") and
|
||||
e = a.getRightOperand() and
|
||||
e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,8 +6,8 @@ import csharp
|
||||
|
||||
from Assignment a, ArrayCreation e
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("t") and
|
||||
e = a.getRValue() and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("t") and
|
||||
e = a.getRightOperand() and
|
||||
e.isImplicitlyTyped() and
|
||||
e.isImplicitlySized() and
|
||||
e.getArrayType().getDimension() = 1 and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f1") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f1") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getParameter(0).getType() instanceof ShortType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f2") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f2") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getParameter(0).getType() instanceof IntType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f3") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f3") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getParameter(0).getType() instanceof IntType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f4") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f4") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 1 and
|
||||
e.getParameter(0).getType() instanceof IntType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f5") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f5") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 2 and
|
||||
e.getParameter(0).getType() instanceof IntType and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment assign, LambdaExpr e
|
||||
where
|
||||
assign.getLValue().(VariableAccess).getTarget().hasName("f6") and
|
||||
assign.getLeftOperand().(VariableAccess).getTarget().hasName("f6") and
|
||||
e.getParent+() = assign and
|
||||
e.getNumberOfParameters() = 0 and
|
||||
e.getType().(DelegateType).hasName("Unit") and
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment a, CollectionInitializer i
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("list1") and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("list1") and
|
||||
i.getParent+() = a and
|
||||
i.getElementInitializer(0).getArgument(0) instanceof AssignExpr
|
||||
select i.getAChild+()
|
||||
|
||||
@@ -6,7 +6,7 @@ import csharp
|
||||
|
||||
from Assignment a, CollectionInitializer i, AnonymousObjectCreation o
|
||||
where
|
||||
a.getLValue().(VariableAccess).getTarget().hasName("list2") and
|
||||
a.getLeftOperand().(VariableAccess).getTarget().hasName("list2") and
|
||||
i.getParent+() = a and
|
||||
i.getElementInitializer(0).getArgument(0) = o
|
||||
select i, o
|
||||
|
||||
@@ -15,9 +15,9 @@ where
|
||||
cc.hasName("Point") and
|
||||
i = e.getInitializer() and
|
||||
a = i.getMemberInitializer(0) and
|
||||
a.getLValue().(PropertyAccess).getTarget().hasName("X") and
|
||||
a.getRValue().getValue() = "0" and
|
||||
a.getLeftOperand().(PropertyAccess).getTarget().hasName("X") and
|
||||
a.getRightOperand().getValue() = "0" and
|
||||
b = i.getMemberInitializer(1) and
|
||||
b.getLValue().(PropertyAccess).getTarget().hasName("Y") and
|
||||
b.getRValue().getValue() = "1"
|
||||
b.getLeftOperand().(PropertyAccess).getTarget().hasName("Y") and
|
||||
b.getRightOperand().getValue() = "1"
|
||||
select e, i, a, b
|
||||
|
||||
@@ -15,10 +15,10 @@ where
|
||||
cc.hasName("Point") and
|
||||
i = e.getInitializer() and
|
||||
a = i.getMemberInitializer(0) and
|
||||
a.getLValue().(PropertyAccess).getTarget().hasName("X") and
|
||||
a.getRValue().getValue() = "2" and
|
||||
a.getLeftOperand().(PropertyAccess).getTarget().hasName("X") and
|
||||
a.getRightOperand().getValue() = "2" and
|
||||
b = i.getMemberInitializer(1) and
|
||||
b.getLValue().(PropertyAccess).getTarget().hasName("Y") and
|
||||
b.getRValue().getValue() = "3" and
|
||||
b.getLeftOperand().(PropertyAccess).getTarget().hasName("Y") and
|
||||
b.getRightOperand().getValue() = "3" and
|
||||
i.getNumberOfMemberInitializers() = 2
|
||||
select i, a, b
|
||||
|
||||
@@ -15,10 +15,10 @@ where
|
||||
cc.hasName("Rectangle") and
|
||||
i = e.getInitializer() and
|
||||
a = i.getMemberInitializer(0) and
|
||||
a.getLValue().(PropertyAccess).getTarget().hasName("P1") and
|
||||
a.getRValue() instanceof ObjectCreation and
|
||||
a.getLeftOperand().(PropertyAccess).getTarget().hasName("P1") and
|
||||
a.getRightOperand() instanceof ObjectCreation and
|
||||
b = i.getMemberInitializer(1) and
|
||||
b.getLValue().(PropertyAccess).getTarget().hasName("P2") and
|
||||
b.getRValue() instanceof ObjectCreation and
|
||||
b.getLeftOperand().(PropertyAccess).getTarget().hasName("P2") and
|
||||
b.getRightOperand() instanceof ObjectCreation and
|
||||
i.getNumberOfMemberInitializers() = 2
|
||||
select i, a, b
|
||||
|
||||
@@ -15,10 +15,10 @@ where
|
||||
cc.hasName("Rectangle2") and
|
||||
i = e.getInitializer() and
|
||||
a = i.getMemberInitializer(0) and
|
||||
a.getLValue().(PropertyAccess).getTarget().hasName("P1") and
|
||||
a.getRValue() instanceof ObjectInitializer and
|
||||
a.getLeftOperand().(PropertyAccess).getTarget().hasName("P1") and
|
||||
a.getRightOperand() instanceof ObjectInitializer and
|
||||
b = i.getMemberInitializer(1) and
|
||||
b.getLValue().(PropertyAccess).getTarget().hasName("P2") and
|
||||
b.getRValue() instanceof ObjectInitializer and
|
||||
b.getLeftOperand().(PropertyAccess).getTarget().hasName("P2") and
|
||||
b.getRightOperand() instanceof ObjectInitializer and
|
||||
i.getNumberOfMemberInitializers() = 2
|
||||
select m, e
|
||||
|
||||
@@ -9,5 +9,5 @@ where
|
||||
c.hasName("LoginDialog") and
|
||||
e.getEnclosingCallable() = c and
|
||||
e.getTarget().hasName("Click") and
|
||||
e.getLValue().getQualifier().(FieldAccess).getTarget().hasName("CancelButton")
|
||||
e.getLeftOperand().getQualifier().(FieldAccess).getTarget().hasName("CancelButton")
|
||||
select c, e
|
||||
|
||||
Reference in New Issue
Block a user