Skip to content

Conversation

@RubenSandwich
Copy link
Collaborator

Potential fix for https://github.com/hashicorp/dev-portal/security/code-scanning/17

In general, to fix this category of issue you must escape literal dots and any other regex metacharacters when you intend to match them literally in hostnames. For a domain like learn.hashicorp.com, the safe literal regex is learn\.hashicorp\.com, so the dots do not act as wildcards.

For this specific test, the best minimal change that preserves intent is to change the inline regex from /(learn.hashicorp.com)?\/search/ to /^(https?:\/\/)?(learn\.hashicorp\.com)?\/search/ if you want to be precise about the host, or more conservatively and minimally to /(learn\.hashicorp\.com)?\/search/. The latter keeps the existing behavior and intent (optional hostname followed by /search) while ensuring the hostname is matched literally. No imports or additional helpers are needed; we only adjust the regex literal in the test file src/lib/remark-plugins/rewrite-tutorial-links/__tests__/rewrite-tutorial-links.test.ts at the expect(String(contents)).toMatch(...) line around 240.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ession for hostnames

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
dev-portal Ready Ready Preview, Comment Jan 14, 2026 7:19pm

@github-actions
Copy link

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

This PR introduced no changes to the javascript bundle 🙌

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.

1 participant