Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
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
vicotor
frontend
Commits
aae435fe
Commit
aae435fe
authored
Feb 21, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix csp warnings and delete console
parent
4feeb9db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
21 deletions
+12
-21
getCspPolicy.ts
lib/csp/getCspPolicy.ts
+12
-13
useGetCsrfToken.tsx
lib/hooks/useGetCsrfToken.tsx
+0
-8
No files found.
lib/csp/getCspPolicy.ts
View file @
aae435fe
...
@@ -16,22 +16,21 @@ const MAIN_DOMAINS = [ `*.${ appConfig.host }`, appConfig.host ];
...
@@ -16,22 +16,21 @@ const MAIN_DOMAINS = [ `*.${ appConfig.host }`, appConfig.host ];
// eslint-disable-next-line no-restricted-properties
// eslint-disable-next-line no-restricted-properties
const
REPORT_URI
=
process
.
env
.
SENTRY_CSP_REPORT_URI
;
const
REPORT_URI
=
process
.
env
.
SENTRY_CSP_REPORT_URI
;
function
getNetworksExternalAssets
()
{
function
getNetworksExternalAssets
Hosts
()
{
const
icons
=
featuredNetworks
const
icons
=
featuredNetworks
.
filter
(({
icon
})
=>
typeof
icon
===
'
string
'
)
.
filter
(({
icon
})
=>
typeof
icon
===
'
string
'
)
.
map
(({
icon
})
=>
new
URL
(
icon
as
string
));
.
map
(({
icon
})
=>
new
URL
(
icon
as
string
)
.
host
);
const
logo
=
appConfig
.
network
.
logo
?
new
URL
(
appConfig
.
network
.
logo
)
:
undefined
;
const
logo
=
appConfig
.
network
.
logo
?
new
URL
(
appConfig
.
network
.
logo
)
.
host
:
undefined
;
return
logo
?
icons
.
concat
(
logo
)
:
icons
;
return
logo
?
icons
.
concat
(
logo
)
:
icons
;
}
}
function
getMarketplaceAppsOrigins
()
{
function
getMarketplaceAppsHosts
()
{
return
appConfig
.
marketplaceAppList
.
map
(({
url
})
=>
url
);
return
{
}
frames
:
appConfig
.
marketplaceAppList
.
map
(({
url
})
=>
new
URL
(
url
).
host
),
logos
:
appConfig
.
marketplaceAppList
.
map
(({
logo
})
=>
new
URL
(
logo
).
host
),
function
getMarketplaceAppsLogosOrigins
()
{
};
return
appConfig
.
marketplaceAppList
.
map
(({
logo
})
=>
new
URL
(
logo
));
}
}
// we cannot use lodash/uniq in middleware code since it calls new Set() and it'is causing an error in Nextjs
// we cannot use lodash/uniq in middleware code since it calls new Set() and it'is causing an error in Nextjs
...
@@ -46,7 +45,7 @@ function unique(array: Array<string | undefined>) {
...
@@ -46,7 +45,7 @@ function unique(array: Array<string | undefined>) {
}
}
function
makePolicyMap
()
{
function
makePolicyMap
()
{
const
networkExternalAssets
=
getNetworksExternalAsse
ts
();
const
marketplaceAppsHosts
=
getMarketplaceAppsHos
ts
();
return
{
return
{
'
default-src
'
:
[
'
default-src
'
:
[
...
@@ -130,10 +129,10 @@ function makePolicyMap() {
...
@@ -130,10 +129,10 @@ function makePolicyMap() {
'
avatars.githubusercontent.com
'
,
// github avatars
'
avatars.githubusercontent.com
'
,
// github avatars
// network assets
// network assets
...
networkExternalAssets
.
map
((
url
)
=>
url
.
host
),
...
getNetworksExternalAssetsHosts
(
),
// marketplace apps logos
// marketplace apps logos
...
getMarketplaceAppsLogosOrigins
().
map
((
url
)
=>
url
.
host
)
,
...
marketplaceAppsHosts
.
logos
,
// ad
// ad
'
servedbyadbutler.com
'
,
'
servedbyadbutler.com
'
,
...
@@ -167,7 +166,7 @@ function makePolicyMap() {
...
@@ -167,7 +166,7 @@ function makePolicyMap() {
],
],
'
frame-src
'
:
[
'
frame-src
'
:
[
...
getMarketplaceAppsOrigins
()
,
...
marketplaceAppsHosts
.
frames
,
// ad
// ad
'
request-global.czilladx.com
'
,
'
request-global.czilladx.com
'
,
...
...
lib/hooks/useGetCsrfToken.tsx
View file @
aae435fe
...
@@ -14,14 +14,6 @@ export default function useGetCsrfToken() {
...
@@ -14,14 +14,6 @@ export default function useGetCsrfToken() {
const
url
=
buildUrl
(
'
csrf
'
);
const
url
=
buildUrl
(
'
csrf
'
);
const
apiResponse
=
await
fetch
(
url
,
{
credentials
:
'
include
'
});
const
apiResponse
=
await
fetch
(
url
,
{
credentials
:
'
include
'
});
const
csrfFromHeader
=
apiResponse
.
headers
.
get
(
'
x-bs-account-csrf
'
);
const
csrfFromHeader
=
apiResponse
.
headers
.
get
(
'
x-bs-account-csrf
'
);
// eslint-disable-next-line no-console
console
.
log
(
'
>>> RESPONSE HEADERS <<<
'
);
// eslint-disable-next-line no-console
console
.
table
([
{
'
content-length
'
:
apiResponse
.
headers
.
get
(
'
content-length
'
),
'
x-bs-account-csrf
'
:
csrfFromHeader
,
}
]);
return
csrfFromHeader
?
{
token
:
csrfFromHeader
}
:
undefined
;
return
csrfFromHeader
?
{
token
:
csrfFromHeader
}
:
undefined
;
}
}
...
...
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