Skip to content

Comments

567/user-data-dir-config#630

Merged
cvasseng merged 11 commits intomasterfrom
567/user-data-dir-config
Feb 26, 2025
Merged

567/user-data-dir-config#630
cvasseng merged 11 commits intomasterfrom
567/user-data-dir-config

Conversation

@PaulDalek
Copy link
Contributor

Added the PUPPETEER_TEMP_DIR option, touch #567.

INFO:
Based on the @jszuminski's PR: #569.

@PaulDalek PaulDalek self-assigned this Feb 10, 2025
.refine(
(value) => {
// Simplified regex to match both absolute and relative paths
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '0'.

Copilot Autofix

AI about 1 year ago

To fix the problem, we need to modify the regular expression to remove the ambiguity that can lead to exponential backtracking. Specifically, we should replace the [\w]+ pattern with a more precise pattern that avoids ambiguity. One way to achieve this is to use a non-capturing group with a negated character class to ensure that each character is matched in a deterministic way.

  • Replace the [\w]+ pattern with (?:[\w-]+) to ensure that the pattern matches sequences of word characters and hyphens without causing exponential backtracking.
  • Update the regular expression in the path validator function in the lib/envs.js file.
Suggested changeset 1
lib/envs.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/envs.js b/lib/envs.js
--- a/lib/envs.js
+++ b/lib/envs.js
@@ -74,3 +74,3 @@
           // Simplified regex to match both absolute and relative paths
-          return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(
+          return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test(
             value
EOF
@@ -74,3 +74,3 @@
// Simplified regex to match both absolute and relative paths
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test(
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test(
value
Copilot is powered by AI and may make mistakes. Always verify output.
@PaulDalek PaulDalek committed this autofix suggestion about 1 year ago.
…ression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@PaulDalek PaulDalek linked an issue Feb 10, 2025 that may be closed by this pull request
@cvasseng cvasseng merged commit fd5edc3 into master Feb 26, 2025
2 of 3 checks passed
@cvasseng cvasseng deleted the 567/user-data-dir-config branch February 26, 2025 12:06
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.

v4: make userDataDir configurable

2 participants