Skip to content
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

Swift: Update summary queries #14329

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Swift: Update summary queries #14329

wants to merge 6 commits into from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Sep 27, 2023

Update summary queries. Three new queries are added:

  • swift/summary/regex-evals, which lists regular expression evaluations (approximately the sinks for the regex queries).
  • swift/summary/query-sinks, which lists all other query sinks. Hopefully this will give us a much better understanding of why certain queries are under-performing.
  • swift/summary/taint-reach, which computes the taint reach metric now instead of being done as part of swift/summary/summary-statistics. This change is made because taint reach is expensive to compute and could potentially fail on large projects, so it's best for it to be separate.

@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Swift labels Sep 27, 2023
@geoffw0 geoffw0 requested a review from a team as a code owner September 27, 2023 17:59
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! A few small comments, but nothing blocking

import codeql.swift.security.StaticInitializationVectorQuery

string queryForSink(DataFlow::Node sink) {
PathInjectionConfig::isSink(sink) and result = "swift/path-injection"
Copy link
Contributor

Choose a reason for hiding this comment

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

This almost makes me wish every dataflow module that fully defined a query defined a predicate like:

module PathInjectionConfig implements DataFlow::ConfigSig {
  ...
  
  string queryId() {
    result = "swift/path-injection"
  }
}

but that's probably too much effort to put into making this table-like diagnostics query.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that would be nice. Regardless there will be a small maintenance burden adding new queries to this list, but I think it's worth it for the data we get. At some point queryForSink may move out into a shared .qll so that we can write other queries using it.

@@ -1,5 +1,5 @@
/**
* @name Summary statistics
* @name Summary Statistics
Copy link
Contributor

Choose a reason for hiding this comment

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

There's actually no style-guide requirement to capitalize every word in the @name meta-data field. See here: https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md#query-name-name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does make the queries in this directory consistent, which is nice, if unimportant.

(I'll change them all to lower case if you prefer)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, I don't think it's worth running CI again for this small change.

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.

None yet

2 participants