@vantageos/backend-doctor 0.1.14 → 0.3.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.
Files changed (93) hide show
  1. package/README.md +66 -5
  2. package/dist/args.d.ts +16 -0
  3. package/dist/args.js +72 -0
  4. package/dist/build-stamp.d.ts +13 -0
  5. package/dist/build-stamp.js +76 -0
  6. package/dist/build-stamp.json +4 -0
  7. package/dist/caller-resolution.d.ts +222 -0
  8. package/dist/caller-resolution.js +1198 -0
  9. package/dist/cli.js +249 -17
  10. package/dist/contract.d.ts +25 -7
  11. package/dist/contract.js +52 -7
  12. package/dist/coverage-cli.js +8 -0
  13. package/dist/coverage.d.ts +1 -1
  14. package/dist/coverage.js +2 -2
  15. package/dist/detectors/oracle-axis1.d.ts +5 -3
  16. package/dist/detectors/oracle-axis1.js +28 -18
  17. package/dist/detectors/oracle-axis2.d.ts +6 -0
  18. package/dist/detectors/oracle-axis2.js +37 -22
  19. package/dist/detectors/predicates.d.ts +3 -0
  20. package/dist/detectors/predicates.js +93 -19
  21. package/dist/detectors/shared.js +8 -7
  22. package/dist/detectors/source/_ast.d.ts +92 -0
  23. package/dist/detectors/source/_ast.js +353 -0
  24. package/dist/detectors/source/_scan.js +4 -3
  25. package/dist/detectors/source/backfill.js +71 -18
  26. package/dist/detectors/source/contract.js +21 -13
  27. package/dist/detectors/source/cross-tenant-write.d.ts +46 -0
  28. package/dist/detectors/source/cross-tenant-write.js +1408 -0
  29. package/dist/detectors/source/guard-helper-flow.d.ts +134 -0
  30. package/dist/detectors/source/guard-helper-flow.js +1216 -0
  31. package/dist/detectors/source/identity-by-id.d.ts +80 -0
  32. package/dist/detectors/source/identity-by-id.js +1783 -0
  33. package/dist/detectors/source/identity.d.ts +58 -2
  34. package/dist/detectors/source/identity.js +1158 -28
  35. package/dist/detectors/source/isolation.d.ts +11 -1
  36. package/dist/detectors/source/isolation.js +106 -25
  37. package/dist/detectors/source/jobs.js +178 -4
  38. package/dist/detectors/source/lifecycle.js +14 -2
  39. package/dist/detectors/source/local-identity.d.ts +26 -0
  40. package/dist/detectors/source/local-identity.js +661 -0
  41. package/dist/detectors/source/package-principal.d.ts +9 -0
  42. package/dist/detectors/source/package-principal.js +177 -0
  43. package/dist/detectors/source/r6-shapes.d.ts +20 -0
  44. package/dist/detectors/source/r6-shapes.js +285 -0
  45. package/dist/detectors/source/readbudget.d.ts +1 -0
  46. package/dist/detectors/source/readbudget.js +358 -4
  47. package/dist/detectors/source/recipient-by-id.d.ts +40 -0
  48. package/dist/detectors/source/recipient-by-id.js +1108 -0
  49. package/dist/detectors/source/refusal.d.ts +14 -0
  50. package/dist/detectors/source/refusal.js +75 -2
  51. package/dist/detectors/source/security.d.ts +16 -0
  52. package/dist/detectors/source/security.js +680 -33
  53. package/dist/detectors/source/write-isolation.d.ts +8 -1
  54. package/dist/detectors/source/write-isolation.js +64 -30
  55. package/dist/detectors/source/writesafety.js +27 -14
  56. package/dist/detectors/standard/_doc.d.ts +1 -1
  57. package/dist/detectors/standard/_doc.js +5 -4
  58. package/dist/detectors/standard/r41-frontier.js +3 -2
  59. package/dist/detectors/standard/r46-returns-validator.d.ts +8 -0
  60. package/dist/detectors/standard/r46-returns-validator.js +48 -16
  61. package/dist/detectors/structural.d.ts +6 -7
  62. package/dist/detectors/structural.js +84 -48
  63. package/dist/not-checkable.d.ts +1 -1
  64. package/dist/not-checkable.js +11 -0
  65. package/dist/oracle.d.ts +92 -3
  66. package/dist/oracle.js +229 -12
  67. package/dist/registry.d.ts +8 -1
  68. package/dist/registry.js +74 -8
  69. package/dist/report.d.ts +11 -1
  70. package/dist/report.js +15 -2
  71. package/dist/rule-class.d.ts +85 -0
  72. package/dist/rule-class.js +218 -0
  73. package/dist/state-rank.d.ts +5 -0
  74. package/dist/state-rank.js +9 -0
  75. package/dist/tally.d.ts +13 -5
  76. package/dist/tally.js +15 -13
  77. package/dist/target.d.ts +32 -0
  78. package/dist/target.js +173 -0
  79. package/dist/violation-count.d.ts +48 -0
  80. package/dist/violation-count.js +94 -0
  81. package/fixtures/backend-standard-2825122.md +722 -0
  82. package/fixtures/backend-standard-4dcd3e0.md +722 -0
  83. package/fixtures/cr1-classes/_generated/api.d.ts +24 -0
  84. package/fixtures/cr1-classes/surface.ts +206 -0
  85. package/fixtures/cr1-empty/nothing.ts +1 -0
  86. package/fixtures/cr1-refusal-on-resolved/_generated/api.d.ts +24 -0
  87. package/fixtures/cr1-refusal-on-resolved/doors.ts +180 -0
  88. package/fixtures/cr1-refusal-on-resolved/lib/auth.ts +104 -0
  89. package/fixtures/r34-vp-auth-30e821b/auth-805-812.ts.txt +8 -0
  90. package/fixtures/r34-vp-auth-30e821b/auth-878-890.ts.txt +13 -0
  91. package/fixtures/rule-classes-2825122.json +228 -0
  92. package/fixtures/vp-writer-tier-1e4ab36.csv +55 -0
  93. package/package.json +2 -2
@@ -0,0 +1,80 @@
1
+ import * as ts from "typescript";
2
+ import type { Detector } from "../../engine-types.js";
3
+ import { type FnDef, type Parsed, type SrcFile } from "./_ast.js";
4
+ import { type Scan, type SourceDetectorEntry } from "./_scan.js";
5
+ export declare const IDENTITY_PACKAGE = "@vantageos/cloud-identity";
6
+ export declare const R53_ID = "R-53 an actor and a target are identified by ID through @vantageos/cloud-identity; a name never selects or authorises a row";
7
+ /** Name fields: a display label that must never be an admission operand. */
8
+ export declare const NAME_TOKENS: ReadonlySet<string>;
9
+ /** The package's principal resolvers: the ONLY sinks a host credential read
10
+ * may feed (first argument). The package verifies nothing about the credential
11
+ * (cloud-identity 0.11.0 `principal-by-id.d.ts:37`, `person-principal.d.ts:28`),
12
+ * so the host MUST read `ctx.auth` and hand the claims over; the read is a local
13
+ * identity decision only when its value goes anywhere else. */
14
+ export declare const PACKAGE_RESOLVERS: ReadonlySet<string>;
15
+ /** Name comparisons in a node's OWN body: `a === b` with a name on one side
16
+ * and no literal on either, or `names.includes(x)` over a name list. */
17
+ export declare function nameComparisons(n: ts.Node): ts.Node[];
18
+ /** The package's own target check (cloud-identity `principal-by-id`):
19
+ * `assertTargetBelongsTo(principal, { orgId, ownerId? }, opts?)` at a6e5780,
20
+ * `await assertTargetBelongsTo(principal, target, lookups, opts?)` at PR #21. */
21
+ export declare const TARGET_CHECK = "assertTargetBelongsTo";
22
+ /** A file's bindings of the package: local name -> exported name for a named
23
+ * import (aliases resolved), and the locals bound to a namespace import. */
24
+ interface PkgImports {
25
+ named: Map<string, string>;
26
+ namespaces: Set<string>;
27
+ }
28
+ export declare function importsOf(p: Parsed): {
29
+ pkg: Set<string>;
30
+ imports: PkgImports;
31
+ unresolved: boolean;
32
+ };
33
+ /** The package export a callee names, through the file's own import of it
34
+ * (`assertTargetBelongsTo`, `x as y`, `identity.assertTargetBelongsTo`). */
35
+ export declare function pkgExportOf(callee: ts.Expression, imp: PkgImports): string | undefined;
36
+ /** `!v.ok`, `v.ok === false`, `v.ok !== true` (either operand order). */
37
+ export declare function refusesOnNotOk(c0: ts.Expression, v: string): boolean;
38
+ export declare class HostReadFlow {
39
+ private readonly parsed;
40
+ private readonly fns;
41
+ private readonly pkgImports;
42
+ private readonly defOf;
43
+ private readonly memo;
44
+ constructor(parsed: Parsed[], fns: Map<string, FnDef[]>, pkgImports: Map<string, PkgImports>);
45
+ /** Every `getUserIdentity()` call in `n` whose value does NOT end only in a
46
+ * package resolver. */
47
+ unsanctioned(n: ts.Node): ts.CallExpression[];
48
+ sanctioned(read: ts.CallExpression): boolean;
49
+ /** Does the value of expression `e` reach ONLY package resolvers? */
50
+ private flows;
51
+ private bindingFlows;
52
+ /** One read of a bound value: an absence test forwarded to the package, or
53
+ * a value that flows on. */
54
+ private refFlows;
55
+ /** A function's return reaches only package resolvers, at EVERY call site. */
56
+ private returnFlows;
57
+ }
58
+ export declare const ORG_KIND_ADAPTER = "orgKindOf";
59
+ export declare const ORG_BY_ID_ADAPTER = "organisationById";
60
+ /** The host adapters that may hold the ID-keyed mapping read. */
61
+ export declare const ORG_ID_ADAPTERS: ReadonlySet<string>;
62
+ export declare const ORG_ID_INDEX = "by_clerk_org_id";
63
+ export declare const ORG_ID_FIELD = "clerkOrgId";
64
+ /**
65
+ * The `client_org_mapping` reads the org-kind ruling admits (see OrgKindReads),
66
+ * computed over `parsed` so a caller holding the same AST nodes can test
67
+ * membership. Exported for CR-2 (local-identity.ts), which must not re-derive
68
+ * R-53's ruling.
69
+ */
70
+ export declare function conformantMappingReads(parsed: Parsed[]): Set<ts.CallExpression>;
71
+ export interface R53Detail {
72
+ scan: Scan;
73
+ doors: number;
74
+ gates: number;
75
+ }
76
+ export declare function scanR53(files: SrcFile[]): Scan;
77
+ export declare function scanR53Detailed(files: SrcFile[]): R53Detail;
78
+ export declare const R53: Detector;
79
+ export declare const SOURCE_IDENTITY_BY_ID_DETECTORS: SourceDetectorEntry[];
80
+ export {};