Repository navigation
Conversation
asgerf
force-pushed
the
asgerf-optional-chaining
branch
from
December 2, 2026 13:04
f30c4ab to
052a0f0
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
asgerf
force-pushed
the
asgerf-optional-chaining
branch
from
December 3, 2026 09:00
052a0f0 to
5221795
Compare
asgerf
marked this pull request as ready for review
December 3, 2026 09:53
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues break weak-capture call resolution and optional value-type setter dataflow, while the command-injection baseline still records an expectation failure.
3 open issues
What changed in this PR
Expands Swift optional-chaining support in Unified so type inference and security models can recognize members accessed through optional values. Wrapping the final chain result in Optional remains deferred.
Changes:
- Extracts
?as a postfix operator and unwraps optional types during inference. - Preserves data flow through optional chaining.
- Adds regression cases and refreshes extractor and query expectations.
| File | Description |
|---|---|
| unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected | Updates paths through optional accesses. |
| unified/ql/test/query-tests/security/CWE-078/CommandInjection/CommandInjection.expected | Records a newly detected optional-property sink. |
| unified/ql/test/library-tests/type-inference/type-inference.expected | Adds optional-chaining inference results. |
| unified/ql/test/library-tests/type-inference/optional-chaining.swift | Tests optional members, chains, and calls. |
| unified/ql/test/library-tests/mad/test.swift | Tests optional source and sink properties. |
| unified/ql/test/library-tests/mad/test.expected | Records modeled property results. |
| unified/ql/test/library-tests/mad-builtins/test.swift | Tests optional properties without stubs. |
| unified/ql/test/library-tests/mad-builtins/test.expected | Records model-only property results. |
| unified/ql/test/library-tests/dataflow/test.expected | Adds optional-chaining flow paths. |
| unified/ql/test/library-tests/dataflow/optional-chaining.swift | Tests field, method, and subscript flows. |
| unified/ql/test/library-tests/controlflow/basicblock-slices.expected | Includes postfix ? nodes. |
| unified/ql/lib/codeql/unified/internal/typeinference/TypeInferencePluginSwift.qll | Unwraps optional operand types. |
| unified/ql/lib/codeql/unified/internal/dataflow/DataFlowPluginSwift.qll | Propagates flow through postfix ?. |
| unified/extractor/tests/corpus/swift/optionals-and-errors/optional-chaining.output | Updates nested-chain extraction expectations. |
| unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output | Updates optional-call extraction expectations. |
| unified/extractor/tests/corpus/swift/closures/closure-with-capture-list.output | Updates optional access in closures. |
| unified/extractor/src/languages/swift/swift.rs | Emits postfix ? while preserving optional patterns. |
Review effort: Balanced (adaptive)
asgerf
marked this pull request as draft
December 3, 2026 10:06
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
3372fa9dee11b3b3d0175637551e907cab4c21ad↑ Unified dataflow, type-inference, and CommandInjection tests pass.
↓ Hosted checks are still running: clippy, qldoc, analyze, two sync checks, framework coverage artifacts, and analyze (rust).
↑ Added targeted setter-flow and weak-capture call-resolution/data-flow coverage.
Optional chaining
x?.ywas previously "supported" by the fact that the?was dropped during extraction, and that data flow bypassesOptional<T>contents. But type inference could still get confused, meaning things likeprocess?.argumentswas not recognized as a sink.This PR extracts the
?as a post-fix unary operator, unwraps the optional type in type inference. At the end of the access chain it should wrap the type inOptional<T>again, but this is not yet implemented, and I think it matters slightly less in practice. It would make sense to wait for theAccessChainclass from here to get merged before implementing that.