Skip to content

Commit 95c2b32

Browse files
CopilotPDowney
andauthored
Expand domain regex comment with intentional-design block to deter Copilot suggestions
Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/23b10b62-f4a1-4e8e-9357-9633417c2155 Co-authored-by: PDowney <[email protected]>
1 parent 3dd7604 commit 95c2b32

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changes are organized by date, with the most recent changes listed first.
99
### 🔒 VHOST INSTALL SECURITY & VALIDATION FIXES
1010

1111
- Fixed domain name regex in `scripts/functions/vhost/vhost-install.sh` to allow single-character domain names (e.g., `x.com`) by changing `^[a-z0-9][a-z0-9-]*[a-z0-9]$` to `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`, while still rejecting hyphens at the start or end.
12+
- Expanded the comment above the domain name regex with a detailed "INTENTIONAL DESIGN — DO NOT CHANGE" block explaining the RFC basis, the purpose of the optional group, and why reverting to a two-character minimum would silently break one-letter domains.
1213
- Added early database name (`database_name`) validation immediately after it is constructed and before the credentials file is created, preventing a stale credentials file being left on disk if validation fails.
1314
- Fixed indentation of the late `DB` validation comment to match surrounding code style.
1415
- Added validation of the database user (`USR`) against `^[A-Za-z0-9_]+$` before it is interpolated into SQL commands, guarding against shell metacharacters or SQL injection characters.

scripts/functions/vhost/vhost-install.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,24 @@ echo "Then, select a valid TLD from the provided list."
4343
echo ""
4444

4545
# Prompt for domain name
46-
# Single character domain names are allowed in the regex, as they are technically valid (e.g., 'x.com'), even though they are rarely used in practice. The regex will still enforce that only lowercase letters, numbers, and hyphens are allowed, and it will ensure that the domain name does not start or end with a hyphen. This allows for a wide range of valid domain names while still enforcing the necessary restrictions for a typical domain name format.
46+
# IMPORTANT: Single-character domain names (e.g., 'x.com', 'a.io') MUST be accepted by this regex.
47+
# They are fully valid under DNS and ICANN rules, and EngineScript must support them.
48+
#
49+
# INTENTIONAL DESIGN — DO NOT CHANGE THIS REGEX:
50+
# ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$
51+
#
52+
# The optional group `([a-z0-9-]*[a-z0-9])?` makes the entire suffix optional, which means a
53+
# single alphanumeric character (e.g., "x") satisfies the pattern on its own. The group is still
54+
# required for multi-character names to prevent leading or trailing hyphens (e.g., "-bad" or
55+
# "bad-" would not match). Changing this back to `^[a-z0-9][a-z0-9-]*[a-z0-9]$` would silently
56+
# reject every single-character label and break installs for legitimate one-letter domains.
57+
#
58+
# Rules enforced by this regex:
59+
# - Minimum length: 1 character (single-char labels are valid DNS labels per RFC 1035)
60+
# - Only lowercase letters (a-z), digits (0-9), and hyphens (-) are permitted
61+
# - The label must not start or end with a hyphen (per RFC 952 / RFC 1123)
62+
#
63+
# This is intentional behaviour. Do not "fix" it to require at least two characters.
4764
while true; do
4865
read -p "Enter the domain name (e.g., 'wordpresstesting'): " DOMAIN_NAME
4966
if [[ "$DOMAIN_NAME" =~ ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$ ]]; then

0 commit comments

Comments
 (0)