-
Notifications
You must be signed in to change notification settings - Fork 193
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
User should be able to generate a database from the current workspace #306
Comments
For compiled languages, presumably you would just run the autobuilder, or perhaps let the user specify the build command to run. If the user already has a VSCode "Task" set up to build their project, I wonder if we could have the user tell us which task they use to build, and figure out how to run that task under the tracer. If the task uses Having to duplicate the build command, and keep the duplicate build command in sync with the real build command, has been a recurring problem for setting up CodeQL analysis in CI systems. If we can avoid having to do that, at least in the common case, for VS Code, that should make it easier for users to get started. |
Good point about piggy-backing off of a vscode task. I wonder if defining our own kind of |
With https://github.com/github/codeql-cli-binaries/releases/tag/v2.6.0 now supporting |
I don't know if this is the right approach, but I've been using this for a few days now for quickly building C/C++ databases from individual source files: interface MakeTaskDefinition extends vscode.TaskDefinition {
}
async function getTask(): Promise<vscode.Task> {
const folders = vscode.workspace.workspaceFolders?.map(folder => folder.uri.path)
let pwd = null;
if (folders) {
pwd = await vscode.window.showQuickPick(folders)
}
if (pwd == null) {
pwd = '.'
}
channel.appendLine(pwd)
console.log(pwd)
const command = await vscode.window.showInputBox({
title: 'Build command',
placeHolder: 'Build command',
value: 'gcc -o test -c test.cpp',
});
console.log(command);
const dbPath = `${pwd}/test-db`
vscode.window.showInformationMessage(`Creating database at ${dbPath}`)
let task = new vscode.Task(
<MakeTaskDefinition>{type: "codeql"},
vscode.TaskScope.Workspace,
"codeql",
'codeql',
new vscode.ShellExecution(`codeql database create ${dbPath} --language=cpp --overwrite --command="${command}" --source-root="${pwd}"`)
);
task.group = vscode.TaskGroup.Build;
return task;
}
context.subscriptions.push(vscode.commands.registerCommand('gsgx.buildCodeQLDatabase', async () => {
if (vscode.window.activeTextEditor) {
if (vscode.languages.match(["c", "cpp"], vscode.window.activeTextEditor.document)) {
let fileName = vscode.window.activeTextEditor.document.fileName
console.log(fileName);
let task = await getTask();
await vscode.tasks.executeTask(task);
}
}
})); Obviously needs some work to make it more generic, but maybe it'll be a good starting point for this issue? |
There is no easy way for a user to create a database locally if the only version of the cli installed is the default extension's version. The reason is that there is no easy way for a user to determine the file system path to the executable.
Instead, the extension should offer a mechanism to generate a database from the current workspace.
My idea is this:
CodeQL: Create database from workspace
commanddatabase create
command with the given language and placed in a well-known location (perhaps specified in configuration)Open questions:
See https://github.com/orgs/github/teams/codeql-core/discussions/1 for a longer discussion on this.
The text was updated successfully, but these errors were encountered: