@taggor/contract 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/artifact-keys.d.ts +169 -0
- package/dist/artifact-keys.d.ts.map +1 -0
- package/dist/artifact-keys.js +195 -0
- package/dist/artifact-keys.js.map +1 -0
- package/dist/assets.d.ts +72 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +94 -0
- package/dist/assets.js.map +1 -0
- package/dist/bounded-path.d.ts +29 -0
- package/dist/bounded-path.d.ts.map +1 -0
- package/dist/bounded-path.js +57 -0
- package/dist/bounded-path.js.map +1 -0
- package/dist/bounded.d.ts +47 -0
- package/dist/bounded.d.ts.map +1 -0
- package/dist/bounded.js +93 -0
- package/dist/bounded.js.map +1 -0
- package/dist/build-diagnostic.d.ts +89 -0
- package/dist/build-diagnostic.d.ts.map +1 -0
- package/dist/build-diagnostic.js +91 -0
- package/dist/build-diagnostic.js.map +1 -0
- package/dist/component-types.d.ts +61 -0
- package/dist/component-types.d.ts.map +1 -0
- package/dist/component-types.js +277 -0
- package/dist/component-types.js.map +1 -0
- package/dist/consent-text.d.ts +31 -0
- package/dist/consent-text.d.ts.map +1 -0
- package/dist/consent-text.js +41 -0
- package/dist/consent-text.js.map +1 -0
- package/dist/contract-version.d.ts +150 -0
- package/dist/contract-version.d.ts.map +1 -0
- package/dist/contract-version.js +198 -0
- package/dist/contract-version.js.map +1 -0
- package/dist/credential-fields.d.ts +31 -0
- package/dist/credential-fields.d.ts.map +1 -0
- package/dist/credential-fields.js +36 -0
- package/dist/credential-fields.js.map +1 -0
- package/dist/css-tokens.d.ts +46 -0
- package/dist/css-tokens.d.ts.map +1 -0
- package/dist/css-tokens.js +189 -0
- package/dist/css-tokens.js.map +1 -0
- package/dist/css-value.d.ts +42 -0
- package/dist/css-value.d.ts.map +1 -0
- package/dist/css-value.js +78 -0
- package/dist/css-value.js.map +1 -0
- package/dist/data-api.d.ts +127 -0
- package/dist/data-api.d.ts.map +1 -0
- package/dist/data-api.js +167 -0
- package/dist/data-api.js.map +1 -0
- package/dist/denylist-keys.d.ts +19 -0
- package/dist/denylist-keys.d.ts.map +1 -0
- package/dist/denylist-keys.js +48 -0
- package/dist/denylist-keys.js.map +1 -0
- package/dist/diagnostic-catalog.d.ts +1402 -0
- package/dist/diagnostic-catalog.d.ts.map +1 -0
- package/dist/diagnostic-catalog.js +1311 -0
- package/dist/diagnostic-catalog.js.map +1 -0
- package/dist/dom-members.snapshot.d.ts +33 -0
- package/dist/dom-members.snapshot.d.ts.map +1 -0
- package/dist/dom-members.snapshot.js +760 -0
- package/dist/dom-members.snapshot.js.map +1 -0
- package/dist/early-loading.d.ts +27 -0
- package/dist/early-loading.d.ts.map +1 -0
- package/dist/early-loading.js +44 -0
- package/dist/early-loading.js.map +1 -0
- package/dist/error-catalog.d.ts +749 -0
- package/dist/error-catalog.d.ts.map +1 -0
- package/dist/error-catalog.js +720 -0
- package/dist/error-catalog.js.map +1 -0
- package/dist/executable-config.d.ts +35 -0
- package/dist/executable-config.d.ts.map +1 -0
- package/dist/executable-config.js +44 -0
- package/dist/executable-config.js.map +1 -0
- package/dist/freeze.d.ts +17 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +29 -0
- package/dist/freeze.js.map +1 -0
- package/dist/gunzip.d.ts +33 -0
- package/dist/gunzip.d.ts.map +1 -0
- package/dist/gunzip.js +330 -0
- package/dist/gunzip.js.map +1 -0
- package/dist/hostname.d.ts +74 -0
- package/dist/hostname.d.ts.map +1 -0
- package/dist/hostname.js +215 -0
- package/dist/hostname.js.map +1 -0
- package/dist/human-actions.d.ts +49 -0
- package/dist/human-actions.d.ts.map +1 -0
- package/dist/human-actions.js +272 -0
- package/dist/human-actions.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +108 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +240 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/key-checksum.d.ts +33 -0
- package/dist/key-checksum.d.ts.map +1 -0
- package/dist/key-checksum.js +67 -0
- package/dist/key-checksum.js.map +1 -0
- package/dist/libraries.d.ts +60 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +120 -0
- package/dist/libraries.js.map +1 -0
- package/dist/limit-catalog.d.ts +371 -0
- package/dist/limit-catalog.d.ts.map +1 -0
- package/dist/limit-catalog.js +414 -0
- package/dist/limit-catalog.js.map +1 -0
- package/dist/limits.d.ts +167 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +175 -0
- package/dist/limits.js.map +1 -0
- package/dist/locale-tag.d.ts +21 -0
- package/dist/locale-tag.d.ts.map +1 -0
- package/dist/locale-tag.js +21 -0
- package/dist/locale-tag.js.map +1 -0
- package/dist/make-diagnostic.d.ts +74 -0
- package/dist/make-diagnostic.d.ts.map +1 -0
- package/dist/make-diagnostic.js +100 -0
- package/dist/make-diagnostic.js.map +1 -0
- package/dist/manifest-compat-diagnostics.d.ts +23 -0
- package/dist/manifest-compat-diagnostics.d.ts.map +1 -0
- package/dist/manifest-compat-diagnostics.js +150 -0
- package/dist/manifest-compat-diagnostics.js.map +1 -0
- package/dist/manifest-compat.d.ts +58 -0
- package/dist/manifest-compat.d.ts.map +1 -0
- package/dist/manifest-compat.js +377 -0
- package/dist/manifest-compat.js.map +1 -0
- package/dist/manifest.d.ts +1769 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +421 -0
- package/dist/manifest.js.map +1 -0
- package/dist/metering.d.ts +126 -0
- package/dist/metering.d.ts.map +1 -0
- package/dist/metering.js +147 -0
- package/dist/metering.js.map +1 -0
- package/dist/migrate.d.ts +70 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +159 -0
- package/dist/migrate.js.map +1 -0
- package/dist/names.d.ts +37 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +55 -0
- package/dist/names.js.map +1 -0
- package/dist/overage-pricing.d.ts +89 -0
- package/dist/overage-pricing.d.ts.map +1 -0
- package/dist/overage-pricing.js +170 -0
- package/dist/overage-pricing.js.map +1 -0
- package/dist/plan-ids.d.ts +10 -0
- package/dist/plan-ids.d.ts.map +1 -0
- package/dist/plan-ids.js +8 -0
- package/dist/plan-ids.js.map +1 -0
- package/dist/plan-limits.d.ts +138 -0
- package/dist/plan-limits.d.ts.map +1 -0
- package/dist/plan-limits.js +112 -0
- package/dist/plan-limits.js.map +1 -0
- package/dist/plan-pricing.d.ts +145 -0
- package/dist/plan-pricing.d.ts.map +1 -0
- package/dist/plan-pricing.js +172 -0
- package/dist/plan-pricing.js.map +1 -0
- package/dist/plan-usage.d.ts +112 -0
- package/dist/plan-usage.d.ts.map +1 -0
- package/dist/plan-usage.js +134 -0
- package/dist/plan-usage.js.map +1 -0
- package/dist/preview-token.d.ts +52 -0
- package/dist/preview-token.d.ts.map +1 -0
- package/dist/preview-token.js +106 -0
- package/dist/preview-token.js.map +1 -0
- package/dist/prop-names.d.ts +51 -0
- package/dist/prop-names.d.ts.map +1 -0
- package/dist/prop-names.js +150 -0
- package/dist/prop-names.js.map +1 -0
- package/dist/prop-type-docs.d.ts +20 -0
- package/dist/prop-type-docs.d.ts.map +1 -0
- package/dist/prop-type-docs.js +89 -0
- package/dist/prop-type-docs.js.map +1 -0
- package/dist/prop-types.d.ts +97 -0
- package/dist/prop-types.d.ts.map +1 -0
- package/dist/prop-types.js +299 -0
- package/dist/prop-types.js.map +1 -0
- package/dist/props.d.ts +996 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +183 -0
- package/dist/props.js.map +1 -0
- package/dist/proto-guard.d.ts +29 -0
- package/dist/proto-guard.d.ts.map +1 -0
- package/dist/proto-guard.js +79 -0
- package/dist/proto-guard.js.map +1 -0
- package/dist/runtime-errors.d.ts +42 -0
- package/dist/runtime-errors.d.ts.map +1 -0
- package/dist/runtime-errors.js +42 -0
- package/dist/runtime-errors.js.map +1 -0
- package/dist/runtime-pointers.d.ts +58 -0
- package/dist/runtime-pointers.d.ts.map +1 -0
- package/dist/runtime-pointers.js +84 -0
- package/dist/runtime-pointers.js.map +1 -0
- package/dist/secret-scan.d.ts +191 -0
- package/dist/secret-scan.d.ts.map +1 -0
- package/dist/secret-scan.js +542 -0
- package/dist/secret-scan.js.map +1 -0
- package/dist/semver.d.ts +89 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +400 -0
- package/dist/semver.js.map +1 -0
- package/dist/server-key.d.ts +68 -0
- package/dist/server-key.d.ts.map +1 -0
- package/dist/server-key.js +150 -0
- package/dist/server-key.js.map +1 -0
- package/dist/site-manifest-keys.d.ts +107 -0
- package/dist/site-manifest-keys.d.ts.map +1 -0
- package/dist/site-manifest-keys.js +146 -0
- package/dist/site-manifest-keys.js.map +1 -0
- package/dist/site-manifest.d.ts +286 -0
- package/dist/site-manifest.d.ts.map +1 -0
- package/dist/site-manifest.js +100 -0
- package/dist/site-manifest.js.map +1 -0
- package/dist/source-archive.d.ts +119 -0
- package/dist/source-archive.d.ts.map +1 -0
- package/dist/source-archive.js +644 -0
- package/dist/source-archive.js.map +1 -0
- package/dist/source-package-corpus.d.ts +55 -0
- package/dist/source-package-corpus.d.ts.map +1 -0
- package/dist/source-package-corpus.js +303 -0
- package/dist/source-package-corpus.js.map +1 -0
- package/dist/source-package.d.ts +227 -0
- package/dist/source-package.d.ts.map +1 -0
- package/dist/source-package.js +361 -0
- package/dist/source-package.js.map +1 -0
- package/dist/source-secrets.d.ts +21 -0
- package/dist/source-secrets.d.ts.map +1 -0
- package/dist/source-secrets.js +43 -0
- package/dist/source-secrets.js.map +1 -0
- package/dist/ssr-cap.d.ts +61 -0
- package/dist/ssr-cap.d.ts.map +1 -0
- package/dist/ssr-cap.js +107 -0
- package/dist/ssr-cap.js.map +1 -0
- package/dist/ssr-kv.d.ts +18 -0
- package/dist/ssr-kv.d.ts.map +1 -0
- package/dist/ssr-kv.js +18 -0
- package/dist/ssr-kv.js.map +1 -0
- package/dist/ssr-version-ledger.d.ts +53 -0
- package/dist/ssr-version-ledger.d.ts.map +1 -0
- package/dist/ssr-version-ledger.js +88 -0
- package/dist/ssr-version-ledger.js.map +1 -0
- package/dist/style-references.d.ts +58 -0
- package/dist/style-references.d.ts.map +1 -0
- package/dist/style-references.js +241 -0
- package/dist/style-references.js.map +1 -0
- package/dist/tag-name.d.ts +87 -0
- package/dist/tag-name.d.ts.map +1 -0
- package/dist/tag-name.js +222 -0
- package/dist/tag-name.js.map +1 -0
- package/dist/tar-writer.d.ts +74 -0
- package/dist/tar-writer.d.ts.map +1 -0
- package/dist/tar-writer.js +148 -0
- package/dist/tar-writer.js.map +1 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +11 -0
- package/dist/testing.js.map +1 -0
- package/dist/text-codec.d.ts +36 -0
- package/dist/text-codec.d.ts.map +1 -0
- package/dist/text-codec.js +32 -0
- package/dist/text-codec.js.map +1 -0
- package/dist/url-value.d.ts +41 -0
- package/dist/url-value.d.ts.map +1 -0
- package/dist/url-value.js +147 -0
- package/dist/url-value.js.map +1 -0
- package/dist/usage-guard.d.ts +99 -0
- package/dist/usage-guard.d.ts.map +1 -0
- package/dist/usage-guard.js +104 -0
- package/dist/usage-guard.js.map +1 -0
- package/dist/usage-mirror.d.ts +55 -0
- package/dist/usage-mirror.d.ts.map +1 -0
- package/dist/usage-mirror.js +52 -0
- package/dist/usage-mirror.js.map +1 -0
- package/dist/value-check.d.ts +88 -0
- package/dist/value-check.d.ts.map +1 -0
- package/dist/value-check.js +279 -0
- package/dist/value-check.js.map +1 -0
- package/dist/value-patterns.d.ts +9 -0
- package/dist/value-patterns.d.ts.map +1 -0
- package/dist/value-patterns.js +17 -0
- package/dist/value-patterns.js.map +1 -0
- package/dist/value-schema.d.ts +796 -0
- package/dist/value-schema.d.ts.map +1 -0
- package/dist/value-schema.js +231 -0
- package/dist/value-schema.js.map +1 -0
- package/dist/zod-free.d.ts +59 -0
- package/dist/zod-free.d.ts.map +1 -0
- package/dist/zod-free.js +57 -0
- package/dist/zod-free.js.map +1 -0
- package/package.json +75 -3
- package/schema/DEPLOYED +12 -0
- package/schema/build-diagnostic.v1.json +63 -0
- package/schema/component-manifest.v1.json +1000 -0
- package/schema/data-api.v1.json +194 -0
- package/schema/library-manifest.v1.json +60 -0
- package/schema/published/SHA256SUMS +36 -0
- package/schema/published/build-diagnostic/v1.10.json +83 -0
- package/schema/published/build-diagnostic/v1.3.json +83 -0
- package/schema/published/build-diagnostic/v1.4.json +83 -0
- package/schema/published/build-diagnostic/v1.5.json +83 -0
- package/schema/published/build-diagnostic/v1.6.json +83 -0
- package/schema/published/build-diagnostic/v1.7.json +83 -0
- package/schema/published/build-diagnostic/v1.8.json +83 -0
- package/schema/published/build-diagnostic/v1.9.json +83 -0
- package/schema/published/component-manifest/v1.10.json +1443 -0
- package/schema/published/component-manifest/v1.3.json +1411 -0
- package/schema/published/component-manifest/v1.4.json +1419 -0
- package/schema/published/component-manifest/v1.5.json +1437 -0
- package/schema/published/component-manifest/v1.6.json +1437 -0
- package/schema/published/component-manifest/v1.7.json +1437 -0
- package/schema/published/component-manifest/v1.8.json +1437 -0
- package/schema/published/component-manifest/v1.9.json +1437 -0
- package/schema/published/data-api/v1.10.json +282 -0
- package/schema/published/data-api/v1.3.json +281 -0
- package/schema/published/data-api/v1.4.json +281 -0
- package/schema/published/data-api/v1.5.json +281 -0
- package/schema/published/data-api/v1.6.json +281 -0
- package/schema/published/data-api/v1.7.json +281 -0
- package/schema/published/data-api/v1.8.json +282 -0
- package/schema/published/data-api/v1.9.json +282 -0
- package/schema/published/library-manifest/v1.10.json +68 -0
- package/schema/published/library-manifest/v1.5.json +68 -0
- package/schema/published/library-manifest/v1.6.json +68 -0
- package/schema/published/library-manifest/v1.7.json +68 -0
- package/schema/published/library-manifest/v1.8.json +68 -0
- package/schema/published/library-manifest/v1.9.json +68 -0
- package/schema/published/taggor-config/v1.10.json +56 -0
- package/schema/published/taggor-config/v1.5.json +56 -0
- package/schema/published/taggor-config/v1.6.json +56 -0
- package/schema/published/taggor-config/v1.7.json +56 -0
- package/schema/published/taggor-config/v1.8.json +56 -0
- package/schema/published/taggor-config/v1.9.json +56 -0
- package/schema/taggor-config.v1.json +39 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret detector (TAG-1707): finds credentials in the text of a component's source package or of
|
|
3
|
+
* its built bundle, so the build can refuse them with `SECRET_IN_SOURCE` (a component's code is
|
|
4
|
+
* public: anyone who loads the page can read it).
|
|
5
|
+
*
|
|
6
|
+
* The rules are data in the shape of gitleaks rules (`id`, `description`, `regex`,
|
|
7
|
+
* `secretGroup`, `keywords`; `caseInsensitive` stands in for gitleaks' inline `(?i)`, which
|
|
8
|
+
* JavaScript regular expressions lack), taken from the gitleaks default config and the
|
|
9
|
+
* providers' documented prefixes. Keys that are public by design (Stripe publishable keys
|
|
10
|
+
* `pk_…`, Google API keys `AIza…` that browser SDKs embed) have no rule and never block.
|
|
11
|
+
*
|
|
12
|
+
* Obvious placeholders never block (TAG-1724, gitleaks' allowlist kept strict): a value ending in
|
|
13
|
+
* `EXAMPLE`, a body of one repeated character, or a sample the provider itself publishes
|
|
14
|
+
* (`isPlaceholderSecret`). Every source file counts, documentation (`README.md`) included: the
|
|
15
|
+
* package is kept by Taggor and a key in it is leaked all the same.
|
|
16
|
+
*
|
|
17
|
+
* The value of a secret never leaves this module: a finding carries only the rule, the
|
|
18
|
+
* position and a mask (the first `SECRET_MASK_VISIBLE_CHARS` characters and `…`, or only `…`
|
|
19
|
+
* for a rule that recognizes the value by its variable name, whose first characters are already
|
|
20
|
+
* random), so nothing downstream (diagnostics, logs, the `builds` table, the API) can store or
|
|
21
|
+
* print it. `redactSecrets` masks the same way in texts that may quote a source file, and
|
|
22
|
+
* `mentionsSecretKeyword` tells whether such a text may quote a key; both read the text as
|
|
23
|
+
* written and with its JavaScript and CSS escapes decoded (`escapeReadings`), and count a keyword
|
|
24
|
+
* that is also an ordinary word (`cloudflare`, `Asia`) only before a token mixing letters and
|
|
25
|
+
* digits (TAG-1725).
|
|
26
|
+
*
|
|
27
|
+
* Cost is bounded (golden rule 5, the text is untrusted): at most `SECRET_SCAN_LIMITS.maxFiles`
|
|
28
|
+
* files and `maxChars` UTF-16 units per scan (the builder's own ceilings), a rule's regex runs
|
|
29
|
+
* only on texts that contain one of its keywords, every quantifier of every rule is bounded and
|
|
30
|
+
* starts after a literal, and the scan stops at `SECRET_SCAN_MAX_FINDINGS`. Zod-free and
|
|
31
|
+
* dependency-free, so the CLI (`taggor check`, `taggor publish`: TAG-1006, TAG-1004) and the API
|
|
32
|
+
* can run the same scan before a package leaves the agent's machine or is stored.
|
|
33
|
+
*/
|
|
34
|
+
/** One detection rule, in the shape of a gitleaks rule. */
|
|
35
|
+
export interface SecretRule {
|
|
36
|
+
/** Stable id, as in gitleaks (`stripe-access-token`). */
|
|
37
|
+
readonly id: string;
|
|
38
|
+
/** What the secret is, in English, as a diagnostic names it: "a Stripe secret key". */
|
|
39
|
+
readonly description: string;
|
|
40
|
+
/** Regular expression source (JavaScript syntax); every quantifier bounded. */
|
|
41
|
+
readonly regex: string;
|
|
42
|
+
/** Capture group holding the secret (0: the whole match). */
|
|
43
|
+
readonly secretGroup: number;
|
|
44
|
+
/** Lowercase substrings; the regex only runs on a text that contains one of them. */
|
|
45
|
+
readonly keywords: readonly string[];
|
|
46
|
+
/** Match letters in any case (gitleaks' `(?i)`). */
|
|
47
|
+
readonly caseInsensitive?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The secret has no prefix of its own and is recognized by the name it is assigned to
|
|
50
|
+
* (`CLOUDFLARE_API_TOKEN = "…"`): its first characters are random, so the mask shows none.
|
|
51
|
+
*/
|
|
52
|
+
readonly byName?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Capture group holding the random body of the secret, without its fixed prefix or marker
|
|
55
|
+
* (default: `secretGroup`). The placeholder allowlist (`isPlaceholderSecret`) reads it.
|
|
56
|
+
*/
|
|
57
|
+
readonly bodyGroup?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The rules. A new provider adds an entry here with a test in both directions in
|
|
61
|
+
* `secret-scan.test.ts` (a fake value that blocks, a near miss or public key that does not).
|
|
62
|
+
* The Taggor API key format (`tgr_live_` or `tgr_test_`, then base62 with a CRC32 at the end) is
|
|
63
|
+
* the one TAG-902 implements; the body length here is a range so the rule holds whatever length
|
|
64
|
+
* TAG-902 settles on within it. The SSR server key (`tgs_live_`/`tgs_test_`, server-key.ts) has the
|
|
65
|
+
* same shape and its own rule.
|
|
66
|
+
*/
|
|
67
|
+
export declare const SECRET_RULES: readonly SecretRule[];
|
|
68
|
+
/**
|
|
69
|
+
* Whether a value a rule matched is an obvious placeholder, never a real key (TAG-1724, the
|
|
70
|
+
* gitleaks allowlist idea, kept strict): the secret ends with `SECRET_EXAMPLE_SUFFIX`
|
|
71
|
+
* (`AKIAIOSFODNN7EXAMPLE`; a random body ends so with odds of 1 in 32^7, about 3·10^10, or less), its body is one
|
|
72
|
+
* character repeated (`sk_test_xxxxxxxxxxxxxxxx`, `tgr_test_0000…`), or it is a value the
|
|
73
|
+
* provider published as its own documentation sample. A body with two different characters is
|
|
74
|
+
* not a placeholder: `sk_test_xxxxxxxxxxxxxxxy` blocks.
|
|
75
|
+
*
|
|
76
|
+
* Inputs: the secret and its body (`SecretRule.bodyGroup`). Output: a boolean. Errors: none.
|
|
77
|
+
* Side effects: none.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isPlaceholderSecret(secret: string, body: string): boolean;
|
|
80
|
+
/** Ceilings of one scan: the builder's own (`BUILD_LIMITS.maxFiles`, `maxUnpackedBytes`). */
|
|
81
|
+
export declare const SECRET_SCAN_LIMITS: Readonly<{
|
|
82
|
+
/** Texts in one scan. */
|
|
83
|
+
maxFiles: 500;
|
|
84
|
+
/** UTF-16 units of all the texts together (20 MiB of UTF-8 is at most this many). */
|
|
85
|
+
maxChars: number;
|
|
86
|
+
}>;
|
|
87
|
+
/** Findings of one scan, at most (the builder reports at most 50 diagnostics). */
|
|
88
|
+
export declare const SECRET_SCAN_MAX_FINDINGS = 50;
|
|
89
|
+
/** Characters of a secret a mask shows before the ellipsis. */
|
|
90
|
+
export declare const SECRET_MASK_VISIBLE_CHARS = 4;
|
|
91
|
+
/** One text to scan: a path (any label the caller understands) and its content. */
|
|
92
|
+
export interface SecretScanInput {
|
|
93
|
+
readonly path: string;
|
|
94
|
+
readonly text: string;
|
|
95
|
+
}
|
|
96
|
+
/** One secret found. Never holds the value. */
|
|
97
|
+
export interface SecretFinding {
|
|
98
|
+
/** `SecretRule.id`. */
|
|
99
|
+
readonly ruleId: string;
|
|
100
|
+
/** `SecretRule.description`. */
|
|
101
|
+
readonly description: string;
|
|
102
|
+
/** The `path` of the input it was found in. */
|
|
103
|
+
readonly path: string;
|
|
104
|
+
/** 1-based line and column (UTF-16 units) where the secret starts. */
|
|
105
|
+
readonly line: number;
|
|
106
|
+
readonly column: number;
|
|
107
|
+
/** `maskSecret` of the value. */
|
|
108
|
+
readonly masked: string;
|
|
109
|
+
}
|
|
110
|
+
/** The outcome of a scan. */
|
|
111
|
+
export type SecretScanResult = {
|
|
112
|
+
readonly ok: true;
|
|
113
|
+
readonly findings: readonly SecretFinding[];
|
|
114
|
+
} | {
|
|
115
|
+
readonly ok: false;
|
|
116
|
+
/** More inputs than `maxFiles`, or more characters than `maxChars`. */
|
|
117
|
+
readonly reason: "too-many-files" | "too-large";
|
|
118
|
+
readonly message: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The mask of a secret: its first `visible` characters (default `SECRET_MASK_VISIBLE_CHARS`; for
|
|
122
|
+
* the prefixed rules above, a prefix that names the provider and none of the random part) and
|
|
123
|
+
* `…`. A rule recognized by name (`byName`) masks with 0: the value has no prefix to show.
|
|
124
|
+
*
|
|
125
|
+
* Inputs: the value and how many characters to show. Output: the mask. Errors: none. Side
|
|
126
|
+
* effects: none.
|
|
127
|
+
*/
|
|
128
|
+
export declare function maskSecret(value: string, visible?: number): string;
|
|
129
|
+
/**
|
|
130
|
+
* Scans texts for secrets.
|
|
131
|
+
*
|
|
132
|
+
* Inputs: the texts (a source package's files, or a bundle's outputs) and, optionally, other
|
|
133
|
+
* limits (tests). Output: `ok: true` with the findings in input and text order (at most
|
|
134
|
+
* `SECRET_SCAN_MAX_FINDINGS`; one per start position, the first rule in `SECRET_RULES` order
|
|
135
|
+
* when two match there; empty when nothing matches), or `ok: false` when the inputs are over the
|
|
136
|
+
* limits, checked before any text is read. Never holds or returns a secret's value. Errors: never
|
|
137
|
+
* throws. Side effects: none.
|
|
138
|
+
*/
|
|
139
|
+
export declare function scanSecrets(inputs: readonly SecretScanInput[], limits?: {
|
|
140
|
+
readonly maxFiles: number;
|
|
141
|
+
readonly maxChars: number;
|
|
142
|
+
}): SecretScanResult;
|
|
143
|
+
/**
|
|
144
|
+
* The most characters `escapeReadings`, `mentionsSecretKeyword` and `redactSecrets` read: they
|
|
145
|
+
* are for short diagnostic texts (a message is at most 2,000 characters, a snippet 300). Linear
|
|
146
|
+
* as they are, they take seconds of CPU on 20 MiB (TAG-1725 security review, B2), so a longer
|
|
147
|
+
* text is cut and its rest treated as one that may quote a secret.
|
|
148
|
+
*/
|
|
149
|
+
export declare const SECRET_TEXT_MAX_CHARS = 4000;
|
|
150
|
+
/**
|
|
151
|
+
* A text as it reads with its escapes decoded (TAG-1725): as written, as JavaScript decodes it
|
|
152
|
+
* (`\xNN`, `\uNNNN`, `\u{…}`, legacy octal, `\n` and the like, and any other `\c` as `c`) and as
|
|
153
|
+
* CSS does (`\73 `). A key written with escapes (`"\x73k_live_…"`) only shows its keyword in a
|
|
154
|
+
* decoded reading. Linear: one pass per reading. Only for short diagnostic texts: past
|
|
155
|
+
* `SECRET_TEXT_MAX_CHARS`, only the first `SECRET_TEXT_MAX_CHARS` characters are decoded.
|
|
156
|
+
*
|
|
157
|
+
* Inputs: any text. Output: the distinct readings, the text as written first (only it when the
|
|
158
|
+
* text has no backslash); for a longer text, the decoded readings are of its first
|
|
159
|
+
* `SECRET_TEXT_MAX_CHARS` characters. Errors: never throws. Side effects: none.
|
|
160
|
+
*/
|
|
161
|
+
export declare function escapeReadings(text: string): readonly string[];
|
|
162
|
+
/**
|
|
163
|
+
* Whether a text may quote a secret, even one the rules miss (a value split across literals, an
|
|
164
|
+
* odd boundary), in any of its `escapeReadings`: a rule finds a value in it, or it names a
|
|
165
|
+
* rule's keyword, a keyword that is also an ordinary word (`cloudflare`, `Asia`:
|
|
166
|
+
* `WORD_KEYWORDS`) only when the token after it mixes letters and digits. Case-insensitive.
|
|
167
|
+
* Only for short diagnostic texts: one longer than `SECRET_TEXT_MAX_CHARS` may quote a secret
|
|
168
|
+
* as far as this function knows, without being read.
|
|
169
|
+
*
|
|
170
|
+
* Inputs: any text. Output: a boolean, `true` for a text over `SECRET_TEXT_MAX_CHARS`. Errors:
|
|
171
|
+
* none. Side effects: none.
|
|
172
|
+
*/
|
|
173
|
+
export declare function mentionsSecretKeyword(text: string): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* A text with every secret masked: each value a rule finds, and each run of a keyword and token
|
|
176
|
+
* characters of `MIN_MASKED_RUN` characters or more (a key a rule misses, such as one with an
|
|
177
|
+
* odd boundary), replaced by its mask; a keyword that is also an ordinary word (`WORD_KEYWORDS`)
|
|
178
|
+
* only starts a run when the token after it mixes letters and digits, so
|
|
179
|
+
* `cloudflare-turnstile-loader.js` and `Asia/Ho_Chi_Minh` stay whole (TAG-1725). When a decoded
|
|
180
|
+
* reading (`escapeReadings`) has something to mask, that reading is returned masked (the
|
|
181
|
+
* JavaScript one before the CSS one): `"\x73k_live_…"` becomes `"sk_l…"`. For texts that are not a
|
|
182
|
+
* source file but may quote one: a bundler's message, a thrown error. Only for short diagnostic
|
|
183
|
+
* texts (the builder passes messages of at most 2,000 characters): past `SECRET_TEXT_MAX_CHARS`,
|
|
184
|
+
* the rest is unread and replaced by `…`, since it may quote a secret.
|
|
185
|
+
*
|
|
186
|
+
* Inputs: any text. Output: the text, unchanged when nothing is found and it is not longer than
|
|
187
|
+
* `SECRET_TEXT_MAX_CHARS`; otherwise its first `SECRET_TEXT_MAX_CHARS` characters, less the
|
|
188
|
+
* token the cut splits, masked, then `…`. Errors: never throws. Side effects: none.
|
|
189
|
+
*/
|
|
190
|
+
export declare function redactSecrets(text: string): string;
|
|
191
|
+
//# sourceMappingURL=secret-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-scan.d.ts","sourceRoot":"","sources":["../src/secret-scan.ts"],"names":[],"mappings":"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"}
|