Skip to content

Commit

Permalink
Re-add connector method if ControlFlowSensitiveDFG is not executed
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA committed Mar 12, 2024
1 parent 8e0d577 commit a017f39
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/DFGPass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,34 @@ class DFGPass(ctx: TranslationContext) : ComponentPass(ctx) {
for (tu in component.translationUnits) {
walker.iterate(tu)
}
if (config.registeredPasses.any { ControlFlowSensitiveDFGPass::class !in it }) {
connectInferredCallArguments(config.functionSummaries)
}
}

/**
* For inferred functions which have function summaries encoded, we connect the arguments to
* modified parameter to propagate the changes to the arguments out of the [FunctionDeclaration]
* again.
*/
private fun connectInferredCallArguments(functionSummaries: DFGFunctionSummaries) {
for (call in callsInferredFunctions) {
for (invoked in call.invokes.filter { it.isInferred }) {
val changedParams =
functionSummaries.functionToChangedParameters[invoked] ?: mapOf()
for ((param, _) in changedParams) {
if (param == (invoked as? MethodDeclaration)?.receiver) {
(call as? MemberCallExpression)
?.base
?.addPrevDFGContext(param, CallingContextOut(call))
} else if (param is ParameterDeclaration) {
val arg = call.arguments[param.argumentIndex]
arg.addPrevDFGContext(param, CallingContextOut(call))
// (arg as? Reference)?.access = AccessValues.READWRITE
}
}
}
}
}

override fun cleanup() {
Expand Down

0 comments on commit a017f39

Please sign in to comment.