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

(OraklNode) Vault integration #1499

Merged
merged 1 commit into from
May 20, 2024
Merged

Conversation

nick-bisonai
Copy link
Collaborator

@nick-bisonai nick-bisonai commented May 18, 2024

Description

First tries to load settings from vault, fallbacks to environment variable if not exists in vault. use sync.Once to load vault secrets only once on package load

Vault secrets (OraklNode)

  • KLAYTN_REPORTER_PK
  • SIGNER_PK
  • ETH_REPORTER_PK (but not utilized at the moment)
  • PRIVATE_NETWORK_SECRET
  • ENCRYPT_PASSWORD
  • DATABASE_URL

Vault secrets (POR)

  • POR_REPORTER_PK

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this May 18, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner May 18, 2024 05:14
Copy link
Contributor

coderabbitai bot commented May 18, 2024

Warning

Rate Limit Exceeded

@nick-bisonai has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 50 minutes and 31 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 Files that changed from the base of the PR and between bd902a0 and a26054f.

Walkthrough

The recent updates bolster the node application's security by seamlessly integrating HashiCorp Vault for securely managing secrets. The codebase now utilizes secrets.GetSecret() instead of os.Getenv() to enhance security across database connections, encryption, and network setups.

Changes

Files/Paths Change Summaries
node/.env.example Added new configuration options for Vault integration: VAULT_ADDR, JWT_PATH, VAULT_ROLE, VAULT_SECRET_PATH, VAULT_KEY_NAME.
node/pkg/chain/helper/helper.go Replaced os.Getenv() with secrets.GetSecret() for private key retrieval.
node/pkg/db/pgsql.go Updated to use secrets.GetSecret() for loading PostgreSQL connection string.
node/pkg/libp2p/setup/setup.go Modified to use secrets.GetSecret() for private network secret retrieval.
node/pkg/secrets/secrets.go Added functionality to interact securely with HashiCorp Vault for secret management.
node/pkg/utils/encryptor/encryptor.go Updated to use secrets.GetSecret() for fetching the encryption password.
node/pkg/por/app.go Replaced os.Getenv("POR_REPORTER_PK") with secrets.GetSecret("POR_REPORTER_PK") in function New.

In tunnels deep, where secrets sleep,
A vault now stands, its watch to keep,
With keys and codes in silence steep,
Our data safe, our vigil steep.
🐇🔒✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

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: 4

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 28a2f1e and e732785.
Files selected for processing (6)
  • node/.env.example (2 hunks)
  • node/pkg/chain/helper/helper.go (4 hunks)
  • node/pkg/db/pgsql.go (2 hunks)
  • node/pkg/libp2p/setup/setup.go (2 hunks)
  • node/pkg/secrets/secrets.go (1 hunks)
  • node/pkg/utils/encryptor/encryptor.go (2 hunks)
Additional comments not posted (3)
node/.env.example (1)

16-20: The addition of Vault configuration settings is well-documented and clear.

node/pkg/secrets/secrets.go (1)

65-78: The fallback to environment variables in GetSecret is a good safeguard.

node/pkg/db/pgsql.go (1)

49-49: Centralizing the PostgreSQL connection string retrieval in Vault enhances security.

node/pkg/secrets/secrets.go Outdated Show resolved Hide resolved
node/pkg/utils/encryptor/encryptor.go Show resolved Hide resolved
node/pkg/libp2p/setup/setup.go Show resolved Hide resolved
node/pkg/chain/helper/helper.go Show resolved Hide resolved
@nick-bisonai nick-bisonai requested a review from jo-bisonai May 18, 2024 05:21
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: 2

Out of diff range and nitpick comments (2)
node/pkg/por/app.go (2)

65-65: The use of secrets.GetSecret("POR_REPORTER_PK") for fetching secrets is a secure improvement. Consider adding a comment explaining the necessity of this secret for new developers or maintainers.


65-65: The Run method is well-structured. Consider adding more detailed logging at key operation stages to improve traceability and debugging.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e732785 and a2a0d1c.
Files selected for processing (1)
  • node/pkg/por/app.go (2 hunks)
Additional comments not posted (1)
node/pkg/por/app.go (1)

15-15: The addition of the secrets package aligns with the new feature for secure secret management. Ensure that all necessary configurations for Vault are properly set up in the environment or configuration files.

node/pkg/por/app.go Show resolved Hide resolved
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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between a2a0d1c and bd902a0.
Files selected for processing (1)
  • node/pkg/secrets/secrets.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • node/pkg/secrets/secrets.go

feat: use vault secret from POR

fix: use defined ctx instead of background

fix: minor update

feat: remove sync.Once as init is executed once
@nick-bisonai nick-bisonai force-pushed the feat/orakl-node-use-vault branch from bd902a0 to a26054f Compare May 18, 2024 12:34
Copy link
Member

@jo-bisonai jo-bisonai left a comment

Choose a reason for hiding this comment

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

LGTM!

@Intizar-T
Copy link
Contributor

lgtm! very neat implementation!

@nick-bisonai nick-bisonai merged commit 33276c2 into master May 20, 2024
2 checks passed
@nick-bisonai nick-bisonai deleted the feat/orakl-node-use-vault branch May 20, 2024 04:04
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.

3 participants