Retrieve external API usage snippets using SARIF#2457
Conversation
1d36fe3 to
ec3fabe
Compare
ec3fabe to
5c81671
Compare
starcke
left a comment
There was a problem hiding this comment.
Looks pretty good to me. But probably also good to get a second review from Charis as it is touching some existing code.
| where | ||
| apiName = api.getApiName() and | ||
| usage = aUsage(api) | ||
| select usage, apiName |
There was a problem hiding this comment.
I am ok to do it like this for now. But it feels like we should be able to reuse the previous query as it selects all the same data.
There was a problem hiding this comment.
I found a way to use a single query for this, so I'll change it to use a single query for both retrieving the external APIs and for retrieving the usages.
charisk
left a comment
There was a problem hiding this comment.
Thanks for doing this! The approach looks good to me but I'm worried about the extensive use of Pick/Omit, specially for code outside of the data extensions editor/auto-model. Can we avoid these changes?
8aba87b to
c017530
Compare
|
|
||
| interface BqrsColumn { | ||
| name: string; | ||
| name?: string; |
There was a problem hiding this comment.
Sorry this is probably a stupid question, but why would a column not have a name?
There was a problem hiding this comment.
This is dependent on the query. In the query we're now using, the BQRS column definitions look like this:
[
{ name: "usage", kind: "Entity" },
{ name: "apiName", kind: "String" },
{ kind: "String" },
{ kind: "String" },
]CodeQL is probably not naming the last two columns because it can't automatically determine a name based on the name of a variable:
usage, apiName, supported.toString(), "supported"
starcke
left a comment
There was a problem hiding this comment.
Query looks good to me. It is similar to the approach the CodeML queries have.
Co-authored-by: Charis Kyriakou <charisk@users.noreply.github.com>
This implements the retrieval of external API usage snippets using a SARIF file.
The alternative is retrieving the usage manually given a file and a range within this file. However, this is quite hard to do and would create a separate implementation from the one already present in the CodeQL CLI.
Checklist
ready-for-doc-reviewlabel there.