Skip to content

Templates engine#91

Closed
Stivenjs wants to merge 17 commits into
mainfrom
templates-engine
Closed

Templates engine#91
Stivenjs wants to merge 17 commits into
mainfrom
templates-engine

Conversation

@Stivenjs
Copy link
Copy Markdown
Contributor

@Stivenjs Stivenjs commented Jun 5, 2025

No description provided.

Stivenjs added 17 commits June 5, 2025 12:58
Comment thread middleware.ts
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

'
fasttify.com
' may be preceded by an arbitrary host name.

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:

  1. Replace the endsWith check with a whitelist-based validation.
  2. Use a list of allowed domains and subdomains for comparison.
  3. Parse the hostname using a reliable library (e.g., URL or urlLib) to ensure accurate extraction of the domain.

Suggested changeset 1
middleware.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/middleware.ts b/middleware.ts
--- a/middleware.ts
+++ b/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];
         }
EOF
@@ -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.
@Stivenjs Stivenjs closed this Jun 5, 2025
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.

2 participants