Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
469a0060
Unverified
Commit
469a0060
authored
Jun 26, 2023
by
Vignesh Mohankumar
Committed by
GitHub
Jun 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: filter more CSP errors (#6839)
* fix: filter more CSP errors * fix regex * fix
parent
c673c9e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
errors.test.ts
src/tracing/errors.test.ts
+12
-0
errors.ts
src/tracing/errors.ts
+4
-3
No files found.
src/tracing/errors.test.ts
View file @
469a0060
...
...
@@ -128,6 +128,18 @@ describe('beforeSend', () => {
expect
(
beforeSend
(
ERROR
,
{
originalException
})).
toBeNull
()
})
it
(
'
filters blocked frame errors
'
,
()
=>
{
const
originalException
=
new
Error
(
'
Blocked a frame with origin "https://app.uniswap.org" from accessing a cross-origin frame.
'
)
expect
(
beforeSend
(
ERROR
,
{
originalException
})).
toBeNull
()
})
it
(
'
fiters write permission denied errors
'
,
()
=>
{
const
originalException
=
new
Error
(
'
NotAllowedError: Write permission denied.
'
)
expect
(
beforeSend
(
ERROR
,
{
originalException
})).
toBeNull
()
})
it
(
'
filters CSP unsafe-eval compile/instatiate errors
'
,
()
=>
{
const
originalException
=
new
Error
(
"
Refused to compile or instantiate WebAssembly module because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive:
\"
script-src 'self' https://www.google-a...
"
...
...
src/tracing/errors.ts
View file @
469a0060
...
...
@@ -42,6 +42,7 @@ function updateRequestUrl(event: ErrorEvent) {
}
}
// TODO(WEB-2400): Refactor to use a config instead of returning true for each condition.
function
shouldRejectError
(
error
:
EventHint
[
'
originalException
'
])
{
if
(
error
instanceof
Error
)
{
// ethers aggressively polls for block number, and it sometimes fails (whether spuriously or through rate-limiting).
...
...
@@ -74,9 +75,9 @@ function shouldRejectError(error: EventHint['originalException']) {
// Content security policy 'unsafe-eval' errors can be filtered out because there are expected failures.
// For example, if a user runs an eval statement in console this error would still get thrown.
// TODO(WEB-2348): We should extend this to filter out any type of CSP error.
if
(
error
.
message
.
match
(
/'unsafe-eval'.*content security policy/i
))
{
return
true
}
if
(
error
.
message
.
match
(
/'unsafe-eval'.*content security policy/i
))
return
true
if
(
error
.
message
.
match
(
/Blocked a frame with origin ".*" from accessing a cross-origin frame./
))
return
true
if
(
error
.
message
.
match
(
/NotAllowedError: Write permission denied./
))
return
true
// WebAssembly compilation fails because we do not allow 'unsafe-eval' in our CSP.
// Any thrown errors are due to 3P extensions/applications, so we do not need to handle them.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment