Skip to content

Move FlowSummaryImpl.qll to dataflow pack#14573

Merged
hvitved merged 14 commits intogithub:mainfrom
hvitved:flow-summary-impl-param
Dec 14, 2023
Merged

Move FlowSummaryImpl.qll to dataflow pack#14573
hvitved merged 14 commits intogithub:mainfrom
hvitved:flow-summary-impl-param

Conversation

@hvitved
Copy link
Copy Markdown
Contributor

@hvitved hvitved commented Oct 24, 2023

This PR turns FlowSummaryImpl.qll (and AccessPathSyntax.qll) into a proper parameterized module, and moves it to the shared dataflow pack.

Previously, the exposed SummarizedCallable class would look like

abstract class SummarizedCallable extends SummarizedCallableBase {
  predicate propagatesFlow(
    SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
  ) {
    none()
  }

  predicate propagatesFlowExt(
    string input, string output, boolean preservesValue
  ) {
    none()
  }
}

but after this PR it is simply

abstract class SummarizedCallable extends SummarizedCallableBase {
  abstract predicate propagatesFlow(
    string input, string output, boolean preservesValue
  );
}

That is, we now consider SummaryComponentStack an internal implementation detail, which is not exposed to the user (the user-facing aliases have been deprecated).

Commit-by-commit review is encouraged, and for each of the <LANG>: Use FlowSummaryImpl from dataflow pack commits, I recommend viewing the FlowSummaryImpl.qll in full, as the diff is not really meaningful (previously, it was the synced copy of share library, now it contains the inputs to the shared library).

Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Fixed
Comment thread ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll Fixed
Comment on lines +1597 to +1778
/**
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind;provenance",
* ext is hardcoded to empty.
*/

Check warning

Code scanning / CodeQL

Predicate QLDoc style.

The QLDoc for a predicate without a result should start with 'Holds'.
sinkElement(_, spec, _, _)
}

private module AccessPath = AccessPathSyntax::AccessPath<sourceSinkSpec/1>;

Check warning

Code scanning / CodeQL

Dead code

This code is never used, and it's not publicly exported.
@hvitved hvitved force-pushed the flow-summary-impl-param branch from 741725b to 45b59c1 Compare October 24, 2023 12:30
@hvitved hvitved force-pushed the flow-summary-impl-param branch from 45b59c1 to 6185feb Compare October 24, 2023 18:54
@github-actions github-actions Bot added the C# label Oct 24, 2023
Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Fixed
module SourceSinkInterpretationInput implements
Impl::Private::External::SourceSinkInterpretationInputSig
{
private import csharp as Cs

Check warning

Code scanning / CodeQL

Names only differing by case

Cs is only different by casing from CS that is used elsewhere for modules.
@hvitved hvitved force-pushed the flow-summary-impl-param branch from 6185feb to a047beb Compare October 30, 2023 08:33
Comment thread csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll Fixed
Comment thread csharp/ql/test/library-tests/dataflow/library/FlowSummaries.ql Fixed
Comment thread csharp/ql/test/library-tests/dataflow/library/FlowSummaries.ql Fixed
Comment thread csharp/ql/test/shared/FlowSummaries.qll Fixed
Comment thread csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll Fixed
Comment thread csharp/ql/test/shared/FlowSummaries.qll Fixed
Comment thread csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll Fixed
@hvitved hvitved force-pushed the flow-summary-impl-param branch 7 times, most recently from 94cefa4 to b2ee1f0 Compare November 27, 2023 11:45
@github-actions github-actions Bot added the Go label Nov 27, 2023
Comment thread go/ql/lib/semmle/go/dataflow/ExternalFlow.qll Fixed
@hvitved hvitved force-pushed the flow-summary-impl-param branch from b2ee1f0 to 5f79e7c Compare November 27, 2023 13:31
@github-actions github-actions Bot added the Swift label Nov 27, 2023
Comment thread swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll Fixed
@hvitved hvitved force-pushed the flow-summary-impl-param branch from 5f79e7c to c656fba Compare November 27, 2023 14:45
@hvitved hvitved force-pushed the flow-summary-impl-param branch from c656fba to d73136b Compare December 7, 2023 10:43
@github-actions github-actions Bot added the Java label Dec 7, 2023
@hvitved hvitved force-pushed the flow-summary-impl-param branch 2 times, most recently from ae7e347 to fcb6c19 Compare December 7, 2023 12:59
@hvitved hvitved force-pushed the flow-summary-impl-param branch from fb1102c to f9dbf67 Compare December 10, 2023 10:26
erik-krogh
erik-krogh previously approved these changes Dec 11, 2023
Copy link
Copy Markdown
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

JS 👍

MathiasVP
MathiasVP previously approved these changes Dec 11, 2023
Copy link
Copy Markdown
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.

Swift 👍

@hvitved hvitved dismissed stale reviews from MathiasVP and erik-krogh via cdf59e1 December 11, 2023 09:27
Copy link
Copy Markdown
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but there are 2 things I would like to get fixed for Python 🙏

Comment thread python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll Outdated
Comment thread python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll Outdated
)
}

private class SummarizedCallableAdapter extends SummarizedCallable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a comment that this is where the MaD rows are being used to create SummarizedCallable's (the same for neutrals as well).

michaelnebel
michaelnebel previously approved these changes Dec 12, 2023
Copy link
Copy Markdown
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

C#: Looks good to me!
Thank you for doing this @hvitved !

RasmusWL
RasmusWL previously approved these changes Dec 13, 2023
Copy link
Copy Markdown
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Python 👍 (thanks for the updates)

Copy link
Copy Markdown
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

I can see this has already been approved by Python. I can also see that I have a pending comment, but I do not remember what it is, so I will just submit the partial review now, to see if it is still relevant.

Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Outdated
@aschackmull
Copy link
Copy Markdown
Contributor

aschackmull commented Dec 13, 2023

I think I might see a bug related to the MaD provenance column. Could you verify that the presence of both a manual and a generated model for the same callable yields only the manual summary? I believe this used to work, but I think it might be broken now. Alright, I no longer think there's a bug, instead I think that most of the logic in SummarizedCallableExternal can be deleted as it appears to be useless (and that's what threw me off in the first place).

Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Outdated
Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Outdated
@owen-mc
Copy link
Copy Markdown
Contributor

owen-mc commented Dec 13, 2023

@aschackmull Do we have a test for what happens when we have a manual model and a generated model?

@hvitved
Copy link
Copy Markdown
Contributor Author

hvitved commented Dec 13, 2023

Do we have a test for what happens when we have a manual model and a generated model?

There is at least https://github.com/github/codeql/blob/main/java/ql/src/Metrics/Summaries/GeneratedVsManualCoverage.ql.

Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll
Comment thread shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Outdated
Comment thread shared/dataflow/codeql/dataflow/internal/AccessPathSyntax.qll Outdated
@michaelnebel
Copy link
Copy Markdown
Contributor

michaelnebel commented Dec 14, 2023

@aschackmull Do we have a test for what happens when we have a manual model and a generated model?

I don't think there exists such a test for Java.
But one can use the summary/1 predicate for creating such a test. (cc @owen-mc)

@hvitved hvitved dismissed stale reviews from RasmusWL and michaelnebel via 098afb9 December 14, 2023 08:49
Copy link
Copy Markdown
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for tackling this!

@hvitved hvitved merged commit c8b4a21 into github:main Dec 14, 2023
@hvitved hvitved deleted the flow-summary-impl-param branch December 14, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants