Skip to content

Commit

Permalink
refactor: fix deprecation in tests & update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken committed Aug 15, 2024
1 parent 86cb3d9 commit 8179426
Show file tree
Hide file tree
Showing 39 changed files with 469 additions and 380 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

19 changes: 19 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ESLintConfig } from "@openally/config.eslint";

export default [
{
ignores: [
"**/test/fixtures/**/*.js",
"**/test/probes/fixtures/**/*.js"
]
},
...ESLintConfig,
{
languageOptions: {
sourceType: "module",
parserOptions: {
requireConfigFile: false
}
}
}
];
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"node": ">=18.0.0"
},
"scripts": {
"lint": "eslint src test",
"prepublishOnly": "pkg-ok",
"lint": "eslint src workspaces test",
"test-only": "glob -c \"node --test-reporter=spec --test\" \"./test/**/*.spec.js\"",
"test": "c8 --all --src ./src -r html npm run test-only",
"check": "npm run lint && npm run test-only"
Expand Down Expand Up @@ -54,13 +53,10 @@
"ts-pattern": "^5.0.6"
},
"devDependencies": {
"@nodesecure/eslint-config": "^1.6.0",
"@openally/config.eslint": "^1.0.0",
"@types/node": "^22.0.0",
"c8": "^10.1.2",
"cross-env": "^7.0.3",
"eslint": "^9.0.0",
"glob": "^11.0.0",
"iterator-matcher": "^2.1.0",
"pkg-ok": "^3.0.0"
"iterator-matcher": "^2.1.0"
}
}
1 change: 1 addition & 0 deletions src/probes/isLiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { builtinModules } from "repl";
import { Hex } from "@nodesecure/sec-literal";

const kMapRegexIps = Object.freeze({
// eslint-disable-next-line @stylistic/max-len
regexIPv4: /^(https?:\/\/)(?!127\.)(?!.*:(?:0{1,3}|25[6-9])\.)(?!.*:(?:25[6-9])\.(?:0{1,3}|25[6-9])\.)(?!.*:(?:25[6-9])\.(?:25[6-9])\.(?:0{1,3}|25[6-9])\.)(?!.*:(?:25[6-9])\.(?:25[6-9])\.(?:25[6-9])\.(?:0{1,3}|25[6-9]))((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?::\d{1,5})?(\/[^\s]*)?$/,
regexIPv6: /^(https?:\/\/)(\[[0-9A-Fa-f:]+\])(?::\d{1,5})?(\/[^\s]*)?$/
});
Expand Down
2 changes: 0 additions & 2 deletions test/AstAnalyser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ describe("AstAnalyser", (t) => {
});
});


it("intialize should be called before finalize", async() => {
const calls = [];

Expand Down Expand Up @@ -461,7 +460,6 @@ describe("AstAnalyser", (t) => {
});
});


it("intialize should be called before finalize", () => {
const calls = [];

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/entryFiles/deps/default.cjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('externalDep')
require('dep.cjs')
require("externalDep");
require("dep.cjs");
2 changes: 1 addition & 1 deletion test/fixtures/entryFiles/deps/default.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('externalDep')
require("externalDep");
4 changes: 2 additions & 2 deletions test/fixtures/entryFiles/deps/default.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import externalDep from 'externalDep';
import('dep.mjs')
import externalDep from "externalDep";
import("dep.mjs");
2 changes: 1 addition & 1 deletion test/fixtures/entryFiles/deps/dep.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = {}
module.exports = {};
2 changes: 1 addition & 1 deletion test/fixtures/entryFiles/deps/dep.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {}
export {};
2 changes: 1 addition & 1 deletion test/fixtures/issues/html-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ var bar;
// == fake comment == //

const yo = 5;
//-->;
// -->;
42 changes: 41 additions & 1 deletion test/fixtures/issues/prop-types.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,44 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
!function(f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).PropTypes=f()}(function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var p="function"==typeof require&&require;if(!f&&p)return p(i,!0);if(u)return u(i,!0);throw(p=new Error("Cannot find module '"+i+"'")).code="MODULE_NOT_FOUND",p}p=n[i]={exports:{}},e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){"use strict";var ReactPropTypesSecret=require(3);function emptyFunction(){}function emptyFunctionWithReset(){}emptyFunctionWithReset.resetWarningCache=emptyFunction,module.exports=function(){function e(e,t,n,r,o,c){if(c!==ReactPropTypesSecret){c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}var n={array:e.isRequired=e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:emptyFunctionWithReset,resetWarningCache:emptyFunction};return n.PropTypes=n}},{3:3}],2:[function(require,module,exports){module.exports=require(1)()},{1:1}],3:[function(require,module,exports){"use strict";module.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},{}]},{},[2])(2)});
!(function(f) {
typeof exports == "object" && typeof module != "undefined" ? module.exports = f() : typeof define == "function" && define.amd ? define([], f) : (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this).PropTypes = f();
}(function() {
return (function r(e, n, t) {
function o(i, f) {
if (!n[i]) {
if (!e[i]) {
var p = typeof require == "function" && require; if (!f && p) {
return p(i, !0);
} if (u) {
return u(i, !0);
} throw (p = new Error("Cannot find module '" + i + "'")).code = "MODULE_NOT_FOUND", p;
}p = n[i] = { exports: {} }, e[i][0].call(p.exports, function(r) {
return o(e[i][1][r] || r);
}, p, p.exports, r, e, n, t);
}

return n[i].exports;
} for (var u = typeof require == "function" && require, i = 0; i < t.length; i++) {
o(t[i]);
}

return o;
}({ 1: [function(require, module, exports) {
"use strict"; const ReactPropTypesSecret = require(3); function emptyFunction() {} function emptyFunctionWithReset() {}emptyFunctionWithReset.resetWarningCache = emptyFunction, module.exports = function() {
function e(e, t, n, r, o, c) {
if (c !== ReactPropTypesSecret) {
c = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"); throw c.name = "Invariant Violation", c;
}
} function t() {
return e;
} const n = { array: e.isRequired = e, bigint: e, bool: e, func: e, number: e, object: e, string: e, symbol: e, any: e, arrayOf: t, element: e, elementType: e, instanceOf: t, node: e, objectOf: t, oneOf: t, oneOfType: t, shape: t, exact: t, checkPropTypes: emptyFunctionWithReset, resetWarningCache: emptyFunction };

return n.PropTypes = n;
};
}, { 3: 3 }], 2: [function(require, module, exports) {
module.exports = require(1)();
}, { 1: 1 }], 3: [function(require, module, exports) {
"use strict"; module.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
}, {}] }, {}, [2]))(2);
}));
43 changes: 22 additions & 21 deletions test/fixtures/obfuscated/freejsobfuscator.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
var _cs = [
"\x7a\x7a\x7a",
"\x24\x24\x20",
"\x6d\x61\x74\x68",
"\x74\x69\x6d\x65",
"\x74\x69\x6d\x65",
"\x62\x62\x62",
"\x20\x24",
"\x61\x61\x61",
"\x79\x79\x79",
"\x42\x79"
]
function _f1(_p2, _p1, _p0) {
var _v0 = _p2 + _p0 + _p1
var _v1 = "[" + _v0 + "]"
return _v1
}
function _f0() {}
var _g0 = _f1(_cs[7], _cs[5], "-")
_g0 += _cs[6] + _cs[1]
_g0 += _f1(_cs[0], _cs[8], "-")
alert(_g0)
"\x7a\x7a\x7a",
"\x24\x24\x20",
"\x6d\x61\x74\x68",
"\x74\x69\x6d\x65",
"\x74\x69\x6d\x65",
"\x62\x62\x62",
"\x20\x24",
"\x61\x61\x61",
"\x79\x79\x79",
"\x42\x79"
];
function _f1(_p2, _p1, _p0) {
const _v0 = _p2 + _p0 + _p1;
const _v1 = "[" + _v0 + "]";

return _v1;
}
function _f0() {}
var _g0 = _f1(_cs[7], _cs[5], "-");
_g0 += _cs[6] + _cs[1];
_g0 += _f1(_cs[0], _cs[8], "-");
alert(_g0);
36 changes: 18 additions & 18 deletions test/fixtures/obfuscated/jjencode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boo = ~[]
boo = ~[];
boo = {
___: ++boo,
$$$$: (![] + "")[boo],
Expand All @@ -16,7 +16,7 @@ boo = {
$$$: ++boo,
$___: ++boo,
$__$: ++boo
}
};
boo.$_ =
(boo.$_ = boo + "")[boo.$_$] +
(boo._$ = boo.$_[boo.__$]) +
Expand All @@ -28,22 +28,22 @@ boo.$_ =
boo.$_[boo.$_$] +
boo.__ +
boo._$ +
boo.$
boo.$$ = boo.$ + (!"" + "")[boo._$$] + boo.__ + boo._ + boo.$ + boo.$$
boo.$ = boo.___[boo.$_][boo.$_]
boo.$;
boo.$$ = boo.$ + (!"" + "")[boo._$$] + boo.__ + boo._ + boo.$ + boo.$$;
boo.$ = boo.___[boo.$_][boo.$_];
boo.$(
boo.$(
boo.$$ +
'"' +
boo.$_$_ +
(![] + "")[boo._$_] +
boo.$$$_ +
"\\" +
boo.__$ +
boo.$$_ +
boo._$_ +
boo.__ +
'(\\"\\' +
"\"" +
boo.$_$_ +
(![] + "")[boo._$_] +
boo.$$$_ +
"\\" +
boo.__$ +
boo.$$_ +
boo._$_ +
boo.__ +
"(\\\"\\" +
boo.__$ +
boo.__$ +
boo.___ +
Expand Down Expand Up @@ -82,10 +82,10 @@ boo.$(
boo.$$_ +
boo.___ +
boo.__ +
'\\"\\' +
"\\\"\\" +
boo.$__ +
boo.___ +
")" +
'"'
"\""
)()
)()
)();
Loading

0 comments on commit 8179426

Please sign in to comment.