Skip to content

Commit

Permalink
fix alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
decyjphr committed Aug 27, 2024
1 parent fc5b693 commit 587b768
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions lib/glob.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
class Glob {
constructor (glob) {
this.glob = glob
const regexptex = glob.replace(/\//g, '\\/').replace(/\?/g, '([^\\/])').replace(/\./g, '\\.').replace(/\*/g, '([^\\/]*)')
this.regexp = new RegExp(`^${regexptex}$`, 'u')
constructor(glob) {
this.glob = glob;

// If not a glob pattern then just match the string.
if (!this.glob.includes("*")) {
this.regexp = new RegExp(`.*${glob}.*`, "u");

Check failure

Code scanning / CodeQL

Regular expression injection High

This regular expression is constructed from a
environment variable
.
return;
}
const regexptex = this.glob
.replace(/\\/g, "\\\\")
.replace(/\//g, "\\/")
.replace(/\?/g, "([^\\/])")
.replace(/\./g, "\\.")
.replace(/\*\*/g, ".+")
.replace(/\*/g, "([^\\/]*)");
this.regexp = new RegExp(`^${regexptex}$`, "u");

Check failure

Code scanning / CodeQL

Regular expression injection High

This regular expression is constructed from a
environment variable
.
}

toString () {
return this.glob
toString() {
return this.glob;
}

[Symbol.search] (s) {
return s.search(this.regexp)
[Symbol.search](s) {
return s.search(this.regexp);
}

[Symbol.match] (s) {
return s.match(this.regexp)
[Symbol.match](s) {
return s.match(this.regexp);
}

[Symbol.replace] (s, replacement) {
return s.replace(this.regexp, replacement)
[Symbol.replace](s, replacement) {
return s.replace(this.regexp, replacement);
}

[Symbol.replaceAll] (s, replacement) {
return s.replaceAll(this.regexp, replacement)
[Symbol.replaceAll](s, replacement) {
return s.replaceAll(this.regexp, replacement);
}
}
module.exports = Glob
module.exports = Glob;

0 comments on commit 587b768

Please sign in to comment.