Make package publication immutable#4
Conversation
|
@coderabbitai full review |
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe local registry now validates publication coordinates, stages allowed package contents, prevents overwriting published versions, and stores registry entries using cache-derived keys. Registry resolution and documentation reflect the updated layout, including scoped package encoding. ChangesLocal registry publication
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PublishCommand
participant pkg_publish
participant PublishStaging
participant LocalRegistry
PublishCommand->>pkg_publish: publish package name and version
pkg_publish->>pkg_publish: validate publication coordinates
pkg_publish->>PublishStaging: copy allowed package contents
PublishStaging->>LocalRegistry: rename staged version
LocalRegistry-->>pkg_publish: reject existing version
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/pkg.rs`:
- Around line 1500-1501: Update copy_package_for_publish to inspect the manifest
with symlink_metadata before fs::copy and reject it when it is a symlink,
preserving the existing copy error handling for regular files. Add a test
covering a symlinked mako.toml manifest, including the corresponding failure
behavior.
- Around line 1463-1469: Update valid_registry_version to require strict,
canonical SemVer rather than relying solely on parse_semver, rejecting
abbreviated, prefixed, and extra-component forms such as 1, v1.2.3, and 1.2.3.4
while preserving valid canonical versions. Extend the coordinate test covering
this validation to assert these rejected cases.
In `@src/tooling.rs`:
- Around line 2455-2457: Validate registry names with valid_registry_name before
deriving cache keys or performing lookups. In src/tooling.rs lines 2455-2457,
reject invalid name values before registry_root and dep_cache_key; apply the
same validation to the effective/external registry lookup in src/pkg.rs lines
552-553, and ensure only the validated name reaches the project dependency cache
path in src/pkg.rs lines 719-722.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8aec9acf-cbd9-4733-b030-43da71b20885
📒 Files selected for processing (6)
docs/CLI.mddocs/GUIDE.mddocs/book/src/ch10-packages.mdsrc/main.rssrc/pkg.rssrc/tooling.rs
| fn copy_package_for_publish(project: &Path, manifest: &Path, dest: &Path) -> Result<(), String> { | ||
| fs::copy(manifest, dest.join("mako.toml")).map_err(|e| format!("copy toml: {e}"))?; |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Reject a symlinked mako.toml before copying it.
The manifest is copied directly with fs::copy, which follows symlinks, whereas the test only covers links inside src/. Check symlink_metadata(manifest) before copying and add a manifest-symlink case.
Proposed fix
fn copy_package_for_publish(project: &Path, manifest: &Path, dest: &Path) -> Result<(), String> {
+ let manifest_kind = fs::symlink_metadata(manifest)
+ .map_err(|e| format!("inspect {}: {e}", manifest.display()))?;
+ if manifest_kind.file_type().is_symlink() {
+ return Err(format!("refusing to publish symlink {}", manifest.display()));
+ }
fs::copy(manifest, dest.join("mako.toml")).map_err(|e| format!("copy toml: {e}"))?;Also applies to: 2305-2335
🤖 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/pkg.rs` around lines 1500 - 1501, Update copy_package_for_publish to
inspect the manifest with symlink_metadata before fs::copy and reject it when it
is a symlink, preserving the existing copy error handling for regular files. Add
a test covering a symlinked mako.toml manifest, including the corresponding
failure behavior.
Published versions could previously be replaced in place. This rejects republishing the same name and version, stages package contents before an atomic rename, validates registry coordinates, isolates scoped package names, and rejects symlinked sources. Tests: cargo test --bin mako passes.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation