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 587b768 commit aefa374
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
48 changes: 25 additions & 23 deletions lib/glob.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
const _ = require('lodash')
class Glob {
constructor(glob) {
this.glob = glob;
constructor (glob) {
const safeGlob = _.escapeRegExp(glob)
this.glob = safeGlob

// If not a glob pattern then just match the string.
if (!this.glob.includes("*")) {
this.regexp = new RegExp(`.*${glob}.*`, "u");
return;
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");
.replace(/\\/g, '\\\\')
.replace(/\//g, '\\/')
.replace(/\?/g, '([^\\/])')
.replace(/\./g, '\\.')
.replace(/\*\*/g, '.+')
.replace(/\*/g, '([^\\/]*)')
this.regexp = new RegExp(`^${regexptex}$`, 'u')
}

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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
"deepmerge": "^4.3.1",
"eta": "^3.0.3",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"node-cron": "^3.0.2",
"octokit": "^3.1.2",
"probot": "^12.3.3"
},
"devDependencies": {
"@eslint/eslintrc": "^2.0.2",
"@travi/any": "^2.1.8",
"check-engine": "^1.10.1",
"eslint": "^8.46.0",
"@eslint/eslintrc": "^2.0.2",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
Expand Down Expand Up @@ -83,4 +84,4 @@
"."
]
}
}
}

0 comments on commit aefa374

Please sign in to comment.