-
Notifications
You must be signed in to change notification settings - Fork 11
init target variables #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5cab4f0
cab9e82
dcf4316
068e78a
3625589
d5adfe2
39a7cb6
6de6ffa
21895c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,9 @@ | ||||||||||||||||||||||||||||||||||
| # Since .env is gitignored, you can use .env.example to build a new `.env` file when you clone the repo. | ||||||||||||||||||||||||||||||||||
| # Keep this file up-to-date when you add new variables to \`.env\`. | ||||||||||||||||||||||||||||||||||
| BASE_URL="http://localhost:3000" | ||||||||||||||||||||||||||||||||||
| POSTGRES_URL="postgresql://ctrlplane:ctrlplane@127.0.0.1:5432/ctrlplane" | ||||||||||||||||||||||||||||||||||
| REDIS_URL="redis://127.0.0.1:6379" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # This file will be committed to version control, so make sure not to have any secrets in it. | ||||||||||||||||||||||||||||||||||
| # If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # The database URL is used to connect to your Supabase database. | ||||||||||||||||||||||||||||||||||
| POSTGRES_URL="postgres://postgres.[USERNAME]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?workaround=supabase-pooler.vercel" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # You can generate the secret via 'openssl rand -base64 32' on Unix | ||||||||||||||||||||||||||||||||||
| # @see https://next-auth.js.org/configuration/options#secret | ||||||||||||||||||||||||||||||||||
| AUTH_SECRET='supersecret' | ||||||||||||||||||||||||||||||||||
| AUTH_TRUST_HOST=false | ||||||||||||||||||||||||||||||||||
|
Comment on lines
4
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security: Add warning about AUTH_SECRET configuration. The example includes a weak default secret that could be accidentally used in production. Add a warning and use a placeholder instead. -AUTH_SECRET='supersecret'
+# WARNING: Generate a strong random secret in production!
+# Minimum length: 32 characters
+AUTH_SECRET='<your-secure-random-secret>'
AUTH_TRUST_HOST=false📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| VARIABLES_AES_256_KEY=0000000000000000000000000000000000000000000000000000000000000000 | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security: Replace example encryption key with placeholder. The AES key is currently set to all zeros, which is insecure. Replace with a placeholder and add guidance on generating a secure key. -VARIABLES_AES_256_KEY=0000000000000000000000000000000000000000000000000000000000000000
+# AES-256 encryption key for variable encryption (required)
+# Generate a secure 64-character hex key for production use
+# Example command: openssl rand -hex 32
+VARIABLES_AES_256_KEY=<generated-hex-key>📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the search results, I can now provide a comprehensive response about the environment variables. The .env.example file is missing some required environment variables. The following required variables should be added to the .env.example file:
These variables are defined in the environment schema (apps/webservice/src/env.ts) but missing from the example configuration file. 🔗 Analysis chainAdd missing configuration variables. Based on the AI summary, this PR introduces new functionality for target variables and secrets management. However, some potentially required variables might be missing from the example configuration. Let's check for any missing required environment variables: Let me gather more information about environment variables by checking the schema definitions and configuration files. Let me search for all environment variable schema definitions to identify required variables. Let me try a different search pattern to find environment variable definitions. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for environment variable usage in the codebase
# Look for process.env references in TypeScript/JavaScript files
rg -t ts -t js 'process\.env\.' -A 1
# Look for @env decorator usage in TypeScript files
rg -t ts '@env' -A 1
Length of output: 3847 Script: #!/bin/bash
# Search for environment schema definitions
rg -t ts "z.object\({" -A 20
# Look for environment variable validation
fd "env" --type f --exec cat {}
Length of output: 67900 Script: #!/bin/bash
# Search for environment variable schema definitions in zod objects
rg -t ts "createEnv\({" -B 2 -A 20
Length of output: 124 Script: #!/bin/bash
# Search for environment variable schemas
rg -t ts "server: \{" -B 2 -A 20
# Also search for any environment variable validation
rg -t ts "z\.string\(\)\.min\(1\)" -B 2 -A 2
Length of output: 34031 |
||||||||||||||||||||||||||||||||||
| JOB_AGENT_WORKSPACE="ctrlplane" | ||||||||||||||||||||||||||||||||||
| JOB_AGENT_NAME="agent" | ||||||||||||||||||||||||||||||||||
| JOB_AGENT_API_KEY= | ||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ COPY packages/db/package.json ./packages/db/package.json | |
| COPY packages/validators/package.json ./packages/validators/package.json | ||
| COPY packages/logger/package.json ./packages/logger/package.json | ||
| COPY packages/job-dispatch/package.json ./packages/job-dispatch/package.json | ||
| COPY packages/secrets/package.json ./packages/secrets/package.json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Environment variable VARIABLES_AES_256_KEY required for secrets package The secrets package implements AES-256 encryption and requires a specific environment variable to be set:
Make sure to set the required environment variable in your event-worker service configuration. 🔗 Analysis chainLGTM! Verify secrets package configuration. The addition of the secrets package follows the established pattern for shared packages. The package is correctly copied before dependency installation. Let's verify the secrets package setup: Let me try to gather more information about the secrets package to better understand its configuration and requirements. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if the secrets package requires specific environment variables
rg -g 'packages/secrets/**' 'process\.env\.' -A 2
# Check for any security-related configuration files
fd -g 'packages/secrets/**' -e config.ts -e config.js
Length of output: 107 Script: #!/bin/bash
# Check the contents of the secrets package
fd . packages/secrets -t f -x cat {}
# Look for any environment variable patterns in a more generic way
rg -g 'packages/secrets/**' -i '(env|secret|config|environment)' -A 2
# Check package.json for dependencies and scripts
cat packages/secrets/package.json
Length of output: 5895 |
||
|
|
||
| COPY apps/event-worker/package.json ./apps/event-worker/package.json | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||||||||||||
| CREATE TABLE IF NOT EXISTS "target_variable" ( | ||||||||||||||||||||||||||||||||
| "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||||||||||||||||||||||||||||||||
| "target_id" uuid NOT NULL, | ||||||||||||||||||||||||||||||||
| "key" text NOT NULL, | ||||||||||||||||||||||||||||||||
| "value" jsonb NOT NULL, | ||||||||||||||||||||||||||||||||
| "sensitive" boolean DEFAULT false NOT NULL | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding constraints for data integrity. While the basic structure is sound, consider adding these constraints for better data integrity:
CREATE TABLE IF NOT EXISTS "target_variable" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"target_id" uuid NOT NULL,
- "key" text NOT NULL,
+ "key" text NOT NULL CHECK (length(key) <= 100),
"value" jsonb NOT NULL,
"sensitive" boolean DEFAULT false NOT NULL
+ CONSTRAINT "value_is_valid" CHECK (jsonb_typeof(value) IN ('object', 'array', 'string', 'number', 'boolean'))
);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||
| DO $$ BEGIN | ||||||||||||||||||||||||||||||||
| ALTER TABLE "target_variable" ADD CONSTRAINT "target_variable_target_id_target_id_fk" FOREIGN KEY ("target_id") REFERENCES "public"."target"("id") ON DELETE cascade ON UPDATE no action; | ||||||||||||||||||||||||||||||||
| EXCEPTION | ||||||||||||||||||||||||||||||||
| WHEN duplicate_object THEN null; | ||||||||||||||||||||||||||||||||
| END $$; | ||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||
| CREATE UNIQUE INDEX IF NOT EXISTS "target_variable_target_id_key_index" ON "target_variable" USING btree ("target_id","key"); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security: Remove credentials from example PostgreSQL URL.
The PostgreSQL URL contains default credentials which could be accidentally used in production. Consider using placeholder values instead.
📝 Committable suggestion