@node9/proxy 1.12.6 → 1.12.8
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/dist/cli.js +180 -51
- package/dist/cli.mjs +180 -51
- package/dist/index.js +121 -7
- package/dist/index.mjs +121 -7
- package/node_modules/mvdan-sh/LICENSE +27 -0
- package/node_modules/mvdan-sh/README.md +84 -0
- package/node_modules/mvdan-sh/index.js +56 -0
- package/node_modules/mvdan-sh/package.json +24 -0
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -965,6 +965,17 @@ var ASSIGNMENT_CONTEXT_RE = /\b(?:password|passwd|secret|token|api[_-]?key|auth(
|
|
|
965
965
|
function isAssignmentContext(text) {
|
|
966
966
|
return ASSIGNMENT_CONTEXT_RE.test(text);
|
|
967
967
|
}
|
|
968
|
+
function shannonEntropy(s) {
|
|
969
|
+
if (s.length === 0) return 0;
|
|
970
|
+
const freq = /* @__PURE__ */ new Map();
|
|
971
|
+
for (const ch of s) freq.set(ch, (freq.get(ch) ?? 0) + 1);
|
|
972
|
+
let h = 0;
|
|
973
|
+
for (const count of freq.values()) {
|
|
974
|
+
const p = count / s.length;
|
|
975
|
+
h -= p * Math.log2(p);
|
|
976
|
+
}
|
|
977
|
+
return h;
|
|
978
|
+
}
|
|
968
979
|
var DLP_STOPWORDS = [
|
|
969
980
|
"example",
|
|
970
981
|
"placeholder",
|
|
@@ -987,7 +998,9 @@ var DLP_STOPWORDS = [
|
|
|
987
998
|
"%{",
|
|
988
999
|
"<your",
|
|
989
1000
|
"test_key",
|
|
990
|
-
"test_token"
|
|
1001
|
+
"test_token",
|
|
1002
|
+
"your",
|
|
1003
|
+
"here"
|
|
991
1004
|
];
|
|
992
1005
|
var DLP_PATTERNS = [
|
|
993
1006
|
// ── AWS ───────────────────────────────────────────────────────────────────
|
|
@@ -1038,7 +1051,8 @@ var DLP_PATTERNS = [
|
|
|
1038
1051
|
name: "OpenAI API Key",
|
|
1039
1052
|
regex: /\bsk-[a-zA-Z0-9_-]{20,}\b/,
|
|
1040
1053
|
severity: "block",
|
|
1041
|
-
keywords: ["sk-"]
|
|
1054
|
+
keywords: ["sk-"],
|
|
1055
|
+
minEntropy: 3.5
|
|
1042
1056
|
},
|
|
1043
1057
|
// ── Stripe ────────────────────────────────────────────────────────────────
|
|
1044
1058
|
{
|
|
@@ -1109,7 +1123,13 @@ var DLP_PATTERNS = [
|
|
|
1109
1123
|
keywords: ["hvb."]
|
|
1110
1124
|
},
|
|
1111
1125
|
// ── Hugging Face ──────────────────────────────────────────────────────────
|
|
1112
|
-
{
|
|
1126
|
+
{
|
|
1127
|
+
name: "HuggingFace Token",
|
|
1128
|
+
regex: /\bhf_[A-Za-z]{34}\b/,
|
|
1129
|
+
severity: "block",
|
|
1130
|
+
keywords: ["hf_"],
|
|
1131
|
+
minEntropy: 3
|
|
1132
|
+
},
|
|
1113
1133
|
// ── Postman ───────────────────────────────────────────────────────────────
|
|
1114
1134
|
{
|
|
1115
1135
|
name: "Postman API Token",
|
|
@@ -1261,7 +1281,8 @@ var DLP_PATTERNS = [
|
|
|
1261
1281
|
name: "PyPI Upload Token",
|
|
1262
1282
|
regex: /\bpypi-[A-Za-z0-9_-]{50,}\b/,
|
|
1263
1283
|
severity: "block",
|
|
1264
|
-
keywords: ["pypi-"]
|
|
1284
|
+
keywords: ["pypi-"],
|
|
1285
|
+
minEntropy: 3
|
|
1265
1286
|
},
|
|
1266
1287
|
// ── Bearer Token ─────────────────────────────────────────────────────────
|
|
1267
1288
|
// contextBoost: promoted to block when assigned (e.g. AUTH_TOKEN=Bearer eyJ...)
|
|
@@ -1270,7 +1291,99 @@ var DLP_PATTERNS = [
|
|
|
1270
1291
|
regex: /Bearer\s+[a-zA-Z0-9\-._~+/]{20,}=*/i,
|
|
1271
1292
|
severity: "review",
|
|
1272
1293
|
keywords: ["bearer"],
|
|
1273
|
-
contextBoost: true
|
|
1294
|
+
contextBoost: true,
|
|
1295
|
+
minEntropy: 3
|
|
1296
|
+
},
|
|
1297
|
+
// ── Resend ────────────────────────────────────────────────────────────────
|
|
1298
|
+
{
|
|
1299
|
+
name: "Resend API Key",
|
|
1300
|
+
regex: /\bre_[a-zA-Z0-9]{24}\b/,
|
|
1301
|
+
severity: "block",
|
|
1302
|
+
keywords: ["re_"]
|
|
1303
|
+
},
|
|
1304
|
+
// ── Telegram ──────────────────────────────────────────────────────────────
|
|
1305
|
+
{
|
|
1306
|
+
name: "Telegram Bot Token",
|
|
1307
|
+
regex: /\b[0-9]{7,10}:AA[a-zA-Z0-9_-]{33}\b/,
|
|
1308
|
+
severity: "block",
|
|
1309
|
+
keywords: [":aa"]
|
|
1310
|
+
},
|
|
1311
|
+
// ── Mapbox ────────────────────────────────────────────────────────────────
|
|
1312
|
+
{
|
|
1313
|
+
name: "Mapbox Access Token",
|
|
1314
|
+
regex: /\bpk\.eyJ1[a-zA-Z0-9._-]{20,}\b/,
|
|
1315
|
+
severity: "block",
|
|
1316
|
+
keywords: ["pk.eyj1"]
|
|
1317
|
+
},
|
|
1318
|
+
// ── Notion ────────────────────────────────────────────────────────────────
|
|
1319
|
+
{
|
|
1320
|
+
name: "Notion Integration Token",
|
|
1321
|
+
regex: /\bsecret_[a-zA-Z0-9]{43}\b/,
|
|
1322
|
+
severity: "block",
|
|
1323
|
+
keywords: ["secret_"]
|
|
1324
|
+
},
|
|
1325
|
+
// ── Square ────────────────────────────────────────────────────────────────
|
|
1326
|
+
{
|
|
1327
|
+
name: "Square Access Token",
|
|
1328
|
+
regex: /\bsq0atp-[0-9A-Za-z_-]{22}\b/,
|
|
1329
|
+
severity: "block",
|
|
1330
|
+
keywords: ["sq0atp-"]
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
name: "Square OAuth Secret",
|
|
1334
|
+
regex: /\bsq0csp-[0-9A-Za-z_-]{43}\b/,
|
|
1335
|
+
severity: "block",
|
|
1336
|
+
keywords: ["sq0csp-"]
|
|
1337
|
+
},
|
|
1338
|
+
// ── Typeform ──────────────────────────────────────────────────────────────
|
|
1339
|
+
{
|
|
1340
|
+
name: "Typeform Token",
|
|
1341
|
+
regex: /\btfp_[a-zA-Z0-9_]{59}\b/,
|
|
1342
|
+
severity: "block",
|
|
1343
|
+
keywords: ["tfp_"]
|
|
1344
|
+
},
|
|
1345
|
+
// ── Cloudinary ────────────────────────────────────────────────────────────
|
|
1346
|
+
{
|
|
1347
|
+
name: "Cloudinary URL",
|
|
1348
|
+
regex: /\bcloudinary:\/\/[0-9]+:[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+/,
|
|
1349
|
+
severity: "block",
|
|
1350
|
+
keywords: ["cloudinary://"]
|
|
1351
|
+
},
|
|
1352
|
+
// ── Airtable ──────────────────────────────────────────────────────────────
|
|
1353
|
+
// New PAT format: pat + 14 alphanum + . + 64 alphanum
|
|
1354
|
+
{
|
|
1355
|
+
name: "Airtable PAT",
|
|
1356
|
+
regex: /\bpat[a-zA-Z0-9]{14}\.[a-zA-Z0-9]{64}\b/,
|
|
1357
|
+
severity: "block",
|
|
1358
|
+
keywords: ["pat"]
|
|
1359
|
+
},
|
|
1360
|
+
// ── RubyGems ──────────────────────────────────────────────────────────────
|
|
1361
|
+
{
|
|
1362
|
+
name: "RubyGems API Key",
|
|
1363
|
+
regex: /\brubygems_[a-f0-9]{48}\b/,
|
|
1364
|
+
severity: "block",
|
|
1365
|
+
keywords: ["rubygems_"]
|
|
1366
|
+
},
|
|
1367
|
+
// ── Shippo ────────────────────────────────────────────────────────────────
|
|
1368
|
+
{
|
|
1369
|
+
name: "Shippo Token",
|
|
1370
|
+
regex: /\bshippo_(?:live|test)_[a-f0-9]{40}\b/,
|
|
1371
|
+
severity: "block",
|
|
1372
|
+
keywords: ["shippo_"]
|
|
1373
|
+
},
|
|
1374
|
+
// ── Plaid ─────────────────────────────────────────────────────────────────
|
|
1375
|
+
{
|
|
1376
|
+
name: "Plaid Access Token",
|
|
1377
|
+
regex: /\baccess-(?:sandbox|development|production)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/,
|
|
1378
|
+
severity: "block",
|
|
1379
|
+
keywords: ["access-sandbox", "access-development", "access-production"]
|
|
1380
|
+
},
|
|
1381
|
+
// ── Age ───────────────────────────────────────────────────────────────────
|
|
1382
|
+
{
|
|
1383
|
+
name: "Age Identity Key",
|
|
1384
|
+
regex: /\bAGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JNLH]{58}\b/,
|
|
1385
|
+
severity: "block",
|
|
1386
|
+
keywords: ["age-secret-key-"]
|
|
1274
1387
|
}
|
|
1275
1388
|
];
|
|
1276
1389
|
var SENSITIVE_PATH_PATTERNS = [
|
|
@@ -1367,8 +1480,9 @@ function scanArgs(args, depth = 0, fieldPath = "args") {
|
|
|
1367
1480
|
continue;
|
|
1368
1481
|
}
|
|
1369
1482
|
if (pattern.regex.test(text)) {
|
|
1370
|
-
const
|
|
1371
|
-
if (DLP_STOPWORDS.some((sw) =>
|
|
1483
|
+
const raw = text.match(pattern.regex)?.[0] ?? "";
|
|
1484
|
+
if (DLP_STOPWORDS.some((sw) => raw.toLowerCase().includes(sw))) continue;
|
|
1485
|
+
if (pattern.minEntropy !== void 0 && shannonEntropy(raw) < pattern.minEntropy) continue;
|
|
1372
1486
|
const severity = pattern.contextBoost && assignmentCtx ? "block" : pattern.severity;
|
|
1373
1487
|
return {
|
|
1374
1488
|
patternName: pattern.name,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2016, Daniel Martí. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above
|
|
10
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
11
|
+
in the documentation and/or other materials provided with the
|
|
12
|
+
distribution.
|
|
13
|
+
* Neither the name of the copyright holder nor the names of its
|
|
14
|
+
contributors may be used to endorse or promote products derived from
|
|
15
|
+
this software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
## mvdan-sh
|
|
2
|
+
|
|
3
|
+
This package is a JavaScript version of a shell package written in Go, available
|
|
4
|
+
at https://github.com/mvdan/sh.
|
|
5
|
+
|
|
6
|
+
It is transpiled from Go to JS using https://github.com/gopherjs/gopherjs.
|
|
7
|
+
|
|
8
|
+
### Sample usage
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
const sh = require('mvdan-sh')
|
|
12
|
+
const syntax = sh.syntax
|
|
13
|
+
|
|
14
|
+
var parser = syntax.NewParser()
|
|
15
|
+
var printer = syntax.NewPrinter()
|
|
16
|
+
|
|
17
|
+
var src = "echo 'foo'"
|
|
18
|
+
var f = parser.Parse(src, "src.sh")
|
|
19
|
+
|
|
20
|
+
// print out the syntax tree
|
|
21
|
+
syntax.DebugPrint(f)
|
|
22
|
+
console.log()
|
|
23
|
+
|
|
24
|
+
// replace all single quoted string values
|
|
25
|
+
syntax.Walk(f, function(node) {
|
|
26
|
+
if (syntax.NodeType(node) == "SglQuoted") {
|
|
27
|
+
node.Value = "bar"
|
|
28
|
+
}
|
|
29
|
+
return true
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// print the code back out
|
|
33
|
+
console.log(printer.Print(f)) // echo 'bar'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can find more samples in
|
|
37
|
+
[testmain.js](https://github.com/mvdan/sh/blob/master/_js/testmain.js).
|
|
38
|
+
|
|
39
|
+
### Available APIs
|
|
40
|
+
|
|
41
|
+
The APIs listed below are wrapped to be usable in JavaScript. Follow the links
|
|
42
|
+
to read their documentation.
|
|
43
|
+
|
|
44
|
+
* [syntax.NewParser](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#NewParser)
|
|
45
|
+
- [Parser.Parse](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Parser.Parse)
|
|
46
|
+
- [Parser.Interactive](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Parser.Interactive)
|
|
47
|
+
- [Parser.Incomplete](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Parser.Incomplete)
|
|
48
|
+
* [syntax.DebugPrint](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#DebugPrint)
|
|
49
|
+
* [syntax.Walk](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Walk)
|
|
50
|
+
* [syntax.NewPrinter](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#NewPrinter)
|
|
51
|
+
- [Printer.Print](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Printer.Print)
|
|
52
|
+
|
|
53
|
+
Constructor options like
|
|
54
|
+
[syntax.KeepComments](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#KeepComments) are
|
|
55
|
+
also available.
|
|
56
|
+
|
|
57
|
+
The original `io.Reader` parameters can take a string or a
|
|
58
|
+
[stream.Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable)
|
|
59
|
+
object. `io.Writer` parameters are replaced by string returns.
|
|
60
|
+
|
|
61
|
+
The nodes you will find in the syntax tree are all equivalent to the nodes you
|
|
62
|
+
will see on the Go API. To get the type of a node, use `syntax.NodeType` as the
|
|
63
|
+
example above shows. Some of the most common node types include:
|
|
64
|
+
|
|
65
|
+
* [syntax.File](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#File)
|
|
66
|
+
* [syntax.Stmt](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Stmt)
|
|
67
|
+
* [syntax.CallExpr](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#CallExpr)
|
|
68
|
+
* [syntax.Word](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Word)
|
|
69
|
+
* [syntax.Lit](https://pkg.go.dev/mvdan.cc/sh/v3/syntax#Lit)
|
|
70
|
+
|
|
71
|
+
The five above will show up in your syntax tree if you parse a `echo foo`
|
|
72
|
+
command, which you can see if you use `syntax.DebugPrint` to inspect the syntax
|
|
73
|
+
tree.
|
|
74
|
+
|
|
75
|
+
### Building
|
|
76
|
+
|
|
77
|
+
You will need:
|
|
78
|
+
|
|
79
|
+
* Latest Go 1.17.x
|
|
80
|
+
* NodeJS, to run the `testmain.js` test suite
|
|
81
|
+
|
|
82
|
+
Then, simply run `./build`. The result will be `index.js`, which isn't minified.
|
|
83
|
+
At the time of writing, `index.js` weighs 1.7MiB in plaintext, and 220KiB when
|
|
84
|
+
minified and gzipped.
|