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

feat: blockaid integration #4029

Merged
merged 13 commits into from
Sep 11, 2024
Merged

feat: blockaid integration #4029

merged 13 commits into from
Sep 11, 2024

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented Aug 2, 2024

What it solves

Integrates the BlockAid API for security scanning.

How this PR fixes it

  • exchanges redefine for blockaid
  • redesigns warning component

How to test it

Do any tx or message signing

TODO

  • Better error handling
  • Figure out how we handle the prod API key
  • (optional): Pass Safe App / Wallet Connect URI as domain field

Screenshots

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

- exchanges redefine for blockaid
- redesigns warning component
Copy link

github-actions bot commented Aug 2, 2024

Copy link

Integrate Blockaid Scans

Copy link

github-actions bot commented Aug 2, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link

github-actions bot commented Aug 2, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 949.6 KB (🟡 +19 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/balances 30.64 KB (🟡 +1 B) 980.24 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link

github-actions bot commented Aug 2, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.45% (-0.05% 🔻)
11859/15116
🔴 Branches
59.02% (-0.08% 🔻)
3042/5154
🟡 Functions
65.82% (-0.13% 🔻)
1885/2864
🟡 Lines
79.89% (-0.05% 🔻)
10701/13394
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / useBlockaid.ts
100% 100% 100% 100%
🟢
... / index.ts
83.78% 41.18% 50% 83.78%
🔴
... / index.tsx
50.85% 3.45% 8.33% 52.94%
🟢
... / utils.ts
85.71% 100% 100% 100%
🟡
... / BlockaidHint.tsx
50% 100% 0% 66.67%
🟡
... / BlockaidBalanceChange.tsx
66.67% 4.76% 10% 65.85%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / config.tsx
86.96% (-0.54% 🔻)
100% 100% 100%
🟢
... / SecurityWarnings.tsx
66.67% (-8.33% 🔻)
100% 100% 100%

Test suite run success

1483 tests passing in 203 suites.

Report generated by 🧪jest coverage report action from cc7f22b

Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@schmanu schmanu requested a review from katspaugh August 19, 2024 08:07
Copy link

github-actions bot commented Aug 28, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@katspaugh
Copy link
Member

Some unit tests are failing but we can already send this to QA.

@schmanu
Copy link
Member Author

schmanu commented Aug 29, 2024

Some unit tests are failing but we can already send this to QA.

They are not really failing. The job just fails when trying to publish results -.- but the test cases all pass.

# Redefine
NEXT_PUBLIC_REDEFINE_API=
# Blockaid
NEXT_PUBLIC_BLOCKAID_CLIENT_ID
Copy link
Member

Choose a reason for hiding this comment

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

This var has to be added to the build.yml action too.

@francovenica
Copy link
Contributor

francovenica commented Sep 4, 2024

I tried using the tool provided and tried to trigger some transactions, but all of them would show this message (bening and malicious ones the same)
image

It seems that the validation of the tx is failing, thus not being able to tell you if the tx is malicious or not.

I got the message to show up once when the SDK initialialize correctly, but I'd assume this is a mistake because the message seems to be there by default as soon as the tx pop's up and then it should be updated depending on if the tx is malicious or not, so I think in this particular case the message simply didn't update
image

Also I don't think the message should be green if the tx is malicious

@schmanu
Copy link
Member Author

schmanu commented Sep 6, 2024

@francovenica could you share what those transactions did?
I cannot reproduce any of those cases :/

@francovenica
Copy link
Contributor

I used the tool you shsared with Lily https://examples.blockaid.io/. Every malicious tx would show what I reported in my comment

@schmanu
Copy link
Member Author

schmanu commented Sep 9, 2024

I used the tool you shsared with Lily https://examples.blockaid.io/. Every malicious tx would show what I reported in my comment

@francovenica And the last case where it says "Transaction is malicious" in the success color? Do you remember how that happened?

@katspaugh
Copy link
Member

Blocked on BlockAid's side due to some errors (we reached out for help).

Copy link

github-actions bot commented Sep 9, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@schmanu schmanu removed the blocked label Sep 9, 2024
@francovenica
Copy link
Contributor

@schmanu I never got to see it twice. There was that SDK error that happened once and the green message just popped.
I tested several times after and it seems that there is a split second that the green text shows up, like if it is loaded by default, and then is covered by the "could not check" warning message

@liliya-soroka
Copy link
Member

approved internally together with @kirkkonen

Copy link

github-actions bot commented Sep 11, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@katspaugh katspaugh merged commit ab3871b into dev Sep 11, 2024
15 of 16 checks passed
@katspaugh katspaugh deleted the feat/switch-security-provider branch September 11, 2024 14:59
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants