You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): reject flags as ca-cert path argument - #1490
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Improved validation for config set ca-cert: missing, empty, or flag-like paths now produce a clear required-path error instead of being saved.
Dash-prefixed relative paths are accepted when written with a ./ prefix, and invalid input no longer writes to the configuration file.
config set ca-cert now rejects missing, empty, or flag-prefixed paths with a required-path error. A dash-prefixed relative filename such as ./-cert.pem remains accepted.
Changes: CA certificate path validation
Layer / File(s)
Summary
Validate config set CA certificate paths src/cli/args.ts, tests/cli/config-command.test.ts, tests/e2e/commands-and-exit-codes.test.ts
The parser uses requireFlagValue to validate the CA certificate path. Parser tests cover valid paths and missing, empty, or flag-prefixed values. End-to-end tests verify error output, exit status, config-file behavior, and saving a valid dash-prefixed relative path.
OWASP/cve-lite-cli#1417: Both changes validate CA certificate paths with requireFlagValue in separate command paths.
Merge Risk: Minimal · up to a4a17
The change prevents flags from being saved as certificate paths while preserving valid paths such as ./-cert.pem. No actionable merge-blocking risk remains; test execution was not independently verified.
Pre-merge checks: 7
Check name
Status
Explanation
Title check
I think this title is a pass. It follows the type: description form with the allowed fix type, and it is lowercase with no trailing period. It names the change: the CLI now rejects flags as the ca-cer…
Description check
The description covers the summary of the change, the reason for it, and the testing done. It links the issue, which closes #1479, and the template only needs a brief description with a Closes line. T…
Linked Issues check
For users, cve-lite config set ca-cert --json now fails. It exits with status 1 and prints cve-lite config set ca-cert requires a path argument. Before this change, the parser accepted --json as…
Out of Scope Changes check
The whole-PR diff against the merge base changes three files: src/cli/args.ts, tests/cli/config-command.test.ts, and tests/e2e/commands-and-exit-codes.test.ts.
In src/cli/args.ts, the diff at…
Linked Issue
The pull request body references GitHub issue #1479 with the supported keyword “Closes #1479”.
Closes Keyword Matches Scope
The body uses Closes #1479. That issue asks config set ca-cert to reject missing, empty, and flag-like certificate paths, including --json. The changed parser now uses requireFlagValue, which …
No New Runtime Dependency
The pull request changes only src/cli/args.ts and two test files. It does not modify package.json. The base and head dependency sections are identical, so no new runtime dependency or dev-to-runti…
Full details: Title check
Explanation
I think this title is a pass. It follows the type: description form with the allowed fix type, and it is lowercase with no trailing period. It names the change: the CLI now rejects flags as the ca-cert path argument. This matches the summary, which shows requireFlagValue now guards the ca-cert value in config set.
Full details: Description check
Explanation
The description covers the summary of the change, the reason for it, and the testing done. It links the issue, which closes #1479, and the template only needs a brief description with a Closes line. The description meets the template. It explains the change in plain terms: the config set ca-cert command no longer takes a flag as a certificate path. It also lists the unit and E2E tests added and the checks run.
Full details: Linked Issues check
Explanation
For users, cve-lite config set ca-cert --json now fails. It exits with status 1 and prints cve-lite config set ca-cert requires a path argument. Before this change, the parser accepted --json as the certificate path. [#1479] asks the parser to reject a path argument that is empty or starts with -.
Implementation at the reviewed head: In src/cli/args.ts, the config set branch checks the key first. It then calls requireFlagValue("cve-lite config set ca-cert", argv[3], "path"). The helper throws when the value is undefined, empty, or starts with -. The old if (!value) check rejected undefined and empty values, but it accepted flag-like values. That gap was the reported defect. The issue text says empty values are not rejected. The original code already rejected the empty string, so the flag-like case is the real gap, and the change covers both.
Tests: The change summary for tests/cli/config-command.test.ts says it covers valid paths, missing paths, empty paths, and flag-like values. The change summary for tests/e2e/commands-and-exit-codes.test.ts says it covers a flag used as the path, a missing path, and a valid dash-prefixed relative path (./-cert.pem). I could not read these test blobs at the reviewed head in this review, because the changed blobs are missing from the checkout. The test coverage therefore rests on the change summary and the previous assessment. The author reports that npm test passed with 201 suites and 3047 tests. I did not run the tests.
No unmet coding requirement was found.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base changes three files: src/cli/args.ts, tests/cli/config-command.test.ts, and tests/e2e/commands-and-exit-codes.test.ts.
In src/cli/args.ts, the diff at the reviewed head is one hunk in the config set branch. It moves the const value = argv[3]; read to the line that calls requireFlagValue, removes the old falsy check and its throw, and adds the requireFlagValue call. The key check still runs before the value check, so the behavior for valid keys does not change. The line count (+1/-4) matches the change summary. This edit directly implements [#1479].
The test changes cover only config set ca-cert path parsing and its E2E output. The summaries show no unrelated code. I could not read the test diffs in this review, so that conclusion rests on the change summaries and the previous assessment.
No unrelated change was demonstrated.
Full details: Closes Keyword Matches Scope
Explanation
The body uses Closes #1479. That issue asks config set ca-cert to reject missing, empty, and flag-like certificate paths, including --json. The changed parser now uses requireFlagValue, which rejects all three cases. The added unit and E2E tests cover these cases and confirm the required error and exit status. The PR also preserves valid paths such as ./-cert.pem.
Full details: No New Runtime Dependency
Explanation
The pull request changes only src/cli/args.ts and two test files. It does not modify package.json. The base and head dependency sections are identical, so no new runtime dependency or dev-to-runtime move was introduced.
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between af6a2a0 and a4a1789.
Files selected for processing: 2
tests/cli/config-command.test.ts
tests/e2e/commands-and-exit-codes.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ZiadEwis, and welcome. Reusing the shared helper was the right call: --json, a missing value, an empty value and -cert.pem all stop with the existing requires a path argument message and nothing is saved, while a path with spaces, a relative path and ./-cert.pem still save fine. Putting the old check back fails exactly your two new tests. Approved.
One optional thing, no need to hold it for this: could the two new e2e tests pass { env: { HOME: scratch() } } like the round-trip test above them, and assert that .cve-lite-cli/config.json was not created? That pins the "nothing saved on rejection" half, and keeps a future regression from writing a real user's config during the test run.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for isolating HOME and checking that nothing gets saved, that was exactly the gap. The relative-path case is a nice addition too. Approved. I merge these one at a time rather than in a batch, so it will land shortly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where
cve-lite config set ca-cert --jsonincorrectly accepts a CLI flag as a certificate path.requireFlagValuehelper to reject missing, empty, and flag-like path arguments.Testing
npm run lint:testsnpm run buildnode dist/index.js advisories syncnpm test— 201 test suites passed, 3047 tests passed.node scripts/typecheck-changed-tests.mjs upstream/mainCloses #1479