Repository navigation
Unified: Mark static members in legacy MaD models - #23296
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The added tests only exercise matchesCall, leaving the new receiver-type distinction in matchesCallable without regression coverage.
1 open issue
What changed in this PR
Updates Unified’s legacy Swift Models-as-Data to represent static members on meta-types such as Process.Type, preparing for broader name-binding changes.
Changes:
- Migrate static-member models to
.Typereceivers. - Add meta-type selectors and static-aware callable matching.
- Add static/instance fixtures that record current matching limitations.
| File | Description |
|---|---|
unified/ql/test/library-tests/mad/test.swift |
Add static/instance method and property cases. |
unified/ql/test/library-tests/mad/test.ext.json |
Add models for the new fixtures. |
unified/ql/test/library-tests/mad/test.expected |
Update expected source and sink results. |
unified/ql/lib/ext/legacy-swift.model.json |
Mark static Swift model receivers with .Type. |
unified/ql/lib/ext/format-string.model.yml |
Update static format-string sink receivers. |
unified/ql/lib/ext/database.model.json |
Update static database API receivers. |
unified/ql/lib/codeql/unified/internal/typeinference/Type.qll |
Exclude meta-types from ordinary model types. |
unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll |
Add meta-type selectors and static callable selection. |
Review effort: Max (adaptive)
geoffw0
left a comment
There was a problem hiding this comment.
LGTM. As discussed on Slack, there are some new models on main now that may still need updating.
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>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
b46f541 to
450ca8a
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved
left a comment
There was a problem hiding this comment.
I wonder if we should use another keyword which is not potentially in conflict with actual types?
class C {
class Type {
}
}|
@hvitved Sorry perhaps I should have mentioned in the PR description.
The |
|
Conflicts have been resolved. @geoffw0 could you check the changes to the |
Yes - this is a bit of a confusing area, because we're modelling the Objective C RNCryptor library (this, I think), but a direct Swift RNCryptor port also exists. I believe the former was more popular when the original models were made (which may or may not still be true); it may also be that the latter is build on top of the former. Anyway...
|

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
b46f54171867176c05ec8b84fbbfebd58f88332aBase.TypeParameter[0]model matches the static method in a subtype, while the same-named instance method emits no source.↑ The test exercises callable declarations rather than call-site matching.
↓ Existing call-site cases remain marked
SPURIOUS, and static-property access remains markedMISSINGin this PR.Smaller change split out from this PR.
Previously the MaD models did not indicate if a member was a static or instance member. Static members as now considered members of the "meta-type". The meta-types is written as
E.Typefor some classE, and describes "the class itself" as opposed to instances of the class.For example, the model for
Process.runmust now be described as an method on theProcess.Typereceiver:The larger PR above takes meta-types a step further, after which it starts to make more sense to represent it this way. For example, having a representative for the meta type means all member accesses can be assigned a "base type", which can simplify handling of calls in some contexts. But to avoid a huge PR I've just done the MaD refactoring in this PR.