@nodesecure/js-x-ray 8.2.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +17 -3
- package/src/AstAnalyser.js +18 -5
- package/src/probes/isLiteral.js +1 -1
- package/src/warnings.js +6 -5
- package/types/api.d.ts +3 -3
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ $ yarn add @nodesecure/estree-ast-util
|
|
|
161
161
|
## Contributors ✨
|
|
162
162
|
|
|
163
163
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
164
|
-
[](#contributors-)
|
|
165
165
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
166
166
|
|
|
167
167
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
@@ -195,6 +195,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
195
195
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sairuss7"><img src="https://avatars.githubusercontent.com/u/87803528?v=4?s=100" width="100px;" alt="SairussDev"/><br /><sub><b>SairussDev</b></sub></a><br /><a href="https://github.com/NodeSecure/js-x-ray/commits?author=sairuss7" title="Code">💻</a></td>
|
|
196
196
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/fless-lab"><img src="https://avatars.githubusercontent.com/u/71844440?v=4?s=100" width="100px;" alt="Abdou-Raouf ATARMLA"/><br /><sub><b>Abdou-Raouf ATARMLA</b></sub></a><br /><a href="https://github.com/NodeSecure/js-x-ray/commits?author=fless-lab" title="Code">💻</a></td>
|
|
197
197
|
<td align="center" valign="top" width="14.28%"><a href="https://clementgombauld.netlify.app/"><img src="https://avatars.githubusercontent.com/u/91478082?v=4?s=100" width="100px;" alt="Clement Gombauld"/><br /><sub><b>Clement Gombauld</b></sub></a><br /><a href="https://github.com/NodeSecure/js-x-ray/commits?author=clemgbld" title="Code">💻</a> <a href="https://github.com/NodeSecure/js-x-ray/commits?author=clemgbld" title="Tests">⚠️</a></td>
|
|
198
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/intincrab"><img src="https://avatars.githubusercontent.com/u/93028153?v=4?s=100" width="100px;" alt="Ajāy "/><br /><sub><b>Ajāy </b></sub></a><br /><a href="https://github.com/NodeSecure/js-x-ray/commits?author=intincrab" title="Code">💻</a></td>
|
|
198
199
|
</tr>
|
|
199
200
|
</tbody>
|
|
200
201
|
</table>
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodesecure/js-x-ray",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "JavaScript AST XRay analysis",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports":
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./index.js",
|
|
9
|
+
"types": "./index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./warnings": {
|
|
12
|
+
"import": "./src/warnings.js",
|
|
13
|
+
"types": "./types/warnings.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
7
17
|
"engines": {
|
|
8
18
|
"node": ">=20.0.0"
|
|
9
19
|
},
|
|
@@ -11,7 +21,9 @@
|
|
|
11
21
|
"lint": "eslint src workspaces test",
|
|
12
22
|
"test-only": "glob -c \"node --test-reporter=spec --test\" \"./test/**/*.spec.js\"",
|
|
13
23
|
"test": "c8 --all --src ./src -r html npm run test-only",
|
|
14
|
-
"check": "npm run lint && npm run test-only"
|
|
24
|
+
"check": "npm run lint && npm run test-only",
|
|
25
|
+
"ci:publish": "changeset publish",
|
|
26
|
+
"ci:version": "changeset version"
|
|
15
27
|
},
|
|
16
28
|
"repository": {
|
|
17
29
|
"type": "git",
|
|
@@ -54,6 +66,8 @@
|
|
|
54
66
|
"ts-pattern": "^5.0.6"
|
|
55
67
|
},
|
|
56
68
|
"devDependencies": {
|
|
69
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
70
|
+
"@changesets/cli": "^2.29.4",
|
|
57
71
|
"@openally/config.eslint": "^2.0.0",
|
|
58
72
|
"@types/node": "^22.0.0",
|
|
59
73
|
"c8": "^10.1.2",
|
package/src/AstAnalyser.js
CHANGED
|
@@ -75,11 +75,15 @@ export class AstAnalyser {
|
|
|
75
75
|
finalize(source);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// Add oneline-require flag if this is a one-line require expression
|
|
79
|
+
if (isOneLineExpressionExport(body)) {
|
|
80
|
+
source.flags.add("oneline-require");
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
return {
|
|
79
84
|
...source.getResult(isMinified),
|
|
80
85
|
dependencies: source.dependencies,
|
|
81
|
-
flags: source.flags
|
|
82
|
-
isOneLineRequire: isOneLineExpressionExport(body)
|
|
86
|
+
flags: source.flags
|
|
83
87
|
};
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -112,12 +116,16 @@ export class AstAnalyser {
|
|
|
112
116
|
data.dependencies.delete(packageName);
|
|
113
117
|
}
|
|
114
118
|
|
|
119
|
+
// Add is-minified flag if the file is minified and not a one-line require
|
|
120
|
+
if (!data.flags.has("oneline-require") && isMin) {
|
|
121
|
+
data.flags.add("is-minified");
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
return {
|
|
116
125
|
ok: true,
|
|
117
126
|
dependencies: data.dependencies,
|
|
118
127
|
warnings: data.warnings,
|
|
119
|
-
flags: data.flags
|
|
120
|
-
isMinified: !data.isOneLineRequire && isMin
|
|
128
|
+
flags: data.flags
|
|
121
129
|
};
|
|
122
130
|
}
|
|
123
131
|
catch (error) {
|
|
@@ -159,11 +167,16 @@ export class AstAnalyser {
|
|
|
159
167
|
data.dependencies.delete(packageName);
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
// Add is-minified flag if the file is minified and not a one-line require
|
|
171
|
+
if (!data.flags.has("oneline-require") && isMin) {
|
|
172
|
+
data.flags.add("is-minified");
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
return {
|
|
163
176
|
ok: true,
|
|
164
177
|
dependencies: data.dependencies,
|
|
165
178
|
warnings: data.warnings,
|
|
166
|
-
|
|
179
|
+
flags: data.flags
|
|
167
180
|
};
|
|
168
181
|
}
|
|
169
182
|
catch (error) {
|
package/src/probes/isLiteral.js
CHANGED
|
@@ -15,7 +15,7 @@ const kNodeDeps = new Set(builtinModules);
|
|
|
15
15
|
const kShadyLinkRegExps = [
|
|
16
16
|
kMapRegexIps.regexIPv4,
|
|
17
17
|
kMapRegexIps.regexIPv6,
|
|
18
|
-
/(http[s]?:\/\/bit\.ly.*)$/,
|
|
18
|
+
/(http[s]?:\/\/(bit\.ly|ipinfo\.io|httpbin\.org).*)$/,
|
|
19
19
|
/(http[s]?:\/\/.*\.(link|xyz|tk|ml|ga|cf|gq|pw|top|club|mw|bd|ke|am|sbs|date|quest|cd|bid|cd|ws|icu|cam|uno|email|stream))$/
|
|
20
20
|
];
|
|
21
21
|
/**
|
package/src/warnings.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Import Internal Dependencies
|
|
2
|
-
import
|
|
2
|
+
import { toArrayLocation } from "./utils/toArrayLocation.js";
|
|
3
|
+
import { notNullOrUndefined } from "./utils/notNullOrUndefined.js";
|
|
3
4
|
|
|
4
5
|
export const warnings = Object.freeze({
|
|
5
6
|
"parsing-error": {
|
|
@@ -58,16 +59,16 @@ export function generateWarning(kind, options) {
|
|
|
58
59
|
|
|
59
60
|
if (kind === "encoded-literal") {
|
|
60
61
|
return Object.assign(
|
|
61
|
-
{ kind, value, location: [
|
|
62
|
+
{ kind, value, location: [toArrayLocation(location)], source },
|
|
62
63
|
warnings[kind]
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
const result = { kind, location:
|
|
67
|
-
if (
|
|
67
|
+
const result = { kind, location: toArrayLocation(location), source };
|
|
68
|
+
if (notNullOrUndefined(file)) {
|
|
68
69
|
result.file = file;
|
|
69
70
|
}
|
|
70
|
-
if (
|
|
71
|
+
if (notNullOrUndefined(value)) {
|
|
71
72
|
result.value = value;
|
|
72
73
|
}
|
|
73
74
|
|
package/types/api.d.ts
CHANGED
|
@@ -30,7 +30,9 @@ export {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
type SourceFlags =
|
|
33
|
-
| "fetch"
|
|
33
|
+
| "fetch"
|
|
34
|
+
| "oneline-require"
|
|
35
|
+
| "is-minified";
|
|
34
36
|
|
|
35
37
|
interface SourceLocation {
|
|
36
38
|
start: {
|
|
@@ -96,7 +98,6 @@ interface Report {
|
|
|
96
98
|
flags: Set<SourceFlags>;
|
|
97
99
|
idsLengthAvg: number;
|
|
98
100
|
stringScore: number;
|
|
99
|
-
isOneLineRequire: boolean;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
type ReportOnFile = {
|
|
@@ -104,7 +105,6 @@ type ReportOnFile = {
|
|
|
104
105
|
warnings: Warning[];
|
|
105
106
|
dependencies: Map<string, Dependency>;
|
|
106
107
|
flags: Set<SourceFlags>;
|
|
107
|
-
isMinified: boolean;
|
|
108
108
|
} | {
|
|
109
109
|
ok: false,
|
|
110
110
|
warnings: Warning[];
|