@fabrika/provider-zerops 0.9.0-dev.10 → 0.9.0-dev.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/provider-zerops",
3
- "version": "0.9.0-dev.10",
3
+ "version": "0.9.0-dev.11",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,15 +45,15 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "zod": "^3.25.76",
48
- "@fabrika/app": "0.9.0-dev.10",
49
- "@fabrika/auth": "0.9.0-dev.10",
50
- "@fabrika/auth-core": "0.9.0-dev.10",
51
- "@fabrika/email": "0.9.0-dev.10",
52
- "@fabrika/iam-contract": "0.9.0-dev.10",
53
- "@fabrika/installation-init": "0.9.0-dev.10",
54
- "@fabrika/operations-contract": "0.9.0-dev.10",
55
- "@fabrika/provider-contract": "0.9.0-dev.10",
56
- "@fabrika/proxy-core": "0.9.0-dev.10",
48
+ "@fabrika/app": "0.9.0-dev.11",
49
+ "@fabrika/auth": "0.9.0-dev.11",
50
+ "@fabrika/auth-core": "0.9.0-dev.11",
51
+ "@fabrika/email": "0.9.0-dev.11",
52
+ "@fabrika/iam-contract": "0.9.0-dev.11",
53
+ "@fabrika/installation-init": "0.9.0-dev.11",
54
+ "@fabrika/operations-contract": "0.9.0-dev.11",
55
+ "@fabrika/provider-contract": "0.9.0-dev.11",
56
+ "@fabrika/proxy-core": "0.9.0-dev.11",
57
57
  "yaml": "^2.9.1"
58
58
  }
59
59
  }
@@ -13,7 +13,9 @@
13
13
  // error naming both the flag and the variable that would supply it.
14
14
 
15
15
  import { describeArgument, type McpClient, parseMcpClientsJson, readEnv, requiredSetting, setting } from '@fabrika/installation-init'
16
+ import { PLATFORM_DEPLOY_ORDER } from './deploy'
16
17
  import { parsePlatformHosts, parsePlatformScheme } from './placement-options'
18
+ import { parsePlainVariables } from './plain-credentials'
17
19
  import { readInstallationSourceDir } from './source-options'
18
20
 
19
21
  /** How the project this installation lives in is named. */
@@ -39,6 +41,11 @@ export interface PlatformDeployInput {
39
41
  readonly mcpClients?: readonly McpClient[]
40
42
  /** IAM-issued `px_` admin key, used only to reconcile the console's schema. Environment only. */
41
43
  readonly iamAdminKey: string
44
+ /**
45
+ * Readable service variables, as `<service>/<KEY>`, the operator has checked are not credentials. The deploy refuses
46
+ * every other readable variable that looks like one (`plain-credentials.ts`).
47
+ */
48
+ readonly plainVariables?: ReadonlySet<string>
42
49
  /** Read everything, write nothing, trigger nothing. */
43
50
  readonly dryRun: boolean
44
51
  }
@@ -54,6 +61,7 @@ const FLAGS = [
54
61
  '--scheme',
55
62
  '--source-dir',
56
63
  '--mcp-clients',
64
+ '--plain-variables',
57
65
  ] as const
58
66
 
59
67
  const assertKnownArguments = (argv: readonly string[]): void => {
@@ -128,6 +136,7 @@ export const parsePlatformDeployArgs = (
128
136
  ? readEnv(env, 'FABRIKA_IAM_PROVISIONING_KEY') ?? ''
129
137
  : requiredSetting(readEnv(env, 'FABRIKA_IAM_PROVISIONING_KEY'), '(no flag)', 'FABRIKA_IAM_PROVISIONING_KEY'),
130
138
  scheme,
139
+ plainVariables: parsePlainVariables(setting(argv, env, '--plain-variables', 'FABRIKA_PLATFORM_PLAIN_VARIABLES'), PLATFORM_DEPLOY_ORDER),
131
140
  dryRun,
132
141
  ...(hosts === undefined ? {} : { hosts }),
133
142
  sourceDir,
@@ -84,6 +84,7 @@ import {
84
84
  validateInstallationSetups,
85
85
  } from './installation-source'
86
86
  import type { DeployLog } from './log'
87
+ import { plainCredentialRefusal, plainCredentialVariables } from './plain-credentials'
87
88
  import { archiveWithDataFile } from './platform-archive'
88
89
  import type { PreparedPlatformSource } from './platform-source'
89
90
  import { type PlatformUploadFetch, uploadPlatformArchive } from './platform-upload'
@@ -804,9 +805,23 @@ export const deployPreparedPlatform = async (
804
805
  controlTableDigest,
805
806
  input.iamAdminKey,
806
807
  )
808
+ // Every service's environment is read, and checked, before the first write: a refusal leaves nothing half-written.
809
+ const liveEnv = new Map<PlatformDeployService, LiveServiceEnv>()
810
+ for (const hostname of PLATFORM_DEPLOY_ORDER) {
811
+ liveEnv.set(hostname, hostname === PLATFORM_PROXY_SERVICE ? proxyEnv : await readServiceEnv(serviceOf(services, hostname).id, collaborators))
812
+ }
813
+ const plain = PLATFORM_DEPLOY_ORDER.flatMap((hostname) =>
814
+ plainCredentialVariables(
815
+ hostname,
816
+ liveEnv.get(hostname) ?? new Map(),
817
+ new Set(desired.get(hostname)?.keys() ?? []),
818
+ input.plainVariables ?? new Set(),
819
+ )
820
+ )
821
+ if (plain.length > 0) throw plainCredentialRefusal(plain)
807
822
  for (const hostname of PLATFORM_DEPLOY_ORDER) {
808
823
  const service = serviceOf(services, hostname)
809
- const live = hostname === PLATFORM_PROXY_SERVICE ? proxyEnv : await readServiceEnv(service.id, collaborators)
824
+ const live = liveEnv.get(hostname) ?? new Map<string, ZeropsServiceEnv>()
810
825
  const keys = desired.get(hostname) ?? new Map<string, string>()
811
826
  const liveOAuthConfig = live.get(IAM_OAUTH_CONFIG_VARIABLE)
812
827
  const oauthStillSet = liveOAuthConfig !== undefined && (liveOAuthConfig.sensitive || liveOAuthConfig.content.trim() !== '')
@@ -394,7 +394,11 @@ none, and `install` cannot be re-run.
394
394
 
395
395
  1. Set the same `FABRIKA_EMAIL_*` variables on BOTH `iam` and `control`, in the Zerops GUI or with `zcli`:
396
396
  `FABRIKA_EMAIL_PROVIDER`, `FABRIKA_EMAIL_FROM`, optionally `FABRIKA_EMAIL_FROM_NAME`, and the provider's
397
- variables. Mark the credentials sensitive. Delete the variables of a provider you leave.
397
+ variables. Store the credentials (every variable `fabrika platform install --provider=zerops --help` marks secret) as SENSITIVE variables: a readable
398
+ one is read by every member of the project, and `platform deploy` refuses to run while one is readable. A
399
+ variable already stored readable does not become sensitive through `zops env set --sensitive`, which leaves
400
+ an existing variable as it was: delete it and add it again as a secret one in the GUI. Delete the variables of a
401
+ provider you leave.
398
402
  2. Restart `iam` and `control`. Each reads the transport at boot. IAM refuses to start on an invalid one.
399
403
  Control starts, logs a line that names the invalid variables, and refuses every deploy that needs the transport
400
404
  until you fix them and restart it.
@@ -228,6 +228,7 @@ Options (a flag beats the environment variable beside it):
228
228
  --scheme=<http|https> FABRIKA_PLATFORM_SCHEME default https
229
229
  --source-dir=<checkout> required clean full checkout running this CLI
230
230
  --mcp-clients=<json> FABRIKA_PLATFORM_MCP_CLIENTS_JSON MCP authoring clients; unset = off
231
+ --plain-variables=<svc/KEY,...> FABRIKA_PLATFORM_PLAIN_VARIABLES readable variables that are not credentials
231
232
  --dry-run read everything, change nothing
232
233
 
233
234
  Naming NO host derives all three from the proxy service's Zerops subdomains and makes this a
@@ -250,6 +251,12 @@ process listing:
250
251
  (a --dry-run does not need it)
251
252
  FABRIKA_ZEROPS_API_URL optional region API base, when not the default
252
253
 
254
+ Before it writes anything, the deploy reads the environment of every platform service and refuses a
255
+ READABLE variable that looks like a credential (a mail provider's secret, a name with TOKEN, SECRET,
256
+ PASSWORD or a KEY, a value that reads like a token): every member of the Zerops project can read it.
257
+ Store such a variable sensitive. One checked and found not to be a credential is named in
258
+ --plain-variables as <service>/<KEY>.
259
+
253
260
  This command writes one credential, derived from FABRIKA_IAM_PROVISIONING_KEY: the secret the proxy
254
261
  proves its requests to IAM with. Every other secret an installation holds is placed at bring-up.
255
262
 
@@ -0,0 +1,91 @@
1
+ // `platform deploy` refuses an installation whose platform services hold a credential as a READABLE variable.
2
+ //
3
+ // A readable service variable is read by every member of the Zerops project, and Zerops keeps no record of who read it.
4
+ // Nothing Fabrika writes is one: `install` writes the generated secrets and the mail credentials sensitive, and the
5
+ // deploy writes only configuration readable. But the guide's own procedures (setting or rotating the mail transport)
6
+ // are manual writes in the Zerops GUI or `zcli`, where `sensitive` is a checkbox. An installation was found holding its
7
+ // mail provider's token readable on `iam` and `control`, written that way. The deploy reads every service's environment
8
+ // anyway, and every upgrade runs it, so it is where such a variable is caught.
9
+ //
10
+ // The check is `plainCredentialFinding`'s heuristic plus the mail providers' own declarations, and it errs towards
11
+ // refusing, so `FABRIKA_PLATFORM_PLAIN_VARIABLES` names the variables an operator has checked are not credentials.
12
+
13
+ import { builtinEmailProviders } from '@fabrika/email/providers'
14
+ import { plainCredentialFinding } from '@fabrika/provider-contract'
15
+ import type { LiveServiceEnv, PlatformDeployService } from './deploy'
16
+
17
+ /** One readable variable that looks like a credential. Names only; the value is never carried. */
18
+ export interface PlainCredentialVariable {
19
+ readonly service: PlatformDeployService
20
+ readonly key: string
21
+ readonly because: string
22
+ }
23
+
24
+ /** Every mail provider variable the provider itself declares secret, whichever provider an installation uses. */
25
+ const DECLARED_SECRET_EMAIL_VARIABLES: ReadonlySet<string> = new Set(
26
+ Object.values(builtinEmailProviders).flatMap((provider) =>
27
+ provider.variables.filter((variable) => variable.secret).map((variable) => variable.name)
28
+ ),
29
+ )
30
+
31
+ /** `<service>/<KEY>`, the form an operator names an exception in. */
32
+ export const plainVariableId = (service: string, key: string): string => `${service}/${key}`
33
+
34
+ /**
35
+ * The readable variables of one service that look like credentials.
36
+ *
37
+ * `written` are the keys this deploy writes itself, readable by design and about to be overwritten: they are its own
38
+ * configuration, never a credential. `allowed` are the `<service>/<KEY>` exceptions the operator named.
39
+ */
40
+ export const plainCredentialVariables = (
41
+ service: PlatformDeployService,
42
+ live: LiveServiceEnv,
43
+ written: ReadonlySet<string>,
44
+ allowed: ReadonlySet<string>,
45
+ ): PlainCredentialVariable[] => {
46
+ const found: PlainCredentialVariable[] = []
47
+ for (const [key, record] of live) {
48
+ // A record the platform owns (`type: SYSTEM`) is not the operator's to make sensitive, so it is not refused.
49
+ if (record.sensitive || record.type === 'SYSTEM' || written.has(key) || allowed.has(plainVariableId(service, key))) continue
50
+ if (DECLARED_SECRET_EMAIL_VARIABLES.has(key) && record.content.trim() !== '') {
51
+ found.push({ service, key, because: 'its mail provider declares it secret' })
52
+ continue
53
+ }
54
+ const finding = plainCredentialFinding(key, record.content)
55
+ if (finding !== null) found.push({ service, key, because: finding.because })
56
+ }
57
+ return found
58
+ }
59
+
60
+ /** The refusal: each variable by name and reason, where it belongs instead, and the opt-out. Never a value. */
61
+ export const plainCredentialRefusal = (found: readonly PlainCredentialVariable[]): Error =>
62
+ new Error(
63
+ [
64
+ `${found.length} readable service variable(s) look like credentials, and every member of the Zerops project can read them:`,
65
+ ...found.map((entry) => ` ${plainVariableId(entry.service, entry.key)}: ${entry.because}`),
66
+ 'Store each one as a SENSITIVE variable of the same service, then restart that service: in the Zerops GUI, delete',
67
+ 'the variable and add it again as a secret one. `zops env set --sensitive` does not change an existing variable.',
68
+ 'Nothing has been written or deployed.',
69
+ 'A variable that is not a credential: name it in FABRIKA_PLATFORM_PLAIN_VARIABLES (or --plain-variables) as',
70
+ '`<service>/<KEY>`, comma-separated, and deploy again.',
71
+ ].join('\n'),
72
+ )
73
+
74
+ /** Parse the operator's exceptions: comma-separated `<service>/<KEY>`, each naming a platform service. */
75
+ export const parsePlainVariables = (raw: string | undefined, services: readonly string[]): ReadonlySet<string> => {
76
+ const allowed = new Set<string>()
77
+ if (raw === undefined) return allowed
78
+ for (const [index, entry] of raw.split(',').map((item) => item.trim()).filter((item) => item !== '').entries()) {
79
+ const slash = entry.indexOf('/')
80
+ const service = slash === -1 ? '' : entry.slice(0, slash)
81
+ const key = slash === -1 ? '' : entry.slice(slash + 1)
82
+ if (!services.includes(service) || !/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(key)) {
83
+ throw new Error(
84
+ // The entry is not echoed: a value pasted there by mistake would land in a CI log.
85
+ `--plain-variables / FABRIKA_PLATFORM_PLAIN_VARIABLES: entry ${index + 1} is not \`<service>/<KEY>\` with a service of ${services.join(', ')}`,
86
+ )
87
+ }
88
+ allowed.add(plainVariableId(service, key))
89
+ }
90
+ return allowed
91
+ }
@@ -81,16 +81,17 @@ installation already holds.
81
81
 
82
82
  **Variables** — the rest of the configuration, all non-secret.
83
83
 
84
- | Variable | Required | What it is |
85
- | ----------------------------------- | -------- | -------------------------------------------------------------------------------------------------- |
86
- | `FABRIKA_ZEROPS_PROJECT_ID` | yes | The Zerops project holding the four platform runtime services. |
87
- | `FABRIKA_PLATFORM_ENVIRONMENT` | yes | The name this installation calls itself; written to every service as `ENVIRONMENT`. Never `local`. |
88
- | `FABRIKA_PLATFORM_SCHEME` | yes | `https` for anything reachable from a browser. |
89
- | `FABRIKA_PLATFORM_IAM_HOST` | no | Where IAM answers publicly. |
90
- | `FABRIKA_PLATFORM_CONSOLE_HOST` | no | Where the console answers publicly. |
91
- | `FABRIKA_PLATFORM_OPERATIONS_HOST` | no | Where Operations ingest answers publicly. |
92
- | `FABRIKA_ZEROPS_API_URL` | no | Region API base, when this installation is not on the default one. |
93
- | `FABRIKA_PLATFORM_MCP_CLIENTS_JSON` | no | The MCP clients that may author applications (JSON array). Unset leaves MCP authoring off. |
84
+ | Variable | Required | What it is |
85
+ | ----------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------- |
86
+ | `FABRIKA_ZEROPS_PROJECT_ID` | yes | The Zerops project holding the four platform runtime services. |
87
+ | `FABRIKA_PLATFORM_ENVIRONMENT` | yes | The name this installation calls itself; written to every service as `ENVIRONMENT`. Never `local`. |
88
+ | `FABRIKA_PLATFORM_SCHEME` | yes | `https` for anything reachable from a browser. |
89
+ | `FABRIKA_PLATFORM_IAM_HOST` | no | Where IAM answers publicly. |
90
+ | `FABRIKA_PLATFORM_CONSOLE_HOST` | no | Where the console answers publicly. |
91
+ | `FABRIKA_PLATFORM_OPERATIONS_HOST` | no | Where Operations ingest answers publicly. |
92
+ | `FABRIKA_ZEROPS_API_URL` | no | Region API base, when this installation is not on the default one. |
93
+ | `FABRIKA_PLATFORM_MCP_CLIENTS_JSON` | no | The MCP clients that may author applications (JSON array). Unset leaves MCP authoring off. |
94
+ | `FABRIKA_PLATFORM_PLAIN_VARIABLES` | no | Readable service variables checked and found not to be credentials, as `<service>/<KEY>`, comma-separated. |
94
95
 
95
96
  The three host variables go together: **all three, or none.** Naming none derives them from the
96
97
  proxy's generated Zerops subdomains, and the deploy publishes that subdomain. Naming all three makes
@@ -98,8 +99,8 @@ this a custom-domain installation — the domains are bound to the project balan
98
99
  deploy publishes no subdomain, because that would add a second public address nobody asked for.
99
100
 
100
101
  `FABRIKA_PLATFORM_MCP_CLIENTS_JSON` turns on MCP authoring (ADR-0049). A workflow generated before
101
- that variable existed does not forward it, and `platform upgrade` never rewrites the workflow — add
102
- this line to the `env:` of the _Deploy the platform_ step in `.github/workflows/platform.yml`:
102
+ that variable existed does not forward it. `platform upgrade` rewrites such a workflow at its next roll; to forward it
103
+ sooner, add this line to the `env:` of the _Deploy the platform_ step in `.github/workflows/platform.yml`:
103
104
 
104
105
  ```yaml
105
106
  FABRIKA_PLATFORM_MCP_CLIENTS_JSON: ${{ vars.FABRIKA_PLATFORM_MCP_CLIENTS_JSON }}
@@ -152,6 +152,9 @@ jobs:
152
152
  FABRIKA_ZEROPS_API_URL: ${{ vars.FABRIKA_ZEROPS_API_URL }}
153
153
  # MCP authoring (ADR-0049): a JSON array of the MCP clients this installation trusts. Unset = off.
154
154
  FABRIKA_PLATFORM_MCP_CLIENTS_JSON: ${{ vars.FABRIKA_PLATFORM_MCP_CLIENTS_JSON }}
155
+ # The deploy refuses a readable service variable that looks like a credential. Comma-separated
156
+ # `<service>/<KEY>` names the ones checked and found not to be. Unset = none.
157
+ FABRIKA_PLATFORM_PLAIN_VARIABLES: ${{ vars.FABRIKA_PLATFORM_PLAIN_VARIABLES }}
155
158
  run: fabrika platform deploy --provider=zerops --source-dir=. ${{ inputs.dry_run && '--dry-run' || '' }}
156
159
 
157
160
  - name: Summary
@@ -364,7 +364,7 @@ const lightPlatformTopology = (options: TopologyOptions, publicAccess: PublicAcc
364
364
  priority: 30,
365
365
  public: publicAccess === 'zerops-subdomain',
366
366
  // Still the only publicly routed service (ADR-0022). One container is a real availability
367
- // trade and the reason this tier is not for production; it is not a relaxation of the rule
367
+ // trade (the operator guide prices it against `standard`); it is not a relaxation of the rule
368
368
  // about WHICH service faces the internet.
369
369
  minContainers: 1,
370
370
  maxContainers: 2,
package/src/manifest.ts CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  type ZeropsRuntimePackage,
23
23
  } from './execution'
24
24
  import { assertAuthoredManagedDocument, assertAuthoredManagedInputs } from './managed-env'
25
+ import { assertNoAuthoredPlainCredential } from './plain-credentials'
25
26
  import { allowedReferenceHosts, foreignReferenceHost, platformOnlyServiceReference } from './service-references'
26
27
  import type { ZeropsAppConfig, ZeropsNamespaceResourceRequirement, ZeropsProxySpec, ZeropsSharedPostgresBinding } from './types'
27
28
 
@@ -663,7 +664,15 @@ export function compileFabrikaManifest(config: ZeropsAppConfig, env: string, sou
663
664
  },
664
665
  }
665
666
  // The JSON copy is the artifact's own form: authored objects lose inherited fields and undefined keys once, here.
666
- return parseFabrikaManifest(jsonValue(candidate), { appId: config.id, env })
667
+ const manifest = parseFabrikaManifest(jsonValue(candidate), { appId: config.id, env })
668
+ // After the parse, whose refusals are more precise (a Fabrika-managed name), and at build only: a stored manifest is
669
+ // never refused for it when decoded, so an application built by an older release keeps deploying.
670
+ assertNoAuthoredPlainCredential(
671
+ jsonValue(manifest.target.importDocument),
672
+ parseZeropsDescriptor(manifest.target.sourceDescriptor.contents).document,
673
+ config.target.notSecret ?? [],
674
+ )
675
+ return manifest
667
676
  } finally {
668
677
  for (const name of declaredVars) {
669
678
  const value = prior[name]
@@ -0,0 +1,90 @@
1
+ // `fabrika app build` refuses an application configuration that writes a credential where everyone can read it.
2
+ //
3
+ // Every `envVariables` value a Zerops application authors (in any setup of its `zerops.yaml`; the compiled import of
4
+ // `fabrika.config.ts` is checked the same way, though its types offer none today) becomes a READABLE service variable,
5
+ // read by every member of the project, and sits in the repository in clear. A `run.routing.headers` value is sent to every visitor. A credential belongs in `pipeline.secrets`, set with
6
+ // `fabrika control apps secrets put`, which Zerops stores sensitive. The check runs at build only, never when a stored
7
+ // manifest is decoded: an application meets it when it raises its own pin, as with any framework API change.
8
+ //
9
+ // The heuristic errs towards refusing, so `target.notSecret` names the variables and headers the author has checked.
10
+
11
+ import type { JsonValue } from '@fabrika/provider-contract'
12
+ import { plainCredentialFinding } from '@fabrika/provider-contract'
13
+
14
+ /** One authored value that looks like a credential: where it is, and why. Never the value. */
15
+ interface AuthoredPlainCredential {
16
+ readonly path: string
17
+ readonly name: string
18
+ readonly because: string
19
+ readonly header: boolean
20
+ }
21
+
22
+ const isMapping = (value: JsonValue | undefined): value is { readonly [key: string]: JsonValue } =>
23
+ typeof value === 'object' && value !== null && !Array.isArray(value)
24
+
25
+ /** Every `envVariables` entry and every `routing.headers[].values` entry of a document, at any depth. */
26
+ const authoredPlainCredentials = (document: JsonValue, root: string, notSecret: ReadonlySet<string>): AuthoredPlainCredential[] => {
27
+ const found: AuthoredPlainCredential[] = []
28
+ const check = (path: string, name: string, value: JsonValue, header: boolean): void => {
29
+ // A header name is case-insensitive, as HTTP has it; a variable name is exact.
30
+ const listed = header ? [...notSecret].some((entry) => entry.toLowerCase() === name.toLowerCase()) : notSecret.has(name)
31
+ if (typeof value !== 'string' || listed) return
32
+ const finding = plainCredentialFinding(name, value)
33
+ if (finding !== null) found.push({ path, name, because: finding.because, header })
34
+ }
35
+ const visit = (value: JsonValue, path: string): void => {
36
+ if (Array.isArray(value)) {
37
+ value.forEach((item, index) => visit(item, `${path}[${index}]`))
38
+ return
39
+ }
40
+ if (!isMapping(value)) return
41
+ for (const [key, item] of Object.entries(value)) {
42
+ const at = `${path}.${key}`
43
+ if (key === 'envVariables' && isMapping(item)) {
44
+ for (const [name, text] of Object.entries(item)) check(`${at}.${name}`, name, text, false)
45
+ continue
46
+ }
47
+ if (key === 'routing' && isMapping(item) && Array.isArray(item['headers'])) {
48
+ item['headers'].forEach((rule, index) => {
49
+ const values = isMapping(rule) ? rule['values'] : undefined
50
+ if (!isMapping(values)) return
51
+ for (const [name, text] of Object.entries(values)) check(`${at}.headers[${index}].values.${name}`, name, text, true)
52
+ })
53
+ }
54
+ visit(item, at)
55
+ }
56
+ }
57
+ visit(document, root)
58
+ return found
59
+ }
60
+
61
+ /**
62
+ * Refuse every authored plain value that looks like a credential, naming each by its path and reason, never by value.
63
+ *
64
+ * `importDocument` is the compiled import of `fabrika.config.ts`; `descriptor` the parsed `zerops.yaml`, every setup.
65
+ */
66
+ export function assertNoAuthoredPlainCredential(
67
+ importDocument: JsonValue,
68
+ descriptor: JsonValue,
69
+ notSecret: readonly string[],
70
+ ): void {
71
+ const allowed = new Set(notSecret)
72
+ const found = [
73
+ ...authoredPlainCredentials(importDocument, 'fabrika.config.ts', allowed),
74
+ ...authoredPlainCredentials(descriptor, 'zerops.yaml', allowed),
75
+ ]
76
+ if (found.length === 0) return
77
+ const lines = found.map((entry) => ` ${entry.path}: ${entry.because}`)
78
+ const remedies = [
79
+ found.some((entry) => !entry.header)
80
+ ? 'An `envVariables` value is a readable service variable, which every member of the Zerops project can read, and it '
81
+ + 'sits in the repository in clear. Declare a credential in `pipeline.secrets` instead and set it with '
82
+ + '`fabrika control apps secrets put --app=<id> --name=<NAME>` (the value on stdin); Zerops stores it sensitive.'
83
+ : '',
84
+ found.some((entry) => entry.header)
85
+ ? 'A `routing.headers` value is sent to every visitor. A credential has no place there.'
86
+ : '',
87
+ 'A value that is not a credential: list its variable or header name in `target.notSecret` of fabrika.config.ts.',
88
+ ].filter((line) => line !== '')
89
+ throw new Error(['fabrika app build: plain configuration that looks like a credential:', ...lines, ...remedies].join('\n'))
90
+ }
package/src/types.ts CHANGED
@@ -119,6 +119,12 @@ export interface ZeropsSourceTarget {
119
119
  runtimePackages?: ZeropsRuntimePackage[]
120
120
  services: (ctx: ZeropsResourceContext) => ZeropsServiceSpec[]
121
121
  project?: ZeropsProjectSpec
122
+ /**
123
+ * Variable and header names whose plain value is not a credential. `fabrika app build` refuses an `envVariables` or
124
+ * `routing.headers` value that looks like one (its name says `TOKEN`, `PASSWORD`, `SECRET`, a key, or its value reads
125
+ * like a token); a name listed here is stored as written. A real credential goes in `pipeline.secrets`.
126
+ */
127
+ notSecret?: readonly string[]
122
128
  }
123
129
 
124
130
  export interface ZeropsAppConfig extends AppConfigBase {
@@ -30,6 +30,11 @@ export interface PlatformDeployInput {
30
30
  readonly mcpClients?: readonly McpClient[];
31
31
  /** IAM-issued `px_` admin key, used only to reconcile the console's schema. Environment only. */
32
32
  readonly iamAdminKey: string;
33
+ /**
34
+ * Readable service variables, as `<service>/<KEY>`, the operator has checked are not credentials. The deploy refuses
35
+ * every other readable variable that looks like one (`plain-credentials.ts`).
36
+ */
37
+ readonly plainVariables?: ReadonlySet<string>;
33
38
  /** Read everything, write nothing, trigger nothing. */
34
39
  readonly dryRun: boolean;
35
40
  }
@@ -0,0 +1,20 @@
1
+ import type { LiveServiceEnv, PlatformDeployService } from './deploy';
2
+ /** One readable variable that looks like a credential. Names only; the value is never carried. */
3
+ export interface PlainCredentialVariable {
4
+ readonly service: PlatformDeployService;
5
+ readonly key: string;
6
+ readonly because: string;
7
+ }
8
+ /** `<service>/<KEY>`, the form an operator names an exception in. */
9
+ export declare const plainVariableId: (service: string, key: string) => string;
10
+ /**
11
+ * The readable variables of one service that look like credentials.
12
+ *
13
+ * `written` are the keys this deploy writes itself, readable by design and about to be overwritten: they are its own
14
+ * configuration, never a credential. `allowed` are the `<service>/<KEY>` exceptions the operator named.
15
+ */
16
+ export declare const plainCredentialVariables: (service: PlatformDeployService, live: LiveServiceEnv, written: ReadonlySet<string>, allowed: ReadonlySet<string>) => PlainCredentialVariable[];
17
+ /** The refusal: each variable by name and reason, where it belongs instead, and the opt-out. Never a value. */
18
+ export declare const plainCredentialRefusal: (found: readonly PlainCredentialVariable[]) => Error;
19
+ /** Parse the operator's exceptions: comma-separated `<service>/<KEY>`, each naming a platform service. */
20
+ export declare const parsePlainVariables: (raw: string | undefined, services: readonly string[]) => ReadonlySet<string>;
@@ -0,0 +1,7 @@
1
+ import type { JsonValue } from '@fabrika/provider-contract';
2
+ /**
3
+ * Refuse every authored plain value that looks like a credential, naming each by its path and reason, never by value.
4
+ *
5
+ * `importDocument` is the compiled import of `fabrika.config.ts`; `descriptor` the parsed `zerops.yaml`, every setup.
6
+ */
7
+ export declare function assertNoAuthoredPlainCredential(importDocument: JsonValue, descriptor: JsonValue, notSecret: readonly string[]): void;
@@ -88,6 +88,12 @@ export interface ZeropsSourceTarget {
88
88
  runtimePackages?: ZeropsRuntimePackage[];
89
89
  services: (ctx: ZeropsResourceContext) => ZeropsServiceSpec[];
90
90
  project?: ZeropsProjectSpec;
91
+ /**
92
+ * Variable and header names whose plain value is not a credential. `fabrika app build` refuses an `envVariables` or
93
+ * `routing.headers` value that looks like one (its name says `TOKEN`, `PASSWORD`, `SECRET`, a key, or its value reads
94
+ * like a token); a name listed here is stored as written. A real credential goes in `pipeline.secrets`.
95
+ */
96
+ notSecret?: readonly string[];
91
97
  }
92
98
  export interface ZeropsAppConfig extends AppConfigBase {
93
99
  target: ZeropsSourceTarget;