ai-saas-guard 0.30.1 → 0.31.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
@@ -124,6 +124,8 @@ One command returns a launch-readiness report with:
124
124
  | Are tools and CI overpowered? | MCP side-effect classes, local policy/receipt templates, GitHub Actions permissions, concurrency, checkout depth, action pinning |
125
125
  | Can reviewers trust the PR? | `pr-risk` ranking for auth, billing, RLS, deploy, API, storage, tests, silent-success paths, missing spec context, and large AI diffs |
126
126
 
127
+ For a concise comparison with Semgrep, zizmor, OpenSSF Scorecard, Snyk, and GitHub code scanning, see [docs/launch-gate-positioning.md](docs/launch-gate-positioning.md).
128
+
127
129
  ## Quick Start
128
130
 
129
131
  Run the published CLI without installing it globally:
@@ -185,13 +187,13 @@ The CLI is published on npm as `ai-saas-guard`, and the GitHub Action is availab
185
187
  | Area | Status |
186
188
  | --- | --- |
187
189
  | Public GitHub repository | Available |
188
- | npm CLI | `ai-saas-guard@0.30.1` |
189
- | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.30.1` |
190
+ | npm CLI | `ai-saas-guard@0.31.0` |
191
+ | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.31.0` |
190
192
  | Outputs | Short summary, terminal, JSON, SARIF, and PR-focused markdown |
191
193
  | Project config | `.ai-saas-guard.json` rule toggles, severity overrides, suppressions, and fail thresholds |
192
194
  | Privacy model | Local-first, read-only scan commands, no LLM calls, no code upload |
193
- | Versioned Action tags | `v0.30.1`, `v0` |
194
- | Current release | `0.30.1` adds `--summary` for first-run launch triage and sharper fix directions for Stripe, Supabase, silent-success, and Next/Vercel findings |
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
197
  | npm publishing | Trusted Publisher/OIDC, no long-lived publish token |
196
198
  | Repository trust hardening | Strict branch protection, Dependabot, CodeQL, fast-check fuzzing, signed release provenance assets, private vulnerability reporting, secret scanning, and push protection |
197
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 |
@@ -302,13 +304,13 @@ The hosted GitHub App deployment planner is documented in [docs/github-app-deplo
302
304
 
303
305
  The hosted production adapter layer is documented in [docs/hosted-production-adapters.md](docs/hosted-production-adapters.md). It exports `createHostedGitHubAppJwt`, `planHostedGitHubInstallationTokenRequest`, and `planHostedProductionWorkerExecution` from `ai-saas-guard/hosted/production-adapters`. It adds RS256 GitHub App JWT generation, selected-repository installation-token request plans, separate worker and Check Run token scopes, a fixed read-only worker command, bounded timeout and output budgets, compact JSON-only output, and cleanup plans for success, failure, timeout, and cancellation. It still does not expose a public hosted service by itself.
304
306
 
305
- The hosted read-only checkout worker is exported from `ai-saas-guard/hosted/worker`. It creates a temporary checkout from trusted GitHub App identity, uses a runtime installation token only through git askpass, runs the fixed `ai-saas-guard pr-risk --json` command with bounded timeout/output, converts CLI JSON into compact findings, and deletes the checkout after success or failure. It does not return source, diffs, secrets, checkout paths, PR-authored commands, or installation tokens.
307
+ The hosted read-only checkout worker is exported from `ai-saas-guard/hosted/worker`. It creates a temporary checkout from trusted GitHub App identity, uses a runtime installation token only through git askpass, removes askpass material before the CLI phase, rejects mutated command/checkout/token-scope plans, runs the fixed `ai-saas-guard pr-risk --json` command with bounded timeout/output, converts CLI JSON into compact findings, and deletes the checkout after success or failure. It does not return source, diffs, secrets, checkout paths, PR-authored commands, or installation tokens.
306
308
 
307
309
  The hosted Node/container app skeleton is documented in [docs/hosted-node-container-app.md](docs/hosted-node-container-app.md). It exports `createHostedHttpApp`, `createInMemoryHostedAppPlatform`, `createHostedNodeCheckoutAppPlatform`, and `planHostedNodeContainerDeployment` from `ai-saas-guard/hosted/app`. It adds a safe `/healthz` route, signed `/github/webhook` ingress, one-job worker tick, in-memory provider adapters for tests, a concrete read-only checkout worker composition with visible timeout/output safety budgets, and deployment-plan validation for secret manager, queue, compact report store, worker sandbox, and GitHub Checks publisher references. It still does not deploy or expose a public hosted service by itself.
308
310
 
309
311
  The hosted staging deployment planner is documented in [docs/hosted-staging-deployment.md](docs/hosted-staging-deployment.md). It exports `planHostedProviderBinding`, `planHostedStagingDeployment`, and `planHostedGitHubAppPromotion` from `ai-saas-guard/hosted/staging`. It composes real provider references, the Node/container deployment plan, hosted operational release-gate evidence, and GitHub App deployment planning so staging and production promotion stay blocked until the required queue, store, worker sandbox, Check Run publisher, logs, metrics, rollback, and incident-response references are present. It still does not call a cloud provider, create a GitHub App, or expose a public hosted service by itself.
310
312
 
311
- The hosted staging harness is documented in [docs/hosted-staging-harness.md](docs/hosted-staging-harness.md). It exports `createFileBackedHostedStagingHarness` and `createHostedStagingHarnessEvidence` 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, then verifies worker sandbox cleanup. 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.
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.
312
314
 
313
315
  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.
314
316
 
@@ -358,7 +360,7 @@ Use `suppressions` for narrower false-positive handling when one rule is noisy o
358
360
 
359
361
  ## GitHub Action
360
362
 
361
- The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.30.1` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
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:
362
364
 
363
365
  ```yaml
364
366
  name: ai-saas-guard
@@ -173,7 +173,7 @@ export function createHostedServiceRuntime(options) {
173
173
  cleanup
174
174
  };
175
175
  }
176
- catch {
176
+ catch (error) {
177
177
  const cleanup = createHostedWorkerCheckoutCleanupPlan({
178
178
  identity: queuedRecord.identity,
179
179
  jobKey: queuedRecord.key,
@@ -186,6 +186,7 @@ export function createHostedServiceRuntime(options) {
186
186
  processed: true,
187
187
  status: "failed",
188
188
  queueRecord: cloneQueueRecord(queuedRecord),
189
+ reason: safeScanRunnerFailureReason(error),
189
190
  errorClass: "scan_runner_failed",
190
191
  workerPlan: acceptedWorkerPlan,
191
192
  cleanup
@@ -194,6 +195,16 @@ export function createHostedServiceRuntime(options) {
194
195
  }
195
196
  };
196
197
  }
198
+ function safeScanRunnerFailureReason(error) {
199
+ if (typeof error === "object" &&
200
+ error !== null &&
201
+ "safeReason" in error &&
202
+ typeof error.safeReason === "string" &&
203
+ /^[a-z][a-z0-9_]{1,80}$/.test(error.safeReason)) {
204
+ return error.safeReason;
205
+ }
206
+ return "scan_runner_failed";
207
+ }
197
208
  function rejectWebhookRequest(stage, reason, deliveryId) {
198
209
  return {
199
210
  accepted: false,
@@ -1,5 +1,5 @@
1
- import { type HostedOperationalReleaseGateEvidence } from "./contracts.js";
2
- import { type HostedServiceRuntimeOptions, type HostedServiceScanRunnerResult, type HostedServiceWebhookStage } from "./service.js";
1
+ import { type HostedOperationalReleaseGateDecision, type HostedOperationalReleaseGateEvidence } from "./contracts.js";
2
+ import { type HostedServiceRuntimeOptions, type HostedServiceScanRunnerInput, type HostedServiceScanRunnerResult, type HostedServiceWebhookStage } from "./service.js";
3
3
  type RepositoryIdSource = HostedServiceRuntimeOptions["selectedRepositoryIdsByInstallation"];
4
4
  export interface FileBackedHostedStagingHarnessOptions {
5
5
  rootDir: string;
@@ -7,7 +7,7 @@ export interface FileBackedHostedStagingHarnessOptions {
7
7
  scannerVersion: string;
8
8
  selectedRepositoryIdsByInstallation: RepositoryIdSource;
9
9
  removedRepositoryIdsByInstallation?: RepositoryIdSource;
10
- scanResult: HostedServiceScanRunnerResult;
10
+ scanResult: HostedServiceScanRunnerResult | ((input: HostedServiceScanRunnerInput) => HostedServiceScanRunnerResult | Promise<HostedServiceScanRunnerResult>);
11
11
  now?: () => string;
12
12
  }
13
13
  export interface FileBackedHostedStagingHarness {
@@ -59,6 +59,7 @@ export type HostedStagingHarnessWorkerTickResult = {
59
59
  status: "failed";
60
60
  errorClass: "worker_plan_rejected" | "check_run_publication_rejected" | "scan_runner_failed";
61
61
  reason?: string;
62
+ safeFailureReason?: string;
62
63
  workerSandboxDeleted: boolean;
63
64
  activeWorkerSandboxCount: number;
64
65
  cleanupVerified: boolean;
@@ -80,6 +81,67 @@ export interface HostedStagingHarnessPrivacy {
80
81
  includesInstallationToken: false;
81
82
  claimsLiveHostedService: false;
82
83
  }
84
+ export type HostedLogBoundaryBlockedReason = "raw_source" | "raw_diff" | "secret_value" | "customer_payload" | "installation_token" | "checkout_path" | "private_url" | "untrusted_pr_text";
85
+ export interface HostedLogBoundaryForbiddenInput {
86
+ rawSource?: string;
87
+ rawDiff?: string;
88
+ secretValues?: string[];
89
+ customerPayloads?: string[];
90
+ installationTokens?: string[];
91
+ checkoutPaths?: string[];
92
+ privateUrls?: string[];
93
+ untrustedPrText?: string[];
94
+ }
95
+ export interface HostedLogBoundaryValidationInput {
96
+ samples: unknown[];
97
+ forbidden: HostedLogBoundaryForbiddenInput;
98
+ }
99
+ export interface HostedLogBoundaryValidation {
100
+ accepted: boolean;
101
+ sampleCount: number;
102
+ blockedReasons: HostedLogBoundaryBlockedReason[];
103
+ allowedFields: string[];
104
+ privacy: HostedStagingHarnessPrivacy;
105
+ }
106
+ export interface HostedStagingReleaseEvidenceBundleInput {
107
+ collectedAt: string;
108
+ evidenceBaseUrl: string;
109
+ owner: string;
110
+ webhookReplays: HostedStagingHarnessReplayResult[];
111
+ workerTicks: HostedStagingHarnessWorkerTickResult[];
112
+ logBoundary: HostedLogBoundaryValidation;
113
+ externalEvidence: HostedOperationalReleaseGateEvidence[];
114
+ requiredFailureReasons?: string[];
115
+ }
116
+ export interface HostedStagingReleaseEvidenceBundle {
117
+ readyForReleaseGate: boolean;
118
+ evidence: HostedOperationalReleaseGateEvidence[];
119
+ releaseGateInput: {
120
+ evidence: HostedOperationalReleaseGateEvidence[];
121
+ };
122
+ scenarioSummary: {
123
+ webhookReplayAccepted: boolean;
124
+ completedWorkerProbe: boolean;
125
+ failureCleanupProbe: boolean;
126
+ observedFailureReasons: string[];
127
+ allWorkerCheckoutsDeleted: boolean;
128
+ logBoundaryAccepted: boolean;
129
+ };
130
+ privacy: HostedStagingHarnessPrivacy;
131
+ }
132
+ export interface HostedStagingReleaseEvidenceGateInput {
133
+ bundle: HostedStagingReleaseEvidenceBundle;
134
+ commitSha: string;
135
+ scannerVersion: string;
136
+ deploymentTarget: string;
137
+ evaluatedAt: string;
138
+ releaseNotes: string;
139
+ containerImageDigest: string;
140
+ maxEvidenceAgeDays?: number;
141
+ }
83
142
  export declare function createFileBackedHostedStagingHarness(options: FileBackedHostedStagingHarnessOptions): FileBackedHostedStagingHarness;
84
143
  export declare function createHostedStagingHarnessEvidence(input: HostedStagingHarnessEvidenceInput): HostedOperationalReleaseGateEvidence[];
144
+ export declare function validateHostedLogBoundary(input: HostedLogBoundaryValidationInput): HostedLogBoundaryValidation;
145
+ export declare function createHostedStagingReleaseEvidenceBundle(input: HostedStagingReleaseEvidenceBundleInput): HostedStagingReleaseEvidenceBundle;
146
+ export declare function evaluateHostedStagingReleaseEvidenceBundle(input: HostedStagingReleaseEvidenceGateInput): HostedOperationalReleaseGateDecision;
85
147
  export {};
@@ -1,6 +1,6 @@
1
1
  import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS } from "./contracts.js";
3
+ import { evaluateHostedOperationalReleaseGate, HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS } from "./contracts.js";
4
4
  import { createHostedServiceRuntime } from "./service.js";
5
5
  export function createFileBackedHostedStagingHarness(options) {
6
6
  const paths = hostedStagingHarnessPaths(options.rootDir);
@@ -16,12 +16,16 @@ export function createFileBackedHostedStagingHarness(options) {
16
16
  queue,
17
17
  compactReportStore: reportStore,
18
18
  checkRunPublisher,
19
- scanRunner: async ({ queueRecord }) => {
19
+ scanRunner: async (input) => {
20
+ const { queueRecord } = input;
20
21
  const sandboxPath = join(paths.workerSandboxRoot, safeFileSegment(queueRecord.key));
21
22
  workerSandboxPaths.add(sandboxPath);
22
23
  await mkdir(sandboxPath, { recursive: true });
23
- await writeFile(join(sandboxPath, "source.ts"), options.scanResult.rawSource ?? "", "utf8");
24
- return options.scanResult;
24
+ const scanResult = typeof options.scanResult === "function"
25
+ ? await options.scanResult(input)
26
+ : options.scanResult;
27
+ await writeFile(join(sandboxPath, "source.ts"), scanResult.rawSource ?? "", "utf8");
28
+ return scanResult;
25
29
  },
26
30
  now: options.now
27
31
  });
@@ -77,6 +81,7 @@ export function createFileBackedHostedStagingHarness(options) {
77
81
  status: "failed",
78
82
  errorClass: result.errorClass,
79
83
  ...(result.reason === undefined ? {} : { reason: result.reason }),
84
+ ...(result.reason === undefined ? {} : { safeFailureReason: result.reason }),
80
85
  workerSandboxDeleted: activeWorkerSandboxCount === 0,
81
86
  activeWorkerSandboxCount,
82
87
  cleanupVerified: (result.cleanup?.shouldDeleteWorkerCheckout ?? true) && activeWorkerSandboxCount === 0,
@@ -95,6 +100,171 @@ export function createHostedStagingHarnessEvidence(input) {
95
100
  owner: input.owner
96
101
  }));
97
102
  }
103
+ export function validateHostedLogBoundary(input) {
104
+ const serializedSamples = input.samples.map((sample) => JSON.stringify(sample)).join("\n");
105
+ const blockedReasons = new Set();
106
+ markIfContains(blockedReasons, serializedSamples, input.forbidden.rawSource, "raw_source");
107
+ markIfContains(blockedReasons, serializedSamples, input.forbidden.rawDiff, "raw_diff");
108
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.secretValues, "secret_value");
109
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.customerPayloads, "customer_payload");
110
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.installationTokens, "installation_token");
111
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.checkoutPaths, "checkout_path");
112
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.privateUrls, "private_url");
113
+ markIfContainsAny(blockedReasons, serializedSamples, input.forbidden.untrustedPrText, "untrusted_pr_text");
114
+ if (/\bgh[opsu]_[A-Za-z0-9_]{8,}\b/.test(serializedSamples)) {
115
+ blockedReasons.add("installation_token");
116
+ }
117
+ if (/\b(?:sk_(?:live|test)|whsec_)[A-Za-z0-9_]+\b|-----BEGIN [A-Z ]+-----/.test(serializedSamples)) {
118
+ blockedReasons.add("secret_value");
119
+ }
120
+ return {
121
+ accepted: blockedReasons.size === 0,
122
+ sampleCount: input.samples.length,
123
+ blockedReasons: [...blockedReasons].sort(),
124
+ allowedFields: [
125
+ "scanKey",
126
+ "installationId",
127
+ "repositoryId",
128
+ "pullRequestNumber",
129
+ "headSha",
130
+ "scannerVersion",
131
+ "durationMs",
132
+ "summaryCounts",
133
+ "errorClass",
134
+ "cleanupStatus"
135
+ ],
136
+ privacy: hostedStagingHarnessPrivacy()
137
+ };
138
+ }
139
+ export function createHostedStagingReleaseEvidenceBundle(input) {
140
+ const externalEvidence = new Map(input.externalEvidence.map((evidence) => [evidence.id, sanitizeEvidence(evidence, input)]));
141
+ const scenarioSummary = hostedStagingScenarioSummary(input);
142
+ const evidence = HOSTED_OPERATIONAL_RELEASE_GATE_REQUIREMENTS.map((requirement) => {
143
+ const generated = generatedEvidenceFor(requirement.id, input, scenarioSummary);
144
+ return generated ?? externalEvidence.get(requirement.id) ?? missingEvidence(requirement.id, input);
145
+ });
146
+ const readyForReleaseGate = evidence.every((item) => item.status === "passed");
147
+ return {
148
+ readyForReleaseGate,
149
+ evidence,
150
+ releaseGateInput: { evidence },
151
+ scenarioSummary,
152
+ privacy: hostedStagingHarnessPrivacy()
153
+ };
154
+ }
155
+ export function evaluateHostedStagingReleaseEvidenceBundle(input) {
156
+ return evaluateHostedOperationalReleaseGate({
157
+ commitSha: input.commitSha,
158
+ scannerVersion: input.scannerVersion,
159
+ deploymentTarget: input.deploymentTarget,
160
+ evaluatedAt: input.evaluatedAt,
161
+ evidence: input.bundle.evidence,
162
+ releaseNotes: input.releaseNotes,
163
+ containerImageDigest: input.containerImageDigest,
164
+ maxEvidenceAgeDays: input.maxEvidenceAgeDays
165
+ });
166
+ }
167
+ function hostedStagingScenarioSummary(input) {
168
+ const processedWorkers = input.workerTicks.filter((tick) => tick.processed);
169
+ const webhookReplayAccepted = input.webhookReplays.some((replay) => replay.accepted && replay.queuedWorker && replay.shouldCreateCheckRun);
170
+ const completedWorkerProbe = processedWorkers.some((tick) => tick.status === "completed" && tick.cleanupVerified);
171
+ const observedFailureReasons = [
172
+ ...new Set(processedWorkers.flatMap((tick) => tick.status === "failed" && tick.cleanupVerified && tick.safeFailureReason
173
+ ? [tick.safeFailureReason]
174
+ : []))
175
+ ].sort();
176
+ const requiredFailureReasons = input.requiredFailureReasons ?? [];
177
+ const failureCleanupProbe = requiredFailureReasons.length
178
+ ? requiredFailureReasons.every((reason) => observedFailureReasons.includes(reason))
179
+ : processedWorkers.some((tick) => tick.status === "failed" && tick.cleanupVerified);
180
+ const allWorkerCheckoutsDeleted = processedWorkers.length > 0 &&
181
+ processedWorkers.every((tick) => tick.workerSandboxDeleted &&
182
+ tick.activeWorkerSandboxCount === 0 &&
183
+ tick.cleanupVerified);
184
+ return {
185
+ webhookReplayAccepted,
186
+ completedWorkerProbe,
187
+ failureCleanupProbe,
188
+ observedFailureReasons,
189
+ allWorkerCheckoutsDeleted,
190
+ logBoundaryAccepted: input.logBoundary.accepted
191
+ };
192
+ }
193
+ function generatedEvidenceFor(id, input, summary) {
194
+ if (id === "webhook_replay") {
195
+ return summary.webhookReplayAccepted
196
+ ? passedEvidence(id, "Signed webhook replay queued a check-run-only worker from trusted fields.", input)
197
+ : missingEvidence(id, input);
198
+ }
199
+ if (id === "queue_worker_cleanup") {
200
+ return summary.completedWorkerProbe &&
201
+ summary.failureCleanupProbe &&
202
+ summary.allWorkerCheckoutsDeleted
203
+ ? passedEvidence(id, "Success and failure worker probes deleted worker checkouts and recorded cleanup-safe status.", input)
204
+ : missingEvidence(id, input);
205
+ }
206
+ if (id === "privacy_retention") {
207
+ return input.logBoundary.sampleCount > 0 && summary.logBoundaryAccepted && privacyFlagsAreSafe(input)
208
+ ? passedEvidence(id, "Log boundary accepted safe metadata only and compact reports avoided raw payloads.", input)
209
+ : missingEvidence(id, input);
210
+ }
211
+ if (id === "release_cleanup") {
212
+ return summary.allWorkerCheckoutsDeleted
213
+ ? passedEvidence(id, "Release cleanup probe left no active staging worker sandbox entries.", input)
214
+ : missingEvidence(id, input);
215
+ }
216
+ return undefined;
217
+ }
218
+ function privacyFlagsAreSafe(input) {
219
+ const replayPrivacySafe = input.webhookReplays.every((replay) => Object.values(replay.privacy).every((value) => value === false));
220
+ const workerPrivacySafe = input.workerTicks.every((tick) => Object.values(tick.privacy).every((value) => value === false));
221
+ const logPrivacySafe = Object.values(input.logBoundary.privacy).every((value) => value === false);
222
+ return replayPrivacySafe && workerPrivacySafe && logPrivacySafe;
223
+ }
224
+ function sanitizeEvidence(evidence, input) {
225
+ return {
226
+ id: evidence.id,
227
+ status: evidence.status,
228
+ ...(evidence.collectedAt === undefined
229
+ ? { collectedAt: input.collectedAt }
230
+ : { collectedAt: evidence.collectedAt }),
231
+ ...(evidence.evidenceUrl === undefined ? {} : { evidenceUrl: evidence.evidenceUrl }),
232
+ note: `External release-gate evidence recorded for ${evidence.id}.`,
233
+ ...(evidence.owner === undefined ? { owner: input.owner } : { owner: evidence.owner })
234
+ };
235
+ }
236
+ function passedEvidence(id, note, input) {
237
+ return {
238
+ id,
239
+ status: "passed",
240
+ collectedAt: input.collectedAt,
241
+ evidenceUrl: evidenceUrlFor(input, id),
242
+ note,
243
+ owner: input.owner
244
+ };
245
+ }
246
+ function missingEvidence(id, input) {
247
+ return {
248
+ id,
249
+ status: "missing",
250
+ collectedAt: input.collectedAt,
251
+ note: `Missing executable staging evidence for ${id}.`,
252
+ owner: input.owner
253
+ };
254
+ }
255
+ function evidenceUrlFor(input, id) {
256
+ return `${input.evidenceBaseUrl.replace(/\/+$/, "")}/${id}.json`;
257
+ }
258
+ function markIfContains(blockedReasons, haystack, value, reason) {
259
+ if (value && haystack.includes(value)) {
260
+ blockedReasons.add(reason);
261
+ }
262
+ }
263
+ function markIfContainsAny(blockedReasons, haystack, values, reason) {
264
+ for (const value of values ?? []) {
265
+ markIfContains(blockedReasons, haystack, value, reason);
266
+ }
267
+ }
98
268
  function hostedStagingHarnessPaths(rootDir) {
99
269
  const queueDir = join(rootDir, "queue");
100
270
  const reportDir = join(rootDir, "reports");
@@ -34,6 +34,9 @@ export async function runHostedReadOnlyCheckoutScan(input, options) {
34
34
  if (!plan.accepted || !plan.readOnly || !checkout || !cli || cli.writeMode !== "read_only") {
35
35
  throw new HostedReadOnlyCheckoutScanError("invalid_worker_plan");
36
36
  }
37
+ if (!isTrustedFixedReadOnlyPlan(input)) {
38
+ throw new HostedReadOnlyCheckoutScanError("invalid_worker_plan");
39
+ }
37
40
  const repository = parseRepositoryFullName(checkout.repositoryFullName);
38
41
  if (!repository) {
39
42
  throw new HostedReadOnlyCheckoutScanError("invalid_repository_full_name");
@@ -76,6 +79,7 @@ export async function runHostedReadOnlyCheckoutScan(input, options) {
76
79
  await runCommand(options, gitSecretEnv, commandSpec("git_fetch_head", gitCommand, ["fetch", "--no-tags", "--depth", String(fetchDepth), "origin", checkout.targetCommitSha], checkoutDir, gitEnv, timeoutMs, maxOutputBytes));
77
80
  await runCommand(options, gitSecretEnv, commandSpec("git_fetch_base", gitCommand, ["fetch", "--no-tags", "--depth", String(fetchDepth), "origin", checkout.baseSha], checkoutDir, gitEnv, timeoutMs, maxOutputBytes));
78
81
  await runCommand(options, gitSecretEnv, commandSpec("git_checkout", gitCommand, ["checkout", "--detach", checkout.targetCommitSha], checkoutDir, gitEnv, timeoutMs, maxOutputBytes));
82
+ await rm(askpassPath, { force: true });
79
83
  const cliEnv = safeWorkerEnv(checkoutDir);
80
84
  const cliArgs = cli.args.map((arg) => arg === "<worker-checkout>" ? checkoutDir : arg);
81
85
  const cliResult = await runCommand(options, {}, commandSpec("cli_scan", options.cliCommand ?? cli.command, cliArgs, checkoutDir, cliEnv, timeoutMs, maxOutputBytes));
@@ -143,6 +147,53 @@ function compactScanRunnerResult(stdout) {
143
147
  throw new HostedReadOnlyCheckoutScanError("invalid_cli_output");
144
148
  }
145
149
  }
150
+ function isTrustedFixedReadOnlyPlan(input) {
151
+ const { plan, queueRecord } = input;
152
+ const { checkout, cli, installationTokenScope, output } = plan;
153
+ const identity = queueRecord.identity;
154
+ if (!checkout || !cli || !installationTokenScope || !output)
155
+ return false;
156
+ const expectedCliArgs = [
157
+ "pr-risk",
158
+ "--root",
159
+ "<worker-checkout>",
160
+ "--base",
161
+ identity.baseSha,
162
+ "--json"
163
+ ];
164
+ return (plan.jobKey === queueRecord.key &&
165
+ plan.readOnly === true &&
166
+ plan.shouldFetchSource === true &&
167
+ plan.shouldRunCli === true &&
168
+ plan.shouldPersistRawSource === false &&
169
+ plan.shouldPersistRawDiffs === false &&
170
+ plan.shouldCreatePrComment === false &&
171
+ installationTokenScope.installationId === identity.installationId &&
172
+ installationTokenScope.repositoryId === identity.repositoryId &&
173
+ installationTokenScope.permissions.contents === "read" &&
174
+ installationTokenScope.selectedRepositoryOnly === true &&
175
+ checkout.repositoryId === identity.repositoryId &&
176
+ checkout.repositoryFullName === identity.repositoryFullName &&
177
+ checkout.pullRequestNumber === identity.pullRequestNumber &&
178
+ checkout.baseSha === identity.baseSha &&
179
+ checkout.targetCommitSha === identity.headSha &&
180
+ checkout.directoryScope === "temporary_worker_directory" &&
181
+ checkout.cleanupRequired === true &&
182
+ checkout.returnsCheckoutPath === false &&
183
+ cli.command === "ai-saas-guard" &&
184
+ cli.workingDirectory === "<worker-checkout>" &&
185
+ cli.networkAccess === "disabled" &&
186
+ cli.writeMode === "read_only" &&
187
+ arraysEqual(cli.args, expectedCliArgs) &&
188
+ output.compactJsonOnly === true &&
189
+ output.persistRawSource === false &&
190
+ output.persistRawDiffs === false &&
191
+ output.persistSecrets === false &&
192
+ output.persistCustomerPayloads === false);
193
+ }
194
+ function arraysEqual(left, right) {
195
+ return left.length === right.length && left.every((value, index) => value === right[index]);
196
+ }
146
197
  function compactFinding(value) {
147
198
  if (!isRecord(value))
148
199
  return [];
@@ -101,7 +101,17 @@ function runsOnPullRequestOrPush(content) {
101
101
  return /^\s*(pull_request(?:_target)?|push):/im.test(content);
102
102
  }
103
103
  function hasCancelInProgressConcurrency(content) {
104
- return /^\s*concurrency:/im.test(content) && /^\s*cancel-in-progress:\s*true\b/im.test(content);
104
+ if (!/^\s*concurrency:/im.test(content))
105
+ return false;
106
+ const match = /^\s*cancel-in-progress:\s*(.+?)\s*$/im.exec(content);
107
+ if (!match)
108
+ return false;
109
+ const value = match[1]?.trim() ?? "";
110
+ if (/^true\b/i.test(value))
111
+ return true;
112
+ if (/^\$\{\{[\s\S]*\}\}$/.test(value) && !/\bfalse\b/i.test(value))
113
+ return true;
114
+ return false;
105
115
  }
106
116
  function hasPathFilters(content) {
107
117
  return /^\s*(paths|paths-ignore):\s*$/im.test(content) || /^\s*(paths|paths-ignore):\s*\[/im.test(content);
@@ -180,11 +180,18 @@ function isImportantServerEnv(name) {
180
180
  return /(STRIPE|SUPABASE|DATABASE|NEXTAUTH|AUTH|WEBHOOK|SECRET|TOKEN|OPENAI|ANTHROPIC|PAYMENT)/.test(name);
181
181
  }
182
182
  function hasSecurityHeaders(files) {
183
- const combined = files
183
+ const nextOrMiddleware = files
184
184
  .filter((file) => /(^|\/)(next\.config\.[cm]?[jt]s|middleware\.[cm]?[jt]s)$/i.test(file.path))
185
185
  .map((file) => file.content)
186
186
  .join("\n");
187
- return /\bheaders\s*\(/i.test(combined) && /(X-Frame-Options|Content-Security-Policy|X-Content-Type-Options|Referrer-Policy)/i.test(combined);
187
+ if (/\bheaders\s*\(/i.test(nextOrMiddleware) && hasBrowserSecurityHeaderNames(nextOrMiddleware))
188
+ return true;
189
+ return files.some((file) => {
190
+ return /(^|\/)vercel\.json$/i.test(file.path) && /"headers"\s*:/i.test(file.content) && hasBrowserSecurityHeaderNames(file.content);
191
+ });
192
+ }
193
+ function hasBrowserSecurityHeaderNames(content) {
194
+ return /(X-Frame-Options|Content-Security-Policy|X-Content-Type-Options|Referrer-Policy)/i.test(content);
188
195
  }
189
196
  function usesUnboundedNextImage(path, content, nextConfigContent) {
190
197
  if (/next\.config\.(ts|js|mjs|cjs)$/.test(path) && /remotePatterns[\s\S]{0,240}hostname\s*:\s*["'](?:\*\*|\*)["']/i.test(content))
@@ -123,6 +123,8 @@ Next steps
123
123
  | 工具和 CI 权限是不是过大? | MCP side-effect 分类、本地 policy/receipt 模板、GitHub Actions 权限、concurrency、checkout depth、Action pinning |
124
124
  | reviewer 能不能看懂 AI PR? | `pr-risk` 对 auth、billing、RLS、deploy、API、storage、测试、silent-success、缺 spec context 和大型 diff 排序 |
125
125
 
126
+ 如果想看它和 Semgrep、zizmor、OpenSSF Scorecard、Snyk、GitHub code scanning 的边界区别,见 [launch-gate-positioning.md](launch-gate-positioning.md)。
127
+
126
128
  ## 快速开始
127
129
 
128
130
  无需全局安装,直接运行:
@@ -167,18 +169,18 @@ node dist/cli.js scan --root /path/to/your-saas
167
169
 
168
170
  这个仓库是公开 GitHub 仓库。
169
171
 
170
- CLI 已发布到 npm:`ai-saas-guard@0.30.1`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.30.1`。
172
+ CLI 已发布到 npm:`ai-saas-guard@0.31.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.31.0`。
171
173
 
172
174
  | 模块 | 状态 |
173
175
  | --- | --- |
174
176
  | 公开 GitHub 仓库 | 已可用 |
175
- | npm CLI | `ai-saas-guard@0.30.1` |
176
- | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.30.1` |
177
+ | npm CLI | `ai-saas-guard@0.31.0` |
178
+ | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.31.0` |
177
179
  | 输出格式 | 短 summary、Terminal、JSON、SARIF 和 PR markdown |
178
180
  | 项目配置 | `.ai-saas-guard.json` 支持规则开关、severity 覆盖、suppressions 和 fail threshold |
179
181
  | 隐私模型 | 本地优先、只读扫描、不调用 LLM、不上传代码 |
180
- | 当前版本 | `0.30.1` 增加首次使用的 `--summary` 输出,并强化 StripeSupabase、silent-success、Next/Vercel finding 的具体修复方向 |
181
- | Action 标签 | `v0.30.1`、`v0` |
182
+ | 当前版本 | `0.31.0` 增加可执行 hosted staging evidence:成功/失败 cleanup probeslog-boundary validation、更严格的 read-only checkout worker 边界,以及从 evidence bundle 直接评估 release gate |
183
+ | Action 标签 | `v0.31.0`、`v0` |
182
184
  | npm 发布 | GitHub Actions Trusted Publisher/OIDC,无需长期 npm token |
183
185
  | 仓库可信度加固 | 严格 branch protection、Dependabot、CodeQL、fast-check fuzzing、signed release provenance assets、private vulnerability reporting、secret scanning 和 push protection |
184
186
  | Cloudflare hosted ingress | 已部署到 `https://ai-saas-guard-hosted.zr9959.workers.dev`;签名 GitHub App webhook delivery 和 compact Check Run staging smoke 已通过 |
@@ -357,13 +359,13 @@ GitHub Marketplace wrapper 决策见 [docs/github-marketplace-wrapper-decision.m
357
359
  - pull request webhook intake planner:先验签,再解析 payload、生成可信 identity、校验 selected-repository scope,并默认只走 check-run-only 输出
358
360
  - durable scan queue planner:同一个 trusted scan key 的 queued/running/completed job 会复用,不重复排 worker,也不会把源码、diff、secret 或 PR 正文放进队列 payload
359
361
  - worker read-only scan planner:只用 trusted identity 规划临时 worker checkout,要求 repository `contents: read`,固定运行 `ai-saas-guard pr-risk --json`,并忽略 PR 正文里的 repo 名、token scope 或命令
360
- - hosted read-only checkout worker:`ai-saas-guard/hosted/worker` 导出 `createHostedReadOnlyCheckoutScanRunner`,从 trusted GitHub App identity 创建临时 checkout,只通过 git askpass 使用 runtime installation token,运行固定 `ai-saas-guard pr-risk --json`,把 CLI JSON 转成 compact findings,并在成功或失败后删除 checkout;不会返回源码、diff、secret、checkout path、PR 里写的命令或 installation token
362
+ - hosted read-only checkout worker:`ai-saas-guard/hosted/worker` 导出 `createHostedReadOnlyCheckoutScanRunner`,从 trusted GitHub App identity 创建临时 checkout,只通过 git askpass 使用 runtime installation token,在 CLI 阶段前移除 askpass material,拒绝被篡改的 command/checkout/token-scope plan,运行固定 `ai-saas-guard pr-risk --json`,把 CLI JSON 转成 compact findings,并在成功或失败后删除 checkout;不会返回源码、diff、secret、checkout path、PR 里写的命令或 installation token
361
363
  - hosted service runtime:`ai-saas-guard/hosted/service` 导出 `createHostedServiceRuntime`,把签名 webhook intake、幂等 queue upsert、read-only worker 编排、compact report 存储、Check Run 发布 adapter 和 worker cleanup 串成可测试的服务核心;它本身不部署公开 hosted 环境
362
364
  - GitHub App deployment planner:`ai-saas-guard/hosted/github-app` 导出 `planHostedGitHubAppDeployment`,生成 first slice 最小权限 manifest,并在 release gate、公开 HTTPS URL、container digest、secret 引用、原始 secret 输入、permission 或 event 不安全时阻止创建
363
365
  - Hosted production adapter layer:`ai-saas-guard/hosted/production-adapters` 导出 `createHostedGitHubAppJwt`、`planHostedGitHubInstallationTokenRequest` 和 `planHostedProductionWorkerExecution`,用于 GitHub App RS256 JWT、selected-repository installation token 请求规划、worker/check-run 分离 token scope、固定只读 worker 命令、timeout/output 预算、compact JSON-only 输出,以及 success/failure/timeout/cancellation 的 cleanup 规划;它本身仍然不部署公开 hosted 服务
364
366
  - 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 服务
365
367
  - 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 服务
366
- - Hosted staging harness:`ai-saas-guard/hosted/staging-harness` 导出 `createFileBackedHostedStagingHarness` 和 `createHostedStagingHarnessEvidence`,可以在本地用 file-backed queue、compact report、Check Run request 和 worker sandbox 跑通签名 webhook replay、worker tick 和 cleanup 校验;它只是 staging 演练工具,不会调用云平台、创建 GitHub App、写真实 Check Run 或暴露公开 hosted 服务
368
+ - 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 服务
367
369
  - 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
368
370
  - webhook event parser
369
371
  - check-run summary renderer
@@ -40,7 +40,7 @@ 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 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. 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
44
 
45
45
  Source-level evidence notes for this release candidate:
46
46
 
@@ -52,8 +52,8 @@ Source-level evidence notes for this release candidate:
52
52
  | `workflow_static_checks` | GitHub Actions static analysis | `actionlint` and `uvx zizmor --offline .github/workflows` | Passed for repository workflows |
53
53
  | `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
54
  | `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, and retention cleanup planner tests | Passed for pure contracts; 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, and docs tests | Passed for pure contracts; log sampling still required before 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 |
57
57
  | `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
58
  | `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
59
  | `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 |
@@ -137,6 +137,28 @@ Required evidence:
137
137
 
138
138
  The worker must not persist repository files across jobs.
139
139
 
140
+ ### Read-Only Checkout Worker Evidence
141
+
142
+ For the first source checkout worker, the release blocks unless the deployed artifact records fresh evidence for both success and failure cleanup.
143
+
144
+ Required proof:
145
+
146
+ - checkout identity comes only from signed GitHub event fields and selected-repository installation scope.
147
+ - repository token permissions are limited to `contents: read` for checkout.
148
+ - runtime credentials reach git through temporary askpass material only.
149
+ - the CLI phase runs after credential material is removed from the environment.
150
+ - the worker command is fixed to the deterministic read-only `pr-risk --json` shape.
151
+ - the worker rejects accepted-looking plans if command, checkout identity, or token scope differs from trusted GitHub event identity.
152
+ - success deletes the worker checkout, askpass material, generated JSON/SARIF scratch files, and local package tarballs.
153
+ - failure cleanup covers clone failure, timeout, CLI failure, malformed JSON output, Check Run write failure, cancellation, and process interruption.
154
+ - cleanup failures create an operator-review event without returning raw source, raw diffs, installation tokens, checkout paths, private URLs, or low-level filesystem errors to users.
155
+
156
+ ### Log Boundary Evidence
157
+
158
+ Before exposure, sample ingress, queue, worker, report, and Check Run logs for the release candidate. The sample may contain scan key, installation ID, repository ID, PR number, head SHA, scanner version, duration, summary counts, error class, and cleanup status.
159
+
160
+ The sample must show no raw source, no raw diffs, no secrets, no installation tokens, no customer payloads, no private URLs, no checkout paths, and no untrusted PR prose.
161
+
140
162
  ## Dependency And Container Scanning
141
163
 
142
164
  Hosted releases must include dependency and container scanning for the deployed artifact.
@@ -29,6 +29,24 @@ The hosted release gate still requires fresh deployed evidence for:
29
29
  - dependency and container artifact scanning for the deployed worker image
30
30
  - retention and uninstall cleanup against the deployed provider stores
31
31
 
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
+
34
+ ## Read-Only Checkout Worker Evidence Checklist
35
+
36
+ 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.
37
+
38
+ | Evidence area | Required proof | Status before hosted exposure |
39
+ | --- | --- | --- |
40
+ | Trusted checkout identity | Worker input is derived from signed GitHub event identity, selected-repository installation scope, and repository `contents: read`; PR title, body, branch names, README, and code cannot choose the repository, token scope, checkout path, or command | Required |
41
+ | Runtime credential boundary | Installation credentials are passed to git only through temporary askpass material, are removed before the CLI scan phase, and are never returned in worker output, compact reports, Check Runs, or logs | Required |
42
+ | Fixed scanner command | Worker runs the fixed read-only command shape `ai-saas-guard pr-risk --root <worker-checkout> --base <trusted-base-sha> --json` without shell parsing or PR-authored arguments, and rejects command, checkout, or token-scope mutations before running git | Required |
43
+ | Success cleanup | A successful worker run deletes the checkout directory, askpass material, generated JSON/SARIF scratch files, and any local package tarballs | Required |
44
+ | Failure cleanup | A failed clone, timeout, CLI non-zero exit, malformed JSON output, Check Run write failure, cancellation, or process interruption still attempts checkout deletion and records only a safe cleanup status | Required |
45
+ | Log boundary | Logs may include scan key, installation ID, repository ID, PR number, head SHA, scanner version, duration, summary counts, error class, and cleanup status; logs must include no raw source, no raw diffs, no secrets, no installation tokens, no customer payloads, no private URLs, and no checkout paths | Required |
46
+ | Retention boundary | Compact report retention and uninstall cleanup delete repository-scoped records and worker checkout references without exposing low-level cleanup errors | Required |
47
+
48
+ Use the checklist above together with [hosted-operational-release-gate.md](hosted-operational-release-gate.md). The release remains blocked until deployed worker evidence covers success, failure cleanup, log boundary sampling, monitoring, rollback, and incident response.
49
+
32
50
  ## Smoke Procedure
33
51
 
34
52
  Use this sequence after each hosted Worker deployment:
@@ -79,6 +79,8 @@ Default behavior:
79
79
  - derive the GitHub clone URL only from trusted repository identity
80
80
  - require a runtime installation token provider and keep the token out of command arguments, returned results, compact reports, and serialized plans
81
81
  - pass the installation token to git only through a temporary askpass helper inside the worker checkout
82
+ - remove askpass material before the CLI phase starts
83
+ - reject accepted-looking plans when command, checkout identity, or token scope differs from the trusted worker plan
82
84
  - run `git init`, add the trusted remote, fetch the trusted head and base SHAs with bounded depth, and checkout the trusted head SHA
83
85
  - run the fixed `ai-saas-guard pr-risk --root <worker-checkout> --base <baseSha> --json` command without shell parsing
84
86
  - cap command timeout and output bytes
@@ -174,6 +176,9 @@ Default behavior:
174
176
  - create a temporary worker sandbox during the scan runner phase
175
177
  - remove worker sandbox contents before returning the worker result
176
178
  - create hosted operational release-gate evidence fixtures with the same shape required by the deployment gate
179
+ - turn success and failure cleanup probes into executable release-gate evidence
180
+ - validate log boundaries without returning sampled log lines or forbidden values
181
+ - evaluate the hosted release gate directly from the generated evidence bundle
177
182
 
178
183
  Privacy boundaries:
179
184
 
@@ -181,7 +186,7 @@ Privacy boundaries:
181
186
  - result objects do not include raw webhook payloads, untrusted PR text, raw source, raw diffs, secrets, customer payloads, checkout paths, or installation tokens
182
187
  - local evidence is labeled as harness evidence and must not be used to claim live hosted exposure
183
188
 
184
- The exported helpers are `createFileBackedHostedStagingHarness` and `createHostedStagingHarnessEvidence`.
189
+ The exported helpers are `createFileBackedHostedStagingHarness`, `createHostedStagingHarnessEvidence`, `createHostedStagingReleaseEvidenceBundle`, `evaluateHostedStagingReleaseEvidenceBundle`, and `validateHostedLogBoundary`.
185
190
 
186
191
  ## Webhook Event Parser
187
192
 
@@ -10,6 +10,9 @@ The package exports `ai-saas-guard/hosted/staging-harness` with:
10
10
 
11
11
  - `createFileBackedHostedStagingHarness`
12
12
  - `createHostedStagingHarnessEvidence`
13
+ - `createHostedStagingReleaseEvidenceBundle`
14
+ - `evaluateHostedStagingReleaseEvidenceBundle`
15
+ - `validateHostedLogBoundary`
13
16
 
14
17
  The harness composes the hosted service runtime with local adapters:
15
18
 
@@ -20,6 +23,8 @@ The harness composes the hosted service runtime with local adapters:
20
23
  - a temporary worker sandbox under `worker-sandbox/`
21
24
  - cleanup verification after a worker tick
22
25
  - local hosted release-gate evidence fixtures
26
+ - executable evidence bundles for success and failure cleanup probes
27
+ - log boundary validation for safe hosted metadata samples
23
28
 
24
29
  ## Replay Flow
25
30
 
@@ -39,6 +44,35 @@ Invalid signatures stop at the signature stage and create no queue, report, or C
39
44
 
40
45
  The generated notes are explicit that the evidence is local harness evidence, not hosted exposure.
41
46
 
47
+ ## Executable Evidence Bundle
48
+
49
+ `createHostedStagingReleaseEvidenceBundle` turns concrete harness results into release-gate evidence:
50
+
51
+ - signed webhook replay must queue a check-run-only worker from trusted GitHub event fields
52
+ - worker success must delete the worker sandbox
53
+ - worker failure must still delete the worker sandbox and expose only a safe failure reason
54
+ - callers can require explicit failure reasons such as checkout failure, CLI failure, malformed output, Check Run publication failure, timeout, and cancellation before cleanup evidence passes
55
+ - log boundary validation must pass before `privacy_retention` is marked passed
56
+ - external evidence is still required for CI, workflow static checks, dependency scan, container scan, monitoring, rollback, and incident response
57
+
58
+ `evaluateHostedStagingReleaseEvidenceBundle` passes that bundle into the hosted operational release gate evaluator with the release commit, scanner version, deployment target, container digest, and release notes. This makes the local staging gate executable instead of a hand-maintained checklist.
59
+
60
+ The bundle is still source-candidate evidence. It does not prove a deployed hosted service is ready, and it does not replace deployed provider evidence.
61
+
62
+ ## Log Boundary Validation
63
+
64
+ `validateHostedLogBoundary` accepts sampled log metadata and a forbidden-value list for raw source, raw diffs, secret values, customer payloads, installation tokens, checkout paths, private URLs, and untrusted PR prose.
65
+
66
+ The returned result contains only:
67
+
68
+ - pass/fail status
69
+ - blocked reason IDs
70
+ - sample count
71
+ - allowed field names
72
+ - privacy flags
73
+
74
+ It does not return the sampled log lines or the forbidden values. This keeps the evidence useful while avoiding accidental leakage in release notes, compact reports, or Check Runs.
75
+
42
76
  ## Privacy
43
77
 
44
78
  The harness returns safe status objects and compact artifacts only.
@@ -58,6 +92,6 @@ The worker sandbox may contain temporary scan input during a worker tick. The ha
58
92
 
59
93
  ## Current Status
60
94
 
61
- The repository can now run a local staging rehearsal across webhook intake, queue persistence, worker execution, compact report storage, Check Run publication, and worker cleanup.
95
+ The repository can now run a local staging rehearsal across webhook intake, queue persistence, worker execution, compact report storage, Check Run publication, worker cleanup, success and failure cleanup probes, log boundary validation, and executable release-gate evaluation from the generated evidence bundle.
62
96
 
63
97
  This still is not a live hosted service. A real staging environment still requires deployed platform infrastructure, public HTTPS ingress, platform secret references, durable queue/storage resources, worker isolation, GitHub Checks runtime credentials, monitoring, rollback evidence, and incident-response evidence collected from the deployed artifact.
@@ -0,0 +1,33 @@
1
+ # Launch Gate Positioning
2
+
3
+ `ai-saas-guard` is a local-first launch gate for AI-built SaaS apps. It is focused on the code paths that decide whether a product is ready to invite users: auth, billing, tenant data, provider failure handling, deploy config, MCP tool power, GitHub Actions hygiene, and AI-heavy PR review.
4
+
5
+ The narrow bet is simple: a founder or reviewer should know which launch-risk files to inspect first, what manual proof to run, and what fix direction to try before traffic reaches real users.
6
+
7
+ ## Where It Fits
8
+
9
+ | Tool category | Typical strength | How ai-saas-guard fits beside it |
10
+ | --- | --- | --- |
11
+ | Semgrep | Broad customizable static rules across many languages and frameworks | Adds SaaS launch-specific heuristics and review wording for Stripe, Supabase, silent-success, Next/Vercel, MCP, Actions, and AI PR trust boundaries |
12
+ | zizmor | Deep GitHub Actions security analysis | Adds a smaller launch-readiness hygiene check for workflow permissions, PR concurrency, docs-only CI cost, shallow checkout risk, and first-run guidance |
13
+ | OpenSSF Scorecard | Repository supply-chain posture signals | Adds app-level launch triage inside the repo, while Scorecard remains useful for public project maintenance controls |
14
+ | Snyk and dependency scanners | Dependency, container, license, and known-vulnerability workflows | Adds local source review for SaaS trust-boundary mistakes that may not be dependency vulnerabilities |
15
+ | GitHub code scanning | SARIF ingestion and code-security workflow inside GitHub | Emits SARIF, but keeps the primary workflow local-first and focused on launch review queues |
16
+
17
+ ## What It Optimizes For
18
+
19
+ - local-first: source stays on the machine or in the caller's CI job
20
+ - deterministic: no LLM calls and no code upload
21
+ - founder-readable output: severity, rule ID, file evidence, why, manual proof, and fix direction
22
+ - AI-built SaaS launch risk: not every static-analysis finding, only the paths likely to break auth, billing, data access, deploy, or review trust
23
+ - PR triage: ranking trust-boundary files before cosmetic or unrelated AI-generated changes
24
+
25
+ ## What It Does Not Try To Be
26
+
27
+ - not a general vulnerability management platform
28
+ - not a dependency advisory database
29
+ - not a cloud posture dashboard
30
+ - not a runtime WAF or MCP proxy
31
+ - not a guarantee that an app is safe to launch
32
+
33
+ Use it as a short, evidence-first launch review queue alongside dependency scanning, repository hardening, code scanning, manual two-account authorization tests, Stripe webhook replay, deploy-preview checks, and human review.
@@ -5,11 +5,11 @@
5
5
  ## Current State
6
6
 
7
7
  - Package name: `ai-saas-guard`
8
- - Current published version: `0.30.1`
8
+ - Current published version: `0.31.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.30.1`
12
+ - GitHub Release: `v0.31.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.30.1`.
21
+ 1. Create and review a release tag such as `v0.31.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.30.1",
3
+ "version": "0.31.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",