Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ else
echo "Login with [email protected] to: http://fizzy.localhost:$PORT/"
fi

./bin/rails server -p $PORT
./bin/rails server -b 0.0.0.0 -p $PORT
5 changes: 3 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@
"fizzy.localhost",
"localhost",
"127.0.0.1",
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/ # tailscale serve: hostname.tail1234.ts.net
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net

Check failure

Code scanning / CodeQL

Missing regular expression anchor High

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.

Copilot Autofix

AI 8 days ago

In general, to fix missing-anchor issues, change regexes so they match the entire intended value rather than any substring, using \A and \z (or ^ and $ only when line-based behavior is explicitly desired). For hostnames, you usually want “host ends with .example.com” or similar, not “string contains .example.com somewhere”.

Here, config.hosts should allow any host under the ts.net domain. The simplest, least-disruptive fix is to replace /.*\.ts\.net/ with an anchored pattern that still allows any subdomain but ensures .ts.net is at the end of the host (ignoring an optional port). For example:

  • Use \A and \z to anchor the whole host string.
  • Permit an optional :<port> after the hostname to match how Rails may include ports in config.hosts.
  • Keep the comment semantics (“hostname.tail1234.ts.net”) intact.

A robust replacement is:

/\A.*\.ts\.net(?::\d+)?\z/

This matches any string that:

  • Starts with anything ending in .ts.net
  • Optionally has :PORT after it
  • Has no trailing extra characters.

Concretely, in config/environments/development.rb, line 93 should be changed from /.*\.ts\.net/ to /\A.*\.ts\.net(?::\d+)?\z/. No new imports or methods are needed; it’s a direct regex literal change.

Suggested changeset 1
config/environments/development.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/config/environments/development.rb b/config/environments/development.rb
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -89,9 +89,9 @@
     "fizzy.localhost",
     "localhost",
     "127.0.0.1",
-    /fizzy-\d+/,   # review apps: fizzy-123, fizzy-456:3000
-    /.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net
-    /.*\.nip\.io/  # nip.io for mobile apps
+    /fizzy-\d+/,                    # review apps: fizzy-123, fizzy-456:3000
+    /\A.*\.ts\.net(?::\d+)?\z/,     # tailscale serve: hostname.tail1234.ts.net
+    /.*\.nip\.io/                   # nip.io for mobile apps
   ]
 
   # Canonical host for mailer URLs (emails always link here, not personal Tailscale URLs)
EOF
@@ -89,9 +89,9 @@
"fizzy.localhost",
"localhost",
"127.0.0.1",
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net
/.*\.nip\.io/ # nip.io for mobile apps
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/\A.*\.ts\.net(?::\d+)?\z/, # tailscale serve: hostname.tail1234.ts.net
/.*\.nip\.io/ # nip.io for mobile apps
]

# Canonical host for mailer URLs (emails always link here, not personal Tailscale URLs)
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Member

Choose a reason for hiding this comment

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

Rails add the anchors, confusingly.

/.*\.nip\.io/ # nip.io for mobile apps
]

# Canonical host for mailer URLs (emails always link here, not personal Tailscale URLs)
Expand Down