Skip to content

Conversation

@bencmbrook
Copy link
Member

@bencmbrook bencmbrook commented Jul 17, 2025

PR stack:

main
<--#427 (eslint and prettier config changes)
<--#425 (auto-formatting from config changes)
<--#426 (manual fixes which actually are code changes)

Related Issues

  • [none]

Security Implications

[none]

System Availability

[none]

@bencmbrook bencmbrook changed the title bencmbrook/eslintfixes autofixes from prettier and eslint --write Jul 17, 2025
@bencmbrook bencmbrook mentioned this pull request Jul 17, 2025
export function extractClientError(err: string): string | null {
return CLIENT_ERROR.test(err) ? CLIENT_ERROR.exec(err)![1] : null;
export function extractClientError(error: string): string | null {
return CLIENT_ERROR.test(error) ? CLIENT_ERROR.exec(error)![1] : null;

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '{\"message\":\"' and with many repetitions of '{\"message\":\"a'.
export function extractClientError(err: string): string | null {
return CLIENT_ERROR.test(err) ? CLIENT_ERROR.exec(err)![1] : null;
export function extractClientError(error: string): string | null {
return CLIENT_ERROR.test(error) ? CLIENT_ERROR.exec(error)![1] : null;

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '{\"message\":\"' and with many repetitions of '{\"message\":\"a'.
[key.replace(/[^a-z_.+\-A-Z -~]/g, '')]: value,
(accumulator, [key, value]) =>
Object.assign(accumulator, {
[key.replaceAll(/[^a-z_.+\-A-Z -~]/g, '')]: value,

Check warning

Code scanning / CodeQL

Overly permissive regular expression range Medium

Suspicious character range that overlaps with A-Z in the same character class, and overlaps with a-z in the same character class.

Copilot Autofix

AI 3 months ago

To fix the issue, we need to rewrite the regular expression to avoid overlapping ranges while maintaining its intended functionality. The range -~ should be replaced with a more explicit and non-overlapping set of characters. Since the regex appears to target printable ASCII characters, we can explicitly list the allowed characters without relying on overlapping ranges. This will make the regex clearer and easier to maintain.

The updated regex will explicitly include:

  • Lowercase letters (a-z)
  • Uppercase letters (A-Z)
  • Digits (0-9)
  • Specific symbols (_.+- and space)

The corrected regex will be /[^a-zA-Z0-9_.+\- ]/g.


Suggested changeset 1
src/lib/requests/readCsv.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/src/lib/requests/readCsv.ts b/src/lib/requests/readCsv.ts
--- a/src/lib/requests/readCsv.ts
+++ b/src/lib/requests/readCsv.ts
@@ -30,3 +30,3 @@
         Object.assign(accumulator, {
-          [key.replaceAll(/[^a-z_.+\-A-Z -~]/g, '')]: value,
+          [key.replaceAll(/[^a-zA-Z0-9_.+\- ]/g, '')]: value,
         }),
EOF
@@ -30,3 +30,3 @@
Object.assign(accumulator, {
[key.replaceAll(/[^a-z_.+\-A-Z -~]/g, '')]: value,
[key.replaceAll(/[^a-zA-Z0-9_.+\- ]/g, '')]: value,
}),
Copilot is powered by AI and may make mistakes. Always verify output.
@bencmbrook bencmbrook changed the base branch from main to bencmbrook/upgrade-pretter-eslint-node July 22, 2025 21:42
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