Skip to content

Commit

Permalink
fix content header security issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobgetz committed Dec 7, 2023
1 parent 3db866b commit 63f62a8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/analyser.cts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ export default class Analyser {

await this.page.addInitScript({ content: initScript })

await this.page.route('**/*', async (route) => {
const response = await route.fetch()
const headers = response.headers()

// Remove or modify the CSP header
delete headers['content-security-policy'];
delete headers['content-security-policy-report-only']

await route.fulfill({
status: response.status(),
headers: headers,
body: await response.body()
});
})

await this.page.route(`**/*.js*`, async route => {
let response
try {
Expand All @@ -98,9 +113,6 @@ export default class Analyser {
} catch {
route.fulfill({ response, body: script })
}
// const script = response.text()
// const body = `${initScript}${script}`
// await route.fulfill({ response, body: body })
})
this.page.on('worker', worker => {
this.contexts.push(worker)
Expand Down

0 comments on commit 63f62a8

Please sign in to comment.