@@ -139,6 +139,24 @@ module SafeTimeGatheringFunctionCallToModifiedFieldAccessConfig implements Input
139139module SafeTimeGatheringFunctionCallToModifiedFieldAccess =
140140 ControlFlowReachability< SafeTimeGatheringFunctionCallToModifiedFieldAccessConfig > ;
141141
142+ module ModifiedMonthFieldAccessToTimeConversionConfig implements InputSig {
143+ predicate isSource ( ControlFlowNode n ) {
144+ exists ( Variable var , MonthFieldAccess mfa , AssignExpr ae |
145+ n = mfa and
146+ isUnpackedTimeTypeVar ( var , _, _) and
147+ mfa .getQualifier ( ) = var .getAnAccess ( ) and
148+ mfa .isModified ( ) and
149+ ae = mfa .getEnclosingElement ( ) and
150+ ae .getAnOperand ( ) .getValue ( ) .toInt ( ) = 1
151+ )
152+ }
153+
154+ predicate isSink ( ControlFlowNode fcall ) { ModifiedFieldAccessToTimeConversion:: flowsTo ( _, fcall ) }
155+ }
156+
157+ module ModifiedMonthFieldAccessToTimeConversion =
158+ ControlFlowReachability< ModifiedMonthFieldAccessToTimeConversionConfig > ;
159+
142160from FunctionCall fcall , TimeConversionFunction trf , Variable var
143161where
144162 isUnpackedTimeTypeVar ( var , fcall , trf ) and
@@ -158,13 +176,7 @@ where
158176 )
159177 or
160178 // Remove any instance where the year is changed, but the month is set to 1 (year wrapping)
161- exists ( MonthFieldAccess mfa , AssignExpr ae |
162- mfa .getQualifier ( ) = var .getAnAccess ( ) and
163- mfa .isModified ( ) and
164- mfa = fcall .getAPredecessor * ( ) and
165- ae = mfa .getEnclosingElement ( ) and
166- ae .getAnOperand ( ) .getValue ( ) .toInt ( ) = 1
167- )
179+ ModifiedMonthFieldAccessToTimeConversion:: isSink ( fcall )
168180 )
169181select fcall ,
170182 "$@: Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe." ,
0 commit comments