ai-saas-guard 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -187,13 +187,13 @@ The CLI is published on npm as `ai-saas-guard`, and the GitHub Action is availab
187
187
  | Area | Status |
188
188
  | --- | --- |
189
189
  | Public GitHub repository | Available |
190
- | npm CLI | `ai-saas-guard@0.31.0` |
191
- | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.31.0` |
190
+ | npm CLI | `ai-saas-guard@0.32.0` |
191
+ | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.32.0` |
192
192
  | Outputs | Short summary, terminal, JSON, SARIF, and PR-focused markdown |
193
193
  | Project config | `.ai-saas-guard.json` rule toggles, severity overrides, suppressions, and fail thresholds |
194
194
  | Privacy model | Local-first, read-only scan commands, no LLM calls, no code upload |
195
- | Versioned Action tags | `v0.31.0`, `v0` |
196
- | Current release | `0.31.0` adds executable hosted staging evidence: success/failure cleanup probes, log-boundary validation, stricter read-only checkout worker boundaries, and release-gate evaluation from evidence bundles |
195
+ | Versioned Action tags | `v0.32.0`, `v0` |
196
+ | Current release | `0.32.0` adds deployed worker staging evidence: public HTTPS health validation, deployed success/failure cleanup probes, log-boundary checks, and release-gate evaluation for a Node/container read-only checkout worker candidate |
197
197
  | npm publishing | Trusted Publisher/OIDC, no long-lived publish token |
198
198
  | Repository trust hardening | Strict branch protection, Dependabot, CodeQL, fast-check fuzzing, signed release provenance assets, private vulnerability reporting, secret scanning, and push protection |
199
199
  | Cloudflare hosted ingress | Deployed at `https://ai-saas-guard-hosted.zr9959.workers.dev`; signed GitHub App webhook delivery and compact Check Run smoke now pass in staging |
@@ -312,6 +312,8 @@ The hosted staging deployment planner is documented in [docs/hosted-staging-depl
312
312
 
313
313
  The hosted staging harness is documented in [docs/hosted-staging-harness.md](docs/hosted-staging-harness.md). It exports `createFileBackedHostedStagingHarness`, `createHostedStagingHarnessEvidence`, `createHostedStagingReleaseEvidenceBundle`, `evaluateHostedStagingReleaseEvidenceBundle`, and `validateHostedLogBoundary` from `ai-saas-guard/hosted/staging-harness`. It runs signed webhook replay through the provider-independent hosted runtime with local file-backed queue, compact report, and Check Run adapters, verifies worker sandbox cleanup, turns success/failure cleanup probes plus log-boundary samples into release-gate evidence, and evaluates the hosted gate without cloud calls. It is a staging rehearsal tool only; it does not call cloud providers, create a GitHub App, publish live Check Runs, or expose a public hosted service.
314
314
 
315
+ Deployed worker staging evidence is documented in [docs/hosted-deployed-worker-staging.md](docs/hosted-deployed-worker-staging.md). It exports `createHostedDeployedWorkerStagingEvidenceBundle` and `evaluateHostedDeployedWorkerStagingReleaseGate` from `ai-saas-guard/hosted/deployed-staging`. It turns public HTTPS health, signed webhook replay, deployed worker cleanup, log-boundary samples, and external CI/scan/rollback evidence into the hosted release gate for a Node/container read-only checkout worker candidate. It does not deploy cloud resources or claim production hosted exposure.
316
+
315
317
  The first live hosted ingress is deployed on Cloudflare Workers at `https://ai-saas-guard-hosted.zr9959.workers.dev` and documented in [hosted/cloudflare-worker/README.md](hosted/cloudflare-worker/README.md). It exposes `/healthz`, `/github/app/manifest-callback`, and signed `/github/webhook` intake backed by Cloudflare KV. A private staging GitHub App, `ai-saas-guard-hosted`, is installed on `zr9959/ai-saas-guard` with selected-repository access and the first-slice permission contract. The Worker verifies signatures, stores compact pull request identity records, exchanges a scoped installation token, fetches PR file metadata from GitHub, classifies PR-risk hotspots, and publishes a bounded Check Run summary. Current deployed evidence is tracked in [docs/hosted-operations-evidence.md](docs/hosted-operations-evidence.md): health, signed webhook delivery, compact KV records, cleanup, and Check Run publication pass for the staging smoke. The Cloudflare Worker still does not run a full source checkout scan worker or store raw webhook payloads, PR title/body text, raw diffs, source, secrets, checkout paths, or installation tokens.
316
318
 
317
319
  The hosted operational release gate is documented in [docs/hosted-operational-release-gate.md](docs/hosted-operational-release-gate.md). It defines the hosted-specific CI, replay, queue, worker cleanup, privacy, monitoring, rollback, and incident-response evidence required before any hosted environment is exposed to users. The pure gate evaluator exported from `ai-saas-guard/hosted/contracts` blocks hosted exposure unless every P0 evidence item is fresh, a container digest is recorded, and release notes avoid pentest, certification, and full-audit claims.
@@ -320,7 +322,7 @@ Hosted uninstall and data deletion behavior is documented in [docs/hosted-uninst
320
322
 
321
323
  Hosted pricing and packaging boundaries are documented in [docs/hosted-pricing-packaging.md](docs/hosted-pricing-packaging.md). Core local scanning stays useful without an account; hosted plans may add workflow convenience, saved reports, team policy, and optional human review, but they do not gate local CLI scanning.
322
324
 
323
- Hosted pre-implementation pure contracts are documented in [docs/hosted-preimplementation-contracts.md](docs/hosted-preimplementation-contracts.md). They now include a pull request webhook intake planner that verifies signatures before parsing or queueing, a durable scan queue planner that reuses queued, running, and completed jobs for the same trusted scan key, a worker read-only scan planner that fixes the CLI command and requires repository `contents: read`, a concrete Node read-only checkout scan runner, and a Check Run publication planner that requires repository `checks: write` and builds bounded check-only payloads from compact reports. They also cover queue-safe webhook event parsing, bounded check-run summary rendering, idempotent queue cleanup planning, worker checkout cleanup planning, a retention/deletion cleanup planner, an operational release gate evaluator, the production adapter plans needed for GitHub App auth and bounded worker execution, the Node/container app skeleton needed for real provider wiring, the staging deployment planner needed before production GitHub App promotion, and the local staging harness needed to rehearse webhook replay, persistence, publication, and cleanup without cloud calls. The service runtime composes these contracts behind replaceable adapters. PR comments remain a later workflow or paid hosted feature, not part of the hosted MVP contract.
325
+ Hosted pre-implementation pure contracts are documented in [docs/hosted-preimplementation-contracts.md](docs/hosted-preimplementation-contracts.md). They now include a pull request webhook intake planner that verifies signatures before parsing or queueing, a durable scan queue planner that reuses queued, running, and completed jobs for the same trusted scan key, a worker read-only scan planner that fixes the CLI command and requires repository `contents: read`, a concrete Node read-only checkout scan runner, and a Check Run publication planner that requires repository `checks: write` and builds bounded check-only payloads from compact reports. They also cover queue-safe webhook event parsing, bounded check-run summary rendering, idempotent queue cleanup planning, worker checkout cleanup planning, a retention/deletion cleanup planner, an operational release gate evaluator, the production adapter plans needed for GitHub App auth and bounded worker execution, the Node/container app skeleton needed for real provider wiring, the staging deployment planner needed before production GitHub App promotion, the local staging harness needed to rehearse webhook replay, persistence, publication, and cleanup without cloud calls, and the deployed worker staging evidence helper needed to evaluate public HTTPS health, deployed cleanup, and log-boundary evidence without storing raw hosted data. The service runtime composes these contracts behind replaceable adapters. PR comments remain a later workflow or paid hosted feature, not part of the hosted MVP contract.
324
326
 
325
327
  A public hosted compact report schema fixture is available at [examples/hosted-compact-report.json](examples/hosted-compact-report.json). It is synthetic and public-safe: compact evidence only, no raw source, raw diffs, secrets, webhook payload bodies, customer payloads, private URLs, or worker checkout paths.
326
328
 
@@ -360,7 +362,7 @@ Use `suppressions` for narrower false-positive handling when one rule is noisy o
360
362
 
361
363
  ## GitHub Action
362
364
 
363
- The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.31.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
365
+ The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.32.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
364
366
 
365
367
  ```yaml
366
368
  name: ai-saas-guard
@@ -0,0 +1,66 @@
1
+ import { type HostedOperationalReleaseGateDecision, type HostedOperationalReleaseGateEvidence } from "./contracts.js";
2
+ import type { HostedLogBoundaryValidation, HostedStagingHarnessReplayResult, HostedStagingHarnessWorkerTickResult } from "./staging-harness.js";
3
+ export interface HostedDeployedWorkerHealthProbe {
4
+ observedAt: string;
5
+ status: number;
6
+ body: unknown;
7
+ }
8
+ export interface HostedDeployedWorkerStagingEvidenceBundleInput {
9
+ collectedAt: string;
10
+ evidenceBaseUrl: string;
11
+ owner: string;
12
+ publicBaseUrl: string;
13
+ scannerVersion: string;
14
+ healthProbe: HostedDeployedWorkerHealthProbe;
15
+ webhookReplays: HostedStagingHarnessReplayResult[];
16
+ workerTicks: HostedStagingHarnessWorkerTickResult[];
17
+ logBoundary: HostedLogBoundaryValidation;
18
+ externalEvidence: HostedOperationalReleaseGateEvidence[];
19
+ requiredFailureReasons?: string[];
20
+ }
21
+ export interface HostedDeployedWorkerStagingEvidenceBundle {
22
+ readyForReleaseGate: boolean;
23
+ blockedReasons: string[];
24
+ evidence: HostedOperationalReleaseGateEvidence[];
25
+ releaseGateInput: {
26
+ evidence: HostedOperationalReleaseGateEvidence[];
27
+ };
28
+ deployedScenarioSummary: HostedDeployedWorkerStagingScenarioSummary;
29
+ privacy: HostedDeployedWorkerStagingPrivacy;
30
+ }
31
+ export interface HostedDeployedWorkerStagingScenarioSummary {
32
+ publicIngressAccepted: boolean;
33
+ healthAccepted: boolean;
34
+ webhookReplayAccepted: boolean;
35
+ completedWorkerProbe: boolean;
36
+ failureCleanupProbe: boolean;
37
+ observedFailureReasons: string[];
38
+ allWorkerCheckoutsDeleted: boolean;
39
+ checkRunPublished: boolean;
40
+ logBoundaryAccepted: boolean;
41
+ }
42
+ export interface HostedDeployedWorkerStagingReleaseGateInput {
43
+ bundle: HostedDeployedWorkerStagingEvidenceBundle;
44
+ commitSha: string;
45
+ scannerVersion: string;
46
+ deploymentTarget: string;
47
+ evaluatedAt: string;
48
+ releaseNotes: string;
49
+ containerImageDigest: string;
50
+ maxEvidenceAgeDays?: number;
51
+ }
52
+ export interface HostedDeployedWorkerStagingPrivacy {
53
+ includesRawHealthResponse: false;
54
+ includesPublicBaseUrl: false;
55
+ includesRawWebhookPayload: false;
56
+ includesUntrustedPrText: false;
57
+ includesRawSource: false;
58
+ includesRawDiffs: false;
59
+ includesSecrets: false;
60
+ includesCustomerPayloads: false;
61
+ includesPrivateCheckoutPath: false;
62
+ includesInstallationToken: false;
63
+ claimsProductionHostedService: false;
64
+ }
65
+ export declare function createHostedDeployedWorkerStagingEvidenceBundle(input: HostedDeployedWorkerStagingEvidenceBundleInput): HostedDeployedWorkerStagingEvidenceBundle;
66
+ export declare function evaluateHostedDeployedWorkerStagingReleaseGate(input: HostedDeployedWorkerStagingReleaseGateInput): HostedOperationalReleaseGateDecision;
@@ -0,0 +1,267 @@
1
+ import { evaluateHostedOperationalReleaseGate, HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS } from "./contracts.js";
2
+ import { HOSTED_NODE_CONTAINER_PLATFORM, HOSTED_NODE_CONTAINER_ROLES } from "./app.js";
3
+ export function createHostedDeployedWorkerStagingEvidenceBundle(input) {
4
+ const summary = deployedScenarioSummary(input);
5
+ const blockedReasons = deployedBlockedReasons(input, summary);
6
+ const externalEvidence = new Map(input.externalEvidence.map((evidence) => [evidence.id, sanitizeEvidence(evidence, input)]));
7
+ const evidence = HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS.map((requirement) => {
8
+ const generated = generatedEvidenceFor(requirement.id, input, summary, blockedReasons);
9
+ return generated ?? externalEvidence.get(requirement.id) ?? missingEvidence(requirement.id, input);
10
+ });
11
+ const readyForReleaseGate = blockedReasons.length === 0 && evidence.every((item) => item.status === "passed");
12
+ return {
13
+ readyForReleaseGate,
14
+ blockedReasons,
15
+ evidence,
16
+ releaseGateInput: { evidence },
17
+ deployedScenarioSummary: summary,
18
+ privacy: deployedPrivacy()
19
+ };
20
+ }
21
+ export function evaluateHostedDeployedWorkerStagingReleaseGate(input) {
22
+ return evaluateHostedOperationalReleaseGate({
23
+ commitSha: input.commitSha,
24
+ scannerVersion: input.scannerVersion,
25
+ deploymentTarget: input.deploymentTarget,
26
+ evaluatedAt: input.evaluatedAt,
27
+ evidence: input.bundle.evidence,
28
+ releaseNotes: input.releaseNotes,
29
+ containerImageDigest: input.containerImageDigest,
30
+ maxEvidenceAgeDays: input.maxEvidenceAgeDays
31
+ });
32
+ }
33
+ function deployedScenarioSummary(input) {
34
+ const processedWorkers = input.workerTicks.filter((tick) => tick.processed);
35
+ const completedWorkers = processedWorkers.filter((tick) => tick.status === "completed");
36
+ const observedFailureReasons = [
37
+ ...new Set(processedWorkers.flatMap((tick) => tick.status === "failed" && tick.cleanupVerified && tick.safeFailureReason
38
+ ? [tick.safeFailureReason]
39
+ : []))
40
+ ].sort();
41
+ const requiredFailureReasons = input.requiredFailureReasons ?? [];
42
+ const failureCleanupProbe = requiredFailureReasons.length
43
+ ? requiredFailureReasons.every((reason) => observedFailureReasons.includes(reason))
44
+ : processedWorkers.some((tick) => tick.status === "failed" && tick.cleanupVerified);
45
+ const allWorkerCheckoutsDeleted = processedWorkers.length > 0 &&
46
+ processedWorkers.every((tick) => tick.workerSandboxDeleted &&
47
+ tick.activeWorkerSandboxCount === 0 &&
48
+ tick.cleanupVerified);
49
+ return {
50
+ publicIngressAccepted: isSafePublicHttpsUrl(input.publicBaseUrl),
51
+ healthAccepted: healthProbeAccepted(input),
52
+ webhookReplayAccepted: input.webhookReplays.some((replay) => replay.accepted && replay.queuedWorker && replay.shouldCreateCheckRun),
53
+ completedWorkerProbe: completedWorkers.some((tick) => tick.checkRunPublished && tick.compactReportStored),
54
+ failureCleanupProbe,
55
+ observedFailureReasons,
56
+ allWorkerCheckoutsDeleted,
57
+ checkRunPublished: completedWorkers.some((tick) => tick.checkRunPublished),
58
+ logBoundaryAccepted: input.logBoundary.sampleCount > 0 && input.logBoundary.accepted
59
+ };
60
+ }
61
+ function deployedBlockedReasons(input, summary) {
62
+ const reasons = [];
63
+ const health = healthBody(input.healthProbe.body);
64
+ if (!summary.publicIngressAccepted)
65
+ reasons.push("invalid_public_base_url");
66
+ if (!isSafePublicHttpsUrl(input.evidenceBaseUrl))
67
+ reasons.push("unsafe_evidence_base_url");
68
+ if (input.healthProbe.status !== 200)
69
+ reasons.push("health_status_unhealthy");
70
+ if (health.ok !== true)
71
+ reasons.push("health_not_ok");
72
+ if (health.platform !== HOSTED_NODE_CONTAINER_PLATFORM)
73
+ reasons.push("health_platform_mismatch");
74
+ if (health.scannerVersion !== input.scannerVersion) {
75
+ reasons.push("health_scanner_version_mismatch");
76
+ }
77
+ if (!health.roles.includes("webhook-ingress"))
78
+ reasons.push("health_missing_webhook_role");
79
+ if (!health.roles.includes("scan-worker"))
80
+ reasons.push("health_missing_scan_worker_role");
81
+ if (!privacyFlagsAreSafe(health.privacy))
82
+ reasons.push("health_privacy_flags_unsafe");
83
+ if (!summary.webhookReplayAccepted)
84
+ reasons.push("webhook_replay_missing");
85
+ if (!summary.completedWorkerProbe)
86
+ reasons.push("worker_success_probe_missing");
87
+ if (!summary.failureCleanupProbe)
88
+ reasons.push("worker_failure_cleanup_probe_missing");
89
+ if (!summary.allWorkerCheckoutsDeleted)
90
+ reasons.push("worker_cleanup_not_verified");
91
+ if (!summary.checkRunPublished)
92
+ reasons.push("check_run_not_published");
93
+ if (!summary.logBoundaryAccepted)
94
+ reasons.push("log_boundary_rejected");
95
+ return reasons;
96
+ }
97
+ function generatedEvidenceFor(id, input, summary, blockedReasons) {
98
+ if (blockedReasons.length > 0) {
99
+ return undefined;
100
+ }
101
+ if (id === "webhook_replay") {
102
+ return summary.publicIngressAccepted && summary.healthAccepted && summary.webhookReplayAccepted
103
+ ? passedEvidence(id, "Deployed staging ingress accepted a signed webhook and queued check-run-only work.", input)
104
+ : missingEvidence(id, input);
105
+ }
106
+ if (id === "queue_worker_cleanup") {
107
+ return summary.completedWorkerProbe &&
108
+ summary.failureCleanupProbe &&
109
+ summary.allWorkerCheckoutsDeleted
110
+ ? passedEvidence(id, "Deployed staging worker success and failure probes published compact checks and deleted worker checkouts.", input)
111
+ : missingEvidence(id, input);
112
+ }
113
+ if (id === "privacy_retention") {
114
+ return summary.logBoundaryAccepted && privacyFlagsAreSafe(input.logBoundary.privacy)
115
+ ? passedEvidence(id, "Deployed staging log samples stayed within the safe metadata boundary and avoided raw payloads.", input)
116
+ : missingEvidence(id, input);
117
+ }
118
+ if (id === "release_cleanup") {
119
+ return summary.allWorkerCheckoutsDeleted
120
+ ? passedEvidence(id, "Deployed staging release cleanup left no active worker checkout entries.", input)
121
+ : missingEvidence(id, input);
122
+ }
123
+ return undefined;
124
+ }
125
+ function healthProbeAccepted(input) {
126
+ const health = healthBody(input.healthProbe.body);
127
+ return (input.healthProbe.status === 200 &&
128
+ health.ok === true &&
129
+ health.platform === HOSTED_NODE_CONTAINER_PLATFORM &&
130
+ HOSTED_NODE_CONTAINER_ROLES.every((role) => health.roles.includes(role)) &&
131
+ health.scannerVersion === input.scannerVersion &&
132
+ privacyFlagsAreSafe(health.privacy));
133
+ }
134
+ function sanitizeEvidence(evidence, input) {
135
+ return {
136
+ id: evidence.id,
137
+ status: evidence.status,
138
+ ...(evidence.collectedAt === undefined
139
+ ? { collectedAt: input.collectedAt }
140
+ : { collectedAt: evidence.collectedAt }),
141
+ ...(safeEvidenceUrl(evidence.evidenceUrl) === undefined
142
+ ? {}
143
+ : { evidenceUrl: safeEvidenceUrl(evidence.evidenceUrl) }),
144
+ note: `External deployed-staging release-gate evidence recorded for ${evidence.id}.`,
145
+ ...(evidence.owner === undefined ? { owner: input.owner } : { owner: evidence.owner })
146
+ };
147
+ }
148
+ function passedEvidence(id, note, input) {
149
+ return {
150
+ id,
151
+ status: "passed",
152
+ collectedAt: input.collectedAt,
153
+ ...(evidenceUrlFor(input, id) === undefined ? {} : { evidenceUrl: evidenceUrlFor(input, id) }),
154
+ note,
155
+ owner: input.owner
156
+ };
157
+ }
158
+ function missingEvidence(id, input) {
159
+ return {
160
+ id,
161
+ status: "missing",
162
+ collectedAt: input.collectedAt,
163
+ note: `Missing deployed staging worker evidence for ${id}.`,
164
+ owner: input.owner
165
+ };
166
+ }
167
+ function evidenceUrlFor(input, id) {
168
+ const baseUrl = safeEvidenceUrl(input.evidenceBaseUrl);
169
+ return baseUrl === undefined ? undefined : `${baseUrl}/${id}.json`;
170
+ }
171
+ function safeEvidenceUrl(value) {
172
+ if (!value || !isSafePublicHttpsUrl(value)) {
173
+ return undefined;
174
+ }
175
+ return trimTrailingSlashes(value.trim());
176
+ }
177
+ function healthBody(value) {
178
+ if (!isRecord(value)) {
179
+ return {
180
+ ok: undefined,
181
+ platform: undefined,
182
+ roles: [],
183
+ scannerVersion: undefined,
184
+ privacy: undefined
185
+ };
186
+ }
187
+ const roles = Array.isArray(value.roles)
188
+ ? value.roles.filter((role) => typeof role === "string")
189
+ : [];
190
+ return {
191
+ ok: typeof value.ok === "boolean" ? value.ok : undefined,
192
+ platform: typeof value.platform === "string" ? value.platform : undefined,
193
+ roles,
194
+ scannerVersion: typeof value.scannerVersion === "string" ? value.scannerVersion : undefined,
195
+ privacy: isRecord(value.privacy) ? value.privacy : undefined
196
+ };
197
+ }
198
+ function privacyFlagsAreSafe(value) {
199
+ return isRecord(value) && Object.values(value).every((flag) => flag === false);
200
+ }
201
+ function isSafePublicHttpsUrl(value) {
202
+ try {
203
+ const url = new URL(value.trim());
204
+ return (url.protocol === "https:" &&
205
+ !url.username &&
206
+ !url.password &&
207
+ !url.search &&
208
+ !url.hash &&
209
+ !isUnsafeHostedHostname(url.hostname));
210
+ }
211
+ catch {
212
+ return false;
213
+ }
214
+ }
215
+ function isUnsafeHostedHostname(hostname) {
216
+ const normalized = hostname.toLowerCase().replace(/\.$/, "");
217
+ return (normalized === "localhost" ||
218
+ normalized.endsWith(".localhost") ||
219
+ isUnsafeIpv4Hostname(normalized) ||
220
+ normalized === "::1" ||
221
+ normalized.startsWith("fc") ||
222
+ normalized.startsWith("fd") ||
223
+ normalized.startsWith("fe80:"));
224
+ }
225
+ function isUnsafeIpv4Hostname(hostname) {
226
+ const parts = hostname.split(".");
227
+ if (parts.length !== 4 || !parts.every((part) => /^\d+$/.test(part)))
228
+ return false;
229
+ const octets = parts.map((part) => Number(part));
230
+ if (octets.some((octet) => !Number.isInteger(octet) || octet < 0 || octet > 255)) {
231
+ return false;
232
+ }
233
+ const [first, second] = octets;
234
+ return (first === 0 ||
235
+ first === 10 ||
236
+ first === 127 ||
237
+ (first === 169 && second === 254) ||
238
+ (first === 172 && second >= 16 && second <= 31) ||
239
+ (first === 192 && second === 168) ||
240
+ (first === 100 && second >= 64 && second <= 127) ||
241
+ first >= 224);
242
+ }
243
+ function trimTrailingSlashes(value) {
244
+ let end = value.length;
245
+ while (end > 0 && value[end - 1] === "/") {
246
+ end -= 1;
247
+ }
248
+ return value.slice(0, end);
249
+ }
250
+ function isRecord(value) {
251
+ return typeof value === "object" && value !== null && !Array.isArray(value);
252
+ }
253
+ function deployedPrivacy() {
254
+ return {
255
+ includesRawHealthResponse: false,
256
+ includesPublicBaseUrl: false,
257
+ includesRawWebhookPayload: false,
258
+ includesUntrustedPrText: false,
259
+ includesRawSource: false,
260
+ includesRawDiffs: false,
261
+ includesSecrets: false,
262
+ includesCustomerPayloads: false,
263
+ includesPrivateCheckoutPath: false,
264
+ includesInstallationToken: false,
265
+ claimsProductionHostedService: false
266
+ };
267
+ }
@@ -169,18 +169,18 @@ node dist/cli.js scan --root /path/to/your-saas
169
169
 
170
170
  这个仓库是公开 GitHub 仓库。
171
171
 
172
- CLI 已发布到 npm:`ai-saas-guard@0.31.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.31.0`。
172
+ CLI 已发布到 npm:`ai-saas-guard@0.32.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.32.0`。
173
173
 
174
174
  | 模块 | 状态 |
175
175
  | --- | --- |
176
176
  | 公开 GitHub 仓库 | 已可用 |
177
- | npm CLI | `ai-saas-guard@0.31.0` |
178
- | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.31.0` |
177
+ | npm CLI | `ai-saas-guard@0.32.0` |
178
+ | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.32.0` |
179
179
  | 输出格式 | 短 summary、Terminal、JSON、SARIF 和 PR markdown |
180
180
  | 项目配置 | `.ai-saas-guard.json` 支持规则开关、severity 覆盖、suppressions 和 fail threshold |
181
181
  | 隐私模型 | 本地优先、只读扫描、不调用 LLM、不上传代码 |
182
- | 当前版本 | `0.31.0` 增加可执行 hosted staging evidence:成功/失败 cleanup probes、log-boundary validation、更严格的 read-only checkout worker 边界,以及从 evidence bundle 直接评估 release gate |
183
- | Action 标签 | `v0.31.0`、`v0` |
182
+ | 当前版本 | `0.32.0` 增加 deployed worker staging evidence:public HTTPS health validation、deployed 成功/失败 cleanup probes、log-boundary checks,以及针对 Node/container read-only checkout worker candidate release-gate evaluation |
183
+ | Action 标签 | `v0.32.0`、`v0` |
184
184
  | npm 发布 | GitHub Actions Trusted Publisher/OIDC,无需长期 npm token |
185
185
  | 仓库可信度加固 | 严格 branch protection、Dependabot、CodeQL、fast-check fuzzing、signed release provenance assets、private vulnerability reporting、secret scanning 和 push protection |
186
186
  | Cloudflare hosted ingress | 已部署到 `https://ai-saas-guard-hosted.zr9959.workers.dev`;签名 GitHub App webhook delivery 和 compact Check Run staging smoke 已通过 |
@@ -349,6 +349,7 @@ GitHub Marketplace wrapper 决策见 [docs/github-marketplace-wrapper-decision.m
349
349
  - [docs/hosted-node-container-app.md](hosted-node-container-app.md)
350
350
  - [docs/hosted-staging-deployment.md](hosted-staging-deployment.md)
351
351
  - [docs/hosted-staging-harness.md](hosted-staging-harness.md)
352
+ - [docs/hosted-deployed-worker-staging.md](hosted-deployed-worker-staging.md)
352
353
  - [docs/hosted-operational-release-gate.md](hosted-operational-release-gate.md)
353
354
  - [docs/hosted-uninstall-data-deletion.md](hosted-uninstall-data-deletion.md)
354
355
  - [docs/hosted-pricing-packaging.md](hosted-pricing-packaging.md)
@@ -366,6 +367,7 @@ GitHub Marketplace wrapper 决策见 [docs/github-marketplace-wrapper-decision.m
366
367
  - Hosted Node/container app skeleton:`ai-saas-guard/hosted/app` 导出 `createHostedHttpApp`、`createInMemoryHostedAppPlatform`、`createHostedNodeCheckoutAppPlatform` 和 `planHostedNodeContainerDeployment`,提供安全 `/healthz`、签名 `/github/webhook` ingress、单 job worker tick、测试用 in-memory provider adapters、真实 read-only checkout worker 组合入口、可见 timeout/output 安全预算,以及 secret manager、queue、compact report store、worker sandbox、GitHub Checks publisher 的部署引用校验;它本身仍然不部署或暴露公开 hosted 服务
367
368
  - Hosted staging deployment planner:`ai-saas-guard/hosted/staging` 导出 `planHostedProviderBinding`、`planHostedStagingDeployment` 和 `planHostedGitHubAppPromotion`,把真实 provider 引用、Node/container deployment plan、hosted operational release-gate evidence 和 GitHub App deployment planning 组合起来;缺少 queue、store、worker sandbox、Check Run publisher、logs、metrics、rollback 或 incident-response 引用时,会阻止 staging exposure 和 production promotion;它本身仍然不会调用云平台、创建 GitHub App 或暴露公开 hosted 服务
368
369
  - Hosted staging harness:`ai-saas-guard/hosted/staging-harness` 导出 `createFileBackedHostedStagingHarness`、`createHostedStagingHarnessEvidence`、`createHostedStagingReleaseEvidenceBundle`、`evaluateHostedStagingReleaseEvidenceBundle` 和 `validateHostedLogBoundary`,可以在本地用 file-backed queue、compact report、Check Run request 和 worker sandbox 跑通签名 webhook replay、worker tick 和 cleanup 校验,把 success/failure cleanup probes 与 log-boundary samples 转成 release-gate evidence,并直接执行 hosted release gate 判断;它只是 staging 演练工具,不会调用云平台、创建 GitHub App、写真实 Check Run 或暴露公开 hosted 服务
370
+ - Deployed worker staging evidence:`ai-saas-guard/hosted/deployed-staging` 导出 `createHostedDeployedWorkerStagingEvidenceBundle` 和 `evaluateHostedDeployedWorkerStagingReleaseGate`,把 public HTTPS health、signed webhook replay、deployed worker cleanup、log-boundary samples 以及外部 CI/scan/rollback evidence 转成 hosted release gate evidence;它不会部署云资源,也不会宣称 production hosted exposure
369
371
  - Cloudflare hosted ingress:`hosted/cloudflare-worker` 已部署到 `https://ai-saas-guard-hosted.zr9959.workers.dev`,提供 `/healthz`、`/github/app/manifest-callback` 和签名 `/github/webhook` intake;Worker 已具备 compact pull request identity、file/category risk signal 和 Check Run metadata 路径;staging GitHub App ID 为 `3834787`,installation ID 为 `135085075`;真实 GitHub App webhook delivery 和 Check Run smoke 已通过;完整 source checkout worker deployment、monitoring、rollback 和 incident-response evidence 仍需要通过 hosted operational release gate
370
372
  - webhook event parser
371
373
  - check-run summary renderer
@@ -0,0 +1,72 @@
1
+ # Hosted Deployed Worker Staging Evidence
2
+
3
+ This document describes the deployed worker staging evidence helper implemented in `src/hosted/deployed-staging.ts`.
4
+
5
+ The package exports `ai-saas-guard/hosted/deployed-staging` with:
6
+
7
+ - `createHostedDeployedWorkerStagingEvidenceBundle`
8
+ - `evaluateHostedDeployedWorkerStagingReleaseGate`
9
+
10
+ The helper is for a deployed Node/container read-only checkout worker release candidate. It turns safe deployment observations into the same hosted operational release-gate evidence used by the rest of the hosted planning layer.
11
+
12
+ It does not deploy cloud resources, create a GitHub App, call GitHub, fetch repositories, upload source code, or publish Check Runs by itself. It is not production hosted exposure. It records whether a deployed staging candidate has enough public-safe evidence to pass the hosted release gate.
13
+
14
+ ## Inputs
15
+
16
+ `createHostedDeployedWorkerStagingEvidenceBundle` expects only bounded evidence:
17
+
18
+ - public HTTPS health probe metadata from the deployed Node/container app
19
+ - signed webhook replay summaries
20
+ - deployed worker success and failure cleanup summaries
21
+ - log-boundary validation output
22
+ - external evidence for CI, workflow static checks, dependency/container scans, monitoring, rollback, and incident response
23
+ - scanner version, collected timestamp, evidence URL base, and evidence owner
24
+
25
+ The public HTTPS health probe must show:
26
+
27
+ - HTTP `200`
28
+ - `ok: true`
29
+ - `platform: "node_container"`
30
+ - both `webhook-ingress` and `scan-worker` roles
31
+ - a scanner version matching the release candidate
32
+ - privacy flags set to false for raw webhook payloads, PR text, source, diffs, secrets, customer payloads, checkout paths, and installation tokens
33
+
34
+ The helper requires a public HTTPS URL for both the deployed ingress and the evidence base. Localhost, private IPs, link-local addresses, non-HTTPS URLs, file URLs, URL credentials, query strings, and fragments are rejected for deployed staging evidence.
35
+
36
+ ## Generated Evidence
37
+
38
+ The bundle generates deployed evidence for these hosted gate IDs when the probes are complete:
39
+
40
+ - `webhook_replay`: deployed staging ingress accepted a signed webhook and queued check-run-only work
41
+ - `queue_worker_cleanup`: deployed worker success and failure probes completed and deleted worker checkouts
42
+ - `privacy_retention`: deployed log samples stayed within the safe metadata boundary
43
+ - `release_cleanup`: no deployed worker checkout entries remained active after release probes
44
+
45
+ Other gate IDs still come from external evidence because they belong to CI, workflow analysis, dependency/container scan, monitoring, rollback, and incident-response systems.
46
+
47
+ ## Blocking Behavior
48
+
49
+ The helper blocks release-gate readiness when deployed evidence is incomplete. Common blocked reasons include:
50
+
51
+ - `invalid_public_base_url`
52
+ - `unsafe_evidence_base_url`
53
+ - `health_scanner_version_mismatch`
54
+ - `health_missing_scan_worker_role`
55
+ - `health_privacy_flags_unsafe`
56
+ - `worker_failure_cleanup_probe_missing`
57
+ - `worker_cleanup_not_verified`
58
+ - `log_boundary_rejected`
59
+
60
+ Blocked output remains public-safe. It does not return the raw health body, public base URL, raw webhook payload, untrusted PR text, raw source, raw diffs, secrets, customer payloads, private checkout paths, or installation tokens.
61
+
62
+ ## Release Gate
63
+
64
+ `evaluateHostedDeployedWorkerStagingReleaseGate` passes the generated bundle to the hosted operational release gate with the release commit, scanner version, deployment target, container digest, and release notes.
65
+
66
+ The evaluator still blocks hosted exposure unless every P0 evidence row is fresh, the deployed artifact has a `sha256:<digest>` container image digest, and release notes avoid positive pentest, certification, and full-audit claims. Wording such as "not a pentest, certification, or full security audit" remains allowed.
67
+
68
+ ## Boundary
69
+
70
+ This helper narrows the gap between local source-candidate rehearsals and deployed staging evidence. It is still deterministic and local-first: callers collect evidence outside the package and pass only safe summaries into the helper.
71
+
72
+ It is not a pentest, full audit, or certification. It is not production hosted exposure. It does not prove customer SaaS apps are secure. It only helps decide whether the hosted worker release candidate has enough operational evidence to be exposed for the next staged rollout step.
@@ -40,7 +40,11 @@ Every hosted release must record:
40
40
 
41
41
  The current public package release is still a local CLI and pure hosted-contract release. No hosted production environment is exposed by this release.
42
42
 
43
- The pure evaluator `evaluateHostedOperationalReleaseGate` and the exported `HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS` list make the gate machine-checkable for the next hosted service stage. The staging harness also exports `createHostedStagingReleaseEvidenceBundle`, `evaluateHostedStagingReleaseEvidenceBundle`, and `validateHostedLogBoundary` so source-candidate rehearsals can turn webhook replay, success/failure cleanup probes, required safe failure reasons, and log samples into an executable gate decision. The evaluator blocks hosted exposure unless every P0 item has fresh evidence, a `sha256:<digest>` container image digest is recorded, and release notes avoid positive pentest, certification, and full-audit claims. Explicit wording such as "not a pentest, certification, or full security audit" remains allowed.
43
+ The pure evaluator `evaluateHostedOperationalReleaseGate` and the exported `HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS` list make the gate machine-checkable for the next hosted service stage. The staging harness also exports `createHostedStagingReleaseEvidenceBundle`, `evaluateHostedStagingReleaseEvidenceBundle`, and `validateHostedLogBoundary` so source-candidate rehearsals can turn webhook replay, success/failure cleanup probes, required safe failure reasons, and log samples into an executable gate decision.
44
+
45
+ Deployed worker staging evidence is documented in [hosted-deployed-worker-staging.md](hosted-deployed-worker-staging.md). The `ai-saas-guard/hosted/deployed-staging` export adds `createHostedDeployedWorkerStagingEvidenceBundle` and `evaluateHostedDeployedWorkerStagingReleaseGate` so a deployed Node/container read-only checkout worker candidate can turn public HTTPS health, signed webhook replay, deployed success/failure cleanup probes, log-boundary samples, and external CI/scan/rollback evidence into this same gate. It does not deploy cloud resources and is not production hosted exposure.
46
+
47
+ The evaluator blocks hosted exposure unless every P0 item has fresh evidence, a `sha256:<digest>` container image digest is recorded, and release notes avoid positive pentest, certification, and full-audit claims. Explicit wording such as "not a pentest, certification, or full security audit" remains allowed.
44
48
 
45
49
  Source-level evidence notes for this release candidate:
46
50
 
@@ -48,12 +52,12 @@ Source-level evidence notes for this release candidate:
48
52
  | --- | --- | --- | --- |
49
53
  | `clean_ci` | Clean install, tests, build, CLI help, JSON/SARIF scan, PR-risk, npm audit, pack dry-run | Local release gate plus GitHub Actions CI run from the release commit | Passed for source package |
50
54
  | `hosted_contract_tests` | Hosted contract tests for webhook, scope, queue, worker, check summaries, cleanup, retention, and release gate evaluation | `tests/hosted-contracts.test.mjs` | Passed for pure contracts |
51
- | `webhook_replay` | Valid events queue work; invalid, missing, malformed, replayed, removed, and non-installed events queue nothing | Pure replay coverage in hosted webhook intake tests | Passed for pure contracts; must replay against deployed ingress before exposure |
55
+ | `webhook_replay` | Valid events queue work; invalid, missing, malformed, replayed, removed, and non-installed events queue nothing | Pure replay coverage in hosted webhook intake tests plus deployed worker staging evidence helper | Passed for pure contracts; deployed helper can record public HTTPS staging replay before exposure |
52
56
  | `workflow_static_checks` | GitHub Actions static analysis | `actionlint` and `uvx zizmor --offline .github/workflows` | Passed for repository workflows |
53
57
  | `dependency_scan` | Dependency scan has no unresolved high or critical production findings | `npm audit --audit-level=high --registry=https://registry.npmjs.org` | Passed for source package |
54
58
  | `container_scan` | Container image scan has no unresolved high or critical runtime-layer findings | No hosted container image exists in the public package release | Not applicable to current non-hosted release; required before hosted exposure |
55
- | `queue_worker_cleanup` | Queue dedupe, running cancellation, terminal cleanup, worker checkout deletion, and no long-running processes | Pure queue, worker, checkout, retention cleanup planner tests, and staging harness success/failure cleanup probes | Passed for source candidate; must verify against deployed queue and worker before exposure |
56
- | `privacy_retention` | No raw source, raw diffs, secrets, customer payloads, private URLs, or full file contents; retention and uninstall cleanup are proven | Compact report, Check Run publication, retention/deletion cleanup, docs tests, and `validateHostedLogBoundary` source-candidate log checks | Passed for source candidate; deployed log sampling still required before exposure |
59
+ | `queue_worker_cleanup` | Queue dedupe, running cancellation, terminal cleanup, worker checkout deletion, and no long-running processes | Pure queue, worker, checkout, retention cleanup planner tests, staging harness success/failure cleanup probes, and deployed worker staging cleanup evidence helper | Passed for source candidate; deployed helper can record success/failure cleanup before exposure |
60
+ | `privacy_retention` | No raw source, raw diffs, secrets, customer payloads, private URLs, or full file contents; retention and uninstall cleanup are proven | Compact report, Check Run publication, retention/deletion cleanup, docs tests, `validateHostedLogBoundary` source-candidate log checks, and deployed log-boundary staging evidence | Passed for source candidate; deployed log sampling still required before exposure |
57
61
  | `monitoring_alerting` | Ingress, queue depth, worker failures, Check Run failures, cleanup failures, retention failures, and credential rotation alerts | Required alert list remains in this document | Documented; must attach provider evidence before exposure |
58
62
  | `manual_rollback` | Worker pause, previous artifact redeploy, queue resume, controlled ingress failure, and affected Check Run identification | Manual rollback procedure remains in this document | Documented; must execute against deployed artifact before exposure |
59
63
  | `incident_response` | Owner, backup, credential rotation, queue pause, customer communication, status path, and privacy-safe evidence collection | Incident response checklist remains in this document | Documented; must name live owners before exposure |
@@ -31,6 +31,8 @@ The hosted release gate still requires fresh deployed evidence for:
31
31
 
32
32
  Source-candidate executable evidence now exists in `ai-saas-guard/hosted/staging-harness`: `createHostedStagingReleaseEvidenceBundle` combines signed webhook replay, success and failure cleanup probes, safe worker failure reasons, and `validateHostedLogBoundary` samples into hosted release-gate evidence, then `evaluateHostedStagingReleaseEvidenceBundle` runs the same gate evaluator used by deployment planning. This improves local release readiness, but it is still not production hosted exposure and does not replace deployed worker, logging, metrics, rollback, incident-response, dependency, or container evidence.
33
33
 
34
+ Deployed worker staging evidence now has its own helper in `ai-saas-guard/hosted/deployed-staging`: `createHostedDeployedWorkerStagingEvidenceBundle` accepts public HTTPS health, deployed webhook replay, worker cleanup, log-boundary, and external CI/scan/rollback evidence summaries, then `evaluateHostedDeployedWorkerStagingReleaseGate` evaluates the same hosted release gate. Use [hosted-deployed-worker-staging.md](hosted-deployed-worker-staging.md) before exposing a Node/container read-only checkout worker beyond staging.
35
+
34
36
  ## Read-Only Checkout Worker Evidence Checklist
35
37
 
36
38
  Before any hosted source checkout worker is exposed beyond staging, attach fresh evidence for each row below. The current Cloudflare ingress evidence above does not satisfy these rows because it publishes compact PR-risk signals without running a full source checkout scan worker.
@@ -2,7 +2,7 @@
2
2
 
3
3
  This document collects pure hosted contracts that can be tested before any hosted GitHub App service is deployed. These contracts keep the hosted design inspectable, local-first, and implementation-ready without adding network calls, credentials, queues, workers, or GitHub API writes. They are no network calls contracts by design.
4
4
 
5
- The helpers live in `src/hosted/contracts.ts` and are exported from `ai-saas-guard/hosted/contracts`. The production adapter plans live in `src/hosted/production-adapters.ts` and are exported from `ai-saas-guard/hosted/production-adapters`. The Node/container app skeleton lives in `src/hosted/app.ts` and is exported from `ai-saas-guard/hosted/app`. The concrete read-only checkout worker runner lives in `src/hosted/worker.ts` and is exported from `ai-saas-guard/hosted/worker`. The staging deployment planner lives in `src/hosted/staging.ts` and is exported from `ai-saas-guard/hosted/staging`. The local staging harness lives in `src/hosted/staging-harness.ts` and is exported from `ai-saas-guard/hosted/staging-harness`.
5
+ The helpers live in `src/hosted/contracts.ts` and are exported from `ai-saas-guard/hosted/contracts`. The production adapter plans live in `src/hosted/production-adapters.ts` and are exported from `ai-saas-guard/hosted/production-adapters`. The Node/container app skeleton lives in `src/hosted/app.ts` and is exported from `ai-saas-guard/hosted/app`. The concrete read-only checkout worker runner lives in `src/hosted/worker.ts` and is exported from `ai-saas-guard/hosted/worker`. The staging deployment planner lives in `src/hosted/staging.ts` and is exported from `ai-saas-guard/hosted/staging`. The local staging harness lives in `src/hosted/staging-harness.ts` and is exported from `ai-saas-guard/hosted/staging-harness`. The deployed worker staging evidence helper lives in `src/hosted/deployed-staging.ts` and is exported from `ai-saas-guard/hosted/deployed-staging`.
6
6
 
7
7
  ## Pull Request Webhook Intake Planner
8
8
 
@@ -5,11 +5,11 @@
5
5
  ## Current State
6
6
 
7
7
  - Package name: `ai-saas-guard`
8
- - Current published version: `0.31.0`
8
+ - Current published version: `0.32.0`
9
9
  - Next source candidate: none
10
10
  - npm registry state: published at <https://www.npmjs.com/package/ai-saas-guard>
11
11
  - First npm-published version: `0.1.1`
12
- - GitHub Release: `v0.31.0`
12
+ - GitHub Release: `v0.32.0`
13
13
  - Publish workflow: `.github/workflows/npm-publish.yml`
14
14
  - Trusted Publisher: GitHub Actions, `zr9959/ai-saas-guard`, workflow `npm-publish.yml`, allowed action `npm publish`
15
15
  - Long-lived npm publish token: not required
@@ -18,7 +18,7 @@
18
18
 
19
19
  Use GitHub Actions with npm Trusted Publisher/OIDC:
20
20
 
21
- 1. Create and review a release tag such as `v0.31.0`.
21
+ 1. Create and review a release tag such as `v0.32.0`.
22
22
  2. Publish from the GitHub Release or run the `Publish npm` workflow manually with `ref` set to that tag.
23
23
  3. Keep `permissions.id-token: write` in the workflow so npm can exchange the GitHub Actions OIDC identity for a short-lived publish credential.
24
24
  4. Run `npm publish --access public` from the workflow. Trusted publishing automatically generates provenance for this public package from this public repository.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-saas-guard",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Local-first CLI that catches launch blockers in AI-built Next.js/Supabase/Stripe SaaS apps.",
5
5
  "readmeFilename": "README.md",
6
6
  "type": "module",
@@ -70,6 +70,10 @@
70
70
  "types": "./dist/hosted/staging-harness.d.ts",
71
71
  "default": "./dist/hosted/staging-harness.js"
72
72
  },
73
+ "./hosted/deployed-staging": {
74
+ "types": "./dist/hosted/deployed-staging.d.ts",
75
+ "default": "./dist/hosted/deployed-staging.js"
76
+ },
73
77
  "./hosted/worker": {
74
78
  "types": "./dist/hosted/worker.d.ts",
75
79
  "default": "./dist/hosted/worker.js"