@@ -149,6 +149,25 @@ class MonthOrDayFieldAccess extends FieldAccess {
149149 }
150150}
151151
152+ class OperationNode extends DataFlow:: Node {
153+ OperationNode ( ) {
154+ this .asExpr ( ) instanceof Operation
155+ or
156+ this .asExpr ( ) instanceof AssignArithmeticOperation
157+ }
158+ }
159+
160+ /**
161+ * An access or assignment to a Year field.
162+ */
163+ class YearFieldAccessNode extends DataFlow:: Node {
164+ YearFieldAccessNode ( ) {
165+ this .asExpr ( ) instanceof YearFieldAssignment
166+ or
167+ this .asExpr ( ) instanceof YearFieldAccess
168+ }
169+ }
170+
152171/**
153172 * Flow for non operation candidate sources to year assignments to detect
154173 * ignorable functions.
@@ -157,17 +176,12 @@ class MonthOrDayFieldAccess extends FieldAccess {
157176 */
158177module IgnorableOperationToYearConfig implements DataFlow:: ConfigSig {
159178 predicate isSource ( DataFlow:: Node n ) {
160- (
161- n .asExpr ( ) instanceof Operation or
162- n .asExpr ( ) instanceof AssignArithmeticOperation
163- ) and
179+ n instanceof OperationNode and
164180 not isOperationSourceCandidate ( n .asExpr ( ) )
165181 }
166182
167183 predicate isSink ( DataFlow:: Node n ) {
168- n .asExpr ( ) instanceof YearFieldAssignment
169- or
170- n .asExpr ( ) instanceof YearFieldAccess
184+ n instanceof YearFieldAccessNode
171185 }
172186
173187 // looking for sources and sinks in the same function
@@ -182,17 +196,12 @@ module IgnorableOperationToYearFlow = TaintTracking::Global<IgnorableOperationTo
182196
183197module YearToIgnorableOperationConfig implements DataFlow:: ConfigSig {
184198 predicate isSink ( DataFlow:: Node n ) {
185- (
186- n .asExpr ( ) instanceof Operation or
187- n .asExpr ( ) instanceof AssignArithmeticOperation
188- ) and
199+ n instanceof OperationNode and
189200 not isOperationSourceCandidate ( n .asExpr ( ) )
190201 }
191202
192203 predicate isSource ( DataFlow:: Node n ) {
193- n .asExpr ( ) instanceof YearFieldAssignment
194- or
195- n .asExpr ( ) instanceof YearFieldAccess
204+ n instanceof YearFieldAccessNode
196205 }
197206
198207 // looking for sources and sinks in the same function
0 commit comments