-
Notifications
You must be signed in to change notification settings - Fork 191
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
Implement viewing of query results as a CSV #784
Conversation
extensions/ql-vscode/src/cli.ts
Outdated
@@ -629,6 +640,9 @@ export class CodeQLCliServer implements Disposable { | |||
} | |||
} | |||
|
|||
async generateResultsCsv(metadata: { kind: string; id: string; scored?: string }, resultsPath: string, csvPath: string, sourceInfo?: SourceInfo): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...the scored
parameter is unused here. I'm not sure if it is even used when generating csv. @henrymercer is it worth passing in the scored
value as we're doing for sarif interpretation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still producing interpreted alerts here AIUI, so yes I think we'd need to forward the scored
query metadata here so that queries with alert scores are interpreted correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is being forwarded correctly? It's one of the keys in the metadata
parameter, which is passed on and used in line 605. Do you have an example query with the scored metadata I could use to test this? As far as I can tell none of the standard library queries use it unless I'm missing something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah...yes. My mistake. It is being used correctly. The scored parameter is something that @henrymercer has been working on to implement ranked queries that order results by confidence. It's still experimental, and it is only enabled when you enter canary
mode, which explicitly opts into experimental features.
What would be useful here is if you could replace { kind: string; id: string; scored?: string }
with QueryMetadata
from interface-types.ts
since it really is the same type.
Once that is changed, I think this is good to go in.
dc8fbb1
to
69bd939
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
This pull request addresses the second part of #342 by introducing an option when right clicking a completed query in the query history view to see a CSV of the results. If the CSV results for the query have been viewed before, the file is simply opened. If they have not been viewed before, the CSV is generated (in the temporary directory for the query's execution) using a call to the CLI, and is then opened.