@checkstack/dependency-common 1.2.4 → 1.2.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @checkstack/dependency-common
2
2
 
3
+ ## 1.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - f9cfdae: fix(dependency): gate the dependency map behind its own non-public access rule
8
+
9
+ Anonymous users could see the "Dependency Map" nav entry and open the page
10
+ (which then rendered empty) because the map was gated by `dependency.read`,
11
+ which is public so that dependency _warning_ badges stay visible on the
12
+ catalog and dashboard.
13
+
14
+ The full topology map is now gated by a dedicated `dependency.map` access
15
+ rule that is granted to authenticated users by default but is NOT public, so
16
+ anonymous visitors no longer see the nav entry or reach the page. The
17
+ `getAllDependencies`, `getNodePositions`, and `saveNodePositions` endpoints
18
+ move to this rule too, and the dashboard dependency signal now renders as
19
+ plain text (not a map link) for users without map access. Per-system
20
+ dependency warnings stay on the public `dependency.read` rule, so warning
21
+ badges/alerts/signals remain visible to everyone as before.
22
+
23
+ Admins can still grant `dependency.map` to the anonymous role to make the
24
+ map public again.
25
+
26
+ Note: the default-rule sync is add-only, so on existing deployments the
27
+ anonymous role keeps any rules already granted. Since `dependency.map` is a
28
+ brand-new rule the anonymous role never had it, so the map is hidden from
29
+ anonymous users immediately after upgrade with no admin action required.
30
+
3
31
  ## 1.2.4
4
32
 
5
33
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/dependency-common",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/access.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { accessPair } from "@checkstack/common";
1
+ import { access, accessPair } from "@checkstack/common";
2
2
  import { pluginMetadata } from "./plugin-metadata";
3
3
 
4
4
  /**
@@ -7,13 +7,17 @@ import { pluginMetadata } from "./plugin-metadata";
7
7
  export const dependencyAccess = {
8
8
  /**
9
9
  * Dependency access with both read and manage levels.
10
- * Read is public by default so all users can see dependency warnings.
10
+ *
11
+ * Read is public by default so unauthenticated visitors can still see the
12
+ * dependency *warning* badges/alerts/signals on the catalog and dashboard.
13
+ * It does NOT grant the full topology map - that is gated separately by
14
+ * `dependencyAccess.map` (below).
11
15
  */
12
16
  dependency: accessPair(
13
17
  "dependency",
14
18
  {
15
19
  read: {
16
- description: "View system dependencies and dependency warnings",
20
+ description: "View dependency warnings on systems and the dashboard",
17
21
  isDefault: true,
18
22
  isPublic: true,
19
23
  },
@@ -27,6 +31,22 @@ export const dependencyAccess = {
27
31
  pluginId: pluginMetadata.pluginId,
28
32
  },
29
33
  ),
34
+
35
+ /**
36
+ * Access to the dependency map (the full system-topology graph) - its nav
37
+ * entry, page, and full-graph/canvas endpoints.
38
+ *
39
+ * Deliberately NOT public: the map exposes the entire system topology, so
40
+ * anonymous visitors must not get it by default. Authenticated users get it
41
+ * by default (`isDefault`). Per-system dependency warnings stay on the public
42
+ * `dependency.read` rule, so withholding the map does not hide warning badges.
43
+ * Admins can still grant this rule to the anonymous role to make the map
44
+ * public again.
45
+ */
46
+ map: access("map", "read", "View the dependency map (full system topology)", {
47
+ isDefault: true,
48
+ pluginId: pluginMetadata.pluginId,
49
+ }),
30
50
  };
31
51
 
32
52
  /**
@@ -35,4 +55,5 @@ export const dependencyAccess = {
35
55
  export const dependencyAccessRules = [
36
56
  dependencyAccess.dependency.read,
37
57
  dependencyAccess.dependency.manage,
58
+ dependencyAccess.map,
38
59
  ];
@@ -33,11 +33,14 @@ export const dependencyContract = {
33
33
  )
34
34
  .output(z.object({ dependencies: z.array(DependencySchema) })),
35
35
 
36
- /** Get the full dependency graph (all dependencies, for the canvas) */
36
+ /**
37
+ * Get the full dependency graph (all dependencies, for the canvas).
38
+ * Gated by the map rule - the full topology is map-only, not public.
39
+ */
37
40
  getAllDependencies: proc({
38
41
  operationType: "query",
39
42
  userType: "public",
40
- access: [dependencyAccess.dependency.read],
43
+ access: [dependencyAccess.map],
41
44
  }).output(z.object({ dependencies: z.array(DependencySchema) })),
42
45
 
43
46
  /** Bulk-fetch derived warnings for multiple systems (for dashboard badges) */
@@ -101,20 +104,21 @@ export const dependencyContract = {
101
104
 
102
105
  // ==========================================================================
103
106
  // NODE POSITIONS (authenticated - per-user canvas layout persistence)
107
+ // Gated by the map rule - canvas layout only matters to map viewers.
104
108
  // ==========================================================================
105
109
 
106
110
  /** Get saved node positions for the dependency map canvas */
107
111
  getNodePositions: proc({
108
112
  operationType: "query",
109
113
  userType: "user",
110
- access: [dependencyAccess.dependency.read],
114
+ access: [dependencyAccess.map],
111
115
  }).output(z.object({ positions: z.array(NodePositionSchema) })),
112
116
 
113
117
  /** Save node positions for the dependency map canvas */
114
118
  saveNodePositions: proc({
115
119
  operationType: "mutation",
116
120
  userType: "user",
117
- access: [dependencyAccess.dependency.read],
121
+ access: [dependencyAccess.map],
118
122
  })
119
123
  .input(z.object({ positions: z.array(NodePositionSchema) }))
120
124
  .output(z.object({ success: z.boolean() })),
@@ -0,0 +1,58 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { isAccessRuleSatisfied } from "@checkstack/common";
3
+ import {
4
+ dependencyAccess,
5
+ dependencyAccessRules,
6
+ } from "@checkstack/dependency-common";
7
+
8
+ const QUALIFIED_MAP = "dependency.map.read";
9
+ const QUALIFIED_READ = "dependency.dependency.read";
10
+
11
+ describe("dependency-common access rules", () => {
12
+ describe("dependency.map", () => {
13
+ test("is its own resource/level with the dependency pluginId", () => {
14
+ expect(dependencyAccess.map.id).toBe("map.read");
15
+ expect(dependencyAccess.map.resource).toBe("map");
16
+ expect(dependencyAccess.map.level).toBe("read");
17
+ expect(dependencyAccess.map.pluginId).toBe("dependency");
18
+ });
19
+
20
+ test("is NOT public - anonymous users must not get the map by default", () => {
21
+ expect(dependencyAccess.map.isPublic).toBeUndefined();
22
+ });
23
+
24
+ test("is granted to authenticated users by default", () => {
25
+ expect(dependencyAccess.map.isDefault).toBe(true);
26
+ });
27
+
28
+ test("is registered so it syncs to roles", () => {
29
+ expect(dependencyAccessRules).toContain(dependencyAccess.map);
30
+ });
31
+
32
+ test("the public read grant alone does NOT satisfy the map rule", () => {
33
+ // A visitor who only has the public `dependency.read` (warnings) grant
34
+ // must NOT be able to view the map - the map needs its own rule.
35
+ expect(
36
+ isAccessRuleSatisfied([QUALIFIED_READ], dependencyAccess.map),
37
+ ).toBe(false);
38
+ });
39
+
40
+ test("the qualified map grant satisfies the map rule", () => {
41
+ expect(isAccessRuleSatisfied([QUALIFIED_MAP], dependencyAccess.map)).toBe(
42
+ true,
43
+ );
44
+ });
45
+ });
46
+
47
+ describe("dependency.read", () => {
48
+ test("stays public so warning badges remain visible to anonymous users", () => {
49
+ expect(dependencyAccess.dependency.read.isPublic).toBe(true);
50
+ });
51
+
52
+ test("is not satisfied by the map grant (the two are independent)", () => {
53
+ expect(
54
+ isAccessRuleSatisfied([QUALIFIED_MAP], dependencyAccess.dependency.read),
55
+ ).toBe(false);
56
+ });
57
+ });
58
+ });