Skip to content

Commit 0b9a3f0

Browse files
Copilotfelickz
andcommitted
Complete CodeQL discovery and auto-install implementation with documentation
Co-authored-by: felickz <[email protected]>
1 parent 4479639 commit 0b9a3f0

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ Here are some screenshots showcasing the extension's capabilities:
6767

6868
## 📋 Prerequisites
6969

70-
- **CodeQL CLI**: The extension requires the [CodeQL CLI](https://github.com/github/codeql-cli-binaries/releases) to be installed and available on your system PATH
71-
- Download the latest release for your platform from the [CodeQL CLI releases page](https://github.com/github/codeql-cli-binaries/releases)
72-
- Extract the archive and add the `codeql` binary to your system PATH
73-
- Verify installation by running `codeql --version` in your terminal
70+
- **CodeQL CLI**: The extension can automatically install the [CodeQL CLI](https://github.com/github/codeql-cli-binaries/releases) for you
71+
-**Auto-Discovery**: The extension will automatically detect CodeQL CLI from GitHub's CodeQL extension if installed
72+
-**Auto-Install**: If CodeQL CLI is not found, the extension will offer to download and install it automatically
73+
- **Manual Install**: You can also download the latest release manually from the [CodeQL CLI releases page](https://github.com/github/codeql-cli-binaries/releases) and configure the path in settings
74+
- **Verification**: Use `CodeQL: Show CLI Information` command to check your installation
7475

7576
- **GitHub Personal Access Token**: For GitHub integration features, a GitHub token with appropriate permissions is required
7677
- Create a token at [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens)
@@ -89,6 +90,7 @@ Here are some screenshots showcasing the extension's capabilities:
8990
| `CodeQL: Clear Logs` | Clear all log entries |
9091
| `CodeQL: Clear Inline Diagnostics` | Remove inline problem markers |
9192
| `CodeQL: Show CLI Information` | Display information about the CodeQL CLI |
93+
| `CodeQL: Install/Update CLI` | ✨ Download and install CodeQL CLI automatically |
9294
| `CodeQL: Copy Flow Path` | Copy vulnerability data flow path to clipboard |
9395
| `CodeQL: Navigate Flow Steps` | Step through vulnerability data flow paths |
9496

@@ -98,10 +100,21 @@ The extension provides several configuration options to customize its behavior:
98100

99101
```json
100102
{
101-
"codeql-scanner.github.token": "your-github-token"
103+
"codeql-scanner.github.token": "your-github-token",
104+
"codeql-scanner.codeqlPath": "codeql",
105+
"codeql-scanner.autoDetectGitHubExtension": true,
106+
"codeql-scanner.autoInstallCodeQL": true,
107+
"codeql-scanner.useLocalScan": true
102108
}
103109
```
104110

111+
### Key Configuration Options
112+
113+
- **`autoDetectGitHubExtension`** (default: `true`): Automatically detect and use CodeQL CLI from GitHub's CodeQL extension if available
114+
- **`autoInstallCodeQL`** (default: `true`): Automatically download and install CodeQL CLI from GitHub if not found
115+
- **`codeqlPath`**: Path to the CodeQL CLI executable (automatically configured when using auto-install)
116+
- **`useLocalScan`** (default: `true`): Use local CodeQL CLI for scanning instead of GitHub Actions
117+
105118
## 💡 Why CodeQL Scanner?
106119

107120
CodeQL is GitHub's semantic code analysis engine that lets you query code as if it were data. This extension brings that power directly into VS Code, allowing you to:

src/services/codeqlService.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,15 @@ export class CodeQLService {
527527
fs.unlinkSync(zipPath);
528528
}
529529
if (fs.existsSync(extractDir)) {
530-
fs.rmSync(extractDir, { recursive: true, force: true });
530+
try {
531+
fs.rmSync(extractDir, { recursive: true, force: true });
532+
} catch {
533+
// Fallback for older Node.js versions
534+
await execAsync(`rm -rf "${extractDir}"`).catch(() => {
535+
// If rm command also fails, just log a warning
536+
this.logger.warn("CodeQLService", `Could not clean up directory: ${extractDir}`);
537+
});
538+
}
531539
}
532540
throw error;
533541
}

0 commit comments

Comments
 (0)