Skip to content

fix(site): stop the site search at / and validate --domain - #19

Merged
nabil1440 merged 1 commit into
blockers/2-exit-codesfrom
blockers/3-site-lookup
Sep 22, 2026
Merged

nabil1440 merged 1 commit into
blockers/2-exit-codesfrom
blockers/3-site-lookup

Conversation

@nabil1440

@nabil1440 nabil1440 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Change

  • FindComposeFile stops at the home directory or at the filesystem root. Before this change, a command outside $HOME did not stop and used 100% CPU.
  • FindComposeFile returns the errors from os.UserHomeDir and os.Getwd. It returns ErrComposeNotFound when the site has no compose file.
  • --domain must be a valid hostname: labels of letters, digits and inner hyphens, 1–63 characters each, 253 characters in total. Thus the value cannot contain / or ...
  • A second check makes sure that the site directory is directly in the home directory.

Behavior change

  • A domain with Unicode characters must use its punycode form (xn--…).

Tests

  • Unit tests:
    • A search outside $HOME returns in less than 2 s.
    • A search from a nested directory finds the site.
    • The search stops at $HOME.
    • --domain finds the site.
    • A table of valid and invalid domains.
  • End-to-end tests:
    • fly start outside $HOME stops with the no-site error.
    • --domain ../, .., example.com/../.. and a/b show "invalid domain". No Docker call occurs.
  • The end-to-end tests fail on the code before this PR. The test harness stops the process after 10 s.

Closes #3

@nabil1440
nabil1440 added this pull request to stack #24 September 21, 2026 10:41
- FindComposeFile stops at the home directory or at the filesystem
  root, so a command outside $HOME no longer loops forever.
- FindComposeFile returns errors from UserHomeDir and Getwd, and
  ErrComposeNotFound when a site has no compose file.
- --domain must be a valid hostname (labels of letters, digits and
  inner hyphens). This rejects path separators and '..', so the value
  cannot point outside the sites directory.

Closes #3
@nabil1440
nabil1440 force-pushed the blockers/3-site-lookup branch from 89e210c to 0dd9f78 Compare September 22, 2026 06:36
@nabil1440
nabil1440 merged commit cc8a308 into develop Sep 22, 2026
@nabil1440
nabil1440 deleted the blockers/3-site-lookup branch September 22, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: The site search does not stop outside $HOME, and --domain can point outside the home directory

1 participant