Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-redos

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-redos - npm Package Compare versions

Comparing version 4.4.5 to 4.5.0-beta.1

147

lib/main.js

@@ -34,2 +34,5 @@ "use strict";

};
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {

@@ -55,2 +58,116 @@ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;

// src/utils/cache.ts
var fs, os, path, import_find_cache_dir, findDefaultCacheFile, findCacheFileFromOptions, findCacheFile;
var init_cache = __esm({
"src/utils/cache.ts"() {
"use strict";
fs = __toESM(require("fs"));
os = __toESM(require("os"));
path = __toESM(require("path"));
import_find_cache_dir = __toESM(require("find-cache-dir"));
findDefaultCacheFile = () => {
const cacheDir = (0, import_find_cache_dir.default)({ name: "eslint-plugin-redos", create: true }) || os.tmpdir();
const cacheFile = path.join(cacheDir, "recheck-cache.json");
return cacheFile;
};
findCacheFileFromOptions = (location) => {
const cacheFile = path.resolve(location);
let stat;
try {
stat = fs.statSync(cacheFile);
} catch (e) {
}
if (stat) {
if (stat.isDirectory()) {
throw new Error(`Resolved cache.location '${cacheFile}' is a directory`);
}
}
return cacheFile;
};
findCacheFile = (location) => {
if (!location) {
return findDefaultCacheFile();
}
return findCacheFileFromOptions(location);
};
}
});
// src/utils/version.ts
var recheckVersion;
var init_version = __esm({
"src/utils/version.ts"() {
"use strict";
recheckVersion = () => {
const pkg = require.resolve("recheck/package.json");
return pkg.version;
};
}
});
// src/utils/checker.ts
var fs2, util, ReDoS, createCachedCheck;
var init_checker = __esm({
"src/utils/checker.ts"() {
"use strict";
fs2 = __toESM(require("fs"));
util = __toESM(require("util"));
ReDoS = __toESM(require("recheck"));
init_cache();
init_version();
createCachedCheck = (cache, timeout, params) => {
const {
location: cacheLocation = void 0,
strategy: cacheStrategy = "aggressive"
} = typeof cache === "boolean" ? {} : cache;
const cacheFile = cache ? findCacheFile(cacheLocation) : null;
const settings = {
version: recheckVersion(),
timeout,
strategy: cacheStrategy,
params
};
let cacheData;
try {
if (cacheFile) {
cacheData = fs2.existsSync(cacheFile) ? JSON.parse(fs2.readFileSync(cacheFile, "utf-8")) : {};
if (!util.isDeepStrictEqual(cacheData.settings, settings)) {
cacheData = {
settings,
results: {}
};
}
}
} catch (error) {
throw new Error(`Invalid cache: ${error}`);
}
const cachedCheck = (source, flags) => {
const key = `/${source}/${flags}`;
if (cacheData && cacheData.results[key]) {
return cacheData.results[key];
}
const result = ReDoS.checkSync(source, flags, __spreadValues({ timeout }, params));
let shouldCache = false;
switch (cacheStrategy) {
case "aggressive":
shouldCache = true;
break;
case "conservative":
shouldCache = result.checker === "automaton";
break;
}
if (!shouldCache) {
return result;
}
if (cacheFile) {
cacheData.results[key] = result;
fs2.writeFileSync(cacheFile, JSON.stringify(cacheData));
}
return result;
};
return cachedCheck;
};
}
});
// src/rules/no-vulnerable.ts

@@ -60,3 +177,3 @@ var require_no_vulnerable = __commonJS({

"use strict";
var ReDoS = __toESM(require("recheck"));
init_checker();
var rule = {

@@ -82,2 +199,21 @@ meta: {

},
cache: {
oneOf: [
{
type: "boolean"
},
{
properties: {
location: {
type: "string"
},
strategy: {
type: "string",
enum: ["aggressive", "conservative"]
}
},
additionalProperties: false
}
]
},
accelerationMode: {

@@ -177,10 +313,13 @@ type: "string",

permittableComplexities = [],
timeout = 1e4
timeout = 1e4,
cache = false
} = _a, params = __objRest(_a, [
"ignoreErrors",
"permittableComplexities",
"timeout"
"timeout",
"cache"
]);
const cachedCheck = createCachedCheck(cache, timeout, params);
const check = (node, source, flags) => {
const result = ReDoS.checkSync(source, flags, __spreadValues({ timeout }, params));
const result = cachedCheck(source, flags);
switch (result.status) {

@@ -187,0 +326,0 @@ case "safe":

17

package.json
{
"name": "eslint-plugin-redos",
"version": "4.4.5",
"version": "4.5.0-beta.1",
"description": "ESLint plugin for catching ReDoS vulnerability",

@@ -28,3 +28,4 @@ "license": "MIT",

"dependencies": {
"recheck": "4.4.5"
"find-cache-dir": "4.0.0",
"recheck": "4.5.0-beta.1"
},

@@ -35,9 +36,11 @@ "peerDependencies": {

"devDependencies": {
"@types/eslint": "8.21.0",
"@types/node": "18.13.0",
"esbuild": "0.17.8",
"@types/eslint": "8.21.1",
"@types/find-cache-dir": "3.2.1",
"@types/jest": "29.4.0",
"@types/node": "18.14.0",
"esbuild": "0.17.10",
"esbuild-jest": "0.5.0",
"esbuild-register": "3.4.2",
"eslint": "8.34.0",
"jest": "29.4.2",
"jest": "29.4.3",
"prettier": "2.8.4",

@@ -58,3 +61,3 @@ "rimraf": "4.1.2",

],
"gitHead": "e721d682478543cecfc73585c610502dc897037a"
"gitHead": "e53585b7b8ac3baf9953df62f7d1f89f8c5f105e"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc