-
Notifications
You must be signed in to change notification settings - Fork 2k
Swift: add DataFlow::Content for arrays #13741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MathiasVP
merged 21 commits into
github:main
from
rdmarsh2:rdmarsh2/swift/array-content-flow
Aug 2, 2023
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
42cc644
Swift: add DataFlow::Content for arrays
ef9376d
Swift: more ArrayContent tests
0b35be2
Swift: additional dataflow tests for arrays
169326f
Swift: support array keypath reads in dataflow
d4b635d
Swift: add ArrayContent summary support
81a25b2
Swift: fix tests for array concatenation
dfa5e18
Swift: autoformat
1fac08e
Swift: add qldoc for ArrayContent and Array models
bcc4565
Swift: Change note for ArrayContent
093c690
Swift: only read ArrayContent from subscript keypaths
883543f
Swift: force high precision for arraycontent
ec99977
Swift: add test for assignment to nested arrays
41ad1ed
Swift: fix cartesian product in array readStep
3587374
Swift: reverse flow steps through InOutExpr
e54341a
Swift: undo commented out line
bf5ba37
Swift: Hide InOutExpr
c36ce78
Merge branch 'main' into rdmarsh2/swift/array-content-flow
7ed520a
Swift: update test expectations after hiding InOutExpr
6039af0
Swift: autoformat
bb4fe20
Merge branch 'main' into rdmarsh2/swift/array-content-flow
22ae430
Swift: accept more test changes from hiding InOutExpr
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: majorAnalysis | ||
| --- | ||
| * Added `DataFlow::ArrayContent`, which will provide more accurate flow through arrays. |
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
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Array.qll
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * Provides models for `Array` and related Swift classes. | ||
| */ | ||
|
|
||
| import swift | ||
| private import codeql.swift.dataflow.ExternalFlow | ||
|
|
||
| /** | ||
| * An instance of the `Array` type. | ||
| */ | ||
| class ArrayType extends Type { | ||
| ArrayType() { this.getName().matches("Array<%") or this.getName().matches("[%]") } | ||
| } | ||
|
|
||
| /** | ||
| * A model for `Array` and related class members that permit data flow. | ||
| */ | ||
| private class ArraySummaries extends SummaryModelCsv { | ||
| override predicate row(string row) { | ||
| row = | ||
| [ | ||
| ";Array;true;insert(_:at:);;;Argument[0];Argument[-1].ArrayElement;value", | ||
| ";Array;true;insert(_:at:);;;Argument[1];Argument[-1];taint" | ||
| ] | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| | statements.swift:75:7:75:7 | yield ... | 0 | file://:0:0:0:0 | &... | | ||
| | statements.swift:78:7:78:14 | yield ... | 0 | statements.swift:78:13:78:14 | &... | | ||
| | statements.swift:75:7:75:7 | yield ... | 0 | file://:0:0:0:0 | .x | | ||
| | statements.swift:78:7:78:14 | yield ... | 0 | statements.swift:78:14:78:14 | .x | |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be pulled into its own predicate to follow the structure of
parseField?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a considerably simpler case than
parseField, I'd be happy either way TBH.