-
Notifications
You must be signed in to change notification settings - Fork 0
Upgrade to ESM #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
robot.auth = new Auth() | ||
|
||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -_]+) role/i, (msg) => { |
Check warning
Code scanning / CodeQL
Overly permissive regular expression range Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, we need to remove the redundant underscore character from the character range in the regular expression. This will make the regular expression clearer and avoid any potential confusion or unexpected behavior.
- In general terms, we should ensure that character ranges in regular expressions do not overlap with predefined character classes like
\w
. - Specifically, we will update the regular expression on line 89 to remove the underscore character from the character range
-_
. - The change will be made in the file
src/Auth.mjs
on line 89.
-
Copy modified line R89 -
Copy modified line R120
@@ -88,3 +88,3 @@ | ||
|
||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() | ||
@@ -119,3 +119,3 @@ | ||
|
||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() |
} | ||
}) | ||
|
||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -_]+) role/i, (msg) => { |
Check warning
Code scanning / CodeQL
Overly permissive regular expression range Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, we need to make the regular expression more precise by escaping the hyphen and removing the redundant underscore. This will ensure that the character class matches only the intended characters without any unintended overlaps.
- Escape the hyphen character in the regular expression to avoid creating an unintended range.
- Remove the redundant underscore character from the character class since it is already included in
\w
.
-
Copy modified line R89 -
Copy modified line R120
@@ -88,3 +88,3 @@ | ||
|
||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: \-]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() | ||
@@ -119,3 +119,3 @@ | ||
|
||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: \-]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() |
} | ||
}) | ||
|
||
robot.respond(/who has (["'\w: -_]+) role\?*$/i, (msg) => { |
Check warning
Code scanning / CodeQL
Overly permissive regular expression range Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, we need to refine the regular expression to avoid the overlap with the \w
character class. Specifically, we should remove the redundant range -_
from the character class. The \w
character class already includes the underscore _
, so we only need to include the hyphen -
separately if it is intended to be matched.
The best way to fix the problem without changing existing functionality is to update the regular expressions on lines 89, 120, and 162 to remove the redundant range -_
and include the hyphen -
separately if needed.
-
Copy modified line R89 -
Copy modified line R120 -
Copy modified line R162
@@ -88,3 +88,3 @@ | ||
|
||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) ha(?:s|ve) (["'\w: -]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() | ||
@@ -119,3 +119,3 @@ | ||
|
||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -_]+) role/i, (msg) => { | ||
robot.respond(/@?(.+) (?:don['’]t|doesn['’]t|do not|does not) have (["'\w: -]+) role/i, (msg) => { | ||
let name = msg.match[1].trim() | ||
@@ -161,3 +161,3 @@ | ||
|
||
robot.respond(/who has (["'\w: -_]+) role\?*$/i, (msg) => { | ||
robot.respond(/who has (["'\w: -]+) role\?*$/i, (msg) => { | ||
const role = msg.match[1] |
Upgrading to ESM