X Tutup
The Wayback Machine - https://web.archive.org/web/20240213201334/https://github.com/github/codeql/pull/15554
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

Automodel: Improve handling of varargs and overriding in extraction queries #15554

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

Conversation

max-schaefer
Copy link
Collaborator

The two fixes are conceptually independent, but both came up during a recent triage (#15486).

The first one is to do with implicit varargs arrays: the extraction queries for mining endpoint candidates aim to exclude known models, but were previously failing to properly match up implicit varargs arrays in application mode. That's because we were using the data-flow nodes of the individual arguments collected into the varargs array to represent the endpoints, but the MaD models refer to the ImplicitVarargsArray node. We now do the latter as well.

The second one is to do with recognising existing models for method parameters and return values: if an existing model is marked as subtypes=True, we should consider overriding methods to also be covered by that model, but previously we did not handle this correctly.

Finally, the isNeutral predicate didn't look quite right, so I fixed that as well.

I did a comparison of results on apache/geode before and after this PR, and all changes seem reasonable:

  • Application mode
    • Candidates: from 183659 down to 182409 (+2746, -1496)
      • most removed candidates are due to fixed treatment of implicit varargs
      • the rest are due to better treatment of overriding; in particular, the org.apache.http.impl.client endpoints called out in the triage PR are gone, and similar for PrintWriter and JarOutputStream
      • some of the removed candidates re-appear as added candidates, now with the correct modelling status ("ai-manual" vs unmodelled before)
    • Negative examples: from 460845 up to 463646
      • 21 removed: implicit varargs; not really removed, but representing node has changed, so they also appear as added results
      • 2822 added: implicit varargs
    • Positive examples: from 3231 up to 3284
      • 14 removed: implicit varargs; not really removed, representing node has changed
      • 67 added: mostly in org.apache.http.impl.client (cf above)
  • Framework mode
    • Candidates: unchanged at 38950
    • Negative examples: unchanged at 6137
    • Positive examples: from 0 up to 13
      • New results are for parameters/return values of overriding methods where the corresponding parameter/return value of the overridden method is modelled as a sink/source (it's debatable how meaningful these candidates are)

If an existing source/sink model specifies `subtypes=True` we should apply it to endpoints on overriding methods.
@max-schaefer max-schaefer requested a review from a team as a code owner February 8, 2024 13:37
@github-actions github-actions bot added the Java label Feb 8, 2024
exists(string package, string type, string name, string signature, string ext, string input |
sinkSpec(e, package, type, name, signature, ext, input) and
exists(
string package, string type, boolean subtypes, string name, string signature, string ext,

Check warning

Code scanning / CodeQL

Omittable 'exists' variable Warning

This exists variable can be omitted by using a don't-care expression
in this argument
.
exists(string package, string type, string name, string signature, string ext, string input |
sinkSpec(e, package, type, name, signature, ext, input) and
exists(
string package, string type, boolean subtypes, string name, string signature, string ext,

Check warning

Code scanning / CodeQL

Omittable 'exists' variable Warning

This exists variable can be omitted by using a don't-care expression
in this argument
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant
X Tutup