feat: add ek scan#72
Conversation
WalkthroughThis PR adds a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/betterleaks.ts`:
- Around line 80-82: Replace the two execSync(...) invocations with
execFileSync('tar', args, { stdio: "pipe" }) to avoid shell interpolation; for
the non-gzip branch use args = ['-xf', archivePath, '-C', tmpDir] and for the
gzip branch use args = ['-xzf', archivePath, '-C', tmpDir], keeping the same
stdio option and any existing error handling around those calls (referencing the
existing execSync calls and the archivePath/tmpDir variables).
- Around line 76-93: Update BETTERLEAKS_VERSION to "v1.2.0" and add checksum
verification for the downloaded archive before extracting and installing: after
building downloadUrl and saving to archivePath (symbols: downloadUrl,
archivePath) fetch or construct the expected checksum for that release (from the
release checksum file or hardcoded map for v1.2.0), compute the archive's digest
(e.g., SHA-256) and compare it to the expected value; if the checksum does not
match, throw CLIError.from("SCAN_INSTALL_FAILED") and abort; only proceed to
extract (tar commands referencing tmpDir and BINARY_NAME) and copy to
LOCAL_BINARY_PATH/INSTALL_DIR and chmod when verification passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 98f50ed3-6214-4b56-a41b-7c225f4250ca
📒 Files selected for processing (10)
package.jsonsrc/cli.tssrc/cmd/index.tssrc/cmd/scan.tssrc/lib/analytics.tssrc/lib/betterleaks.tssrc/lib/config.tssrc/lib/errors.tssrc/ui/ScanReport.tsxsrc/ui/Spinner.tsx
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/lib/betterleaks.ts (1)
76-82:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winVerify the archive before extracting it.
This block still installs a network-fetched executable without checking its digest first. If the release asset is ever tampered with, the CLI will persist and later run that binary locally. Please fail closed on a checksum/signature mismatch before either
tarinvocation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/betterleaks.ts` around lines 76 - 82, Download currently writes the asset to archivePath and extracts it with execFileSync without verifying integrity; add a checksum/signature verification step before either tar invocation. After receiving the response (the axios.get into response/data and before fs.writeFileSync or immediately after), compute the archive digest (e.g. crypto.createHash('sha256') over the Buffer from response.data or the saved file) and compare it to the expected checksum/signature fetched from the release metadata or a detached signature; if the check fails, delete archivePath, throw an error and do not call execFileSync("tar", ...) — only proceed to extract (for both the .zip and non-.zip branches) when the digest/signature verification succeeds. Ensure error messages reference archivePath and the expected vs actual digest for diagnostics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@src/lib/betterleaks.ts`:
- Around line 76-82: Download currently writes the asset to archivePath and
extracts it with execFileSync without verifying integrity; add a
checksum/signature verification step before either tar invocation. After
receiving the response (the axios.get into response/data and before
fs.writeFileSync or immediately after), compute the archive digest (e.g.
crypto.createHash('sha256') over the Buffer from response.data or the saved
file) and compare it to the expected checksum/signature fetched from the release
metadata or a detached signature; if the check fails, delete archivePath, throw
an error and do not call execFileSync("tar", ...) — only proceed to extract (for
both the .zip and non-.zip branches) when the digest/signature verification
succeeds. Ensure error messages reference archivePath and the expected vs actual
digest for diagnostics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 30c86150-3db7-4700-9052-d6495f3ceeee
📒 Files selected for processing (1)
src/lib/betterleaks.ts
Summary by CodeRabbit