Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

support csp exeptions#503

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromcsp-excemptions
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsdocs/docs/env-vars.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ CodeRoad has a number of configurations:

- `CODEROAD_ADMIN_MODE` - a mode for tutorial developers. Under the "Review" page, you can jump around between levels & steps to test development. Defaults `false`.

- `CODEROAD_CONTENT_SECURITY_POLICY_EXEMPTIONS` - a list of CSP exemption hashes. For multiples, separate the list with a space.

## How to Use Variables

### Local
Expand Down
5 changes: 5 additions & 0 deletionssrc/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,3 +38,8 @@ if (!supportedOS.includes(OS_PLATFORM)) {
export const TUTORIAL_URL: string | null = process.env.CODEROAD_TUTORIAL_URL || null

export const DISABLE_RUN_ON_SAVE = (process.env.CODEROAD_DISABLE_RUN_ON_SAVE || '').toLowerCase() === 'true'

// bypass "Refused to execute inline script because it violates the following Content Security Policy directive" issue
// for multiple exemptions, separate each with a space "a1 b1"
export const CONTENT_SECURITY_POLICY_EXEMPTIONS: string | null =
process.env.CODEROAD_CONTENT_SECURITY_POLICY_EXEMPTIONS || null
8 changes: 8 additions & 0 deletionssrc/services/webview/render.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import { JSDOM } from 'jsdom'
import * as path from 'path'
import * as vscode from 'vscode'
import { onError } from '../telemetry'
import { CONTENT_SECURITY_POLICY_EXEMPTIONS } from '../../environment'

const getNonce = (): string => {
let text = ''
Expand DownExpand Up@@ -46,6 +47,13 @@ async function render(panel: vscode.WebviewPanel, rootPath: string): Promise<voi
}
}

// support additional CSP exemptions when CodeRoad is embedded
if (CONTENT_SECURITY_POLICY_EXEMPTIONS && CONTENT_SECURITY_POLICY_EXEMPTIONS.length) {
for (const exemption of CONTENT_SECURITY_POLICY_EXEMPTIONS.split(' ')) {
nonces.push(exemption)
}
}

// add run-time script from webpack
const runTimeScript = document.createElement('script')
runTimeScript.nonce = getNonce()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp