Conversation
| if (!verbose) { | ||
| pushLine = false; | ||
| } | ||
| } else if (line.match(/index\s[A-z0-9]{7}\.\.[A-z0-9]{7}/)) { |
Check warning
Code scanning / CodeQL
Overly permissive regular expression range Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to update the regular expression to use the correct range for matching uppercase and lowercase letters. Specifically, we should replace A-z with A-Za-z to ensure that only the intended characters are matched.
- Locate the regular expression on line 92 in the file
src/extensions/default/Git/src/Utils.js. - Replace the range
A-zwithA-Za-zto make the regular expression more precise.
| @@ -91,3 +91,3 @@ | ||
| } | ||
| } else if (line.match(/index\s[A-z0-9]{7}\.\.[A-z0-9]{7}/)) { | ||
| } else if (line.match(/index\s[A-Za-z0-9]{7}\.\.[A-Za-z0-9]{7}/)) { | ||
| if (!verbose) { |
| if (!verbose) { | ||
| pushLine = false; | ||
| } | ||
| } else if (line.match(/index\s[A-z0-9]{7}\.\.[A-z0-9]{7}/)) { |
Check warning
Code scanning / CodeQL
Overly permissive regular expression range Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to replace the overly permissive range A-z with a more precise range that matches only the intended characters. In this case, the correct ranges should be A-F and a-f along with digits 0-9. Therefore, we should update the regular expression to use A-Fa-f0-9 instead of A-z.
| @@ -91,3 +91,3 @@ | ||
| } | ||
| } else if (line.match(/index\s[A-z0-9]{7}\.\.[A-z0-9]{7}/)) { | ||
| } else if (line.match(/index\s[A-Fa-f0-9]{7}\.\.[A-Fa-f0-9]{7}/)) { | ||
| if (!verbose) { |
|
|
||
| if (data[7]) { | ||
| var tags = data[7]; | ||
| var regex = new RegExp("tag: ([^,|\)]+)", "g"); |
Check failure
Code scanning / CodeQL
Useless regular-expression character escape High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to remove the unnecessary escape sequence \) from the regular expression on line 553. The correct way to write the regular expression is to use ) instead of \). This change will not affect the functionality of the code but will make it cleaner and more readable.
| @@ -552,3 +552,3 @@ | ||
| var tags = data[7]; | ||
| var regex = new RegExp("tag: ([^,|\)]+)", "g"); | ||
| var regex = new RegExp("tag: ([^,|)]+)", "g"); | ||
| tags = tags.match(regex); |
| if (!stdout) { return false; } | ||
| return _.any(stdout.split("\n"), function (line) { | ||
| return line[0] !== " " && line[0] !== "?" && // first character marks staged status | ||
| line.lastIndexOf(" " + file) === line.length - file.length - 1; // in case another file appeared here? |
Check failure
Code scanning / CodeQL
Incorrect suffix check High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the comparison explicitly handles the case where lastIndexOf returns -1. This can be done by adding a check to ensure that the index is not -1 before performing the length comparison. The best way to fix this without changing existing functionality is to modify the condition to include this additional check.
| @@ -826,3 +826,3 @@ | ||
| return line[0] !== " " && line[0] !== "?" && // first character marks staged status | ||
| line.lastIndexOf(" " + file) === line.length - file.length - 1; // in case another file appeared here? | ||
| line.lastIndexOf(" " + file) !== -1 && line.lastIndexOf(" " + file) === line.length - file.length - 1; // in case another file appeared here? | ||
| }); |
|




This has been ported in from https://github.com/phcode-dev/phoenix-git-port
extension is working, but not loaded for now in default extensions as we need to wire in tests and conditional loading in desktop apps only