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/audit #93

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Fix/audit #93

merged 3 commits into from
Nov 8, 2024

Conversation

joon9823
Copy link
Collaborator

@joon9823 joon9823 commented Nov 8, 2024

  • update dependencies to the latest versions
  • add validateEndpoint method to block side effects (relative paths, query params)

Summary by CodeRabbit

  • New Features

    • Introduced a new dependency for enhanced cryptographic functionality.
    • Improved validation for API endpoint inputs to prevent malformed requests.
  • Bug Fixes

    • Enhanced error handling for API requests by validating endpoint strings.
  • Refactor

    • Streamlined imports and usage of the bip39 library for mnemonic generation and seed conversion.
    • Adjusted constructor logic in the MnemonicKey class for proper private key formatting.

@joon9823 joon9823 requested a review from Vritra4 November 8, 2024 06:41
Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

The pull request introduces several updates primarily focused on the package.json file, where a new dependency @bitcoinerlab/secp256k1 is added, and multiple existing dependencies are updated to newer versions. Additionally, the APIRequester class in src/client/rest/APIRequester.ts gains a new private method for endpoint validation, enhancing error handling for API requests. The MnemonicKey class in src/key/MnemonicKey.ts is also modified to incorporate the new elliptic curve library and streamline the usage of the bip39 library, improving code clarity and modularity.

Changes

File Change Summary
package.json - Added dependency: @bitcoinerlab/secp256k1 version ^1.1.1
- Updated dependencies: @ledgerhq/hw-transport to ^6.31.4, @ledgerhq/hw-transport-webhid to ^6.29.4, @ledgerhq/hw-transport-webusb to ^6.29.4, @mysten/bcs to ^1.1.0, axios to ^1.7.7, bignumber.js to ^9.1.2, bip32 to ^5.0.0-rc.0, bip39 to ^3.1.0, secp256k1 to ^5.0.1, and ws to ^8.18.0.
src/client/rest/APIRequester.ts - Added private method: validateEndpoint(endpoint: string) for endpoint validation in APIRequester class.
src/key/MnemonicKey.ts - Updated imports to use ecc from @bitcoinerlab/secp256k1 and BIP32Factory from bip32.
- Changed mnemonic generation and seed conversion methods to streamline bip39 usage.
- Modified super call to wrap privateKey in a Buffer.

Possibly related PRs

  • Add eth option for mnemonic and raw key #90: The changes in this PR involve modifications to the MnemonicKey class in src/key/MnemonicKey.ts, which is relevant because the main PR also includes updates to this file, specifically related to the handling of dependencies and the integration of the @bitcoinerlab/secp256k1 library.

Suggested reviewers

  • ALPAC-4

Poem

In the code where bunnies hop,
Dependencies grow, they never stop.
With endpoints checked, and keys so bright,
Our API dances in the light.
New libraries join the playful fray,
Hooray for changes, hip-hip-hooray! 🐇✨


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

Copy link

github-actions bot commented Nov 8, 2024

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 2 package(s) with unknown licenses.
See the Details below.

License Issues

package.json

PackageVersionLicenseIssue Type
@bitcoinerlab/secp256k1^1.1.1NullUnknown License
secp256k1^5.0.1NullUnknown License
Denied Licenses: GPL-1.0-or-later, LGPL-2.0-or-later

OpenSSF Scorecard

Scorecard details
PackageVersionScoreDetails
npm/@bitcoinerlab/secp256k1 1.1.1 UnknownUnknown
npm/@ledgerhq/devices 8.4.4 UnknownUnknown
npm/@ledgerhq/errors 6.19.1 UnknownUnknown
npm/@ledgerhq/hw-transport 6.31.4 UnknownUnknown
npm/@ledgerhq/hw-transport-webhid 6.29.4 UnknownUnknown
npm/@ledgerhq/hw-transport-webusb 6.29.4 UnknownUnknown
npm/@ledgerhq/logs 6.12.0 UnknownUnknown
npm/@mysten/bcs 1.1.0 UnknownUnknown
npm/@noble/hashes 1.5.0 UnknownUnknown
npm/@noble/secp256k1 1.7.1 🟢 5.5
Details
CheckScoreReason
Code-Review⚠️ 0Found 2/29 approved changesets -- score normalized to 0
Maintained⚠️ 21 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 2
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ 0Project has not signed or included provenance with any releases.
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Security-Policy🟢 10security policy file detected
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 6dependency not pinned by hash detected -- score normalized to 6
Fuzzing🟢 10project is fuzzed
Packaging🟢 10packaging workflow detected
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 100 existing vulnerabilities detected
npm/@scure/base 1.1.9 UnknownUnknown
npm/axios 1.7.7 🟢 5.8
Details
CheckScoreReason
Code-Review🟢 5Found 12/21 approved changesets -- score normalized to 5
Maintained🟢 1030 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
Security-Policy🟢 10security policy file detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Binary-Artifacts🟢 10no binaries found in the repo
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Fuzzing⚠️ 0project is not fuzzed
SAST🟢 9SAST tool detected but not run on all commits
Vulnerabilities⚠️ 038 existing vulnerabilities detected
npm/base-x 5.0.0 🟢 4.1
Details
CheckScoreReason
Code-Review🟢 5Found 6/12 approved changesets -- score normalized to 5
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Packaging⚠️ -1packaging workflow not detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 100 existing vulnerabilities detected
npm/bignumber.js 9.1.2 🟢 3.7
Details
CheckScoreReason
Code-Review⚠️ 2Found 7/30 approved changesets -- score normalized to 2
Maintained🟢 43 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 4
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow⚠️ -1no workflows found
Token-Permissions⚠️ -1No tokens found
Packaging⚠️ -1packaging workflow not detected
Binary-Artifacts🟢 9binaries present in source code
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Security-Policy⚠️ 0security policy file not detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Pinned-Dependencies⚠️ -1no dependencies found
Fuzzing⚠️ 0project is not fuzzed
npm/bip32 5.0.0-rc.0 🟢 4.9
Details
CheckScoreReason
Code-Review🟢 5Found 5/10 approved changesets -- score normalized to 5
Maintained🟢 1014 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
npm/bip39 3.1.0 🟢 5.7
Details
CheckScoreReason
Code-Review🟢 4Found 3/7 approved changesets -- score normalized to 4
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Pinned-Dependencies🟢 10all dependencies are pinned
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 82 existing vulnerabilities detected
npm/bs58 6.0.0 🟢 4.1
Details
CheckScoreReason
Code-Review🟢 6Found 10/15 approved changesets -- score normalized to 6
Maintained⚠️ 00 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Packaging⚠️ -1packaging workflow not detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Fuzzing⚠️ 0project is not fuzzed
Security-Policy⚠️ 0security policy file not detected
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
npm/bs58check 4.0.0 🟢 5.3
Details
CheckScoreReason
Code-Review🟢 4Found 2/5 approved changesets -- score normalized to 4
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Fuzzing⚠️ 0project is not fuzzed
Security-Policy⚠️ 0security policy file not detected
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
npm/rxjs 7.8.1 🟢 6.5
Details
CheckScoreReason
Code-Review🟢 9GitHub code reviews found for 29 commits out of the last 30 -- score normalized to 9
Maintained🟢 108 commit(s) out of 30 and 8 issue activity out of 30 found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no badge detected
Vulnerabilities🟢 10no vulnerabilities detected
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 3branch protection is not maximal on development and all release branches
Packaging⚠️ -1no published package detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0non read-only tokens detected in GitHub workflows
License🟢 10license file detected
Security-Policy⚠️ 0security policy file not detected
Binary-Artifacts🟢 10no binaries found in the repo
Fuzzing⚠️ 0project is not fuzzed
Dependency-Update-Tool🟢 10update tool detected
Pinned-Dependencies🟢 5dependency not pinned by hash detected -- score normalized to 5
npm/tslib 2.7.0 🟢 5.5
Details
CheckScoreReason
Maintained⚠️ 00 commit(s) out of 30 and 1 issue activity out of 30 found in the last 90 days -- score normalized to 0
Code-Review🟢 7GitHub code reviews found for 23 commits out of the last 30 -- score normalized to 7
CII-Best-Practices⚠️ 0no badge detected
Vulnerabilities🟢 10no vulnerabilities detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1no published package detected
Token-Permissions⚠️ 0non read-only tokens detected in GitHub workflows
License🟢 10license file detected
Binary-Artifacts🟢 10no binaries found in the repo
Pinned-Dependencies🟢 9dependency not pinned by hash detected -- score normalized to 9
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 10security policy file detected
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Dependency-Update-Tool⚠️ 0no update tool detected
Fuzzing⚠️ -1internal error: internal error: Client.Search.Code: Search.Code: GET https://api.github.com/search/code?q=github.com+microsoft+tslib+repo%3Agoogle%2Foss-fuzz+in%3Afile+filename%3Aproject.yaml: 400 []
npm/typescript 5.5.3 🟢 8.7
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
CI-Tests🟢 1030 out of 30 merged PRs checked by a CI test -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Code-Review🟢 10all changesets reviewed
Contributors🟢 10project has 35 contributing companies or organizations
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Dependency-Update-Tool🟢 10update tool detected
Fuzzing🟢 10project is fuzzed
License🟢 10license file detected
Maintained🟢 1030 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Packaging⚠️ -1packaging workflow not detected
Pinned-Dependencies🟢 6dependency not pinned by hash detected -- score normalized to 6
SAST🟢 10SAST tool is run on all commits
Security-Policy🟢 10security policy file detected
Signed-Releases⚠️ 0Project has not signed or included provenance with any releases.
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Vulnerabilities🟢 100 existing vulnerabilities detected
npm/uint8array-tools 0.0.8 UnknownUnknown
npm/valibot 0.37.0 UnknownUnknown
npm/wif 5.0.0 🟢 4.4
Details
CheckScoreReason
Code-Review🟢 5Found 3/6 approved changesets -- score normalized to 5
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Packaging⚠️ -1packaging workflow not detected
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
npm/ws 8.18.0 🟢 6.1
Details
CheckScoreReason
Code-Review⚠️ 2Found 7/30 approved changesets -- score normalized to 2
Maintained🟢 101 commit(s) and 12 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Packaging⚠️ -1packaging workflow not detected
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Vulnerabilities🟢 100 existing vulnerabilities detected
Signed-Releases⚠️ -1no releases found
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
npm/@bitcoinerlab/secp256k1 ^1.1.1 UnknownUnknown
npm/@ledgerhq/hw-transport ^6.31.4 UnknownUnknown
npm/@ledgerhq/hw-transport-webhid ^6.29.4 UnknownUnknown
npm/@ledgerhq/hw-transport-webusb ^6.29.4 UnknownUnknown
npm/@mysten/bcs ^1.1.0 UnknownUnknown
npm/axios ^1.7.7 🟢 5.8
Details
CheckScoreReason
Code-Review🟢 5Found 12/21 approved changesets -- score normalized to 5
Maintained🟢 1030 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
Security-Policy🟢 10security policy file detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Binary-Artifacts🟢 10no binaries found in the repo
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Fuzzing⚠️ 0project is not fuzzed
SAST🟢 9SAST tool detected but not run on all commits
Vulnerabilities⚠️ 038 existing vulnerabilities detected
npm/bignumber.js ^9.1.2 🟢 3.7
Details
CheckScoreReason
Code-Review⚠️ 2Found 7/30 approved changesets -- score normalized to 2
Maintained🟢 43 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 4
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow⚠️ -1no workflows found
Token-Permissions⚠️ -1No tokens found
Packaging⚠️ -1packaging workflow not detected
Binary-Artifacts🟢 9binaries present in source code
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Security-Policy⚠️ 0security policy file not detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Pinned-Dependencies⚠️ -1no dependencies found
Fuzzing⚠️ 0project is not fuzzed
npm/bip32 ^5.0.0-rc.0 🟢 4.9
Details
CheckScoreReason
Code-Review🟢 5Found 5/10 approved changesets -- score normalized to 5
Maintained🟢 1014 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
npm/bip39 ^3.1.0 🟢 5.7
Details
CheckScoreReason
Code-Review🟢 4Found 3/7 approved changesets -- score normalized to 4
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Pinned-Dependencies🟢 10all dependencies are pinned
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Security-Policy⚠️ 0security policy file not detected
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 82 existing vulnerabilities detected
npm/secp256k1 ^5.0.1 🟢 4.1
Details
CheckScoreReason
Maintained⚠️ 23 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Code-Review⚠️ 1Found 3/30 approved changesets -- score normalized to 1
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 9license file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Signed-Releases⚠️ -1no releases found
Security-Policy⚠️ 0security policy file not detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
npm/ws ^8.18.0 🟢 6.1
Details
CheckScoreReason
Code-Review⚠️ 2Found 7/30 approved changesets -- score normalized to 2
Maintained🟢 101 commit(s) and 12 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Packaging⚠️ -1packaging workflow not detected
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Vulnerabilities🟢 100 existing vulnerabilities detected
Signed-Releases⚠️ -1no releases found
Fuzzing⚠️ 0project is not fuzzed
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • package-lock.json
  • package.json

Copy link
Contributor

@Vritra4 Vritra4 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@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

🧹 Outside diff range and nitpick comments (1)
src/client/rest/APIRequester.ts (1)

67-67: LGTM! Consider enhancing error handling.

The validation is well-integrated across all HTTP methods, maintaining a clean separation of concerns. The validation occurs at the right point in the execution flow - before URL computation.

Consider wrapping the validation errors to provide more context:

-    this.validateEndpoint(endpoint)
+    try {
+      this.validateEndpoint(endpoint)
+    } catch (error) {
+      throw new Error(`Invalid endpoint "${endpoint}": ${error.message}`)
+    }

Also applies to: 77-77, 83-83

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7e39759 and 87eb5d4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/client/rest/APIRequester.ts (3 hunks)
  • src/key/MnemonicKey.ts (3 hunks)
🔇 Additional comments (9)
package.json (4)

65-66: LGTM: Minor version updates look safe.

The following updates appear to be backward compatible:

  • @mysten/bcs: ^1.0.2 → ^1.1.0
  • axios: ^1.7.4 → ^1.7.7
  • bignumber.js: ^9.1.0 → ^9.1.2

Also applies to: 68-68, 76-76


62-64: Review security implications of crypto-related updates.

Several security-critical dependencies have been updated:

  • Ledger transport libraries
  • BIP32/39 for key derivation
  • secp256k1 for cryptographic operations

Please ensure:

  1. All changes have been thoroughly tested with existing key derivation and signing operations
  2. No breaking changes in the cryptographic implementations
#!/bin/bash
# Look for cryptographic operations that might be affected
echo "Checking crypto-related code..."
rg -l "createHash|sign|verify|derive|generateMnemonic"

Also applies to: 69-70, 74-74


76-76: Review ws v8 breaking changes.

The update from [email protected] to [email protected] includes breaking changes. Please verify that the codebase has been adapted to handle:

  • Removed legacy WebSocket support
  • Changes in error handling
  • Stricter input validation
#!/bin/bash
# Search for WebSocket usage patterns that might be affected
echo "Checking WebSocket usage patterns..."
rg -A 5 "new WebSocket|require\(['\"]ws['\"]\)"

59-59: Verify the need for two secp256k1 libraries.

The addition of @bitcoinerlab/secp256k1 alongside the existing secp256k1 package might lead to unnecessary duplication. Consider using only one implementation to maintain consistency and reduce bundle size.

Also applies to: 74-74

✅ Verification successful

Both secp256k1 implementations are actively used for different purposes

The codebase shows distinct usage patterns for both secp256k1 implementations:

  • secp256k1 (v5.0.1) is used in RawKey.ts for basic cryptographic operations (key creation, signing)
  • @bitcoinerlab/secp256k1 (v1.1.1) is used in MnemonicKey.ts specifically for BIP32 key derivation alongside bip32 package

Both libraries serve different purposes and are correctly integrated into their respective use cases. The duplication is intentional and necessary.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if both secp256k1 implementations are actually used
echo "Checking usage of secp256k1 implementations..."
rg -l "from ['\"](secp256k1|@bitcoinerlab\/secp256k1)['\"]" 

Length of output: 4409


Script:

#!/bin/bash
# Search for imports of both secp256k1 libraries with context
echo "Searching for secp256k1 imports..."
rg -A 2 "import.*['\"](@bitcoinerlab\/secp256k1|secp256k1)['\"]"

# Search for requires of both secp256k1 libraries with context
echo "Searching for secp256k1 requires..."
rg -A 2 "require\(['\"](@bitcoinerlab\/secp256k1|secp256k1)['\"]\)"

# Search for direct string mentions of both libraries
echo "Searching for direct mentions..."
rg "(@bitcoinerlab\/secp256k1|secp256k1)" --type ts --type js

Length of output: 854


Script:

#!/bin/bash
# Search for secp256k1 imports and requires with fixed regex
echo "Searching for secp256k1 usage..."
rg -A 2 "secp256k1"

# Search specifically for bitcoinerlab mentions
echo "Searching for bitcoinerlab mentions..."
rg -A 2 "bitcoinerlab"

# Check package.json for both dependencies
echo "Checking package.json for secp256k1 dependencies..."
cat package.json | grep -A 1 -B 1 "secp256k1"

Length of output: 12734

src/key/MnemonicKey.ts (4)

83-83: LGTM: Maintained strong entropy for mnemonic generation

The code maintains 256-bit entropy for mnemonic generation, providing maximum security (24 words) while simplifying the implementation.


Line range hint 85-91: LGTM: Standard-compliant seed and key derivation

The implementation follows BIP39/BIP44 standards for seed generation and HD wallet derivation. The derivation path m/44'/${coinType}'/${account}'/0/${index} is correctly structured.


95-97: Verify secure memory handling of private keys

While the Buffer wrapping ensures consistent private key handling, consider implementing secure memory handling practices for sensitive cryptographic material.

Consider these security enhancements:

  1. Implement secure memory wiping after key usage
  2. Use a secure Buffer implementation that automatically zeros memory when garbage collected

Let's verify if there are any memory-related security measures in place:

#!/bin/bash
# Check for secure memory handling patterns in the codebase
rg -A 3 'Buffer\.alloc|\.fill\(0\)|\.destroy|secureBuffer|zeroize'

1-6: LGTM: Improved modularity in cryptographic dependencies

The switch to @bitcoinerlab/secp256k1 and BIP32Factory pattern provides better control over the elliptic curve implementation. This is a good architectural improvement.

Let's verify the dependency versions for security:

✅ Verification successful

Let me try another search to find the package.json dependencies:


Dependencies verified and secure

The cryptographic dependencies are using recent and secure versions:

  • @bitcoinerlab/secp256k1: 1.1.1
  • bip32: 5.0.0-rc.0 (Release Candidate)
  • bip39: 3.1.0

These versions are up-to-date and maintained. The modular approach with BIP32Factory pattern is correctly implemented with the appropriate dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check package.json for crypto-related dependency versions
rg -A 1 '"@bitcoinerlab/secp256k1"|"bip32"|"bip39"' package.json

Length of output: 1099


Script:

#!/bin/bash
# Try finding package.json in the root or common locations
fd package.json --type f --exec cat {}

Length of output: 2242

src/client/rest/APIRequester.ts (1)

Line range hint 43-85: Verify existing endpoint usage patterns.

Let's ensure these changes don't break existing endpoint usage patterns.

✅ Verification successful

Let me try another verification approach with corrected regex patterns:

This script will help us:

  1. See actual endpoint usage patterns in API calls
  2. Find endpoint/route definitions to analyze their patterns
  3. Get better context about how endpoints are structured in the codebase

The multiline search will show us the actual endpoint strings being used, which will help verify if the new validation rules align with existing usage patterns.


Let me try one final verification with simpler patterns:

This simpler approach should help us see:

  1. How get/post methods are actually being called
  2. Any endpoint/path/route constants defined in the codebase
  3. Whether the new validation aligns with existing patterns

New endpoint validation rules are safe to implement

Based on the verification results:

  • All observed API endpoints use absolute paths (e.g., '/foo')
  • No instances of relative paths (../) in endpoint strings
  • No query parameters in endpoint strings (they are properly passed via the params argument)
  • The test file APIRequester.spec.ts follows the same pattern

The new validation rules align perfectly with existing usage patterns in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential breaking changes in endpoint usage

# Test 1: Check for relative paths in endpoint strings
echo "Checking for relative paths in endpoints..."
rg -l "\.get\(['\"](.*\.\.\/.*)['\"]" || echo "No relative paths found in .get calls"
rg -l "\.post\(['\"](.*\.\.\/.*)['\"]" || echo "No relative paths found in .post calls"

# Test 2: Check for query parameters in endpoint strings
echo -e "\nChecking for query parameters in endpoints..."
rg -l "\.get\(['\"](.*\?.*)['\"]" || echo "No query parameters found in .get calls"
rg -l "\.post\(['\"](.*\?.*)['\"]" || echo "No query parameters found in .post calls"

Length of output: 951


Script:

#!/bin/bash
# Search for endpoint usage patterns in API calls

echo "Checking API endpoint patterns..."
# Look for .get and .post calls with their string arguments
rg --multiline '(get|post)\(["\']([^"\']+)["\']' -A 1

echo -e "\nChecking imported endpoints/routes..."
# Look for route/endpoint definitions or constants
rg 'const.*(?i)(endpoint|route|path|url).*=.*["\']'

Length of output: 267


Script:

#!/bin/bash

echo "Checking API endpoint patterns..."
# Look for get/post method calls
rg "\.get\(" -A 1
rg "\.post\(" -A 1

echo -e "\nChecking endpoint definitions..."
# Look for endpoint-related constants
rg "const.*endpoint.*=" 
rg "const.*path.*="
rg "const.*route.*="

Length of output: 2338

package.json Show resolved Hide resolved
src/client/rest/APIRequester.ts Outdated Show resolved Hide resolved
Copy link

@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

🧹 Outside diff range and nitpick comments (1)
src/client/rest/APIRequester.ts (1)

43-52: Consider additional security enhancements.

Good implementation of endpoint validation with multiple path traversal patterns! To further strengthen the security, consider these enhancements:

 private validateEndpoint(endpoint: string) {
+  if (typeof endpoint !== 'string') {
+    throw new Error('Endpoint must be a string')
+  }
+
+  // Normalize the path to handle various encodings
+  const normalizedEndpoint = decodeURIComponent(endpoint)
+
   const traversalPatterns = ['../', '..\\', '%2E%2E%2F', '%2E%2E%5C']
-  if (traversalPatterns.some((pattern) => endpoint.includes(pattern))) {
+  if (traversalPatterns.some((pattern) => normalizedEndpoint.includes(pattern))) {
     throw new Error('Relative path not allowed')
   }

   if (endpoint.includes('?')) {
-    throw new Error('Query param should be passed via the params argument')
+    throw new Error('Query parameters are not allowed in endpoint. Use the params argument instead. Example: client.get("/path", { key: "value" })')
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 87eb5d4 and 4dfa43c.

📒 Files selected for processing (1)
  • src/client/rest/APIRequester.ts (3 hunks)
🔇 Additional comments (3)
src/client/rest/APIRequester.ts (3)

68-68: LGTM!

The validation is properly placed before URL computation, ensuring early failure for invalid endpoints.


78-78: Implementation matches getRaw method.


84-84: Verify impact on existing POST endpoints.

While the validation is correctly implemented, let's verify that no existing POST endpoints use relative paths or query parameters.

✅ Verification successful

This should give us a better view of how POST is being used across the codebase, including both implementation and test files.


No impact on existing POST endpoints

The validation is safe to implement as the codebase search reveals:

  • Only one POST implementation exists in APIRequester.ts
  • No test files are using POST with problematic endpoints
  • The existing POST usage is simple and doesn't use relative paths or query parameters

The endpoint validation addition maintains backward compatibility and improves input validation without breaking changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for POST endpoint usage patterns
echo "Searching for POST method calls that might be affected by the new validation..."
rg -l "\.post\(" | xargs rg -B 2 -A 2 "\.post\(['\"].*['\"]"

Length of output: 235


Script:

#!/bin/bash
# Let's try a different approach to find POST endpoint usages
# First, find all TypeScript/JavaScript files
echo "Searching for POST method calls in the codebase..."
rg --type ts --type js -A 5 "\.post\(" 

# Also search for any test files that might be using POST
echo -e "\nSearching for POST usage in test files..."
fd -e test.ts -e test.js -e spec.ts -e spec.js --exec rg -l "\.post\("

Length of output: 483

@joon9823 joon9823 merged commit ab07c47 into main Nov 8, 2024
4 checks passed
@joon9823 joon9823 deleted the fix/audit branch November 8, 2024 06:59
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.

2 participants