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

chore(repo): switch from pnpm to bun #227

Merged
merged 4 commits into from
Nov 7, 2024
Merged

chore(repo): switch from pnpm to bun #227

merged 4 commits into from
Nov 7, 2024

Conversation

mrcnk
Copy link
Member

@mrcnk mrcnk commented Nov 6, 2024

Describe changes

Ticket or discussion link

Review checklist

  • Proper documentation added
  • Proper tests added

Screenshots

Copy link

deepsource-io bot commented Nov 6, 2024

Here's the code health analysis summary for commits 2bc5d5c..169de40. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 23 occurences introduced
🎯 33 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@@ -38,6 +38,9 @@
const account = accounts[networkId]?.[address] ?? {}
set(
produce((state) => {
state.accounts[networkId] = state.accounts[networkId] ?? {}
state.accounts[networkId][address] =

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix AI about 2 months ago

To fix the prototype pollution vulnerability, we need to ensure that the networkId parameter cannot be used to modify Object.prototype. One effective way to do this is to validate the networkId parameter before using it as a key in the state.accounts object. We can reject any networkId that matches __proto__, constructor, or prototype.

Suggested changeset 1
packages/vault/src/account/accountStore.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/vault/src/account/accountStore.ts b/packages/vault/src/account/accountStore.ts
--- a/packages/vault/src/account/accountStore.ts
+++ b/packages/vault/src/account/accountStore.ts
@@ -21,2 +21,5 @@
   ensureAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      throw new Error('Invalid networkId');
+    }
     set(
@@ -36,2 +39,5 @@
   setAccountInfo: (networkId, address, accountInfo) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      throw new Error('Invalid networkId');
+    }
     const { accounts } = get()
@@ -51,2 +57,5 @@
   setTransactions: (networkId, address, transactions) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      throw new Error('Invalid networkId');
+    }
     const { accounts } = get()
@@ -66,2 +75,5 @@
   addAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      throw new Error('Invalid networkId');
+    }
     set(
@@ -78,2 +90,5 @@
   removeAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      throw new Error('Invalid networkId');
+    }
     set(
EOF
@@ -21,2 +21,5 @@
ensureAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
throw new Error('Invalid networkId');
}
set(
@@ -36,2 +39,5 @@
setAccountInfo: (networkId, address, accountInfo) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
throw new Error('Invalid networkId');
}
const { accounts } = get()
@@ -51,2 +57,5 @@
setTransactions: (networkId, address, transactions) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
throw new Error('Invalid networkId');
}
const { accounts } = get()
@@ -66,2 +75,5 @@
addAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
throw new Error('Invalid networkId');
}
set(
@@ -78,2 +90,5 @@
removeAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
throw new Error('Invalid networkId');
}
set(
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -50,6 +53,9 @@
const account = accounts[networkId]?.[address] ?? {}
set(
produce((state) => {
state.accounts[networkId] = state.accounts[networkId] ?? {}
state.accounts[networkId][address] =

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix AI about 2 months ago

To fix the prototype pollution vulnerability, we need to ensure that the networkId cannot be set to special property names like __proto__, constructor, or prototype. This can be achieved by adding a check to reject these values before using networkId as a key in the state.accounts object.

The best way to fix this without changing existing functionality is to add a validation step for networkId in each function where it is used. If networkId is one of the special property names, we can return early or handle the error appropriately.

Suggested changeset 1
packages/vault/src/account/accountStore.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/vault/src/account/accountStore.ts b/packages/vault/src/account/accountStore.ts
--- a/packages/vault/src/account/accountStore.ts
+++ b/packages/vault/src/account/accountStore.ts
@@ -21,2 +21,5 @@
   ensureAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      return;
+    }
     set(
@@ -36,2 +39,5 @@
   setAccountInfo: (networkId, address, accountInfo) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      return;
+    }
     const { accounts } = get()
@@ -51,2 +57,5 @@
   setTransactions: (networkId, address, transactions) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      return;
+    }
     const { accounts } = get()
@@ -66,2 +75,5 @@
   addAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      return;
+    }
     set(
@@ -78,2 +90,5 @@
   removeAccount: (networkId, address) => {
+    if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
+      return;
+    }
     set(
EOF
@@ -21,2 +21,5 @@
ensureAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
return;
}
set(
@@ -36,2 +39,5 @@
setAccountInfo: (networkId, address, accountInfo) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
return;
}
const { accounts } = get()
@@ -51,2 +57,5 @@
setTransactions: (networkId, address, transactions) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
return;
}
const { accounts } = get()
@@ -66,2 +75,5 @@
addAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
return;
}
set(
@@ -78,2 +90,5 @@
removeAccount: (networkId, address) => {
if (networkId === '__proto__' || networkId === 'constructor' || networkId === 'prototype') {
return;
}
set(
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@mrcnk mrcnk merged commit a9f95d9 into main Nov 7, 2024
4 checks passed
@mrcnk mrcnk deleted the chore/switch-to-bun branch November 7, 2024 14:29
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