@rebasepro/rls-check 0.23.0 → 0.24.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.
@@ -165,6 +165,25 @@ export declare function readReferencedRelations(db: Reader, refs: {
165
165
  * both, so `rls-disabled` and `anonymous-write-allowed` said nothing.
166
166
  */
167
167
  export declare function readGrants(db: Reader, schemas: string[]): Promise<DbGrant[]>;
168
+ /**
169
+ * Who holds USAGE on each schema. Every schema, not only the scanned ones: a
170
+ * view or a foreign key can point outside the scan.
171
+ *
172
+ * `undefined`, not `[]`, when the read failed — an empty list would say no role
173
+ * can use any schema and silence every check that gates on a grant, which is
174
+ * the wrong direction for a scanner to fail in.
175
+ */
176
+ export declare function readSchemaUsage(db: Reader, diagnostics: IntrospectDiagnostics): Promise<{
177
+ schema: string;
178
+ grantee: string;
179
+ }[] | undefined>;
180
+ export declare function readViews(db: Reader, schemas: string[], serverVersionNum: number): Promise<DbView[]>;
181
+ /**
182
+ * Postgres's `parse_bool`: `true`/`false`, `yes`/`no`, `on`/`off`, `1`/`0`,
183
+ * case-insensitively, and any unambiguous prefix of the words — `t`, `ye`,
184
+ * `of` — but not `o`, which could be either. `null` for anything else.
185
+ */
186
+ export declare function parsePgBool(raw: string): boolean | null;
168
187
  export interface ViewDependencyRow extends Record<string, unknown> {
169
188
  view_schema: string;
170
189
  view_name: string;
package/dist/types.d.ts CHANGED
@@ -175,6 +175,18 @@ export interface DbSnapshot {
175
175
  policies: DbPolicy[];
176
176
  roles: DbRole[];
177
177
  grants: DbGrant[];
178
+ /**
179
+ * Who holds USAGE on each schema, from `pg_namespace.nspacl` (`PUBLIC` for
180
+ * a grant to everyone). A role without it cannot name anything in the
181
+ * schema, whatever it holds on the tables there. Absent when it could not
182
+ * be read, and a schema with no entries here counts as unknown: either way
183
+ * every role is assumed to have USAGE, which widens a scan rather than
184
+ * narrowing it.
185
+ */
186
+ schemaUsage?: {
187
+ schema: string;
188
+ grantee: string;
189
+ }[];
178
190
  views: DbView[];
179
191
  foreignKeys: DbForeignKey[];
180
192
  routines: DbRoutine[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/rls-check",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Audit Row-Level Security on any PostgreSQL database — finds tables served without RLS, permissive tautologies, unqualified columns in policy subqueries, RLS-bypassing views and unprotected junction tables. Read-only.",
5
5
  "keywords": [
6
6
  "postgres",