@platform-sec/eslint-plugin-sensitive-string 0.2.0 → 0.2.1

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.
Files changed (69) hide show
  1. package/dist/ast.d.ts +172 -0
  2. package/dist/ast.d.ts.map +1 -0
  3. package/dist/ast.js +418 -0
  4. package/dist/ast.js.map +1 -0
  5. package/dist/configs.d.ts +38 -0
  6. package/dist/configs.d.ts.map +1 -0
  7. package/dist/configs.js +131 -0
  8. package/dist/configs.js.map +1 -0
  9. package/dist/docs.d.ts +28 -0
  10. package/dist/docs.d.ts.map +1 -0
  11. package/dist/docs.js +33 -0
  12. package/dist/docs.js.map +1 -0
  13. package/dist/index.d.ts +44 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +117 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/log-calls.d.ts +28 -0
  18. package/dist/log-calls.d.ts.map +1 -0
  19. package/dist/log-calls.js +80 -0
  20. package/dist/log-calls.js.map +1 -0
  21. package/dist/options.d.ts +32 -0
  22. package/dist/options.d.ts.map +1 -0
  23. package/dist/options.js +56 -0
  24. package/dist/options.js.map +1 -0
  25. package/dist/rules/explicit-class.d.ts +3 -0
  26. package/dist/rules/explicit-class.d.ts.map +1 -0
  27. package/dist/rules/explicit-class.js +93 -0
  28. package/dist/rules/explicit-class.js.map +1 -0
  29. package/dist/rules/no-allow-unaudited.d.ts +3 -0
  30. package/dist/rules/no-allow-unaudited.d.ts.map +1 -0
  31. package/dist/rules/no-allow-unaudited.js +92 -0
  32. package/dist/rules/no-allow-unaudited.js.map +1 -0
  33. package/dist/rules/no-credential-equality.d.ts +3 -0
  34. package/dist/rules/no-credential-equality.d.ts.map +1 -0
  35. package/dist/rules/no-credential-equality.js +146 -0
  36. package/dist/rules/no-credential-equality.js.map +1 -0
  37. package/dist/rules/no-log-reveal.d.ts +3 -0
  38. package/dist/rules/no-log-reveal.d.ts.map +1 -0
  39. package/dist/rules/no-log-reveal.js +67 -0
  40. package/dist/rules/no-log-reveal.js.map +1 -0
  41. package/dist/rules/no-network-sensitive.d.ts +3 -0
  42. package/dist/rules/no-network-sensitive.d.ts.map +1 -0
  43. package/dist/rules/no-network-sensitive.js +106 -0
  44. package/dist/rules/no-network-sensitive.js.map +1 -0
  45. package/dist/rules/no-password-fast-hash.d.ts +3 -0
  46. package/dist/rules/no-password-fast-hash.d.ts.map +1 -0
  47. package/dist/rules/no-password-fast-hash.js +84 -0
  48. package/dist/rules/no-password-fast-hash.js.map +1 -0
  49. package/dist/rules/no-stringify-sensitive.d.ts +3 -0
  50. package/dist/rules/no-stringify-sensitive.d.ts.map +1 -0
  51. package/dist/rules/no-stringify-sensitive.js +96 -0
  52. package/dist/rules/no-stringify-sensitive.js.map +1 -0
  53. package/dist/rules/prefer-safe-log.d.ts +3 -0
  54. package/dist/rules/prefer-safe-log.d.ts.map +1 -0
  55. package/dist/rules/prefer-safe-log.js +85 -0
  56. package/dist/rules/prefer-safe-log.js.map +1 -0
  57. package/dist/rules/require-reveal-context.d.ts +3 -0
  58. package/dist/rules/require-reveal-context.d.ts.map +1 -0
  59. package/dist/rules/require-reveal-context.js +149 -0
  60. package/dist/rules/require-reveal-context.js.map +1 -0
  61. package/dist/type-info.d.ts +134 -0
  62. package/dist/type-info.d.ts.map +1 -0
  63. package/dist/type-info.js +282 -0
  64. package/dist/type-info.js.map +1 -0
  65. package/dist/types.d.ts +137 -0
  66. package/dist/types.d.ts.map +1 -0
  67. package/dist/types.js +23 -0
  68. package/dist/types.js.map +1 -0
  69. package/package.json +10 -10
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAMESPACE = void 0;
4
+ exports.buildConfigs = buildConfigs;
5
+ /**
6
+ * The name a config file uses to reach these rules.
7
+ *
8
+ * ESLint derives it from the package name by dropping `eslint-plugin-`, so
9
+ * `@platform-sec/eslint-plugin-sensitive-string` is written as
10
+ * `@platform-sec/sensitive-string`. Spelling it out here keeps the flat and
11
+ * eslintrc presets addressing the same rules.
12
+ */
13
+ exports.PLUGIN_NAMESPACE = '@platform-sec/sensitive-string';
14
+ /**
15
+ * The default posture.
16
+ *
17
+ * The three rules that catch a value actually escaping are errors, and so is
18
+ * the one that catches an audit control being switched off: `allowUnaudited`
19
+ * is never written by accident, so the finding is never wrong, and a disable
20
+ * comment is where the reason belongs. The three that reason about something
21
+ * they cannot see are warnings, and a warning is the honest severity for a
22
+ * check that can be wrong: a context installed in a caller, a class supplied
23
+ * through a spread, and a password recognised by what the variable holding it
24
+ * is called.
25
+ */
26
+ const RECOMMENDED_RULES = {
27
+ 'no-log-reveal': 'error',
28
+ 'no-credential-equality': 'error',
29
+ 'no-network-sensitive': 'error',
30
+ 'no-allow-unaudited': 'error',
31
+ 'explicit-class': 'warn',
32
+ 'require-reveal-context': 'warn',
33
+ 'no-password-fast-hash': 'warn',
34
+ };
35
+ /**
36
+ * Everything on, at error, with the reveal context required to say why.
37
+ *
38
+ * `allowWithContext: false` also drops the exemption that lets an audited
39
+ * reveal reach the network, so the only way a value leaves the process is
40
+ * through `serialize()`.
41
+ */
42
+ const STRICT_RULES = {
43
+ 'no-log-reveal': 'error',
44
+ 'no-credential-equality': 'error',
45
+ 'no-network-sensitive': ['error', { allowWithContext: false }],
46
+ 'no-allow-unaudited': 'error',
47
+ 'explicit-class': 'error',
48
+ 'require-reveal-context': ['error', { requireReason: true }],
49
+ 'no-password-fast-hash': 'error',
50
+ };
51
+ /**
52
+ * The two rules that need a program, at the severity `recommended` would give
53
+ * them.
54
+ *
55
+ * `no-stringify-sensitive` is an error because both things it catches are
56
+ * definite: a `serialize()` result written out in the clear, and a redaction
57
+ * substituted for a value that was supposed to arrive somewhere. Neither is a
58
+ * judgement call.
59
+ *
60
+ * `prefer-safe-log` is a warning because most of what it reports is not yet a
61
+ * leak. A `SensitiveString` inside a logged object redacts itself today,
62
+ * through whichever of `toJSON` and `util.inspect` the transport reaches for;
63
+ * the rule is about not depending on that. The one case that is a leak, a
64
+ * `serialize()` result in a log line, gets its own message.
65
+ */
66
+ const TYPE_AWARE_RULES = {
67
+ 'no-stringify-sensitive': 'error',
68
+ 'prefer-safe-log': 'warn',
69
+ };
70
+ /** The same two at error, for `strict-type-checked`. */
71
+ const STRICT_TYPE_AWARE_RULES = {
72
+ 'no-stringify-sensitive': 'error',
73
+ 'prefer-safe-log': 'error',
74
+ };
75
+ /**
76
+ * The type-aware rules off.
77
+ *
78
+ * For the block of a flat config that matches the files a program does not
79
+ * cover: plain JavaScript, generated code, anything outside `tsconfig.json`.
80
+ * Layered after a `-type-checked` preset it silences the two rules there,
81
+ * which is what those rules do instead of failing quietly on a file whose
82
+ * types they cannot see.
83
+ */
84
+ const DISABLED_TYPE_AWARE_RULES = {
85
+ 'no-stringify-sensitive': 'off',
86
+ 'prefer-safe-log': 'off',
87
+ };
88
+ /** Rule settings keyed by their fully qualified name. */
89
+ function qualify(rules) {
90
+ return Object.fromEntries(Object.entries(rules).map(([name, entry]) => [`${exports.PLUGIN_NAMESPACE}/${name}`, entry]));
91
+ }
92
+ /** A flat-config object, for `eslint.config.js`. */
93
+ function flatConfig(plugin, name, rules) {
94
+ return {
95
+ name: `${exports.PLUGIN_NAMESPACE}/${name}`,
96
+ plugins: { [exports.PLUGIN_NAMESPACE]: plugin },
97
+ rules: qualify(rules),
98
+ };
99
+ }
100
+ /** An eslintrc config object, for `.eslintrc.*`. */
101
+ function legacyConfig(rules) {
102
+ return {
103
+ plugins: [exports.PLUGIN_NAMESPACE],
104
+ rules: qualify(rules),
105
+ };
106
+ }
107
+ /**
108
+ * Every preset, built against the finished plugin object.
109
+ *
110
+ * A flat preset has to hold the plugin it configures, and the plugin has to
111
+ * hold its presets, so one of the two references is filled in after the fact.
112
+ * Taking the plugin as an argument keeps that knot in `index.ts`, where it is
113
+ * visible, rather than hiding it behind a lazy getter.
114
+ */
115
+ function buildConfigs(plugin) {
116
+ const recommendedTypeChecked = { ...RECOMMENDED_RULES, ...TYPE_AWARE_RULES };
117
+ const strictTypeChecked = { ...STRICT_RULES, ...STRICT_TYPE_AWARE_RULES };
118
+ return {
119
+ recommended: flatConfig(plugin, 'recommended', RECOMMENDED_RULES),
120
+ strict: flatConfig(plugin, 'strict', STRICT_RULES),
121
+ 'recommended-type-checked': flatConfig(plugin, 'recommended-type-checked', recommendedTypeChecked),
122
+ 'strict-type-checked': flatConfig(plugin, 'strict-type-checked', strictTypeChecked),
123
+ 'disable-type-checked': flatConfig(plugin, 'disable-type-checked', DISABLED_TYPE_AWARE_RULES),
124
+ 'legacy-recommended': legacyConfig(RECOMMENDED_RULES),
125
+ 'legacy-strict': legacyConfig(STRICT_RULES),
126
+ 'legacy-recommended-type-checked': legacyConfig(recommendedTypeChecked),
127
+ 'legacy-strict-type-checked': legacyConfig(strictTypeChecked),
128
+ 'legacy-disable-type-checked': legacyConfig(DISABLED_TYPE_AWARE_RULES),
129
+ };
130
+ }
131
+ //# sourceMappingURL=configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.js","sourceRoot":"","sources":["../src/configs.ts"],"names":[],"mappings":"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"}
package/dist/docs.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Where a rule's documentation lives.
3
+ *
4
+ * `meta.docs.url` is what an editor turns into the "learn more" link on a
5
+ * report, and ESLint requires an absolute URL for it. This project has no
6
+ * public repository yet, so there is no honest absolute URL to give: pointing
7
+ * the link at a guessed host would put a dead link in front of every developer
8
+ * who hovers a finding, which is worse than no link at all.
9
+ *
10
+ * The markdown under `docs/rules/` ships in the package either way, so the
11
+ * documentation is present in `node_modules` regardless. When the project gets
12
+ * a home, set {@link DOCS_BASE_URL} and every rule picks the link up.
13
+ */
14
+ /** The published location of `docs/rules/`, with a trailing slash, or `undefined`. */
15
+ export declare const DOCS_BASE_URL: string | undefined;
16
+ /**
17
+ * The `docs` block for a rule, carrying a `url` only when there is one to give.
18
+ *
19
+ * `url` is omitted rather than set to `undefined` because `exactOptionalPropertyTypes`
20
+ * distinguishes the two, and because ESLint's own config-inspector renders an
21
+ * explicit `undefined` as a broken link.
22
+ */
23
+ export declare function ruleDocs(ruleName: string, description: string, recommended: boolean, base?: string | undefined): {
24
+ readonly description: string;
25
+ readonly recommended: boolean;
26
+ readonly url?: string;
27
+ };
28
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,sFAAsF;AACtF,eAAO,MAAM,aAAa,EAAE,MAAM,GAAG,SAAqB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,OAAO,EACpB,IAAI,GAAE,MAAM,GAAG,SAAyB,GACvC;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAKxF"}
package/dist/docs.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Where a rule's documentation lives.
4
+ *
5
+ * `meta.docs.url` is what an editor turns into the "learn more" link on a
6
+ * report, and ESLint requires an absolute URL for it. This project has no
7
+ * public repository yet, so there is no honest absolute URL to give: pointing
8
+ * the link at a guessed host would put a dead link in front of every developer
9
+ * who hovers a finding, which is worse than no link at all.
10
+ *
11
+ * The markdown under `docs/rules/` ships in the package either way, so the
12
+ * documentation is present in `node_modules` regardless. When the project gets
13
+ * a home, set {@link DOCS_BASE_URL} and every rule picks the link up.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.DOCS_BASE_URL = void 0;
17
+ exports.ruleDocs = ruleDocs;
18
+ /** The published location of `docs/rules/`, with a trailing slash, or `undefined`. */
19
+ exports.DOCS_BASE_URL = undefined;
20
+ /**
21
+ * The `docs` block for a rule, carrying a `url` only when there is one to give.
22
+ *
23
+ * `url` is omitted rather than set to `undefined` because `exactOptionalPropertyTypes`
24
+ * distinguishes the two, and because ESLint's own config-inspector renders an
25
+ * explicit `undefined` as a broken link.
26
+ */
27
+ function ruleDocs(ruleName, description, recommended, base = exports.DOCS_BASE_URL) {
28
+ if (base === undefined) {
29
+ return { description, recommended };
30
+ }
31
+ return { description, recommended, url: `${base}${ruleName}.md` };
32
+ }
33
+ //# sourceMappingURL=docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.js","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAYH,4BAUC;AApBD,sFAAsF;AACzE,QAAA,aAAa,GAAuB,SAAS,CAAC;AAE3D;;;;;;GAMG;AACH,SAAgB,QAAQ,CACtB,QAAgB,EAChB,WAAmB,EACnB,WAAoB,EACpB,OAA2B,qBAAa;IAExC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,QAAQ,KAAK,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { explicitClass } from './rules/explicit-class.js';
2
+ import { noAllowUnaudited } from './rules/no-allow-unaudited.js';
3
+ import { noCredentialEquality } from './rules/no-credential-equality.js';
4
+ import { noLogReveal } from './rules/no-log-reveal.js';
5
+ import { noNetworkSensitive } from './rules/no-network-sensitive.js';
6
+ import { noStringifySensitive } from './rules/no-stringify-sensitive.js';
7
+ import { preferSafeLog } from './rules/prefer-safe-log.js';
8
+ import { requireRevealContext } from './rules/require-reveal-context.js';
9
+ import type { Plugin, RuleModule } from './types.js';
10
+ /** Every rule this plugin defines, keyed by the name a config uses. */
11
+ export declare const rules: Readonly<Record<string, RuleModule>>;
12
+ /**
13
+ * Plugin identity, which flat config uses to name the plugin in its output and
14
+ * which ESLint's config inspector reads.
15
+ */
16
+ export declare const meta: {
17
+ readonly name: "@platform-sec/eslint-plugin-sensitive-string";
18
+ readonly version: "0.2.1";
19
+ };
20
+ /**
21
+ * The presets: `recommended`, `strict`, their `-type-checked` forms and
22
+ * `disable-type-checked`, each in a flat and a `legacy-` eslintrc shape.
23
+ *
24
+ * Filled in after the plugin exists, because a flat preset holds the plugin
25
+ * object it configures and the plugin holds its presets. The two names are one
26
+ * object, so a config reached through `plugin.configs` and one reached through
27
+ * this export cannot come apart.
28
+ */
29
+ export declare const configs: Record<string, unknown>;
30
+ declare const plugin: Plugin;
31
+ export { explicitClass, noAllowUnaudited, noCredentialEquality, noLogReveal, noNetworkSensitive, noStringifySensitive, preferSafeLog, requireRevealContext, };
32
+ export { PLUGIN_NAMESPACE } from './configs.js';
33
+ export type { AstNode, Plugin, ReportDescriptor, RuleContext, RuleFix, RuleFixer, RuleListener, RuleMeta, RuleMetaDocs, RuleModule, SourceCode, SuggestionDescriptor, } from './types.js';
34
+ /**
35
+ * The plugin object.
36
+ *
37
+ * Both module shapes work on purpose. Flat config does
38
+ * `import plugin from '...'` and gets this default; eslintrc does
39
+ * `require('...')` and gets the module namespace, whose `rules` and `configs`
40
+ * named exports are the same objects this default holds. Neither format needs
41
+ * an interop shim.
42
+ */
43
+ export default plugin;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoDA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,uEAAuE;AACvE,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAUtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI;;;CAGP,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AAEnD,QAAA,MAAM,MAAM,EAAE,MAAiC,CAAC;AAGhD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,GACrB,CAAC;AACF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EACV,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAMESPACE = exports.requireRevealContext = exports.preferSafeLog = exports.noStringifySensitive = exports.noNetworkSensitive = exports.noLogReveal = exports.noCredentialEquality = exports.noAllowUnaudited = exports.explicitClass = exports.configs = exports.meta = exports.rules = void 0;
4
+ /**
5
+ * @platform-sec/eslint-plugin-sensitive-string
6
+ *
7
+ * Lint rules for the mistakes `SensitiveString`'s type system cannot catch.
8
+ *
9
+ * A type keeps a secret wrapped. It cannot stop `console.log(secret.reveal())`,
10
+ * because the reveal produces an ordinary string and logging a string is
11
+ * ordinary code. Nine rules read the call instead.
12
+ *
13
+ * Seven of them read syntax alone, so they run under any parser and cost
14
+ * nothing beyond the parse:
15
+ *
16
+ * - `no-log-reveal` stops a revealed value reaching a logger.
17
+ * - `no-credential-equality` stops `===` on a revealed value, which leaks its
18
+ * contents through timing.
19
+ * - `no-network-sensitive` stops an unaudited reveal crossing the network.
20
+ * - `explicit-class` asks for the sensitivity class at construction.
21
+ * - `require-reveal-context` asks a reveal to say who is reading and why, and
22
+ * asks the same of the other audited reads where types are available.
23
+ * - `no-password-fast-hash` stops a password being stored under a digest that
24
+ * a wordlist runs through at billions of guesses a second.
25
+ * - `no-allow-unaudited` stops a worker accepting a payload without the audit
26
+ * hook its sender asked for.
27
+ *
28
+ * Two answer a question no syntax can, "does this value carry a sensitive one
29
+ * inside it", and so need typescript-eslint's type-aware mode:
30
+ *
31
+ * - `no-stringify-sensitive` stops `JSON.stringify` silently substituting a
32
+ * redaction, and stops it writing a `serialize()` result in the clear.
33
+ * - `prefer-safe-log` moves the redaction of a logged structure out of
34
+ * whichever serializer the transport installed and into the call site.
35
+ *
36
+ * The type-aware pair lives only in the `*-type-checked` presets, so a
37
+ * consumer who has not configured a program never meets them.
38
+ *
39
+ * @example Flat config
40
+ * ```js
41
+ * import sensitive from '@platform-sec/eslint-plugin-sensitive-string';
42
+ *
43
+ * export default [sensitive.configs.recommended];
44
+ * ```
45
+ *
46
+ * @example eslintrc
47
+ * ```js
48
+ * module.exports = {
49
+ * extends: ['plugin:@platform-sec/sensitive-string/legacy-recommended'],
50
+ * };
51
+ * ```
52
+ *
53
+ * @packageDocumentation
54
+ */
55
+ const configs_js_1 = require("./configs.js");
56
+ const explicit_class_js_1 = require("./rules/explicit-class.js");
57
+ Object.defineProperty(exports, "explicitClass", { enumerable: true, get: function () { return explicit_class_js_1.explicitClass; } });
58
+ const no_allow_unaudited_js_1 = require("./rules/no-allow-unaudited.js");
59
+ Object.defineProperty(exports, "noAllowUnaudited", { enumerable: true, get: function () { return no_allow_unaudited_js_1.noAllowUnaudited; } });
60
+ const no_credential_equality_js_1 = require("./rules/no-credential-equality.js");
61
+ Object.defineProperty(exports, "noCredentialEquality", { enumerable: true, get: function () { return no_credential_equality_js_1.noCredentialEquality; } });
62
+ const no_log_reveal_js_1 = require("./rules/no-log-reveal.js");
63
+ Object.defineProperty(exports, "noLogReveal", { enumerable: true, get: function () { return no_log_reveal_js_1.noLogReveal; } });
64
+ const no_network_sensitive_js_1 = require("./rules/no-network-sensitive.js");
65
+ Object.defineProperty(exports, "noNetworkSensitive", { enumerable: true, get: function () { return no_network_sensitive_js_1.noNetworkSensitive; } });
66
+ const no_password_fast_hash_js_1 = require("./rules/no-password-fast-hash.js");
67
+ const no_stringify_sensitive_js_1 = require("./rules/no-stringify-sensitive.js");
68
+ Object.defineProperty(exports, "noStringifySensitive", { enumerable: true, get: function () { return no_stringify_sensitive_js_1.noStringifySensitive; } });
69
+ const prefer_safe_log_js_1 = require("./rules/prefer-safe-log.js");
70
+ Object.defineProperty(exports, "preferSafeLog", { enumerable: true, get: function () { return prefer_safe_log_js_1.preferSafeLog; } });
71
+ const require_reveal_context_js_1 = require("./rules/require-reveal-context.js");
72
+ Object.defineProperty(exports, "requireRevealContext", { enumerable: true, get: function () { return require_reveal_context_js_1.requireRevealContext; } });
73
+ /** Every rule this plugin defines, keyed by the name a config uses. */
74
+ exports.rules = {
75
+ 'explicit-class': explicit_class_js_1.explicitClass,
76
+ 'no-allow-unaudited': no_allow_unaudited_js_1.noAllowUnaudited,
77
+ 'no-credential-equality': no_credential_equality_js_1.noCredentialEquality,
78
+ 'no-log-reveal': no_log_reveal_js_1.noLogReveal,
79
+ 'no-network-sensitive': no_network_sensitive_js_1.noNetworkSensitive,
80
+ 'no-password-fast-hash': no_password_fast_hash_js_1.noPasswordFastHash,
81
+ 'no-stringify-sensitive': no_stringify_sensitive_js_1.noStringifySensitive,
82
+ 'prefer-safe-log': prefer_safe_log_js_1.preferSafeLog,
83
+ 'require-reveal-context': require_reveal_context_js_1.requireRevealContext,
84
+ };
85
+ /**
86
+ * Plugin identity, which flat config uses to name the plugin in its output and
87
+ * which ESLint's config inspector reads.
88
+ */
89
+ exports.meta = {
90
+ name: '@platform-sec/eslint-plugin-sensitive-string',
91
+ version: '0.2.1',
92
+ };
93
+ /**
94
+ * The presets: `recommended`, `strict`, their `-type-checked` forms and
95
+ * `disable-type-checked`, each in a flat and a `legacy-` eslintrc shape.
96
+ *
97
+ * Filled in after the plugin exists, because a flat preset holds the plugin
98
+ * object it configures and the plugin holds its presets. The two names are one
99
+ * object, so a config reached through `plugin.configs` and one reached through
100
+ * this export cannot come apart.
101
+ */
102
+ exports.configs = {};
103
+ const plugin = { meta: exports.meta, rules: exports.rules, configs: exports.configs };
104
+ Object.assign(exports.configs, (0, configs_js_1.buildConfigs)(plugin));
105
+ var configs_js_2 = require("./configs.js");
106
+ Object.defineProperty(exports, "PLUGIN_NAMESPACE", { enumerable: true, get: function () { return configs_js_2.PLUGIN_NAMESPACE; } });
107
+ /**
108
+ * The plugin object.
109
+ *
110
+ * Both module shapes work on purpose. Flat config does
111
+ * `import plugin from '...'` and gets this default; eslintrc does
112
+ * `require('...')` and gets the module namespace, whose `rules` and `configs`
113
+ * named exports are the same objects this default holds. Neither format needs
114
+ * an interop shim.
115
+ */
116
+ exports.default = plugin;
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,6CAA4C;AAC5C,iEAA0D;AAgDxD,8FAhDO,iCAAa,OAgDP;AA/Cf,yEAAiE;AAgD/D,iGAhDO,wCAAgB,OAgDP;AA/ClB,iFAAyE;AAgDvE,qGAhDO,gDAAoB,OAgDP;AA/CtB,+DAAuD;AAgDrD,4FAhDO,8BAAW,OAgDP;AA/Cb,6EAAqE;AAgDnE,mGAhDO,4CAAkB,OAgDP;AA/CpB,+EAAsE;AACtE,iFAAyE;AA+CvE,qGA/CO,gDAAoB,OA+CP;AA9CtB,mEAA2D;AA+CzD,8FA/CO,kCAAa,OA+CP;AA9Cf,iFAAyE;AA+CvE,qGA/CO,gDAAoB,OA+CP;AA5CtB,uEAAuE;AAC1D,QAAA,KAAK,GAAyC;IACzD,gBAAgB,EAAE,iCAAa;IAC/B,oBAAoB,EAAE,wCAAgB;IACtC,wBAAwB,EAAE,gDAAoB;IAC9C,eAAe,EAAE,8BAAW;IAC5B,sBAAsB,EAAE,4CAAkB;IAC1C,uBAAuB,EAAE,6CAAkB;IAC3C,wBAAwB,EAAE,gDAAoB;IAC9C,iBAAiB,EAAE,kCAAa;IAChC,wBAAwB,EAAE,gDAAoB;CAC/C,CAAC;AAEF;;;GAGG;AACU,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,8CAA8C;IACpD,OAAO,EAAE,OAAO;CACR,CAAC;AAEX;;;;;;;;GAQG;AACU,QAAA,OAAO,GAA4B,EAAE,CAAC;AAEnD,MAAM,MAAM,GAAW,EAAE,IAAI,EAAJ,YAAI,EAAE,KAAK,EAAL,aAAK,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,CAAC,eAAO,EAAE,IAAA,yBAAY,EAAC,MAAM,CAAC,CAAC,CAAC;AAY7C,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AAgBzB;;;;;;;;GAQG;AACH,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { AstNode } from './types.js';
2
+ /**
3
+ * Method names on a logger, plus `write`.
4
+ *
5
+ * `write` is here for `process.stdout.write(secret.reveal())`, which leaks
6
+ * exactly what `console.log` leaks and is the first thing reached for when a
7
+ * log line needs no newline. It only ever matches alongside a name from
8
+ * {@link DEFAULT_LOG_OBJECTS}, so an unrelated `stream.write` is untouched.
9
+ */
10
+ export declare const DEFAULT_LOG_FUNCTIONS: readonly string[];
11
+ /** Names a logger is reached by, anywhere along the callee chain. */
12
+ export declare const DEFAULT_LOG_OBJECTS: readonly string[];
13
+ /**
14
+ * Whether a call reaches a logger.
15
+ *
16
+ * Two shapes count. A method call needs its method name in `logFunctions` and
17
+ * some name along its callee chain in `logObjects`, which covers `console.log`,
18
+ * `this.logger.info`, `req.log.warn` and `logger.child({ id }).info` alike. A
19
+ * bare call counts when the function's own name is in `logObjects`, which is
20
+ * how `log(...)` from a destructured import is caught.
21
+ *
22
+ * Matching anywhere in the chain rather than at its head is a deliberate trade:
23
+ * it takes an object named one of eight logger names carrying a method named
24
+ * one of ten logger methods to produce a false positive, and it is the only way
25
+ * to see a logger that arrives as a property.
26
+ */
27
+ export declare function isLogCall(node: AstNode, logFunctions: ReadonlySet<string>, logObjects: ReadonlySet<string>): boolean;
28
+ //# sourceMappingURL=log-calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-calls.d.ts","sourceRoot":"","sources":["../src/log-calls.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAWlD,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAShD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,OAAO,EACb,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,OAAO,CAsBT"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_LOG_OBJECTS = exports.DEFAULT_LOG_FUNCTIONS = void 0;
4
+ exports.isLogCall = isLogCall;
5
+ /**
6
+ * Recognising a call to a logger.
7
+ *
8
+ * Two rules ask the same question. `no-log-reveal` asks it of a call's
9
+ * arguments, `prefer-safe-log` of their types, and neither is useful if they
10
+ * disagree about what a logger is: a project that configures its own logger
11
+ * name for one and finds the other still blind to it has been given two rules
12
+ * where it configured one. The vocabulary and the matcher live here so there
13
+ * is one answer.
14
+ */
15
+ const ast_js_1 = require("./ast.js");
16
+ /**
17
+ * Method names on a logger, plus `write`.
18
+ *
19
+ * `write` is here for `process.stdout.write(secret.reveal())`, which leaks
20
+ * exactly what `console.log` leaks and is the first thing reached for when a
21
+ * log line needs no newline. It only ever matches alongside a name from
22
+ * {@link DEFAULT_LOG_OBJECTS}, so an unrelated `stream.write` is untouched.
23
+ */
24
+ exports.DEFAULT_LOG_FUNCTIONS = [
25
+ 'log',
26
+ 'info',
27
+ 'warn',
28
+ 'error',
29
+ 'debug',
30
+ 'trace',
31
+ 'fatal',
32
+ 'verbose',
33
+ 'silly',
34
+ 'write',
35
+ ];
36
+ /** Names a logger is reached by, anywhere along the callee chain. */
37
+ exports.DEFAULT_LOG_OBJECTS = [
38
+ 'console',
39
+ 'logger',
40
+ 'log',
41
+ 'winston',
42
+ 'pino',
43
+ 'bunyan',
44
+ 'stdout',
45
+ 'stderr',
46
+ ];
47
+ /**
48
+ * Whether a call reaches a logger.
49
+ *
50
+ * Two shapes count. A method call needs its method name in `logFunctions` and
51
+ * some name along its callee chain in `logObjects`, which covers `console.log`,
52
+ * `this.logger.info`, `req.log.warn` and `logger.child({ id }).info` alike. A
53
+ * bare call counts when the function's own name is in `logObjects`, which is
54
+ * how `log(...)` from a destructured import is caught.
55
+ *
56
+ * Matching anywhere in the chain rather than at its head is a deliberate trade:
57
+ * it takes an object named one of eight logger names carrying a method named
58
+ * one of ten logger methods to produce a false positive, and it is the only way
59
+ * to see a logger that arrives as a property.
60
+ */
61
+ function isLogCall(node, logFunctions, logObjects) {
62
+ const callee = (0, ast_js_1.calleeOf)(node);
63
+ if (callee === undefined) {
64
+ return false;
65
+ }
66
+ const bareName = (0, ast_js_1.identifierName)(callee);
67
+ if (bareName !== undefined) {
68
+ return logObjects.has(bareName);
69
+ }
70
+ if (callee.type !== 'MemberExpression') {
71
+ return false;
72
+ }
73
+ const names = (0, ast_js_1.calleeChainNames)(callee);
74
+ const method = names[0];
75
+ if (method === undefined || !logFunctions.has(method)) {
76
+ return false;
77
+ }
78
+ return names.slice(1).some((name) => logObjects.has(name));
79
+ }
80
+ //# sourceMappingURL=log-calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-calls.js","sourceRoot":"","sources":["../src/log-calls.ts"],"names":[],"mappings":";;;AA4DA,8BA0BC;AAtFD;;;;;;;;;GASG;AACH,qCAAsE;AAGtE;;;;;;;GAOG;AACU,QAAA,qBAAqB,GAAsB;IACtD,KAAK;IACL,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,OAAO;CACR,CAAC;AAEF,qEAAqE;AACxD,QAAA,mBAAmB,GAAsB;IACpD,SAAS;IACT,QAAQ;IACR,KAAK;IACL,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,IAAa,EACb,YAAiC,EACjC,UAA+B;IAE/B,MAAM,MAAM,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,uBAAc,EAAC,MAAM,CAAC,CAAC;IACxC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Reading a rule's options.
3
+ *
4
+ * ESLint validates options against each rule's `meta.schema` before `create` is
5
+ * called, so these readers are not the enforcement point. They exist because
6
+ * the options arrive as `unknown` and a rule should not cast its way out of
7
+ * that: a schema can be edited into disagreement with the code it guards, and
8
+ * on that day a wrong option should fall back to a safe default rather than
9
+ * reach a rule as a string where a list belongs.
10
+ */
11
+ /**
12
+ * One positional option, as an object, or an empty one when it is absent or is
13
+ * not an object. Every reader below then falls back to its default, which is
14
+ * what an omitted option should do.
15
+ */
16
+ export declare function optionObject(options: readonly unknown[], index: number): Readonly<Record<string, unknown>>;
17
+ /** A boolean field of an options object, or `fallback` when it is absent. */
18
+ export declare function readBoolean(option: Readonly<Record<string, unknown>>, key: string, fallback: boolean): boolean;
19
+ /**
20
+ * A list-of-strings field of an options object, as a set, or `fallback` when it
21
+ * is absent.
22
+ *
23
+ * A configured list replaces the default rather than extending it. That is the
24
+ * ESLint convention, and for these rules it is also the useful behaviour: a
25
+ * project that names its logger `report` wants `report` recognised, and a
26
+ * project that has deliberately narrowed the list wants the entries it removed
27
+ * to stay removed.
28
+ */
29
+ export declare function readNameSet(option: Readonly<Record<string, unknown>>, key: string, fallback: readonly string[]): ReadonlySet<string>;
30
+ /** The JSON Schema for an option that is a list of names. */
31
+ export declare function nameListSchema(): Readonly<Record<string, unknown>>;
32
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAMnC;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CACzB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,OAAO,GAChB,OAAO,CAGT;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,WAAW,CAAC,MAAM,CAAC,CAOrB;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAElE"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Reading a rule's options.
4
+ *
5
+ * ESLint validates options against each rule's `meta.schema` before `create` is
6
+ * called, so these readers are not the enforcement point. They exist because
7
+ * the options arrive as `unknown` and a rule should not cast its way out of
8
+ * that: a schema can be edited into disagreement with the code it guards, and
9
+ * on that day a wrong option should fall back to a safe default rather than
10
+ * reach a rule as a string where a list belongs.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.optionObject = optionObject;
14
+ exports.readBoolean = readBoolean;
15
+ exports.readNameSet = readNameSet;
16
+ exports.nameListSchema = nameListSchema;
17
+ /**
18
+ * One positional option, as an object, or an empty one when it is absent or is
19
+ * not an object. Every reader below then falls back to its default, which is
20
+ * what an omitted option should do.
21
+ */
22
+ function optionObject(options, index) {
23
+ const value = options[index];
24
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
25
+ return value;
26
+ }
27
+ return {};
28
+ }
29
+ /** A boolean field of an options object, or `fallback` when it is absent. */
30
+ function readBoolean(option, key, fallback) {
31
+ const value = option[key];
32
+ return typeof value === 'boolean' ? value : fallback;
33
+ }
34
+ /**
35
+ * A list-of-strings field of an options object, as a set, or `fallback` when it
36
+ * is absent.
37
+ *
38
+ * A configured list replaces the default rather than extending it. That is the
39
+ * ESLint convention, and for these rules it is also the useful behaviour: a
40
+ * project that names its logger `report` wants `report` recognised, and a
41
+ * project that has deliberately narrowed the list wants the entries it removed
42
+ * to stay removed.
43
+ */
44
+ function readNameSet(option, key, fallback) {
45
+ const value = option[key];
46
+ if (Array.isArray(value)) {
47
+ const names = value.filter((entry) => typeof entry === 'string');
48
+ return new Set(names);
49
+ }
50
+ return new Set(fallback);
51
+ }
52
+ /** The JSON Schema for an option that is a list of names. */
53
+ function nameListSchema() {
54
+ return { type: 'array', items: { type: 'string' }, uniqueItems: true };
55
+ }
56
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAOH,oCASC;AAGD,kCAOC;AAYD,kCAWC;AAGD,wCAEC;AApDD;;;;GAIG;AACH,SAAgB,YAAY,CAC1B,OAA2B,EAC3B,KAAa;IAEb,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,OAAO,KAA0C,CAAC;IACpD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,6EAA6E;AAC7E,SAAgB,WAAW,CACzB,MAAyC,EACzC,GAAW,EACX,QAAiB;IAEjB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,WAAW,CACzB,MAAyC,EACzC,GAAW,EACX,QAA2B;IAE3B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;QAClF,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,6DAA6D;AAC7D,SAAgB,cAAc;IAC5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RuleModule } from '../types.js';
2
+ export declare const explicitClass: RuleModule;
3
+ //# sourceMappingURL=explicit-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explicit-class.d.ts","sourceRoot":"","sources":["../../src/rules/explicit-class.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAIV,UAAU,EAEX,MAAM,aAAa,CAAC;AAUrB,eAAO,MAAM,aAAa,EAAE,UA2F3B,CAAC"}