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

Save issued certificates #53

Merged
merged 8 commits into from
Jan 7, 2025
Merged

Save issued certificates #53

merged 8 commits into from
Jan 7, 2025

Conversation

jschlyter
Copy link
Member

@jschlyter jschlyter commented Jan 7, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced node enrollment process with more detailed result information
    • Added support for capturing additional X.509 certificate details (authority and subject key identifiers)
  • Refactor

    • Streamlined import statements across multiple files
    • Updated method signatures to return more comprehensive enrollment results
  • Documentation

    • Improved data structure for node enrollment to provide more context during certificate generation

@jschlyter jschlyter requested a review from a team as a code owner January 7, 2025 07:37
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Warning

Rate limit exceeded

@jschlyter has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d599f6f and 6a9d5d2.

📒 Files selected for processing (3)
  • nodeman/db_models.py (3 hunks)
  • nodeman/nodes.py (2 hunks)
  • nodeman/x509.py (2 hunks)

Walkthrough

This pull request introduces changes to the Nodeman project, primarily focusing on enhancing the node enrollment process. The modifications include updating the return type of enrollment functions from NodeConfiguration to NodeEnrollmentResult, adding new fields to the TapirCertificate class for tracking certificate key identifiers, and making some minor import statement consolidations across multiple files.

Changes

File Change Summary
nodeman/client.py - Added import for NodeEnrollmentResult
- Changed enroll and command_enroll function return types
- Updated return statement to use NodeEnrollmentResult
nodeman/db_models.py - Added authority_key_identifier and subject_key_identifier fields to TapirCertificate
- Introduced get_ext_hex static method for extracting certificate extension values
nodeman/models.py - Reformatted jose module import statements
nodeman/settings.py - Consolidated import statements from pydantic and pydantic_settings modules
tests/test_api.py - Condensed import statements for nodeman.x509 module

Sequence Diagram

sequenceDiagram
    participant Client
    participant EnrollmentService
    participant CertificateManager

    Client->>EnrollmentService: Initiate Enrollment
    EnrollmentService->>CertificateManager: Generate Certificates
    CertificateManager-->>EnrollmentService: Return Enrollment Result
    EnrollmentService-->>Client: Provide NodeEnrollmentResult
Loading

Possibly related PRs

Poem

🐰 A Rabbit's Enrollment Tale 🔐

With certificates shiny and new,
Our node enrollment gets a fresh view
Key identifiers now in sight,
Enrollment process burning bright
A dance of data, smooth and clear! 🚀


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. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@jschlyter
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
nodeman/db_models.py (1)

74-81: Consider adding docstring to get_ext_hex method.

The method implementation is solid with proper error handling and type hints. Consider adding a docstring to explain the purpose and parameters.

    @staticmethod
    def get_ext_hex(x509_certificate: x509.Certificate, oid: ObjectIdentifier) -> str | None:
+        """
+        Extract and hex-encode an X.509 certificate extension.
+        
+        Args:
+            x509_certificate: The certificate to extract from
+            oid: The extension OID to extract
+            
+        Returns:
+            Hex-encoded extension value or None if not found
+        """
        try:
            ext = x509_certificate.extensions.get_extension_for_oid(oid)
            return hexlify(ext.value.public_bytes()).decode()
        except ExtensionNotFound:
            return None
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37f0ced and d599f6f.

📒 Files selected for processing (5)
  • nodeman/client.py (2 hunks)
  • nodeman/db_models.py (3 hunks)
  • nodeman/models.py (1 hunks)
  • nodeman/settings.py (1 hunks)
  • tests/test_api.py (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • tests/test_api.py
  • nodeman/settings.py
  • nodeman/models.py
🔇 Additional comments (4)
nodeman/db_models.py (2)

71-72: LGTM! Good addition of certificate key identifier fields.

The new fields will help track the certificate chain relationships, which is essential for certificate management.


92-93: LGTM! Clean integration of new fields.

The update to from_x509_certificate cleanly integrates the new fields using the get_ext_hex helper method.

nodeman/client.py (2)

56-56: Verify NodeEnrollmentResult model fields.

The function now returns NodeEnrollmentResult instead of NodeConfiguration. Let's verify the model structure to ensure all required fields are handled.

✅ Verification successful

Model structure verification successful

NodeEnrollmentResult properly combines both configuration fields (name, MQTT details, JWKS) and certificate data (X.509 certificates, validity) through inheritance from NodeConfiguration and NodeCertificate. The model is well-structured and type-safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check NodeEnrollmentResult model definition
rg -A 10 "class NodeEnrollmentResult" 

Length of output: 148


Script:

#!/bin/bash
# Check parent class definitions
echo "=== NodeConfiguration ==="
rg -A 10 "class NodeConfiguration"

echo -e "\n=== NodeCertificate ==="
rg -A 10 "class NodeCertificate"

Length of output: 1567


56-56: Verify certificate handling in enrollment flow.

The enrollment flow now saves both the node certificate and CA certificate. Let's verify the certificate handling:

  1. Are certificates properly validated before saving?
  2. Is error handling in place for missing certificates?

Also applies to: 208-211

✅ Verification successful

Certificate handling verification completed successfully.

The enrollment flow implements proper certificate validation and error handling:

  • Certificates are validated before saving (PEM format, chain validation)
  • Comprehensive error handling for invalid certificates
  • CSR validation includes signature verification and subject checks
  • Security measures include fingerprint verification
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check certificate validation and error handling
# Look for certificate validation
rg -A 5 "x509_certificate|x509_ca_certificate"

# Look for related error handling
rg -A 5 "raise|except.*certificate"

Length of output: 28348

@jschlyter jschlyter merged commit f4968d6 into main Jan 7, 2025
4 of 5 checks passed
@jschlyter jschlyter deleted the save_issued_certificates branch January 7, 2025 16:12
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