Templates engine#91
Closed
Stivenjs wants to merge 17 commits into
Closed
Conversation
…for improved dependency management
…stent dependency installation
… to support deployment
…ent in amplify.yml
…loyment command in amplify.yml
…use local ampx binary
…directly invoke local ampx binary
…ckage.json and package-lock.json
…r when not on the main domain
| const parts = cleanHostname.split('.') | ||
| if (isProduction) { | ||
| // En producción: verificar si hay un subdominio (ej: tienda.fasttify.com) | ||
| if (parts.length > 2 && cleanHostname.endsWith('fasttify.com')) { |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to replace the endsWith check with a more robust validation mechanism that explicitly checks the host against a whitelist of allowed domains and subdomains. This can be achieved by parsing the hostname and comparing it against a predefined list of allowed domains.
Steps to fix:
- Replace the
endsWithcheck with a whitelist-based validation. - Use a list of allowed domains and subdomains for comparison.
- Parse the hostname using a reliable library (e.g.,
URLorurlLib) to ensure accurate extraction of the domain.
Suggested changeset
1
middleware.ts
| @@ -29,4 +29,6 @@ | ||
| // En producción: verificar si hay un subdominio (ej: tienda.fasttify.com) | ||
| if (parts.length > 2 && cleanHostname.endsWith('fasttify.com')) { | ||
| return parts[0] | ||
| const allowedDomains = ['fasttify.com', 'www.fasttify.com']; | ||
| const domain = parts.slice(-2).join('.'); | ||
| if (parts.length > 2 && allowedDomains.includes(domain)) { | ||
| return parts[0]; | ||
| } |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.