github-advanced-security[bot] commented on code in PR #20421:
URL: https://github.com/apache/druid/pull/20421#discussion_r4099778584


##########
web-console/script/mv:
##########
@@ -56,20 +56,23 @@
   fs.renameSync(newPath + oldName + '.spec.tsx', newPath + newName + 
'.spec.tsx');
 } catch {}
 
-const replacePath = './src/';
-
-replace({
-  regex: oldName,
-  replacement: newName,
-  paths: [replacePath],
-  recursive: true,
-  silent: true,
-});
+function replaceInFiles(dir, replacements) {
+  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+    const entryPath = path.join(dir, entry.name);
+    if (entry.isDirectory()) {
+      replaceInFiles(entryPath, replacements);
+    } else if (entry.isFile()) {
+      const text = fs.readFileSync(entryPath, 'utf-8');
+      let newText = text;
+      for (const [from, to] of replacements) {
+        newText = newText.replace(new RegExp(from, 'g'), to);

Review Comment:
   ## CodeQL / Regular expression injection
   
   This regular expression is constructed from a [command-line argument](1).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/12009)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to