The best way to control Claude Code, Codex and more from any computer or phone

main
ts 70 lines 2.3 KB
Raw
1 import * as securityposture from "@distilled.cloud/gcp/securityposture_v1";
2 import * as Effect from "effect/Effect";
3 import { MinimumLogLevel } from "effect/References";
4 import * as Schedule from "effect/Schedule";
5
6 export const logLevel = Effect.provideService(
7 MinimumLogLevel,
8 process.env.DEBUG ? "Debug" : "Info",
9 );
10
11 // Postures live on the organization and need org-level Security Posture
12 // permissions the testing service account lacks (list/create answer 403);
13 // set GCP_TEST_SECURITY_POSTURE=1 and GOOGLE_ORGANIZATION_ID on an org where
14 // the credential is a Security Posture admin.
15 const organizationId = process.env.GOOGLE_ORGANIZATION_ID?.trim() ?? "";
16 export const organization =
17 organizationId.length === 0 || organizationId.startsWith("organizations/")
18 ? organizationId
19 : `organizations/${organizationId}`;
20 export const runLifecycle =
21 !process.env.FAST && process.env.GCP_TEST_SECURITY_POSTURE === "1" && organization.length > 0;
22
23 export const waitUntilPostureGone = (name: string) =>
24 securityposture.getOrganizationsLocationsPostures({ name }).pipe(
25 Effect.as("found" as const),
26 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
27 Effect.repeat({
28 schedule: Schedule.spaced("1 second"),
29 until: (status) => status === "gone",
30 times: 10,
31 }),
32 );
33
34 export const waitUntilDeploymentGone = (name: string) =>
35 securityposture.getOrganizationsLocationsPostureDeployments({ name }).pipe(
36 Effect.as("found" as const),
37 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
38 Effect.repeat({
39 schedule: Schedule.spaced("1 second"),
40 until: (status) => status === "gone",
41 times: 10,
42 }),
43 );
44
45 export const updatedPolicySets: securityposture.PolicySetList = [
46 {
47 policySetId: "alchemy",
48 description: "updated alchemy policy set",
49 policies: [
50 {
51 policyId: "alchemy-sha",
52 constraint: {
53 securityHealthAnalyticsModule: {
54 moduleName: "API_KEY_EXISTS",
55 moduleEnablementState: "DISABLED",
56 },
57 },
58 },
59 {
60 policyId: "alchemy-sha-2",
61 constraint: {
62 securityHealthAnalyticsModule: {
63 moduleName: "BUCKET_IAM_NOT_MONITORED",
64 moduleEnablementState: "DISABLED",
65 },
66 },
67 },
68 ],
69 },
70 ];