Resolve model editor queries from CodeQL packs if present#2872
Resolve model editor queries from CodeQL packs if present#2872
Conversation
c33b4d0 to
de2b08c
Compare
de2b08c to
e9b67dd
Compare
starcke
left a comment
There was a problem hiding this comment.
I think it looks ok, but a bit fiddy to have both paths active at the same time. Hopefully we can get rid of the writing after codeql have upgraded to the new packs.
| packsToSearch: string[], | ||
| name: string, | ||
| constraints: QueryConstraints, | ||
| allowNoQueriesFound = false, |
There was a problem hiding this comment.
I wonder if it would be neater to have two functions:
function tryResolveQueries(...) {
const queries = await resolveQueriesFromPacks(...);
return queries;
}
function resolveQueries(...)
queries = tryResolveQueries(...)
if (queries.length > 0) {
return queries;
}
// No queries found. Determine the correct error message for the various scenarios.
const humanConstraints = [];
...
}
and the caller could then call tryResolveQueries if the error handling is not needed.
Alternatively one could also call resolveQueriesFromPacks directly?
There was a problem hiding this comment.
👍, I think we can call resolveQueriesFromPacks directly, we don't need any of the additional functionality offered by resolveQueries.
| await cliServer.packInstall(queryDir); | ||
| // Set up a synthetic pack so CodeQL doesn't crash later when we try | ||
| // to resolve a query within this directory | ||
| const syntheticQueryPack = { |
There was a problem hiding this comment.
This is basically unused right? it just needs to exist to satisfy the resolveEndpointsQuery inside runExternalApiQueries?
There was a problem hiding this comment.
Yes, exactly. This is just to reduce the amount of state that would need to be passed around between setUpPack and runExternalApiQueries.
This will start using the model editor endpoints queries from the CodeQL packs (
codeql/java-queriesandcodeql/csharp-queries) if we can find the queries in those packs.There are two cases (example language is Java):
codeql/java-queries, we don't need to write our own queries to disk. We still need to create a synthetic query pack so we can pass thequeryDirto the query resolver without caring about whether the queries are present in the pack or not.codeql/java-queries, we need to write our own queries to disk. We will create a synthetic query pack and install its dependencies so it is fully independent and we can simply pass it through when resolving the queries.These steps together ensure that later steps of the process don't need to keep track of whether the queries
are present in
codeql/java-queriesor in our own query pack. They just need to resolve the query.Checklist
ready-for-doc-reviewlabel there.