eslint-plugin-no-pii 1.1.0 → 1.2.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 +3 -1
- package/dist/index.js +3 -0
- package/dist/rules/no-jwt.d.ts +2 -0
- package/dist/rules/no-jwt.js +21 -0
- package/llms.txt +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://ci.appveyor.com/project/lwojcik/eslint-plugin-no-pii/branch/main)
|
|
5
5
|
[](https://codecov.io/github/lwojcik/eslint-plugin-no-pii)
|
|
6
6
|
|
|
7
|
-
PII linting rules for ESLint 10.
|
|
7
|
+
PII (Personally Identifiable Information) linting rules for ESLint 10.
|
|
8
8
|
|
|
9
9
|
Fork of [shiva-hack/eslint-plugin-pii](https://github.com/shiva-hack/eslint-plugin-pii), modernized and updated for ESLint 10+.
|
|
10
10
|
|
|
@@ -40,6 +40,7 @@ export default [
|
|
|
40
40
|
"pii/no-iban": "error",
|
|
41
41
|
"pii/no-imei": "error",
|
|
42
42
|
"pii/no-ip": "error",
|
|
43
|
+
"pii/no-jwt": "error",
|
|
43
44
|
"pii/no-mac-address": "error",
|
|
44
45
|
"pii/no-national-id": "error",
|
|
45
46
|
"pii/no-phone-number": "error",
|
|
@@ -63,6 +64,7 @@ Each rule has its own page with examples, fix guidance and known limits.
|
|
|
63
64
|
- [`pii/no-iban`](docs/rules/no-iban.md) - IBANs (length and mod-97 validated)
|
|
64
65
|
- [`pii/no-imei`](docs/rules/no-imei.md) - IMEI numbers (Luhn-validated)
|
|
65
66
|
- [`pii/no-ip`](docs/rules/no-ip.md) - IPv4 and IPv6 addresses
|
|
67
|
+
- [`pii/no-jwt`](docs/rules/no-jwt.md) - JSON Web Tokens
|
|
66
68
|
- [`pii/no-mac-address`](docs/rules/no-mac-address.md) - MAC addresses
|
|
67
69
|
- [`pii/no-national-id`](docs/rules/no-national-id.md) - national ID numbers (Polish PESEL/NIP, UK NINO, Spanish DNI/NIE)
|
|
68
70
|
- [`pii/no-phone-number`](docs/rules/no-phone-number.md) - phone numbers
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import noEmail from "./rules/no-email.js";
|
|
|
6
6
|
import noIban from "./rules/no-iban.js";
|
|
7
7
|
import noImei from "./rules/no-imei.js";
|
|
8
8
|
import noIp from "./rules/no-ip.js";
|
|
9
|
+
import noJwt from "./rules/no-jwt.js";
|
|
9
10
|
import noUrlCredentials from "./rules/no-url-credentials.js";
|
|
10
11
|
import noVin from "./rules/no-vin.js";
|
|
11
12
|
import noSsn from "./rules/no-ssn.js";
|
|
@@ -35,6 +36,7 @@ const plugin = {
|
|
|
35
36
|
"no-iban": noIban,
|
|
36
37
|
"no-imei": noImei,
|
|
37
38
|
"no-ip": noIp,
|
|
39
|
+
"no-jwt": noJwt,
|
|
38
40
|
"no-mac-address": noMacAddress,
|
|
39
41
|
"no-national-id": noNationalId,
|
|
40
42
|
"no-phone-number": noPhoneNumber,
|
|
@@ -56,6 +58,7 @@ plugin.configs = {
|
|
|
56
58
|
"pii/no-iban": "error",
|
|
57
59
|
"pii/no-imei": "error",
|
|
58
60
|
"pii/no-ip": "error",
|
|
61
|
+
"pii/no-jwt": "error",
|
|
59
62
|
"pii/no-mac-address": "error",
|
|
60
63
|
"pii/no-national-id": "error",
|
|
61
64
|
"pii/no-phone-number": "error",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createPiiRule } from "../internal/create-pii-rule.js";
|
|
2
|
+
// header.payload[.signature]; both JSON segments start with `eyJ` (`{"`).
|
|
3
|
+
// The signature may be empty for unsecured tokens (`alg: none`).
|
|
4
|
+
const CANDIDATE = /(?<![\w-])(eyJ[\w-]{4,})\.(eyJ[\w-]{4,})(?:\.[\w-]*)?(?![\w-])/g;
|
|
5
|
+
const decodeObject = (segment) => {
|
|
6
|
+
try {
|
|
7
|
+
const json = JSON.parse(Buffer.from(segment, "base64url").toString("utf8"));
|
|
8
|
+
return typeof json === "object" && json !== null && !Array.isArray(json)
|
|
9
|
+
? json
|
|
10
|
+
: undefined;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export default createPiiRule({
|
|
17
|
+
description: "enforces no JSON Web Tokens in comments or string literals",
|
|
18
|
+
subject: "JWT",
|
|
19
|
+
detect: (value) => Array.from(value.matchAll(CANDIDATE)).some(([, header, payload]) => typeof decodeObject(header)?.["alg"] === "string" &&
|
|
20
|
+
decodeObject(payload) !== undefined),
|
|
21
|
+
});
|
package/llms.txt
CHANGED
|
@@ -30,6 +30,7 @@ Each rule has a docs page with examples and known limits.
|
|
|
30
30
|
- [pii/no-iban](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-iban.md): IBANs (length + mod-97). Recommended: error.
|
|
31
31
|
- [pii/no-imei](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-imei.md): IMEI numbers (Luhn). Recommended: error.
|
|
32
32
|
- [pii/no-ip](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-ip.md): IPv4 and IPv6 addresses. Recommended: error.
|
|
33
|
+
- [pii/no-jwt](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-jwt.md): JSON Web Tokens (structurally validated). Recommended: error.
|
|
33
34
|
- [pii/no-mac-address](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-mac-address.md): MAC addresses. Recommended: error.
|
|
34
35
|
- [pii/no-national-id](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-national-id.md): Polish PESEL/NIP, UK NINO, Spanish DNI/NIE. Recommended: error.
|
|
35
36
|
- [pii/no-phone-number](https://github.com/lwojcik/eslint-plugin-no-pii/blob/main/docs/rules/no-phone-number.md): phone numbers (FR, DE, UK, US formats). Recommended: error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-no-pii",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "PII linting rules for ESLint 10",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"node": ">=20.19.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
|
+
"type": "git",
|
|
31
32
|
"url": "git+https://github.com/lwojcik/eslint-plugin-no-pii.git"
|
|
32
33
|
},
|
|
33
34
|
"license": "ISC",
|
|
@@ -49,6 +50,9 @@
|
|
|
49
50
|
"typescript": "^6.0.3",
|
|
50
51
|
"typescript-eslint": "^8.73.0"
|
|
51
52
|
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
52
56
|
"files": [
|
|
53
57
|
"dist",
|
|
54
58
|
"llms.txt"
|