Skip to content

Conversation

@wmertens
Copy link
Member

@wmertens wmertens commented Sep 22, 2024

This PR is for showing progress on v2, and having installable npm packages.

DO NOT MERGE

The changes are meant to be readable and maintainable, so if things are unclear please let us know.

@changeset-bot
Copy link

changeset-bot bot commented Sep 22, 2024

🦋 Changeset detected

Latest commit: 338ac31

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

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 23, 2024

Open in StackBlitz

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@6903
npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@6903
npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@6903
npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@6903

commit: 338ac31

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 338ac31

const insertBefore = journal[idx++] as Element | Text | null;
let newChild: any;
while (idx < length && typeof (newChild = journal[idx]) !== 'number') {
insertParent.insertBefore(newChild, insertBefore);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML

[DOM text](1) is reinterpreted as HTML without escaping meta-characters. [DOM text](2) is reinterpreted as HTML without escaping meta-characters.
@wmertens wmertens changed the title refactor: v2 framework rewrite refactor: v2 release Oct 8, 2024
@wmertens wmertens marked this pull request as ready for review October 17, 2024 21:25
@wmertens wmertens requested review from a team as code owners October 17, 2024 21:25
c.push(`\n/** Qwik Router Entries (${entries.length}) */`);
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);

Check warning

Code scanning / CodeQL

Improper code sanitization

Code construction depends on an [improperly sanitized value](1).

Copilot Autofix

AI 12 months ago

To fix the problem, we need to ensure that entry.filePath is properly sanitized before being used in the dynamically generated JavaScript code. We can achieve this by escaping potentially dangerous characters in the entry.filePath string. This can be done by implementing a function similar to escapeUnsafeChars from the example provided in the background section.

  1. Implement a function escapeUnsafeChars to escape potentially dangerous characters.
  2. Use this function to sanitize entry.filePath before including it in the generated code.
Suggested changeset 1
packages/qwik-router/src/buildtime/runtime-generation/generate-entries.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/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts b/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
--- a/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
+++ b/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
@@ -2,2 +2,20 @@
 
+function escapeUnsafeChars(str: string): string {
+  const charMap: { [key: string]: string } = {
+    '<': '\\u003C',
+    '>': '\\u003E',
+    '/': '\\u002F',
+    '\\': '\\\\',
+    '\b': '\\b',
+   '\f': '\\f',
+   '\n': '\\n',
+   '\r': '\\r',
+   '\t': '\\t',
+   '\0': '\\0',
+   '\u2028': '\\u2028',
+   '\u2029': '\\u2029'
+ };
+ return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, x => charMap[x]);
+}
+
 export function createEntries(ctx: BuildContext, c: string[]) {
@@ -25,3 +43,3 @@
     const entry = entries[i];
-    c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);
+    c.push(`export const ${entry.id} = () => import(${escapeUnsafeChars(JSON.stringify(entry.filePath))});`);
   }
EOF
@@ -2,2 +2,20 @@

function escapeUnsafeChars(str: string): string {
const charMap: { [key: string]: string } = {
'<': '\\u003C',
'>': '\\u003E',
'/': '\\u002F',
'\\': '\\\\',
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t',
'\0': '\\0',
'\u2028': '\\u2028',
'\u2029': '\\u2029'
};
return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, x => charMap[x]);
}

export function createEntries(ctx: BuildContext, c: string[]) {
@@ -25,3 +43,3 @@
const entry = entries[i];
c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);
c.push(`export const ${entry.id} = () => import(${escapeUnsafeChars(JSON.stringify(entry.filePath))});`);
}
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
} else if (key === 'value' && key in element) {
(element as any).value = String(value);
} else if (key === dangerouslySetInnerHTML) {
(element as any).innerHTML = value!;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML

[DOM text](1) is reinterpreted as HTML without escaping meta-characters. [DOM text](2) is reinterpreted as HTML without escaping meta-characters.
return null;
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

The best fix is to replace String(e || 'Error') in the HTTP response body with a generic error message that does not provide any implementation details (e.g., "An unexpected error occurred."). The actual exception's details (e) should still be logged to the server console (as is already done with console.error(e)), so as not to lose valuable debugging information. Specifically:

  • In the catch block starting on line 90, modify the Response creation to use a hard-coded generic error message instead of stringifying the caught exception.
  • No new imports or methods are needed, as logging is already in place.

Suggested changeset 1
packages/qwik-router/src/middleware/bun/index.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/packages/qwik-router/src/middleware/bun/index.ts b/packages/qwik-router/src/middleware/bun/index.ts
--- a/packages/qwik-router/src/middleware/bun/index.ts
+++ b/packages/qwik-router/src/middleware/bun/index.ts
@@ -89,7 +89,7 @@
       return null;
     } catch (e: any) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('An unexpected error occurred.', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
       });
EOF
@@ -89,7 +89,7 @@
return null;
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('An unexpected error occurred.', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
});
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the issue, we should replace String(e || 'Error') in the error response with a generic message, e.g. "An internal server error occurred", and log the actual error on the server using console.error(e).

  • Don't send details about the error, including stack traces or error messages, in the HTTP response.
  • Only log the error server-side so developers can triage it.
  • Make this change only where the error is sent in the HTTP response in file packages/qwik-router/src/middleware/bun/index.ts, specifically in the catch block on lines 115–121.

Suggested changeset 1
packages/qwik-router/src/middleware/bun/index.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/packages/qwik-router/src/middleware/bun/index.ts b/packages/qwik-router/src/middleware/bun/index.ts
--- a/packages/qwik-router/src/middleware/bun/index.ts
+++ b/packages/qwik-router/src/middleware/bun/index.ts
@@ -114,7 +114,7 @@
       });
     } catch (e) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('An internal server error occurred', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
       });
EOF
@@ -114,7 +114,7 @@
});
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('An internal server error occurred', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
return null;
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the problem, do not return the raw stringified exception (String(e)) in the HTTP response to the client. Instead, return a generic error message such as "Internal Server Error" or "An error occurred". Retain the current behavior of logging the full details (console.error(e);) on the server so developers can still perform diagnosis. The actual code change is to update line 170 in the staticFile handler to send only a generic message instead of the stringified error. No new methods or definitions are necessary, and there is no need to add an external logging library unless requested—the existing console.error is sufficient.


Suggested changeset 1
packages/qwik-router/src/middleware/bun/index.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/packages/qwik-router/src/middleware/bun/index.ts b/packages/qwik-router/src/middleware/bun/index.ts
--- a/packages/qwik-router/src/middleware/bun/index.ts
+++ b/packages/qwik-router/src/middleware/bun/index.ts
@@ -167,7 +167,7 @@
       return null;
     } catch (e) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('Internal Server Error', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
       });
EOF
@@ -167,7 +167,7 @@
return null;
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('Internal Server Error', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'bun-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the information exposure issue, the error handling code (specifically within the catch (e: any) block at or after line 127 in packages/qwik-router/src/middleware/cloudflare-pages/index.ts) should be updated so that the HTTP response to the user does not include any information from the caught exception. Instead, return a generic error message such as "Internal Server Error" or "An unexpected error occurred". The detailed error (including stack trace/message) should continue to be logged server-side using console.error(e);.
No additional imports or methods are required to implement the fix, as the existing logging mechanism is sufficient. Only the return statement in the catch block needs to be modified.


Suggested changeset 1
packages/qwik-router/src/middleware/cloudflare-pages/index.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/packages/qwik-router/src/middleware/cloudflare-pages/index.ts b/packages/qwik-router/src/middleware/cloudflare-pages/index.ts
--- a/packages/qwik-router/src/middleware/cloudflare-pages/index.ts
+++ b/packages/qwik-router/src/middleware/cloudflare-pages/index.ts
@@ -126,7 +126,7 @@
       });
     } catch (e: any) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('Internal Server Error', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'cloudflare-pages' },
       });
EOF
@@ -126,7 +126,7 @@
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('Internal Server Error', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'cloudflare-pages' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
return null;
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the problem, modify the router's error-returning code (lines 91–97). Instead of passing potentially sensitive contents of the error (such as a stack trace or message) to the Response body, return a generic error message like "Internal Server Error". Server-side logging (console.error(e)) should be retained for debugging. Only the router function's catch block (lines 91–97) needs changing; other usages (such as in the notFound handler) may remain unless similarly problematic and flagged, but should be checked separately.

No new imports or dependencies are required for this fix because the solution only involves modifying the content of the error message sent in the response body.

Suggested changeset 1
packages/qwik-router/src/middleware/deno/index.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/packages/qwik-router/src/middleware/deno/index.ts b/packages/qwik-router/src/middleware/deno/index.ts
--- a/packages/qwik-router/src/middleware/deno/index.ts
+++ b/packages/qwik-router/src/middleware/deno/index.ts
@@ -90,7 +90,7 @@
       return null;
     } catch (e: any) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response("Internal Server Error", {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
       });
EOF
@@ -90,7 +90,7 @@
return null;
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response("Internal Server Error", {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
});
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the issue, we should avoid sending stack trace or error object details to the client within error responses. Instead, send a generic message like "Internal Server Error" or "An unexpected error occurred." For server-side debugging, the full error (including stack trace) should be logged using console.error(e) as is already done. Specifically, in packages/qwik-router/src/middleware/deno/index.ts, on line 118 inside the catch block of the notFound handler, change new Response(String(e || 'Error'), ...) to new Response("Internal Server Error", ...) (or a similarly generic message). No new methods or imports are needed, as logging is already present.

Suggested changeset 1
packages/qwik-router/src/middleware/deno/index.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/packages/qwik-router/src/middleware/deno/index.ts b/packages/qwik-router/src/middleware/deno/index.ts
--- a/packages/qwik-router/src/middleware/deno/index.ts
+++ b/packages/qwik-router/src/middleware/deno/index.ts
@@ -115,7 +115,7 @@
       });
     } catch (e) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('Internal Server Error', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
       });
EOF
@@ -115,7 +115,7 @@
});
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('Internal Server Error', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
return null;
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix this information exposure, we should make sure that the client only ever receives a generic error message, such as "Internal Server Error" or "An error occurred", instead of the actual error message or stack trace. The detailed error should still be logged on the server for debugging purposes, as is already done with console.error(e).

How to apply the fix:

  • Change the response on line 163 to return a constant string like "An error occurred" or "Internal Server Error" instead of using the stringified error object.
  • This change should only affect the call to the Response constructor in the catch block inside the staticFile function, so that existing behavior (server-side logging) remains unchanged and error information is still available to developers.

Files/Regions/Lines to change:

  • File: packages/qwik-router/src/middleware/deno/index.ts
  • Editing the return statement at line 163.

What is needed:

  • No additional imports or utility methods are required, as the fix is a literal string substitution.

Suggested changeset 1
packages/qwik-router/src/middleware/deno/index.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/packages/qwik-router/src/middleware/deno/index.ts b/packages/qwik-router/src/middleware/deno/index.ts
--- a/packages/qwik-router/src/middleware/deno/index.ts
+++ b/packages/qwik-router/src/middleware/deno/index.ts
@@ -160,7 +160,7 @@
       return null;
     } catch (e) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('Internal Server Error', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
       });
EOF
@@ -160,7 +160,7 @@
return null;
} catch (e) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('Internal Server Error', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix the problem, the error handler should return a generic error message to the user rather than exposing the details of the thrown error object. The stack trace and error details should be logged on the server (using console.error(e) as is currently done) but not exposed in the body of the HTTP response. In this file, specifically, we need to change line 91 so that the response always contains a generic message, such as "Internal Server Error" or "An unexpected error occurred". No new imports are needed—just modify the error response construction to avoid passing String(e) to the client.


Suggested changeset 1
packages/qwik-router/src/middleware/netlify-edge/index.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/packages/qwik-router/src/middleware/netlify-edge/index.ts b/packages/qwik-router/src/middleware/netlify-edge/index.ts
--- a/packages/qwik-router/src/middleware/netlify-edge/index.ts
+++ b/packages/qwik-router/src/middleware/netlify-edge/index.ts
@@ -88,7 +88,7 @@
       });
     } catch (e: any) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response('Internal Server Error', {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'netlify-edge' },
       });
EOF
@@ -88,7 +88,7 @@
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response('Internal Server Error', {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'netlify-edge' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {

Check warning

Code scanning / CodeQL

Information exposure through a stack trace

This information exposed to the user depends on [stack trace information](1).

Copilot Autofix

AI about 2 months ago

To fix this issue, we should ensure that error details sent back to clients do not expose stack traces, implementation details, or server-side file paths. Instead, only a generic error message ("Internal Server Error" or similar) should be returned in the HTTP response, while details should be logged server-side for debugging purposes.

Specifically, in packages/qwik-router/src/middleware/vercel-edge/index.ts, within the catch block at line 116, only a generic error message should be sent in the response, while the detailed error (e) should continue to be logged using console.error(e). The relevant code to edit starts at line 116:

  • Replace String(e || 'Error') (user-facing) with a safe, generic string like "Internal Server Error".
  • No extra dependency is required: logging with console.error suffices for server-side logs.
  • Ensure the change is only made at the point of user-facing error creation; the logging remains unchanged.
Suggested changeset 1
packages/qwik-router/src/middleware/vercel-edge/index.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/packages/qwik-router/src/middleware/vercel-edge/index.ts b/packages/qwik-router/src/middleware/vercel-edge/index.ts
--- a/packages/qwik-router/src/middleware/vercel-edge/index.ts
+++ b/packages/qwik-router/src/middleware/vercel-edge/index.ts
@@ -115,7 +115,7 @@
       });
     } catch (e: any) {
       console.error(e);
-      return new Response(String(e || 'Error'), {
+      return new Response("Internal Server Error", {
         status: 500,
         headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'vercel-edge' },
       });
EOF
@@ -115,7 +115,7 @@
});
} catch (e: any) {
console.error(e);
return new Response(String(e || 'Error'), {
return new Response("Internal Server Error", {
status: 500,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'vercel-edge' },
});
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +10 to +15
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
if: github.event_name == 'pull_request'
with:
workflow_id: ${{ github.event.workflow.id }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 3 months ago

To fix the problem, you should add a permissions block to the workflow or to the specific job. The best practice is to set the minimal permissions required for the workflow to function. In this case, the workflow uses the styfle/cancel-workflow-action, which typically only needs actions: write permission to cancel workflow runs. Therefore, you should add a permissions block with actions: write at either the workflow root (to apply to all jobs) or at the job level (to apply only to the cancel job). The change should be made in .github/workflows/cancel.yml, above the jobs: key (for workflow-level) or inside the cancel: job (for job-level). No additional imports or definitions are needed.

Suggested changeset 1
.github/workflows/cancel.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml
--- a/.github/workflows/cancel.yml
+++ b/.github/workflows/cancel.yml
@@ -2,2 +2,4 @@
 name: Cancel
+permissions:
+  actions: write
 on:
EOF
@@ -2,2 +2,4 @@
name: Cancel
permissions:
actions: write
on:
Copilot is powered by AI and may make mistakes. Always verify output.
const tarballOutDir = join(workspaceRoot, 'temp', 'tarballs');
for (const [name, cfg] of Object.entries(packageCfg)) {
const out = execSync(`pnpm pack --pack-destination=${tarballOutDir}`, {
const out = execSync(`pnpm pack --json --pack-destination=${tarballOutDir}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2).

Copilot Autofix

AI 6 months ago

To fix the issue, the shell command should avoid direct interpolation of environment-derived values. Instead, the execSync call should be replaced with execFileSync, which allows passing arguments separately. This ensures that the shell does not interpret special characters in the tarballOutDir or other dynamically constructed paths.

Steps to fix:

  1. Replace the execSync call with execFileSync.
  2. Pass the pnpm command and its arguments as separate parameters to execFileSync.
  3. Ensure that the tarballOutDir and other paths are passed as arguments, not interpolated into the command string.

Suggested changeset 1
e2e/qwik-cli-e2e/utils/setup.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/e2e/qwik-cli-e2e/utils/setup.ts b/e2e/qwik-cli-e2e/utils/setup.ts
--- a/e2e/qwik-cli-e2e/utils/setup.ts
+++ b/e2e/qwik-cli-e2e/utils/setup.ts
@@ -1,2 +1,2 @@
-import { execSync } from 'child_process';
+import { execFileSync } from 'child_process';
 import { existsSync, writeFileSync } from 'fs';
@@ -30,3 +30,3 @@
   for (const [name, cfg] of Object.entries(packageCfg)) {
-    const out = execSync(`pnpm pack --json --pack-destination=${tarballOutDir}`, {
+    const out = execFileSync('pnpm', ['pack', '--json', `--pack-destination=${tarballOutDir}`], {
       cwd: join(workspaceRoot, cfg.packagePath),
EOF
@@ -1,2 +1,2 @@
import { execSync } from 'child_process';
import { execFileSync } from 'child_process';
import { existsSync, writeFileSync } from 'fs';
@@ -30,3 +30,3 @@
for (const [name, cfg] of Object.entries(packageCfg)) {
const out = execSync(`pnpm pack --json --pack-destination=${tarballOutDir}`, {
const out = execFileSync('pnpm', ['pack', '--json', `--pack-destination=${tarballOutDir}`], {
cwd: join(workspaceRoot, cfg.packagePath),
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Varixo and others added 30 commits November 3, 2025 19:39
fix(serdes): preload qrls work again
fix(computed): actually preload (v2)
fix(asynccomputed): don't throw twice
fix: don't emit script before qwik style element
feat: support promises in attributes
fix(v2): qwikVite client outDir fix
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.

9 participants