@rebasepro/rls-check 0.29.0 → 0.29.2
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 +5 -1
- package/dist/cli.d.ts +8 -0
- package/dist/index.es.js +84 -32
- package/dist/index.es.js.map +1 -1
- package/dist/introspect.d.ts +27 -0
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/introspect.d.ts
CHANGED
|
@@ -14,6 +14,15 @@ export interface ConnectOptions {
|
|
|
14
14
|
* the safe direction of a wrong guess is more findings, not fewer.
|
|
15
15
|
*/
|
|
16
16
|
roles?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The role(s) a Rebase app on this database runs requests as, when it is
|
|
19
|
+
* not `rebase_user` (`rls.requestRole` / `REBASE_RLS_REQUEST_ROLE`).
|
|
20
|
+
* Replaces `rebase_user` in {@link CANDIDATE_EXPOSED_ROLES} and in the
|
|
21
|
+
* checks that treat Rebase's request role specially. Without it, the roles
|
|
22
|
+
* the database recorded in `rebase.schema_meta` are used, then
|
|
23
|
+
* `rebase_user`.
|
|
24
|
+
*/
|
|
25
|
+
requestRoles?: string[];
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
28
|
* Facts about *the scan* rather than about the database.
|
|
@@ -93,6 +102,13 @@ export declare class UnknownSchemaError extends Error {
|
|
|
93
102
|
readonly schemas: string[];
|
|
94
103
|
constructor(schemas: string[]);
|
|
95
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Which roles are this database's Rebase request roles: the ones named with
|
|
107
|
+
* `--request-role`, else the ones a Rebase boot recorded in
|
|
108
|
+
* `rebase.schema_meta` (a comma-separated `request_roles` value), else
|
|
109
|
+
* `rebase_user`.
|
|
110
|
+
*/
|
|
111
|
+
export declare function resolveRequestRoles(explicit: string[] | undefined, recorded: string | null | undefined): string[];
|
|
96
112
|
export declare function introspect(opts: ConnectOptions): Promise<DbSnapshot>;
|
|
97
113
|
export declare function introspectWithDiagnostics(opts: ConnectOptions): Promise<IntrospectResult>;
|
|
98
114
|
type SslOption = false | {
|
|
@@ -221,4 +237,15 @@ export declare function resolveViewDependencies(rows: ViewDependencyRow[]): Map<
|
|
|
221
237
|
* rather than inventing or hiding a finding.
|
|
222
238
|
*/
|
|
223
239
|
export declare function detectPlatform(allSchemas: string[], roles: DbRole[]): DbSnapshot["platform"];
|
|
240
|
+
/**
|
|
241
|
+
* Roles an untrusted caller plausibly arrives as.
|
|
242
|
+
*
|
|
243
|
+
* `service_role` is excluded on purpose. It exists, and it is in `roles`, but it
|
|
244
|
+
* is the *trusted* bypass identity: treating it as exposed would flag every
|
|
245
|
+
* table in every Supabase project as critical, which is both useless and wrong.
|
|
246
|
+
*
|
|
247
|
+
* `connecting` is the role the scan came in as, passed only when it is not
|
|
248
|
+
* privileged — see the call site.
|
|
249
|
+
*/
|
|
250
|
+
export declare function exposedRolesFor(roles: DbRole[], requestRoles: string[], explicit?: string[], connecting?: string): string[];
|
|
224
251
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** Ordered least → most severe; the CLI's `--fail-on` compares by index. */
|
|
14
14
|
export declare const SEVERITIES: readonly ["info", "low", "medium", "high", "critical"];
|
|
15
|
+
/** The role a Rebase app runs every request as when nothing names another (`rls.requestRole`). */
|
|
16
|
+
export declare const DEFAULT_REBASE_REQUEST_ROLE = "rebase_user";
|
|
15
17
|
export type Severity = (typeof SEVERITIES)[number];
|
|
16
18
|
/** What a finding points at. `table` is absent for database-wide findings. */
|
|
17
19
|
export interface FindingTarget {
|
|
@@ -169,6 +171,13 @@ export interface DbSnapshot {
|
|
|
169
171
|
* that list must name it or the checks have nothing to gate on.
|
|
170
172
|
*/
|
|
171
173
|
exposedRoles: string[];
|
|
174
|
+
/**
|
|
175
|
+
* The role(s) a Rebase app runs every request as, signed in or not: those
|
|
176
|
+
* named with `--request-role`, else the ones the database recorded in
|
|
177
|
+
* `rebase.schema_meta` (`request_roles`), else `rebase_user`. Absent on a
|
|
178
|
+
* snapshot built by hand, which means `rebase_user`.
|
|
179
|
+
*/
|
|
180
|
+
requestRoles?: string[];
|
|
172
181
|
/** Detected platform, which changes the wording of several findings. */
|
|
173
182
|
platform: "supabase" | "neon" | "rebase" | "postgrest" | "unknown";
|
|
174
183
|
relations: DbRelation[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/rls-check",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.2",
|
|
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",
|