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

Add domain to Trusted Domain by default#19995

Discussion options

Not sure if this is aCoder orcode-server question. But when provisioning a template, is there any way of pre-adding a domain to Trusted Domains? When doing git push and it responds with a link to create a merge request, it would be nice if each person didn't have to accept that domain as trusted as it is an internally hosted GitLab.

There is a commandManage Trusted Domains which opens a magic file, but I cannot find any way to automate this specific step...

You must be logged in to vote

(This took half of my Saturday, hopefully someone finds this useful.)

VS Code Desktop

I have discovered environments using a Client configuration management tools can use:

sqlite3~/.config/Code/User/globalStorage/state.vscdb"UPDATE ItemTable SET value = '[\"https://github.com\",\"https://git.corp.example.com\",\"https://foorack.com\"]' WHERE key = 'http.linkProtectionTrustedDomains';"

This command needs to be run as each user / on each home folder, and only works for the Desktop installations of Code/Code - Insider/etc.

Warning

This willwipe any previously Developer-added domains each time the command is run. Only run itonce on initial-setup.


Coder / code-server

However, this does…

Replies: 3 comments

Comment options

I have already tried setting"security.workspace.trust.enabled": false, which had no impact.

There is

"workbench.trustedDomains.promptInTrustedWorkspace":false

but it also has no impact, as I suspect the current workspace is not Trusted. Even when re-enabling workspace.trust.enabled to True, and making sure my current folder is trusted -"You trust this folder" - thepromptInTrustedWorkspace still has no effect.

You must be logged in to vote
0 replies
Comment options

Relatedmicrosoft/vscode#82794

You must be logged in to vote
0 replies
Comment options

(This took half of my Saturday, hopefully someone finds this useful.)

VS Code Desktop

I have discovered environments using a Client configuration management tools can use:

sqlite3~/.config/Code/User/globalStorage/state.vscdb"UPDATE ItemTable SET value = '[\"https://github.com\",\"https://git.corp.example.com\",\"https://foorack.com\"]' WHERE key = 'http.linkProtectionTrustedDomains';"

This command needs to be run as each user / on each home folder, and only works for the Desktop installations of Code/Code - Insider/etc.

Warning

This willwipe any previously Developer-added domains each time the command is run. Only run itonce on initial-setup.


Coder / code-server

However, this does not work forcode-server insidecoder/coder, as this state SQLite file cannot be found at the same location.
User storage is inside~/.local/share/code-server/User/, but theglobalStorage folder does not have anything like astate.vscdb file.
After extensive digging I found that this SQLite table is actually stored inside thebrowser IndexedDB storage. 🫨

There is a patch to add--link-protection-trusted-domains as a CLI arg, andlinkProtectionTrustedDomains as a product.json value. Unfortunately thecoder/code-server TF module does not support adding additional arbitrary arguments to the launch of code-server.
https://github.com/coder/registry/blob/main/registry/coder/modules/code-server/run.sh#L19

I spent a lot of time trying to get this patched in but struggled to see the commandline argument have an effect. However, I think this is due to "example.com,example.net" being treated as one value instead of a string-array corrupting things. After a lot of cleanup I made the following PR to upstream this feature:

coder/registry#435


Finally, also sharing this shorter-term but immediately-working solution:

resource"coder_agent""main" {arch=data.coder_provisioner.me.archos="linux"dir="/home/coder/${local.folder_name}"# Add any commands that should be executed at workspace startup (e.g install requirements, start a program, etc) herestartup_script=<<-EOT    #    # CORE SETUP    #    # Update code-server trusted domains    echo "🔧 Updating code-server trusted domains..."    mkdir -p /tmp/code-server/lib    while [ ! -f "$(find /tmp/code-server/lib/ -type f -name 'product.json' | head -n1)" ]; do :; done    CODE_SERVER_PROFILE_JSON="$(find /tmp/code-server/lib/ -type f -name 'product.json' | head -n1)"    cat $CODE_SERVER_PROFILE_JSON | jq '.linkProtectionTrustedDomains = ["https://open-vsx.org","https://github.com","https://git.corp.example.com","https://foorack.com","*.amazonaws.com"]' > /tmp/product-modified.json    mv /tmp/product-modified.json $CODE_SERVER_PROFILE_JSON    #    # REST OF YOUR startup_script, LIKE SKEL HOME, INSTALLING TOOLS, ETC.    #[...]

Caution

REMEMBER TO KEEPhttps://open-vsx.org as one of the values, as this actually OVERRIDES the builtin value.

Tip

Please add the "product.json-override" logic at the very top of thestartup_script, as it is important we can listen and immediately change this config beforecode-server starts up.

Despite the minor race-requirement, I think this solution is elegant in that it doesn't override the users own value. Unlike the Desktop approach, this actually allows the developer to add additional domains, while allowing the core configuration to be enforced at any time.

You must be logged in to vote
0 replies
Answer selected byFoorack
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@Foorack

[8]ページ先頭

©2009-2025 Movatter.jp