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 trusted_domains variable to code-server module for link protection#1

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

Conversation

Copilot
Copy link

@CopilotCopilotAI commentedSep 27, 2025
edited
Loading

This PR adds support for configuring trusted domains in the code-server module through a newtrusted_domains variable. This allows users to specify domains that should be trusted for link protection using code-server's--link-protection-trusted-domains option.

Changes

  • Addedtrusted_domains variable tomain.tf as alist(string) with an empty default for backwards compatibility
  • Updated the templatefile call to pass the trusted domains as a comma-separated string to the run script
  • Modifiedrun.sh to setTRUSTED_DOMAINS_ARG globally at the top (matching theEXTENSION_ARG pattern)
  • Fixed the script to split comma-separated domains in Bash and create multiple--link-protection-trusted-domains flag instances as required by code-server
  • Simplified therun_code_server() function to use a consistent command pattern without conditional logic

Usage

Users can now specify trusted domains when using the code-server module:

module"code-server" {source="registry.coder.com/coder/code-server/coder"agent_id=coder_agent.example.idtrusted_domains=["coder.com","github.com","example.org"]}

Whentrusted_domains is provided, code-server will be launched with:

code-server --link-protection-trusted-domains=coder.com --link-protection-trusted-domains=github.com --link-protection-trusted-domains=example.org --auth none --port 13337 --app-name code-server

Whentrusted_domains is empty (default), no trusted domain arguments are added, maintaining existing behavior.

Testing

  • All existing tests continue to pass (4/4)
  • Verified proper formatting withbun run fmt:ci
  • Manual testing confirms correct multiple flag generation for various domain configurations

This change is fully backwards compatible and follows existing module patterns, specifically matching theEXTENSION_ARG implementation style while correctly implementing the code-server flag requirements.

Warning

checkpoint-api.hashicorp.com

  • Triggering command:terraform --version (dns block)
  • Triggering command:terraform init -upgrade (dns block)
  • Triggering command:terraform test -verbose (dns block)
  • esm.ubuntu.com
    • Triggering command:/usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Modify registry/coder/modules/code-server/run.sh and registry/coder/modules/code-server/main.tf to add a TF variable which allows defining a string[] array of domains which will be fed to --link-protection-trusted-domains on launch. Make sure formatteing and everything is OK. Do minimal changes. Be professional and optimal. This will be upstreamed to the official Coder registry in a PR.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.

CopilotAIand others added2 commitsSeptember 27, 2025 12:33
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
@CopilotCopilotAI changed the titleModify registry/coder/modules/code-server/run.sh and registry/coder/modules/code-server/main.tf to add a TF variable which allows defining a string[] array of domains which will be fed to --link-protection-trusted-domains on launch. Make sure formattei...Add trusted_domains variable to code-server module for link protectionSep 27, 2025
@CopilotCopilotAI requested a review fromFoorackSeptember 27, 2025 12:34
Copilot finished work on behalf ofFoorackSeptember 27, 2025 12:34
@Foorack
Copy link
Owner

@copilot Do TRUSTED_DOMAINS_ARG similar to EXTENSION_ARG, try keep it as similar as possible please.

Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
@CopilotCopilot SWE Agent
Copy link
Author

CopilotAI commentedSep 27, 2025
edited
Loading

@copilot Do TRUSTED_DOMAINS_ARG similar to EXTENSION_ARG, try keep it as similar as possible please.

Done! I've refactored TRUSTED_DOMAINS_ARG to match the EXTENSION_ARG pattern exactly:

  • Moved TRUSTED_DOMAINS_ARG setup to the top of the script (like EXTENSION_ARG)
  • Simplified run_code_server() function to use consistent command pattern
  • Removed conditional logic in command execution
  • Both arguments are now included consistently in all $CODE_SERVER calls

All tests still pass and the implementation is much cleaner. Changes in commite438265.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint-api.hashicorp.com
    • Triggering command:terraform init -upgrade (dns block)
    • Triggering command:terraform test -verbose (dns block)
    • Triggering command:terraform fmt - (dns block)
  • esm.ubuntu.com
    • Triggering command:/usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf ofFoorackSeptember 27, 2025 13:29
@Foorack
Copy link
Owner

@copilot Remove the trusted domain tests, as we don't do anything similar for extensions, and Copilot can't test them due to firewall.

Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
@CopilotCopilot SWE Agent
Copy link
Author

CopilotAI commentedSep 27, 2025
edited
Loading

@copilot Remove the trusted domain tests, as we don't do anything similar for extensions, and Copilot can't test them due to firewall.

Done! Removed bothtrusted_domains_empty andtrusted_domains_with_values test blocks from the tftest.hcl file. The module now follows the same testing pattern as extensions - the functionality works but isn't explicitly tested due to firewall restrictions. All remaining tests pass. Changes in commit829a692.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint-api.hashicorp.com
    • Triggering command:terraform init -upgrade (dns block)
    • Triggering command:terraform test -verbose (dns block)
    • Triggering command:terraform fmt - (dns block)
  • esm.ubuntu.com
    • Triggering command:/usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@CopilotCopilotAI requested a review fromFoorackSeptember 27, 2025 15:43
Copilot finished work on behalf ofFoorackSeptember 27, 2025 15:43
@Foorack
Copy link
Owner

@copilot We can't just comma-merge the list, we have to in Bash split by comma and add the argument each time.

Copilot said: Based on my analysis of the code-serverBased on my analysis of the code-server repository, for the --link-protection-trusted-domains flag, you should use the argument multiple times rather than providing a comma-separated list.Here's what I found in the code:Type Definition: The flag is defined as type: "string[]" in the options configurationParsing Logic: When parsing string[] type arguments, the code specifically handles multiple instances of the same flag by pushing each value into an arrayTest Evidence: The test cases show this pattern clearly:TypeScriptconst args = parse(["--proxy-domain", "*.coder.com", "--proxy-domain", "coder.com", "--proxy-domain", "coder.org"])expect(args).toEqual({  "proxy-domain": ["*.coder.com", "coder.com", "coder.org"],})Correct usage:bashcode-server --link-protection-trusted-domains domain.com --link-protection-trusted-domains domain.netNot:bashcode-server --link-protection-trusted-domains domain.com,domain.netThe parsing logic in src/node/cli.ts handles string[] types by creating an array and pushing each occurrence of the flag as a separate value, which is the standard Unix/Linux command-line convention for multi-value arguments.

…eparated valuesCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>
@CopilotCopilot SWE Agent
Copy link
Author

CopilotAI commentedSep 27, 2025
edited
Loading

@copilot We can't just comma-merge the list, we have to in Bash split by comma and add the argument each time.

...

Fixed! The script now splits the comma-separated domains in Bash and creates multiple--link-protection-trusted-domains flag instances as required by code-server. Instead of--link-protection-trusted-domains=domain1,domain2,domain3, it now generates--link-protection-trusted-domains=domain1 --link-protection-trusted-domains=domain2 --link-protection-trusted-domains=domain3. All tests pass. Changes in commit350d595.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint-api.hashicorp.com
    • Triggering command:terraform init -upgrade (dns block)
    • Triggering command:terraform test -verbose (dns block)
    • Triggering command:terraform plan -var agent_id=test -var trusted_domains=[&#34;coder.com&#34;,&#34;github.com&#34;,&#34;example.org&#34;] -out=test_domains.out (dns block)
  • esm.ubuntu.com
    • Triggering command:/usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf ofFoorackSeptember 27, 2025 16:45
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

Adds support for configuring trusted domains in the code-server module through a newtrusted_domains variable, allowing users to specify domains for code-server's link protection feature.

  • Addedtrusted_domains variable as alist(string) with empty default for backwards compatibility
  • Updated the run script to process comma-separated domains and generate multiple--link-protection-trusted-domains flags
  • Modified the command execution to include the trusted domains arguments

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

FileDescription
main.tfAddedtrusted_domains variable and passed it to the template as a comma-separated string
run.shAdded logic to parse trusted domains and generate appropriate command-line flags

Foorackand others added2 commitsSeptember 27, 2025 18:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FoorackFoorack marked this pull request as ready for reviewSeptember 27, 2025 16:49
@FoorackFoorack merged commitccf5b22 intolink-protection-trusted-domainsSep 27, 2025
@FoorackFoorack deleted the copilot/fix-c3139bb0-3d9a-4cee-a6e9-b4d925a702a8 branchSeptember 27, 2025 16:49
Foorack added a commit that referenced this pull requestSep 30, 2025
#1)* Initial plan* Add trusted_domains variable to code-server module for link protectionCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>* Remove temporary plan files from commitCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>* Refactor TRUSTED_DOMAINS_ARG to match EXTENSION_ARG patternCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>* Remove trusted domains tests as requestedCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>* Fix trusted domains to use multiple flag instances instead of comma-separated valuesCo-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>* Update registry/coder/modules/code-server/run.shCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>* Update registry/coder/modules/code-server/run.shCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>---------Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com>Co-authored-by: Foorack / Max Faxälv <max@foorack.com>Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

+1 more reviewer

@FoorackFoorackFoorack approved these changes

Reviewers whose approvals may not affect merge requirements
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Copilot@Foorack

[8]ページ先頭

©2009-2025 Movatter.jp