@@ -148,46 +148,23 @@ private Callable getCallable(Expr expr) {
148148 )
149149}
150150
151- bindingset [ f, s]
152- bindingset [ result , s]
153- Input2:: SourceSinkReportingElement getEntryElement (
154- Function f , Impl:: Private:: SummaryComponentStack s , boolean isArg ,
155- Input2:: SourceSinkReportingElement exit
156- ) {
157- s .headOfSingleton ( ) = Impl:: Private:: SummaryComponent:: return ( _) and
158- result .( Call ) .getResolvedTarget ( ) = f and
159- isArg = false and
160- exit = result
161- or
162- exists ( RustDataFlow:: ArgumentPosition pos |
163- s .head ( ) = Impl:: Private:: SummaryComponent:: parameter ( pos )
164- |
165- exists ( Call call , Expr arg |
166- call .getResolvedTarget ( ) = f and
167- arg = getArg ( call , s .tail ( ) .headOfSingleton ( ) ) and
168- exit = pos .getParameter ( getCallable ( arg ) ) and
169- result = call and
170- isArg = false
171- )
151+ Input2:: SourceSinkReportingElement getEntryElement ( Function f , Impl:: Private:: SummaryComponent sc ) {
152+ exists ( Call call | call .getResolvedTarget ( ) = f |
153+ sc = Impl:: Private:: SummaryComponent:: return ( _) and
154+ result = call
172155 or
156+ result = getArg ( call , sc )
157+ )
158+ or
159+ exists ( RustDataFlow:: ArgumentPosition pos | sc = Impl:: Private:: SummaryComponent:: parameter ( pos ) |
173160 exists ( Function f0 |
174161 f0 = f
175162 or
176163 f0 .implements ( f )
177164 |
178- s .length ( ) = 1 and
179- result = pos .getParameter ( f0 ) and
180- exit = result and
181- isArg = false
165+ result = pos .getParameter ( f0 )
182166 )
183167 )
184- or
185- exists ( Call call |
186- call .getResolvedTarget ( ) = f and
187- result = getArg ( call , s .headOfSingleton ( ) ) and
188- exit = result and
189- isArg = true
190- )
191168}
192169
193170Input2:: SourceSinkReportingElement getExitElement ( Function f , Impl:: Private:: SummaryComponent sc ) {
@@ -198,26 +175,39 @@ Input2::SourceSinkReportingElement getExitElement(Function f, Impl::Private::Sum
198175}
199176
200177private module Input2 implements Impl:: Private:: InputSig2 {
178+ private import codeql.rust.controlflow.CfgNodes
179+
201180 class SourceSinkReportingElement extends AstNode {
202181 DataFlowCallable getEnclosingCallable ( ) { result .asCfgScope ( ) = this .getEnclosingCfgScope ( ) }
203182 }
204183
205- bindingset [ source, s]
206184 SourceSinkReportingElement getSourceEntryElement (
207- Impl:: Public:: SourceElement source , Impl:: Private:: SummaryComponentStack s
185+ Impl:: Public:: SourceElement source , Impl:: Private:: SummaryComponent sc
208186 ) {
209- result = getEntryElement ( source , s , _ , _ )
187+ result = getEntryElement ( source , sc )
210188 }
211189
212- bindingset [ e, s]
213- NodePublic getSourceExitNode ( SourceSinkReportingElement e , Impl:: Private:: SummaryComponentStack s ) {
214- exists ( boolean isArg , SourceSinkReportingElement exit | e = getEntryElement ( _, s , isArg , exit ) |
215- isArg = false and
216- result .( Node ) .getAstNode ( ) = exit
217- or
218- isArg = true and
219- result .( PostUpdateNode ) .getPreUpdateNode ( ) .( Node ) .getAstNode ( ) = exit
190+ SourceSinkReportingElement getNextElement (
191+ SourceSinkReportingElement prev , Impl:: Private:: SummaryComponent sc
192+ ) {
193+ exists ( RustDataFlow:: ArgumentPosition pos |
194+ sc = Impl:: Private:: SummaryComponent:: parameter ( pos ) and
195+ result = pos .getParameter ( getCallable ( prev ) )
220196 )
197+ or
198+ exists ( Callable c |
199+ sc = Impl:: Private:: SummaryComponent:: return ( _) and
200+ c = getCallable ( prev ) and
201+ result .getACfgNode ( ) .getASuccessor ( ) instanceof AnnotatedExitCfgNode and
202+ result .getEnclosingCfgScope ( ) = c
203+ )
204+ }
205+
206+ bindingset [ e, sc]
207+ NodePublic getSourceExitNode ( SourceSinkReportingElement e , Impl:: Private:: SummaryComponent sc ) {
208+ if sc = Impl:: Private:: SummaryComponent:: argument ( _)
209+ then result .( PostUpdateNode ) .getPreUpdateNode ( ) .( Node ) .getAstNode ( ) = e
210+ else result .( Node ) .getAstNode ( ) = e
221211 }
222212
223213 SourceSinkReportingElement getSinkExitElement (
0 commit comments