Java/C#: Update telemetry queries to report callables with sink/source neutrals as being supported.#13432
Conversation
|
DCA looks good. |
a23ff44 to
ba55b27
Compare
ba55b27 to
3ee02e9
Compare
3ee02e9 to
b23a06c
Compare
| /** | ||
| * A callable that has a neutral model. | ||
| */ | ||
| class NeutralCallable extends ModelingCandidateCallable { |
There was a problem hiding this comment.
Would it make sense for the NeutralCallable class to be in a different file than FlowSummaryImpl.qll since it is no longer specific to summaries?
Also, would it potentially make sense to move the ModelingCandidateCallable class above to a different file than FlowSummary.qll? Or would this be too much code redesign?
I might have use cases for creating SourceCallable, SinkCallable, and NeutralSinkCallable classes 😄, which could extend ModelingCandidateCallable and NeutralCallable, so I'm wondering if it would make sense to place all these callables somewhere different from the FlowSummary* files.
There was a problem hiding this comment.
IMO it is the naming of the file FlowSummaryImpl.qll (and friends) that seem incorrect as the file also includes predicates (and probably has done so for a long time) related to sources, sinks (and now also neutrals). As such, I don't think we need to split the file because (as an example) the External module in the file contains predicates which uses several of modelling predicates in conjunction with each other (as relevantSpec).
If you have uses cases for SourceCallable and friends, this is probably still the right file, but we can consider renaming the files and get rid of the FlowSummary part as it doesn't properly describe the content.
| * A callable that may have a flow summary. This is either a regular `Callable` | ||
| * A callable that may have a model. This is either a regular `Callable` | ||
| * or a `SyntheticCallable`. | ||
| */ | ||
| class SummarizedCallableBase extends TSummarizedCallableBase { | ||
| class ModelingCandidateCallable extends TModelingCandidateCallable { |
There was a problem hiding this comment.
For my own understanding: Since the ModelingCandidateCallable class is not specific to flow summaries, could I have used it when creating the ModelApi class? I hadn't considered it at the time since the name and QLDoc implied that it was specific to summaries. 🤔
There was a problem hiding this comment.
By inspecting this again, I think it needs to re-written. The claims I have made are too strong (especially because there is currently no connection between sources and sinks and then this class - however I think it might be doable to make, but it is out of scope for this PR). Furthermore, since java has synthetic callables, we probably need to separate base classes for summary and neutral candidates.
I will need to do some more work on this.
I don't think you should base the ModelApi on any of the classes already related to modelling from the FlowSummary like files as we using it to test these classes.
Thank you for the review! These are excellent questions! |
c0188d4 to
4315f2a
Compare
|
DCA looks good. |
geoffw0
left a comment
There was a problem hiding this comment.
Changes to Swift look harmless to me. 👍
…tral kind and add a sink neutral example.
… NeutralSummaryCallable.
…eutralSummaryCallable. Also include printing of the neutral kind in FlowSummaries testcase.
4315f2a to
51f166d
Compare
The telemetry queries (
*/telemetry/supported-external-apiand*/telemetry/unsupported-external-apifor java and C#) used for reporting the usage of third party APIs (or missing modeling of third party APIs) are based on theisSupported()predicate below (fromExternalApi.qll).That is, we think of an API as being supported if there exist any model for the API. However, we didn't take sink and source neutrals into account. This is fixed in this PR.
We re-factor
NeutralCallableto include all neutrals regardless of kind and introduce a new class of neutrals (NeutralSummaryCallable) to contain exactly the callables that have neutral of kind summary (i.e. this is equivalent to the previous definition ofNeutralCallable).Furthermore, we also rename
SummarizedCallableBasetoModelingCandidateCallableas the nameSummarizedCallableBaseis misleading. Please feel free to bikeshed the nameModelingCandidateCallable.Thank you to @starcke for bringing this to our attention!