ai-saas-guard 0.12.0 → 0.13.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
@@ -73,8 +73,8 @@ The CLI is published on npm as `ai-saas-guard`, and the GitHub Action is availab
73
73
  | JSON and SARIF output | Available |
74
74
  | Composite GitHub Action | Available |
75
75
  | Project config | `.ai-saas-guard.json` rule toggles, severity overrides, and fail thresholds |
76
- | Versioned Action tags | `v0.12.0`, `v0` |
77
- | npm package | `ai-saas-guard@0.12.0` |
76
+ | Versioned Action tags | `v0.13.0`, `v0` |
77
+ | npm package | `ai-saas-guard@0.13.0` |
78
78
  | npm publishing | Trusted Publisher/OIDC, no long-lived publish token |
79
79
 
80
80
  ## Quick Start
@@ -214,7 +214,7 @@ Hosted uninstall and data deletion behavior is documented in [docs/hosted-uninst
214
214
 
215
215
  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.
216
216
 
217
- 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, plus a durable scan queue planner that reuses queued, running, and completed jobs for the same trusted scan key. They also cover queue-safe webhook event parsing, bounded check-run summary rendering, idempotent queue cleanup planning, worker checkout cleanup planning, and other service-free helpers exported from `ai-saas-guard/hosted/contracts`.
217
+ 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, and a worker read-only scan planner that fixes the CLI command, requires repository `contents: read`, and ignores PR-authored repo names, token scopes, and commands. They also cover queue-safe webhook event parsing, bounded check-run summary rendering, idempotent queue cleanup planning, worker checkout cleanup planning, and other service-free helpers exported from `ai-saas-guard/hosted/contracts`.
218
218
 
219
219
  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.
220
220
 
@@ -254,7 +254,7 @@ Use `suppressions` for narrower false-positive handling when one rule is noisy o
254
254
 
255
255
  ## GitHub Action
256
256
 
257
- The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.12.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
257
+ The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.13.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
258
258
 
259
259
  ```yaml
260
260
  name: ai-saas-guard
package/README.zh-CN.md CHANGED
@@ -55,7 +55,7 @@ AI 能很快把一个 SaaS 从想法做成可运行的产品。真正难的是
55
55
 
56
56
  这个仓库是公开 GitHub 仓库。
57
57
 
58
- CLI 已发布到 npm:`ai-saas-guard@0.12.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.12.0`。
58
+ CLI 已发布到 npm:`ai-saas-guard@0.13.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.13.0`。
59
59
 
60
60
  | 模块 | 状态 |
61
61
  | --- | --- |
@@ -66,8 +66,8 @@ CLI 已发布到 npm:`ai-saas-guard@0.12.0`。GitHub Action 支持 `v0` 浮动
66
66
  | Markdown PR summary | 已可用 |
67
67
  | GitHub Action | 已可用 |
68
68
  | 项目配置 | `.ai-saas-guard.json` 支持规则开关、severity 覆盖和 fail threshold |
69
- | 当前版本 | `0.12.0` |
70
- | Action 标签 | `v0.12.0`、`v0` |
69
+ | 当前版本 | `0.13.0` |
70
+ | Action 标签 | `v0.13.0`、`v0` |
71
71
  | npm 发布 | GitHub Actions Trusted Publisher/OIDC,无需长期 npm token |
72
72
 
73
73
  ## 快速开始
@@ -254,6 +254,7 @@ jobs:
254
254
 
255
255
  - pull request webhook intake planner:先验签,再解析 payload、生成可信 identity、校验 selected-repository scope,并默认只走 check-run-only 输出
256
256
  - durable scan queue planner:同一个 trusted scan key 的 queued/running/completed job 会复用,不重复排 worker,也不会把源码、diff、secret 或 PR 正文放进队列 payload
257
+ - worker read-only scan planner:只用 trusted identity 规划临时 worker checkout,要求 repository `contents: read`,固定运行 `ai-saas-guard pr-risk --json`,并忽略 PR 正文里的 repo 名、token scope 或命令
257
258
  - webhook event parser
258
259
  - check-run summary renderer
259
260
  - queue cleanup planner
@@ -201,6 +201,81 @@ export interface HostedQueueCleanupPlan {
201
201
  deleteCustomerPayloads: false;
202
202
  }
203
203
  export type HostedWorkerCheckoutTerminalState = "success" | "failure" | "timeout" | "cancellation" | "cleanup_failure";
204
+ export type HostedWorkerReadOnlyScanRejectReason = InstallationScopeRejectReason | "contents_read_permission_required";
205
+ export interface HostedWorkerReadOnlyScanInput {
206
+ identity: HostedScanIdentity;
207
+ jobKey: string;
208
+ requestedAt: string;
209
+ installationId: number;
210
+ selectedRepositoryIds: number[];
211
+ removedRepositoryIds?: number[];
212
+ installationTokenPermissions: {
213
+ contents?: string;
214
+ };
215
+ checkoutRoot?: string;
216
+ untrustedRepositoryFullName?: string;
217
+ untrustedTokenPermissions?: unknown;
218
+ untrustedCommand?: string;
219
+ untrustedPrText?: string;
220
+ rawSource?: string;
221
+ rawDiff?: string;
222
+ secretValues?: string[];
223
+ customerPayload?: unknown;
224
+ }
225
+ export interface HostedWorkerReadOnlyScanPlan {
226
+ accepted: boolean;
227
+ reason?: HostedWorkerReadOnlyScanRejectReason;
228
+ jobKey: string;
229
+ requestedAt: string;
230
+ readOnly: true;
231
+ shouldFetchSource: boolean;
232
+ shouldRunCli: boolean;
233
+ shouldPersistRawSource: false;
234
+ shouldPersistRawDiffs: false;
235
+ shouldCreatePrComment: false;
236
+ installationTokenScope?: {
237
+ installationId: number;
238
+ repositoryId: number;
239
+ permissions: {
240
+ contents: "read";
241
+ };
242
+ selectedRepositoryOnly: true;
243
+ };
244
+ checkout?: {
245
+ repositoryId: number;
246
+ repositoryFullName: string;
247
+ pullRequestNumber: number;
248
+ baseSha: string;
249
+ targetCommitSha: string;
250
+ directoryScope: "temporary_worker_directory";
251
+ cleanupRequired: true;
252
+ returnsCheckoutPath: false;
253
+ };
254
+ cli?: {
255
+ command: "ai-saas-guard";
256
+ args: string[];
257
+ workingDirectory: "<worker-checkout>";
258
+ networkAccess: "disabled";
259
+ writeMode: "read_only";
260
+ };
261
+ output?: {
262
+ compactJsonOnly: true;
263
+ persistRawSource: false;
264
+ persistRawDiffs: false;
265
+ persistSecrets: false;
266
+ persistCustomerPayloads: false;
267
+ };
268
+ privacy: {
269
+ returnsCheckoutPath: false;
270
+ includesRawSource: false;
271
+ includesRawDiffs: false;
272
+ includesSecrets: false;
273
+ includesCustomerPayloads: false;
274
+ acceptsRepositoryIdentityFromPrText: false;
275
+ acceptsTokenScopeFromPrText: false;
276
+ acceptsCommandFromPrText: false;
277
+ };
278
+ }
204
279
  export type HostedWorkerCheckoutCleanupAction = "delete_checkout" | "record_cleanup_failure";
205
280
  export interface HostedWorkerCheckoutCleanupInput {
206
281
  identity: HostedScanIdentity;
@@ -361,6 +436,7 @@ export declare function getHostedQueueCleanupIdempotencyKey(input: {
361
436
  repositoryId?: number;
362
437
  }): string;
363
438
  export declare function createHostedQueueCleanupPlan(input: HostedQueueCleanupPlanInput): HostedQueueCleanupPlan;
439
+ export declare function planHostedWorkerReadOnlyScan(input: HostedWorkerReadOnlyScanInput): HostedWorkerReadOnlyScanPlan;
364
440
  export declare function createHostedWorkerCheckoutCleanupPlan(input: HostedWorkerCheckoutCleanupInput): HostedWorkerCheckoutCleanupPlan;
365
441
  export declare function resolveHostedRetentionDays(input?: {
366
442
  teamRequestedDays?: number;
@@ -332,6 +332,69 @@ export function createHostedQueueCleanupPlan(input) {
332
332
  deleteCustomerPayloads: false
333
333
  };
334
334
  }
335
+ export function planHostedWorkerReadOnlyScan(input) {
336
+ const scopeDecision = authorizeInstallationTokenScope({
337
+ identity: input.identity,
338
+ installationId: input.installationId,
339
+ selectedRepositoryIds: input.selectedRepositoryIds,
340
+ removedRepositoryIds: input.removedRepositoryIds
341
+ });
342
+ if (!scopeDecision.authorized) {
343
+ return rejectHostedWorkerReadOnlyScan(input, scopeDecision.reason ?? "repository_not_installed");
344
+ }
345
+ if (input.installationTokenPermissions.contents !== "read") {
346
+ return rejectHostedWorkerReadOnlyScan(input, "contents_read_permission_required");
347
+ }
348
+ return {
349
+ accepted: true,
350
+ jobKey: input.jobKey,
351
+ requestedAt: input.requestedAt,
352
+ readOnly: true,
353
+ shouldFetchSource: true,
354
+ shouldRunCli: true,
355
+ shouldPersistRawSource: false,
356
+ shouldPersistRawDiffs: false,
357
+ shouldCreatePrComment: false,
358
+ installationTokenScope: {
359
+ installationId: input.identity.installationId,
360
+ repositoryId: input.identity.repositoryId,
361
+ permissions: { contents: "read" },
362
+ selectedRepositoryOnly: true
363
+ },
364
+ checkout: {
365
+ repositoryId: input.identity.repositoryId,
366
+ repositoryFullName: input.identity.repositoryFullName,
367
+ pullRequestNumber: input.identity.pullRequestNumber,
368
+ baseSha: input.identity.baseSha,
369
+ targetCommitSha: input.identity.headSha,
370
+ directoryScope: "temporary_worker_directory",
371
+ cleanupRequired: true,
372
+ returnsCheckoutPath: false
373
+ },
374
+ cli: {
375
+ command: "ai-saas-guard",
376
+ args: [
377
+ "pr-risk",
378
+ "--root",
379
+ "<worker-checkout>",
380
+ "--base",
381
+ input.identity.baseSha,
382
+ "--json"
383
+ ],
384
+ workingDirectory: "<worker-checkout>",
385
+ networkAccess: "disabled",
386
+ writeMode: "read_only"
387
+ },
388
+ output: {
389
+ compactJsonOnly: true,
390
+ persistRawSource: false,
391
+ persistRawDiffs: false,
392
+ persistSecrets: false,
393
+ persistCustomerPayloads: false
394
+ },
395
+ privacy: hostedWorkerReadOnlyScanPrivacy()
396
+ };
397
+ }
335
398
  export function createHostedWorkerCheckoutCleanupPlan(input) {
336
399
  const cleanupFailed = input.terminalState === "cleanup_failure";
337
400
  return {
@@ -537,6 +600,33 @@ function hostedScanQueuePrivacy() {
537
600
  includesCustomerPayloads: false
538
601
  };
539
602
  }
603
+ function rejectHostedWorkerReadOnlyScan(input, reason) {
604
+ return {
605
+ accepted: false,
606
+ reason,
607
+ jobKey: input.jobKey,
608
+ requestedAt: input.requestedAt,
609
+ readOnly: true,
610
+ shouldFetchSource: false,
611
+ shouldRunCli: false,
612
+ shouldPersistRawSource: false,
613
+ shouldPersistRawDiffs: false,
614
+ shouldCreatePrComment: false,
615
+ privacy: hostedWorkerReadOnlyScanPrivacy()
616
+ };
617
+ }
618
+ function hostedWorkerReadOnlyScanPrivacy() {
619
+ return {
620
+ returnsCheckoutPath: false,
621
+ includesRawSource: false,
622
+ includesRawDiffs: false,
623
+ includesSecrets: false,
624
+ includesCustomerPayloads: false,
625
+ acceptsRepositoryIdentityFromPrText: false,
626
+ acceptsTokenScopeFromPrText: false,
627
+ acceptsCommandFromPrText: false
628
+ };
629
+ }
540
630
  function parseJsonPayload(payload) {
541
631
  try {
542
632
  return JSON.parse(Buffer.isBuffer(payload) ? payload.toString("utf8") : payload);
@@ -2,7 +2,7 @@
2
2
 
3
3
  `ai-saas-guard` ships as a composite GitHub Action for pull request and code scanning workflows.
4
4
 
5
- Use `zr9959/ai-saas-guard@v0` for the latest compatible pre-1.0 Action. Use a specific tag such as `v0.12.0` or a reviewed commit SHA when reproducibility is more important than automatic minor updates.
5
+ Use `zr9959/ai-saas-guard@v0` for the latest compatible pre-1.0 Action. Use a specific tag such as `v0.13.0` or a reviewed commit SHA when reproducibility is more important than automatic minor updates.
6
6
 
7
7
  ## PR Summary
8
8
 
@@ -47,6 +47,29 @@ Queue payload boundaries:
47
47
 
48
48
  The exported helper is `planHostedScanQueueUpsert`. It is intended to be the queue-provider-independent contract for the first real hosted queue implementation.
49
49
 
50
+ ## Worker Read-Only Scan Planner
51
+
52
+ The worker read-only scan planner defines how a future hosted worker should prepare a scan after the durable queue hands it a trusted job. It is a pure planner only: it does not request installation tokens, create directories, checkout repositories, run the CLI, persist reports, delete files, or call GitHub APIs.
53
+
54
+ Default behavior:
55
+
56
+ - authorize the same installation and selected-repository scope before any checkout is planned
57
+ - require installation token permissions to be repository `contents: read`
58
+ - derive repository ID, repository full name, pull request number, base SHA, head SHA, and scanner version only from trusted scan identity
59
+ - plan checkout of the trusted head commit into a temporary worker directory
60
+ - plan a fixed read-only CLI invocation: `ai-saas-guard pr-risk --root <worker-checkout> --base <baseSha> --json`
61
+ - collect compact JSON output only
62
+ - require checkout cleanup after every terminal worker state
63
+ - keep PR comments disabled for the first hosted slice
64
+
65
+ Trust boundaries:
66
+
67
+ - ignore PR-authored repository names, token scopes, and commands
68
+ - do not accept worker command, checkout target, installation ID, repository ID, repository name, or token permissions from PR title, body, comments, branch names, README, or code
69
+ - do not return checkout paths, raw source, raw diffs, secret values, customer payloads, private URLs, or installation token values
70
+
71
+ The exported helper is `planHostedWorkerReadOnlyScan`. It is intended to be the worker-provider-independent contract for the first real hosted worker implementation.
72
+
50
73
  ## Webhook Event Parser
51
74
 
52
75
  The webhook event parser runs after webhook signature verification. It converts a reduced GitHub `pull_request` webhook payload into a queue-safe scan request identity.
@@ -189,6 +212,9 @@ Automated tests must cover:
189
212
  - duplicate deliveries reuse queued, running, and completed jobs without enqueueing duplicate worker work
190
213
  - completed duplicate jobs reuse compact reports
191
214
  - manual reruns increment attempt without changing the logical scan key
215
+ - worker read-only scan planning requires repository `contents: read` permissions
216
+ - worker read-only scan planning uses trusted identity for checkout target and fixed CLI command
217
+ - worker read-only scan planning does not persist raw source, raw diffs, secrets, customer payloads, checkout paths, PR-authored commands, or PR-authored token scopes
192
218
  - accepted pull request events build the expected trusted scan identity
193
219
  - unsupported actions are rejected
194
220
  - draft pull requests are rejected by default
@@ -5,10 +5,10 @@
5
5
  ## Current State
6
6
 
7
7
  - Package name: `ai-saas-guard`
8
- - Current version: `0.12.0`
8
+ - Current version: `0.13.0`
9
9
  - npm registry state: published at <https://www.npmjs.com/package/ai-saas-guard>
10
10
  - First npm-published version: `0.1.1`
11
- - GitHub Release: `v0.12.0`
11
+ - GitHub Release: `v0.13.0`
12
12
  - Publish workflow: `.github/workflows/npm-publish.yml`
13
13
  - Trusted Publisher: GitHub Actions, `zr9959/ai-saas-guard`, workflow `npm-publish.yml`, allowed action `npm publish`
14
14
  - Long-lived npm publish token: not required
@@ -17,7 +17,7 @@
17
17
 
18
18
  Use GitHub Actions with npm Trusted Publisher/OIDC:
19
19
 
20
- 1. Create and review a release tag such as `v0.12.0`.
20
+ 1. Create and review a release tag such as `v0.13.0`.
21
21
  2. Publish from the GitHub Release or run the `Publish npm` workflow manually with `ref` set to that tag.
22
22
  3. Keep `permissions.id-token: write` in the workflow so npm can exchange the GitHub Actions OIDC identity for a short-lived publish credential.
23
23
  4. Run `npm publish --access public` from the workflow. Trusted publishing automatically generates provenance for this public package from this public repository.
@@ -57,7 +57,7 @@ Implemented surfaces:
57
57
  - hosted operational release gate document requiring hosted CI, webhook replay, dependency and container scanning, privacy and retention verification, worker cleanup, monitoring and alerting, manual rollback, and incident response evidence before exposure
58
58
  - hosted uninstall and data deletion document defining repository removal, full app uninstall, compact report deletion, queue cancellation, audit record retention, repeated cleanup idempotency, and user-facing deletion wording
59
59
  - hosted pricing and packaging document defining open-source CLI boundaries, free/public repo hosted behavior, private repo hosted behavior, PR comments, saved reports, team policy, optional Launch Review, and no pentest/certification/full-audit claims
60
- - hosted pre-implementation contracts document, hosted compact report fixture, and pure helpers for pull request webhook intake planning, durable scan queue upsert planning, queue-safe pull request event parsing from trusted GitHub event fields, bounded check-run summary rendering, idempotent queue cleanup planning, and worker checkout cleanup planning
60
+ - hosted pre-implementation contracts document, hosted compact report fixture, and pure helpers for pull request webhook intake planning, durable scan queue upsert planning, worker read-only scan planning, queue-safe pull request event parsing from trusted GitHub event fields, bounded check-run summary rendering, idempotent queue cleanup planning, and worker checkout cleanup planning
61
61
  - implementation-ready hosted GitHub App permission contract for required permissions, optional PR comment permissions, selected repository installation, and out-of-scope broad permissions
62
62
  - pure hosted GitHub App contract helpers and tests for webhook intake order, webhook verification, installation token scoping, durable scan queue idempotency, compact reports, and retention limits
63
63
  - GitHub issue templates for bug reports, false positives, false negatives, rule requests, and public-safe security reports
@@ -114,19 +114,20 @@ GitHub Project:
114
114
  Current issue set:
115
115
 
116
116
  - Closed hosted MVP issue: #24 webhook intake.
117
- - Open hosted MVP roadmap issues: #25 idempotent queue contract, #26 read-only worker checkout, #27 Check summaries, #28 retention/uninstall cleanup, and #29 hosted operational release gate.
117
+ - Closed hosted MVP issue: #25 idempotent queue contract.
118
+ - Open hosted MVP roadmap issues: #26 read-only worker checkout, #27 Check summaries, #28 retention/uninstall cleanup, and #29 hosted operational release gate.
118
119
 
119
120
  CI:
120
121
 
121
122
  - Workflow: `.github/workflows/ci.yml`
122
123
  - Runs on pull requests and pushes to `main`
123
124
  - Uses `permissions: contents: read`
124
- - Latest verified run for the hosted report fixture batch succeeded
125
+ - Latest verified run for the hosted durable queue contract release succeeded
125
126
 
126
127
  Publishing:
127
128
 
128
129
  - npm package: `ai-saas-guard`
129
- - Current release line: `v0.12.0`
130
+ - Current release line: `v0.13.0`
130
131
  - Publish workflow: `.github/workflows/npm-publish.yml`
131
132
  - Trusted Publisher: GitHub Actions for `zr9959/ai-saas-guard`, workflow `npm-publish.yml`
132
133
  - Long-lived npm publish tokens should not be required.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-saas-guard",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Repo-local launch-readiness scanner for AI-built SaaS apps.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/zr9959/ai-saas-guard#readme",