Repository navigation
Unified: flow summaries - #22809
Draft
asgerf wants to merge 24 commits into
Draft
Unified: flow summaries#22809asgerf wants to merge 24 commits into
asgerf wants to merge 24 commits into
Conversation
This is consistent with how ArgumentNode and ParameterNode gets populated.
To avoid alert wobbles we want to match the original alert location. For now just keep track of which alerts have moved.
This could also have been extracted as a modifier on the 'argument' node, but this way of modeling it lets us handle more cases such as the postfix '!' as well (see next commit).
asgerf
force-pushed
the
unified/flow-summaries
branch
from
October 19, 2026 10:05
161f843 to
90321a8
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved summary-decoding and node-consistency issues can prevent modeled flows from being analyzed correctly.
4 open issues
What changed in this PR
Adds model-driven flow summaries to Unified data flow, enabling existing Swift library models to propagate values and taint.
Changes:
- Integrates summarized callables, callbacks, and access paths.
- Adds Swift must-flow and post-update handling.
- Adds summary tests and debugging support, and updates alert expectations.
| File | Description |
|---|---|
unified/ql/test/query-tests/security/CWE-022/PathInjection/testPathInjection.swift |
Updates inline alert expectations. |
unified/ql/test/query-tests/security/CWE-022/PathInjection/PathInjectionTest.expected |
Updates expected path-injection results. |
unified/ql/test/library-tests/dataflow/test.swift |
Marks optional tuple flow as detected. |
unified/ql/test/library-tests/dataflow/test.ext.yml |
Defines test summary models. |
unified/ql/test/library-tests/dataflow/test.expected |
Updates expected flow graphs and results. |
unified/ql/test/library-tests/dataflow/flow-summaries.swift |
Adds summary propagation fixtures. |
unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll |
Exposes selectors and normalizes summaries. |
unified/ql/lib/codeql/unified/internal/dev/debugSummarizedCallable.ql |
Adds summary graph debugging. |
unified/ql/lib/codeql/unified/internal/dataflow/TaintTrackingInstantiation.qll |
Includes summary taint steps. |
unified/ql/lib/codeql/unified/internal/dataflow/ParameterPositions.qll |
Exposes model operand encoding. |
unified/ql/lib/codeql/unified/internal/dataflow/FlowSummaries.qll |
Instantiates shared summary machinery. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowPluginSwift.qll |
Models inout and unwrap must-flow. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowPlugin.qll |
Adds a language-specific must-flow hook. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowNode.qll |
Adds summary nodes and post-update propagation. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowInstantiation.qll |
Integrates summary nodes and flow steps. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowCallable.qll |
Represents summarized callables. |
unified/ql/lib/codeql/unified/internal/dataflow/DataFlowCall.qll |
Represents synthesized callback calls. |
unified/ql/lib/codeql/unified/internal/dataflow/Content.qll |
Includes model-defined named contents. |
unified/ql/lib/codeql/unified/internal/dataflow/CallGraph.qll |
Resolves calls to summary models. |
unified/ql/lib/codeql/unified/internal/dataflow/AllDataFlow.qll |
Imports the summary implementation. |
unified/ql/consistency-queries/DataFlowConsistency.ql |
Adjusts consistency checks for summary post-updates. |
Review effort: Max
| TLocalSsaNode(LocalSsaDataFlowOutput::SsaNode node) or | ||
| TCaptureSsaNode(CaptureSsaOutput::SynthesizedCaptureNode node) | ||
| TCaptureSsaNode(CaptureSsaOutput::SynthesizedCaptureNode node) or | ||
| TSummaryNode(FlowSummaryOutput::SummaryNode node) |
| // Adapters for the old Swift MaD models | ||
| token = "OptionalSome" and result = ContentSet::namedMember("some.0") | ||
| or | ||
| token = "CollectionElement" and result = ContentSet::arrayElement() |
asgerf
force-pushed
the
unified/flow-summaries
branch
from
October 19, 2026 12:29
74885e3 to
14602be
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds support for flow summaries, that is, MaD entries in
legacySummaryModelthat describe flow through a function.'Inout' parameters
This PR includes support for summaries that involve an
inoutparameter, such as theswapmodel which addsArgument[0] -> Argument[1]flow. We use argument's post-update node to propagate the new value.Support for user-written
inoutparameters is not part of this PR, nor do we insert (uncertain) writes in SSA, which is needed for some non-dataflow use-cases for SSA. I expect another PR to flesh out support forinoutparameters in the future.Call site 'inout' indicator
At a call site, argument to an
inoutparameter must be prefixed by&, e.g:However, when calling an operator with
inoutparameters, there is no syntactic indicator at the call site that an operand is aninoutoperand. Some languages like PHP are lacking such syntactic indicators in general. So we shouldn't rely on its presence too much.The
&is currently represented by aUnaryExprwhich meant thexandyexpressions did not get a post-update node, as they did not appear directly as arguments to the call. A similar issue exists with type casts and the postfix!operator, so I decided to give the language plugin a hook that makes it possible to add post-update flow through unary operators.An alternative would have been to change the extractor to roll the
&into a modifier on theArgumentnode, which would have been slightly nicer, but then the issue would persist for type casts and postfix!.