Skip to content

Commit 91cf9a9

Browse files
committed
fix(deps): replaced glob by fast-glob due to security advisory
1 parent 927d2a5 commit 91cf9a9

File tree

3 files changed

+661
-797
lines changed

3 files changed

+661
-797
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@
5454
},
5555
"dependencies": {
5656
"cron-parser": "^4.6.0",
57-
"glob": "^8.0.3",
57+
"fast-glob": "^3.3.2",
5858
"ioredis": "^5.3.2",
5959
"lodash": "^4.17.21",
60+
"minimatch": "^9.0.3",
6061
"msgpackr": "^1.10.1",
6162
"node-abort-controller": "^3.1.1",
6263
"semver": "^7.5.4",

src/commands/script-loader.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createHash } from 'crypto';
2-
import { glob, hasMagic } from 'glob';
2+
import { Minimatch } from 'minimatch';
3+
import * as fg from 'fast-glob';
34
import * as path from 'path';
45
import * as fs from 'fs';
56
import { RedisClient } from '../interfaces';
@@ -74,9 +75,19 @@ export class ScriptLoaderError extends Error {
7475
}
7576
}
7677

78+
const hasMagic = (pattern: string | string[]): boolean => {
79+
if (!Array.isArray(pattern)) {
80+
pattern = [pattern];
81+
}
82+
for (const p of pattern) {
83+
if (new Minimatch(p, GlobOptions).hasMagic()) {return true;}
84+
}
85+
return false;
86+
};
87+
7788
const isPossiblyMappedPath = (path: string) =>
7889
path && ['~', '<'].includes(path[0]);
79-
const hasFilenamePattern = (path: string) => hasMagic(path, GlobOptions);
90+
const hasFilenamePattern = (path: string) => hasMagic(path);
8091

8192
/**
8293
* Lua script loader with include support
@@ -487,11 +498,7 @@ function splitFilename(filePath: string): {
487498
}
488499

489500
async function getFilenamesByPattern(pattern: string): Promise<string[]> {
490-
return new Promise<string[]>((resolve, reject) => {
491-
glob(pattern, GlobOptions, (err, files) => {
492-
return err ? reject(err) : resolve(files);
493-
});
494-
});
501+
return fg.glob(pattern, { dot: true });
495502
}
496503

497504
// Determine the project root

0 commit comments

Comments
 (0)