Skip to content

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Mar 23, 2023

Modernize the swift/string-length-conflation query:

  • split into three files as most other queries are, with the standard arrangement of classes/predicates/extension points.
  • most existing sources + sinks converted to CSV.

Note that the existing weaknesses in the definitions of sources and sinks in this query become more explicit here (references to too general classes Collection, Sequence etc appear that were implicit before), but on the positive side they're actually slightly more constrained now than before. I've created an issue to find a way to make this better: https://github.com/github/codeql-c-team/issues/1655

I've tested this on the MRVA top 100 - revealing a few false positive results that have been fixed by the slightly more precise sinks. I've also added some test cases inspired by that.

I will do a DCA run as well...

@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Swift labels Mar 23, 2023
@geoffw0 geoffw0 requested a review from a team as a code owner March 23, 2023 11:05
MathiasVP
MathiasVP previously approved these changes Mar 23, 2023
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once DCA is happy.

class StringLengthConflationConfiguration extends TaintTracking::Configuration {
StringLengthConflationConfiguration() { this = "StringLengthConflationConfiguration" }

override predicate isSource(DataFlow::Node node, string flowstate) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once Swift starts converting dataflow configurations to modules this flowstate could be simplified to a newtype with 5 unit branches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I noticed we will benefit from the new configurations here. I've added a note of your exact suggestion to https://github.com/github/codeql-c-team/issues/1625.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Mar 24, 2023

We lose an alert on DCA. I need to look into this. Performance is fine.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Mar 24, 2023

Fixed the regression. For some reason none of the string views work well expressed in MaD, so they are now all defined in QL. Not ideal, but its difficult to investigate further as these are built-in classes.

I also did a MRVA top 1000 run for the base + new top of this branch to check for any other regressions. We lose 5 FPs and gain 2 TPs, I found no other changes.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Mar 24, 2023

DCA LGTM.

@MathiasVP MathiasVP merged commit e3e68b7 into github:main Mar 29, 2023
@geoffw0 geoffw0 deleted the modernstring branch March 31, 2023 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants