Skip to content

Warn on url values new URL() accepts but are not real URLs; default to http/https - #1220

Merged
theoephraim merged 2 commits into
mainfrom
strict-url-validation
Oct 13, 2026
Merged

theoephraim merged 2 commits into
mainfrom
strict-url-validation

Conversation

@theoephraim

@theoephraim theoephraim commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

@type=url validates with new URL(), which accepts any word:rest string as a URL with an opaque path. A user hit this with an SSH key fingerprint (SHA256:nThbg6... parses as scheme sha256:), and the same goes for user:pass, localhost:3000, and C:\path. For http/https the parser also silently repairs malformed input (https:///example.com, http://0x7f.1, https://a..b), and it strips whitespace the raw value still carries.

This PR adds those checks as warnings, to become errors in the next major (one constant, STRICT_URL_SEVERITY, marked TODO(next major)). A value is flagged if it:

  • does not start with scheme://
  • contains whitespace or control characters
  • has no host (special schemes always need one; others can opt in with the new allowNoHost=true for sqlite:///app.db, file:///..., postgresql:///db?host=...)
  • for http/https/ws/wss/ftp: uses a backslash, a percent-encoded host, IPv4 shorthand, or a hostname with empty or hyphen-edged labels

It also warns when the protocol is not http/https and allowedProtocols is not set, since the next major makes http/https the default. The tip names the fix (allowedProtocols=[postgres]), and the new allowedProtocols="*" allows any protocol.

The VSCode extension shows the same checks as warnings, and completes allowNoHost. Docs describe the checks with a caution about the next major; the DATABASE_URL examples in the guides now set allowedProtocols, and the README example (API_URL=localhost:${API_PORT}, which only passed because of this) uses http://.

Two supporting fixes so these warnings stay advisory: a type's validation result that contains only warnings no longer stops the checks after it (the sensitive-value length checks still run), and nested validation errors in array/record keep their severity instead of being rewrapped as errors.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

minor Minor releases

  • @varlock/native-helper-darwin 1.22.0 → 1.23.0
  • @varlock/native-helper-linux-arm64 1.22.0 → 1.23.0
  • @varlock/native-helper-linux-x64 1.22.0 → 1.23.0
  • @varlock/native-helper-win32-x64 1.22.0 → 1.23.0
  • env-spec-language 0.4.4 → 0.5.0
  • varlock 1.22.0 → 1.23.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size

⚠️ grows the bundle by 10.8 KB (+0.2%)

Metric main This PR Δ
Total dist 5029.0 KB 5039.8 KB +10.8 KB (+0.2%)
JS 1904.2 KB 1907.6 KB +3.4 KB (+0.2%)
Sourcemaps 2994.6 KB 3002.0 KB +7.4 KB (+0.2%)
Type defs 130.2 KB 130.2 KB —
Other 0.0 KB 0.0 KB —

dist/ only; native binaries are versioned separately and not counted here.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

Two integration gaps need addressing: URL warnings bypass sensitive-value safety checks, and nested URL warnings become blocking errors immediately.

Reviewed changes Reviewed the runtime URL checks, editor diagnostics, tests, and migration documentation.

  • URL structure warnings: Flag opaque URLs, missing hosts, whitespace, and malformed special-scheme hosts without intentionally rejecting existing values.
  • Protocol options: Warn on implicit non-HTTP protocols, support wildcard allowlists, and add allowNoHost.
  • Editor and docs: Mirror advisory checks in VS Code, add completion, and document the next-major transition with corrected examples.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes Reviewed the advisory-validation fixes added since the previous review.

  • Continued safety checks: Retained warning-only type results while running subsequent sensitive-value validation.
  • Preserved nested severity: Kept warning severity and migration tips through array and record validation wrappers.
  • Added regression coverage: Covered nested structural and protocol warnings, genuine nested failures, and minimum sensitive-value length enforcement.

Verified the runtime build, 317 data-type tests, 32 editor diagnostic tests, and additional probes for warning retention and deeper nesting.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@theoephraim
theoephraim merged commit d2abf8e into main Oct 13, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant