@intentius/behold 0.29.55 → 0.29.57

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 (173) hide show
  1. package/THIRD_PARTY.md +21 -0
  2. package/dist/cli.js +7611 -6919
  3. package/example-three-cloud/azure/composites/container-app-site.ts +77 -0
  4. package/example-three-cloud/azure/src/site.ts +14 -46
  5. package/example-three-cloud/dns/composites/latency-entry.ts +73 -0
  6. package/example-three-cloud/dns/src/route53.ts +9 -39
  7. package/example-three-cloud/gcp/composites/public-cloud-run.ts +102 -0
  8. package/example-three-cloud/gcp/src/site.ts +16 -96
  9. package/licenses/aws-architecture-icons-TERMS.md +19 -0
  10. package/licenses/azure-architecture-icons-Microsoft_Terms_of_Use.pdf +0 -0
  11. package/licenses/azure-architecture-icons-TERMS.md +20 -0
  12. package/licenses/google-cloud-icons-TERMS.md +15 -0
  13. package/package.json +1 -1
  14. package/web/app.js +704 -10
  15. package/web/edge-weight.d.ts +5 -0
  16. package/web/edge-weight.js +71 -0
  17. package/web/edge-weight.test.js +49 -0
  18. package/web/icons/aws/alb.svg +1 -0
  19. package/web/icons/aws/api-gateway.svg +1 -0
  20. package/web/icons/aws/app-runner.svg +1 -0
  21. package/web/icons/aws/appsync.svg +1 -0
  22. package/web/icons/aws/athena.svg +1 -0
  23. package/web/icons/aws/auto-scaling.svg +1 -0
  24. package/web/icons/aws/backup.svg +1 -0
  25. package/web/icons/aws/batch.svg +1 -0
  26. package/web/icons/aws/bedrock-agentcore.svg +1 -0
  27. package/web/icons/aws/bedrock.svg +1 -0
  28. package/web/icons/aws/certificate-manager.svg +1 -0
  29. package/web/icons/aws/cloud-map.svg +1 -0
  30. package/web/icons/aws/cloud.svg +1 -0
  31. package/web/icons/aws/cloudformation.svg +1 -0
  32. package/web/icons/aws/cloudfront.svg +1 -0
  33. package/web/icons/aws/cloudtrail.svg +1 -0
  34. package/web/icons/aws/cloudwatch-alarm.svg +1 -0
  35. package/web/icons/aws/cloudwatch-logs.svg +1 -0
  36. package/web/icons/aws/cloudwatch.svg +1 -0
  37. package/web/icons/aws/codebuild.svg +1 -0
  38. package/web/icons/aws/codecommit.svg +1 -0
  39. package/web/icons/aws/codedeploy.svg +1 -0
  40. package/web/icons/aws/codepipeline.svg +1 -0
  41. package/web/icons/aws/cognito.svg +1 -0
  42. package/web/icons/aws/config.svg +1 -0
  43. package/web/icons/aws/documentdb.svg +1 -0
  44. package/web/icons/aws/dynamodb-table.svg +1 -0
  45. package/web/icons/aws/dynamodb.svg +1 -0
  46. package/web/icons/aws/ebs-volume.svg +1 -0
  47. package/web/icons/aws/ec2-instance.svg +1 -0
  48. package/web/icons/aws/ec2.svg +1 -0
  49. package/web/icons/aws/ecr-registry.svg +1 -0
  50. package/web/icons/aws/ecr.svg +1 -0
  51. package/web/icons/aws/ecs-service.svg +1 -0
  52. package/web/icons/aws/ecs-task.svg +1 -0
  53. package/web/icons/aws/ecs.svg +1 -0
  54. package/web/icons/aws/efs.svg +1 -0
  55. package/web/icons/aws/eks.svg +1 -0
  56. package/web/icons/aws/elastic-beanstalk.svg +1 -0
  57. package/web/icons/aws/elastic-ip.svg +1 -0
  58. package/web/icons/aws/elasticache.svg +1 -0
  59. package/web/icons/aws/elb.svg +1 -0
  60. package/web/icons/aws/emr.svg +1 -0
  61. package/web/icons/aws/eventbridge.svg +1 -0
  62. package/web/icons/aws/firehose.svg +1 -0
  63. package/web/icons/aws/global-accelerator.svg +1 -0
  64. package/web/icons/aws/glue.svg +1 -0
  65. package/web/icons/aws/guardduty.svg +1 -0
  66. package/web/icons/aws/iam.svg +1 -0
  67. package/web/icons/aws/internet-gateway.svg +1 -0
  68. package/web/icons/aws/keyspaces.svg +1 -0
  69. package/web/icons/aws/kinesis.svg +1 -0
  70. package/web/icons/aws/kms.svg +1 -0
  71. package/web/icons/aws/lambda-function.svg +1 -0
  72. package/web/icons/aws/lambda.svg +1 -0
  73. package/web/icons/aws/mq.svg +1 -0
  74. package/web/icons/aws/msk.svg +1 -0
  75. package/web/icons/aws/nat-gateway.svg +1 -0
  76. package/web/icons/aws/neptune.svg +1 -0
  77. package/web/icons/aws/network-acl.svg +1 -0
  78. package/web/icons/aws/network-firewall.svg +1 -0
  79. package/web/icons/aws/opensearch.svg +1 -0
  80. package/web/icons/aws/organizations.svg +1 -0
  81. package/web/icons/aws/rds-instance.svg +1 -0
  82. package/web/icons/aws/rds.svg +1 -0
  83. package/web/icons/aws/redshift.svg +1 -0
  84. package/web/icons/aws/route-53-hosted-zone.svg +1 -0
  85. package/web/icons/aws/route-53.svg +1 -0
  86. package/web/icons/aws/router.svg +1 -0
  87. package/web/icons/aws/s3-bucket.svg +1 -0
  88. package/web/icons/aws/s3.svg +1 -0
  89. package/web/icons/aws/sagemaker.svg +1 -0
  90. package/web/icons/aws/secrets-manager.svg +1 -0
  91. package/web/icons/aws/ses.svg +1 -0
  92. package/web/icons/aws/shield.svg +1 -0
  93. package/web/icons/aws/sns-topic.svg +1 -0
  94. package/web/icons/aws/sns.svg +1 -0
  95. package/web/icons/aws/sqs-queue.svg +1 -0
  96. package/web/icons/aws/sqs.svg +1 -0
  97. package/web/icons/aws/step-functions.svg +1 -0
  98. package/web/icons/aws/systems-manager.svg +1 -0
  99. package/web/icons/aws/transfer-family.svg +1 -0
  100. package/web/icons/aws/transit-gateway.svg +1 -0
  101. package/web/icons/aws/vpc-endpoints.svg +1 -0
  102. package/web/icons/aws/vpc-lattice.svg +1 -0
  103. package/web/icons/aws/vpc.svg +1 -0
  104. package/web/icons/aws/vpn-gateway.svg +1 -0
  105. package/web/icons/aws/waf.svg +1 -0
  106. package/web/icons/azure/app-service-plan.svg +1 -0
  107. package/web/icons/azure/app-services.svg +1 -0
  108. package/web/icons/azure/application-gateway.svg +1 -0
  109. package/web/icons/azure/container-app.svg +1 -0
  110. package/web/icons/azure/container-apps-environment.svg +1 -0
  111. package/web/icons/azure/container-instances.svg +1 -0
  112. package/web/icons/azure/container-registry.svg +1 -0
  113. package/web/icons/azure/cosmos-db.svg +1 -0
  114. package/web/icons/azure/dns-zone.svg +1 -0
  115. package/web/icons/azure/front-door.svg +1 -0
  116. package/web/icons/azure/function-app.svg +1 -0
  117. package/web/icons/azure/kubernetes-service.svg +1 -0
  118. package/web/icons/azure/load-balancer.svg +1 -0
  119. package/web/icons/azure/log-analytics.svg +1 -0
  120. package/web/icons/azure/managed-identity.svg +1 -0
  121. package/web/icons/azure/mysql.svg +1 -0
  122. package/web/icons/azure/nat.svg +1 -0
  123. package/web/icons/azure/network-security-group.svg +1 -0
  124. package/web/icons/azure/postgresql.svg +1 -0
  125. package/web/icons/azure/public-ip.svg +1 -0
  126. package/web/icons/azure/redis.svg +1 -0
  127. package/web/icons/azure/resource-group.svg +1 -0
  128. package/web/icons/azure/route-table.svg +1 -0
  129. package/web/icons/azure/sql-database.svg +1 -0
  130. package/web/icons/azure/sql-server.svg +1 -0
  131. package/web/icons/azure/subnet.svg +1 -0
  132. package/web/icons/azure/subscription.svg +1 -0
  133. package/web/icons/azure/virtual-machine.svg +1 -0
  134. package/web/icons/azure/virtual-network-gateway.svg +1 -0
  135. package/web/icons/azure/virtual-network.svg +1 -0
  136. package/web/icons/gcp/artifact-registry.svg +1 -0
  137. package/web/icons/gcp/bigquery.svg +1 -0
  138. package/web/icons/gcp/bigtable.svg +1 -0
  139. package/web/icons/gcp/certificate-manager.svg +1 -0
  140. package/web/icons/gcp/cloud-armor.svg +1 -0
  141. package/web/icons/gcp/cloud-build.svg +1 -0
  142. package/web/icons/gcp/cloud-composer.svg +1 -0
  143. package/web/icons/gcp/cloud-dns.svg +1 -0
  144. package/web/icons/gcp/cloud-functions.svg +1 -0
  145. package/web/icons/gcp/cloud-load-balancing.svg +1 -0
  146. package/web/icons/gcp/cloud-logging.svg +1 -0
  147. package/web/icons/gcp/cloud-monitoring.svg +1 -0
  148. package/web/icons/gcp/cloud-nat.svg +1 -0
  149. package/web/icons/gcp/cloud-router.svg +1 -0
  150. package/web/icons/gcp/cloud-run.svg +1 -0
  151. package/web/icons/gcp/cloud-scheduler.svg +1 -0
  152. package/web/icons/gcp/cloud-spanner.svg +1 -0
  153. package/web/icons/gcp/cloud-sql.svg +1 -0
  154. package/web/icons/gcp/cloud-storage.svg +1 -0
  155. package/web/icons/gcp/cloud-tasks.svg +1 -0
  156. package/web/icons/gcp/compute-engine.svg +1 -0
  157. package/web/icons/gcp/dataflow.svg +1 -0
  158. package/web/icons/gcp/external-ip.svg +1 -0
  159. package/web/icons/gcp/firestore.svg +1 -0
  160. package/web/icons/gcp/firewall-rules.svg +1 -0
  161. package/web/icons/gcp/gke.svg +1 -0
  162. package/web/icons/gcp/iam.svg +1 -0
  163. package/web/icons/gcp/kms.svg +1 -0
  164. package/web/icons/gcp/memorystore.svg +1 -0
  165. package/web/icons/gcp/persistent-disk.svg +1 -0
  166. package/web/icons/gcp/project.svg +1 -0
  167. package/web/icons/gcp/pubsub.svg +1 -0
  168. package/web/icons/gcp/secret-manager.svg +1 -0
  169. package/web/icons/gcp/vpc.svg +1 -0
  170. package/web/index.html +54 -0
  171. package/web/net-trace.js +649 -0
  172. package/web/net-trace.test.js +180 -0
  173. package/web/view-url.js +12 -7
@@ -0,0 +1,180 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { cidrContains, cidrsOverlap, networkFindings, OUTSIDE, parseCidr, traceRoute } from "./net-trace.js";
3
+
4
+ const ref = (id) => ({ $ref: id });
5
+ const n = (id, kind, attrs = {}) => ({ id, kind, lexicon: kind.startsWith("AWS") ? "aws" : kind.startsWith("GCP") ? "gcp" : "azure", attrs });
6
+
7
+ /** A VPC with a public and a private subnet, a load balancer in front of a service. */
8
+ function aws({ albIngress = [{ IpProtocol: "tcp", FromPort: 80, ToPort: 80, CidrIp: "0.0.0.0/0" }], nacl = false, publicRoute = true, albSubnets = ["a/pub1", "a/pub2"] } = {}) {
9
+ const nodes = [
10
+ n("a/vpc", "AWS::EC2::VPC", { CidrBlock: "10.0.0.0/16" }),
11
+ n("a/igw", "AWS::EC2::InternetGateway"),
12
+ n("a/attach", "AWS::EC2::VPCGatewayAttachment", { VpcId: ref("a/vpc.VpcId"), InternetGatewayId: ref("a/igw.InternetGatewayId") }),
13
+ n("a/pub1", "AWS::EC2::Subnet", { VpcId: ref("a/vpc.VpcId"), CidrBlock: "10.0.0.0/24", MapPublicIpOnLaunch: true }),
14
+ n("a/pub2", "AWS::EC2::Subnet", { VpcId: ref("a/vpc.VpcId"), CidrBlock: "10.0.1.0/24", MapPublicIpOnLaunch: true }),
15
+ n("a/priv", "AWS::EC2::Subnet", { VpcId: ref("a/vpc.VpcId"), CidrBlock: "10.0.10.0/24" }),
16
+ n("a/pubRt", "AWS::EC2::RouteTable", { VpcId: ref("a/vpc.VpcId") }),
17
+ n("a/rta1", "AWS::EC2::SubnetRouteTableAssociation", { SubnetId: ref("a/pub1.SubnetId"), RouteTableId: ref("a/pubRt.RouteTableId") }),
18
+ n("a/rta2", "AWS::EC2::SubnetRouteTableAssociation", { SubnetId: ref("a/pub2.SubnetId"), RouteTableId: ref("a/pubRt.RouteTableId") }),
19
+ ...(publicRoute ? [n("a/pubRoute", "AWS::EC2::Route", { RouteTableId: ref("a/pubRt.RouteTableId"), DestinationCidrBlock: "0.0.0.0/0", GatewayId: ref("a/igw.InternetGatewayId") })] : []),
20
+ n("a/albSg", "AWS::EC2::SecurityGroup", { VpcId: ref("a/vpc.VpcId"), SecurityGroupIngress: albIngress }),
21
+ n("a/taskSg", "AWS::EC2::SecurityGroup", { VpcId: ref("a/vpc.VpcId"), SecurityGroupIngress: [{ IpProtocol: "tcp", FromPort: 8080, ToPort: 8080, SourceSecurityGroupId: ref("a/albSg.GroupId") }] }),
22
+ n("a/alb", "AWS::ElasticLoadBalancingV2::LoadBalancer", { Scheme: "internet-facing", Subnets: albSubnets.map((s) => ref(`${s}.SubnetId`)), SecurityGroups: [ref("a/albSg.GroupId")] }),
23
+ n("a/listener", "AWS::ElasticLoadBalancingV2::Listener", { LoadBalancerArn: ref("a/alb.LoadBalancerArn"), Port: 80, DefaultActions: [{ Type: "forward", TargetGroupArn: ref("a/tg.TargetGroupArn") }] }),
24
+ n("a/tg", "AWS::ElasticLoadBalancingV2::TargetGroup", { Port: 8080, VpcId: ref("a/vpc.VpcId") }),
25
+ n("a/svc", "AWS::ECS::Service", {
26
+ LoadBalancers: [{ ContainerPort: 8080, TargetGroupArn: ref("a/tg.TargetGroupArn") }],
27
+ NetworkConfiguration: { AwsvpcConfiguration: { Subnets: [ref("a/priv.SubnetId")], SecurityGroups: [ref("a/taskSg.GroupId")] } },
28
+ }),
29
+ ];
30
+ if (nacl) {
31
+ nodes.push(
32
+ n("a/acl", "AWS::EC2::NetworkAcl", { VpcId: ref("a/vpc.VpcId") }),
33
+ n("a/aclAssoc1", "AWS::EC2::SubnetNetworkAclAssociation", { SubnetId: ref("a/pub1.SubnetId"), NetworkAclId: ref("a/acl.Id") }),
34
+ n("a/aclAssoc2", "AWS::EC2::SubnetNetworkAclAssociation", { SubnetId: ref("a/pub2.SubnetId"), NetworkAclId: ref("a/acl.Id") }),
35
+ n("a/aclDeny", "AWS::EC2::NetworkAclEntry", { NetworkAclId: ref("a/acl.Id"), RuleNumber: 90, Protocol: 6, PortRange: { From: 80, To: 80 }, CidrBlock: "0.0.0.0/0", RuleAction: "deny", Egress: false }),
36
+ n("a/aclAllow", "AWS::EC2::NetworkAclEntry", { NetworkAclId: ref("a/acl.Id"), RuleNumber: 100, Protocol: -1, CidrBlock: "0.0.0.0/0", RuleAction: "allow", Egress: false }),
37
+ );
38
+ }
39
+ return { nodes, edges: [], groups: {} };
40
+ }
41
+
42
+ describe("addresses (#881)", () => {
43
+ it("reads IPv4 ranges and compares them", () => {
44
+ expect(parseCidr("10.0.0.0/16")).toMatchObject({ bits: 16 });
45
+ expect(parseCidr("::/0")).toBeNull();
46
+ expect(cidrContains("10.0.0.0/16", "10.0.3.0/24")).toBe(true);
47
+ expect(cidrContains("10.0.3.0/24", "10.0.0.0/16")).toBe(false);
48
+ expect(cidrContains("0.0.0.0/0", "0.0.0.0/0")).toBe(true);
49
+ expect(cidrsOverlap("10.0.3.0/24", "10.0.0.0/16")).toBe(true);
50
+ expect(cidrsOverlap("10.0.0.0/24", "10.0.1.0/24")).toBe(false);
51
+ });
52
+ });
53
+
54
+ describe("traceRoute (#881)", () => {
55
+ const steps = (t) => t.hops.map((h) => `${h.open ? "+" : "-"}${h.step}`);
56
+
57
+ it("follows outside through the gateway, ACLs, groups and listener to the service", () => {
58
+ const t = traceRoute(aws(), { from: OUTSIDE, to: "a/svc", port: 80 });
59
+ expect(t.reached).toBe(true);
60
+ expect(steps(t)).toEqual(["+way in", "+gateway", "+network ACL", "+security group", "+listener", "+forward", "+network ACL", "+security group"]);
61
+ expect(t.hops.at(-1)).toMatchObject({ id: "a/taskSg", basis: "source", seen: false });
62
+ expect(t.hops[5].why).toMatch(/forwards to a\/tg on 8080/);
63
+ });
64
+
65
+ it("stops at the security group and the listener for a port nothing takes", () => {
66
+ const t = traceRoute(aws(), { from: OUTSIDE, to: "a/svc", port: 443 });
67
+ expect(t.reached).toBe(false);
68
+ expect(t.stop).toBe("a/albSg");
69
+ expect(t.hops.find((h) => h.step === "listener").why).toBe("a/alb listens on 80, not 443");
70
+ });
71
+
72
+ it("reads a network ACL in rule order", () => {
73
+ const t = traceRoute(aws({ nacl: true }), { from: OUTSIDE, to: "a/svc", port: 80 });
74
+ expect(t.stop).toBe("a/aclDeny");
75
+ expect(t.hops[2].why).toMatch(/rule 90 denies 80/);
76
+ });
77
+
78
+ it("stops at the gateway when the public subnets have no route out", () => {
79
+ const t = traceRoute(aws({ publicRoute: false }), { from: OUTSIDE, to: "a/alb", port: 80 });
80
+ expect(steps(t)[1]).toBe("-gateway");
81
+ expect(t.hops[1].why).toMatch(/no route to 0\.0\.0\.0\/0/);
82
+ });
83
+
84
+ it("judges a security group from its live rules when the card carries them", () => {
85
+ const ir = aws();
86
+ const sg = ir.nodes.find((x) => x.id === "a/albSg");
87
+ sg.attrs.GroupId = "sg-1";
88
+ sg.attrs._status = "good";
89
+ sg.attrs.IpPermissions = [{ IpProtocol: "tcp", FromPort: 443, ToPort: 443, IpRanges: [{ CidrIp: "0.0.0.0/0" }], UserIdGroupPairs: [] }];
90
+ const t = traceRoute(ir, { from: OUTSIDE, to: "a/alb", port: 80 });
91
+ expect(t.hops[3]).toMatchObject({ step: "security group", open: false, basis: "live", seen: true });
92
+ });
93
+
94
+ it("goes card to card inside one VPC", () => {
95
+ const t = traceRoute(aws(), { from: "a/alb", to: "a/svc", port: 8080 });
96
+ expect(t.reached).toBe(true);
97
+ expect(t.hops[0].why).toBe("inside a/vpc: the local route");
98
+ expect(traceRoute(aws(), { from: "a/alb", to: "a/svc", port: 22 }).stop).toBe("a/taskSg");
99
+ });
100
+
101
+ it("follows a forwarding rule to a Cloud Run service and asks who may call it", () => {
102
+ const ir = {
103
+ nodes: [
104
+ n("g/rule", "GCP::Compute::ForwardingRule", { loadBalancingScheme: "EXTERNAL_MANAGED", portRange: "80", target: { targetHTTPProxyRef: { name: ref("g/proxy.name") } } }),
105
+ n("g/proxy", "GCP::Compute::TargetHTTPProxy", { urlMapRef: { name: ref("g/map.name") } }),
106
+ n("g/map", "GCP::Compute::URLMap", { defaultService: { backendServiceRef: { name: ref("g/backend.name") } } }),
107
+ n("g/backend", "GCP::Compute::BackendService", { backend: [{ group: { networkEndpointGroupRef: { name: ref("g/neg.name") } } }] }),
108
+ n("g/neg", "GCP::Compute::RegionNetworkEndpointGroup", { cloudRun: { serviceRef: { name: ref("g/run.name") } } }),
109
+ n("g/run", "GCP::Run::Service", { metadata: { name: "site" } }),
110
+ ],
111
+ edges: [],
112
+ groups: {},
113
+ };
114
+ const closed = traceRoute(ir, { from: OUTSIDE, to: "g/run", port: 80 });
115
+ expect(closed.stop).toBe("g/run");
116
+ expect(closed.hops.at(-1).why).toMatch(/callers need a credential/);
117
+ ir.nodes.push(n("g/public", "GCP::Iam::PolicyMember", { member: "allUsers", role: "roles/run.invoker", resourceRef: { kind: "RunService", name: "site" } }));
118
+ const open = traceRoute(ir, { from: OUTSIDE, to: "g/run", port: 80 });
119
+ expect(open.reached).toBe(true);
120
+ expect(open.hops.map((h) => h.id)).toEqual(["g/rule", "g/proxy", "g/map", "g/backend", "g/neg", "g/run", "g/public"]);
121
+ });
122
+
123
+ it("reads a container app's environment and ingress", () => {
124
+ const ir = {
125
+ nodes: [
126
+ n("z/env", "Microsoft.App/managedEnvironments", { vnetConfiguration: { internal: true } }),
127
+ n("z/app", "Microsoft.App/containerApps", { managedEnvironmentId: ref("z/env.id"), configuration: { ingress: { external: true, targetPort: 8080 } } }),
128
+ ],
129
+ edges: [],
130
+ groups: {},
131
+ };
132
+ const t = traceRoute(ir, { from: OUTSIDE, to: "z/app", port: 443 });
133
+ expect(t.stop).toBe("z/env");
134
+ expect(t.hops.at(-1).why).toBe("takes 443 and forwards to 8080");
135
+ });
136
+
137
+ it("says when it can't read a card, rather than guess", () => {
138
+ const ir = { nodes: [n("k/pod", "K8s::Core::Pod")], edges: [], groups: {} };
139
+ ir.nodes[0].lexicon = "k8s";
140
+ expect(traceRoute(ir, { from: OUTSIDE, to: "k/pod", port: 80 }).unread).toMatch(/reads AWS, GCP and Azure/);
141
+ expect(traceRoute(ir, { from: OUTSIDE, to: "nope", port: 80 }).unread).toMatch(/isn't on this graph/);
142
+ expect(traceRoute(ir, { from: OUTSIDE, to: "k/pod", port: 0 }).unread).toMatch(/port/);
143
+ });
144
+ });
145
+
146
+ describe("networkFindings (#881)", () => {
147
+ it("finds nothing on a sound network", () => {
148
+ expect(networkFindings(aws())).toEqual([]);
149
+ });
150
+
151
+ it("finds a public subnet with no way out, a load balancer in one zone, and an admin port open to anyone", () => {
152
+ const ir = aws({ publicRoute: false, albSubnets: ["a/pub1"], albIngress: [{ IpProtocol: "tcp", FromPort: 0, ToPort: 65535, CidrIp: "0.0.0.0/0" }] });
153
+ const f = networkFindings(ir);
154
+ expect(f.map((x) => `${x.finding}:${x.ids.join(",")}`)).toEqual(["no way out:a/pub1", "no way out:a/pub2", "one zone:a/alb", "admin port:a/albSg"]);
155
+ expect(f.at(-1).text).toMatch(/22 \(SSH\)/);
156
+ });
157
+
158
+ it("finds ranges that overlap across networks and clouds, but not a subnet inside its own network", () => {
159
+ const ir = aws();
160
+ ir.nodes.push(
161
+ n("z/vnet", "Microsoft.Network/virtualNetworks", { name: "v", addressSpace: { addressPrefixes: ["10.0.0.0/20"] } }),
162
+ n("z/sub", "Microsoft.Network/virtualNetworks_subnets", { name: "v/apps", addressPrefix: "10.0.0.0/23" }),
163
+ n("g/sub", "GCP::Compute::Subnetwork", { ipCidrRange: "192.168.0.0/24", networkRef: { name: ref("g/vpc.name") } }),
164
+ );
165
+ const f = networkFindings(ir).filter((x) => x.finding === "overlap");
166
+ expect(f.map((x) => x.ids)).toEqual([["a/vpc", "z/vnet"]]);
167
+ });
168
+
169
+ it("finds an admin port open on a GCP firewall and an Azure security group", () => {
170
+ const ir = {
171
+ nodes: [
172
+ n("g/fw", "GCP::Compute::Firewall", { direction: "INGRESS", sourceRanges: ["0.0.0.0/0"], allow: [{ protocol: "tcp", ports: ["22", "80"] }] }),
173
+ n("z/nsg", "Microsoft.Network/networkSecurityGroups", { securityRules: [{ name: "rdp", properties: { direction: "Inbound", access: "Allow", sourceAddressPrefix: "*", destinationPortRange: "3389", priority: 100 } }] }),
174
+ ],
175
+ edges: [],
176
+ groups: {},
177
+ };
178
+ expect(networkFindings(ir).map((x) => x.text)).toEqual(["g/fw lets anyone reach 22 (SSH)", "z/nsg lets anyone reach 3389 (remote desktop)"]);
179
+ });
180
+ });
package/web/view-url.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * `none` (no run view: the newest pull request's plan), `pull-<n>[-<sha>]`
18
18
  * (no run view, and only that pull request's plan, of that commit) or `base`
19
19
  * (nothing in flight); absent, the newest. */
20
- export const VIEW_KEYS = ["member", "zoom", "env", "tier", "lens", "node", "radial", "gates", "focus", "run", "pull"];
20
+ export const VIEW_KEYS = ["member", "zoom", "env", "tier", "lens", "node", "radial", "alike", "gates", "focus", "run", "pull"];
21
21
 
22
22
  /** An env name as the server takes one (src/workspace-gates.ts isEnvName). */
23
23
  export function isEnvName(env) {
@@ -29,8 +29,8 @@ export function isEnvName(env) {
29
29
  export const LENSES = ["drift", "cost", "headroom"];
30
30
 
31
31
  /**
32
- * The view a query asks for. Only the keys present come back; `radial` is a
33
- * boolean (`1`/`true` on, `0`/`false` off). An empty value is the same as an
32
+ * The view a query asks for. Only the keys present come back; `radial` and
33
+ * `alike` are booleans (`1`/`true` on, `0`/`false` off). An empty value is the same as an
34
34
  * absent one, except `env=` which asks for the source graph (null).
35
35
  */
36
36
  export function readViewQuery(search) {
@@ -39,10 +39,10 @@ export function readViewQuery(search) {
39
39
  for (const k of VIEW_KEYS) {
40
40
  if (!q.has(k)) continue;
41
41
  const v = (q.get(k) || "").trim();
42
- if (k === "radial") {
43
- if (/^(1|true|on|yes)$/i.test(v)) want.radial = true;
44
- else if (/^(0|false|off|no)$/i.test(v)) want.radial = false;
45
- else want.radial = v; // left for settleView to name
42
+ if (k === "radial" || k === "alike") {
43
+ if (/^(1|true|on|yes)$/i.test(v)) want[k] = true;
44
+ else if (/^(0|false|off|no)$/i.test(v)) want[k] = false;
45
+ else want[k] = v; // left for settleView to name
46
46
  continue;
47
47
  }
48
48
  if (k === "env") {
@@ -80,6 +80,7 @@ export function writeViewQuery(search, state, defaults = {}) {
80
80
  if (s.lens && s.lens !== lensDefault) q.set("lens", s.lens);
81
81
  if (s.node) q.set("node", s.node);
82
82
  if (s.radial) q.set("radial", "1");
83
+ if (s.alike) q.set("alike", "1");
83
84
  if (s.gates) q.set("gates", s.gates);
84
85
  if (s.focus) q.set("focus", s.focus);
85
86
  if (s.run) q.set("run", s.run);
@@ -120,6 +121,10 @@ export function settleView(want, offer) {
120
121
  if (typeof want.radial === "boolean") apply.radial = want.radial;
121
122
  else refused.push({ key: "radial", value: want.radial, reason: "radial is 1 or 0" });
122
123
  }
124
+ if ("alike" in want) {
125
+ if (typeof want.alike === "boolean") apply.alike = want.alike;
126
+ else refused.push({ key: "alike", value: want.alike, reason: "alike is 1 or 0" });
127
+ }
123
128
  if ("gates" in want) {
124
129
  // null: the gate strip follows the graph's env again.
125
130
  if (want.gates === null || isEnvName(want.gates)) apply.gates = want.gates;