Skip to content
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

fix(signer): resolve keystore path before retrieving private key #3076

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bengineer42
Copy link
Contributor

@bengineer42 bengineer42 commented Feb 28, 2025

Description

Added support for ~ in keystore paths

Related issue

Tests

Not sure how to test this as its local file system dependent

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

Summary by CodeRabbit

This update improves system stability and reliability without altering user-facing functionality.

  • Chores

    • Streamlined dependency configurations and standardized formatting to ensure consistent performance and smoother maintenance across the application.
  • Bug Fixes

    • Enhanced secure key access by ensuring storage locations are determined correctly, resulting in improved reliability when retrieving secure credentials.

Copy link

coderabbitai bot commented Feb 28, 2025

Ohayo sensei!

Walkthrough

This pull request updates the dependency configuration and path resolution for the Sozo binary. In the Cargo.toml, a new dependency (resolve-path version "0.1.0") is added, the tabled dependency is reintroduced, and the sozo-walnut dependency is repositioned along with formatting adjustments for several dependencies and feature definitions. In addition, the signer command now resolves keystore paths to their absolute forms prior to key retrieval in both CLI and environment-based methods.

Changes

File Path Changes Summary
bin/sozo/Cargo.toml Added resolve-path = "0.1.0"; reintroduced tabled = { version = "0.16.0", features = ["ansi"] }; moved sozo-walnut dependency; updated formatting for reqwest, dojo-test-utils, and feature lists.
bin/sozo/src/commands/options/signer.rs Modified private_key_from_keystore_cli and private_key_from_keystore_env methods to resolve the keystore path using Path::new(path).resolve() before key retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SignerOptions
    participant PathResolver as Path::resolve
    participant SigningKey

    User->>SignerOptions: Call private_key_from_keystore_cli(path)
    SignerOptions->>PathResolver: Resolve relative path
    PathResolver-->>SignerOptions: Return absolute path
    SignerOptions->>SigningKey: Call from_keystore(absolute path)
    SigningKey-->>SignerOptions: Return private key
Loading

Possibly related PRs

Suggested reviewers

  • glihm

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60e0a6b and 05201ee.

📒 Files selected for processing (2)
  • bin/sozo/Cargo.toml (2 hunks)
  • bin/sozo/src/commands/options/signer.rs (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • bin/sozo/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt
🔇 Additional comments (4)
bin/sozo/src/commands/options/signer.rs (4)

1-1: Added imports for path resolution support.

Ohayo! Noticed you've added these imports for the new path resolution functionality. The added PathResolveExt trait will allow for resolving file paths with tilde notation correctly. This looks good!

Also applies to: 11-11


98-98: Path resolution added to keystore CLI handling.

Nice work, sensei! You've enhanced the keystore path handling by resolving the path before retrieving the private key. This will properly expand the tilde (~) in paths to the user's home directory, making the CLI more intuitive for users.


121-121: Path resolution added to keystore ENV handling.

Consistently applied the same path resolution technique to the environment-based keystore path handling. Great consistency, sensei!


213-302:

❓ Verification inconclusive

Consider adding tests for path resolution.

Ohayo! The path resolution functionality looks solid, but there aren't any tests specifically for the tilde expansion behavior. While testing filesystem-dependent code can be challenging, it might be worth adding a test case that mocks the path resolution to verify this behavior.


🏁 Script executed:

#!/bin/bash
# Check if the resolve-path dependency is correctly handling tilde expansion

# Display the version of resolve-path being used
cargo tree | grep resolve-path

# Check if there are examples or documentation for how tilde expansion is handled
cargo doc --open resolve-path || echo "Documentation not available"

# Find any usage examples in the codebase
rg -A 3 "PathResolveExt" --type rust

Length of output: 655


Ohayo, sensei! The path resolution in our signer command looks solid, but I noticed we're missing explicit tests for tilde expansion behavior. While the current implementation is robust, it's a good idea to add a test case (possibly using a mocked home directory) to verify that tilde paths are correctly resolved. This would ensure that our file path handling works as expected even when users supply paths with a tilde.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.40%. Comparing base (60e0a6b) to head (05201ee).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3076   +/-   ##
=======================================
  Coverage   57.39%   57.40%           
=======================================
  Files         440      440           
  Lines       59963    59963           
=======================================
+ Hits        34417    34419    +2     
+ Misses      25546    25544    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant