Skip to content
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

feat: Encrypted fields rework #24966

Merged
merged 66 commits into from
Sep 19, 2024
Merged

feat: Encrypted fields rework #24966

merged 66 commits into from
Sep 19, 2024

Conversation

benjackwhite
Copy link
Contributor

@benjackwhite benjackwhite commented Sep 13, 2024

Problem

Ensures the fields are encrypted and not just removed from payloads.

Changes

  • Adds the encrypted_inputs value
  • Changes the logic to write to them and read back but redacted
  • Remove need for secret key
  • Works in the plugin server
  • New secret values added to deployments - https://github.com/PostHog/charts/pull/1828

Follow up

  • Migrate all fields to the new format
  • Also migrate data warehouse fields

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

Copy link
Contributor

github-actions bot commented Sep 13, 2024

Size Change: 0 B

Total Size: 1.1 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.1 MB

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@benjackwhite benjackwhite marked this pull request as ready for review September 16, 2024 12:41
@benjackwhite benjackwhite changed the title feat(cdp): Encrypted cdp fields feat: Encrypted fields rework Sep 16, 2024
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playing around locally. I had

  1. no keys set: print(inputs.secret) in a function worked
  2. set a key for the plugin server only: print(inputs.secret) returned null
  3. set the same key for django: things started crashing

It appears django wasn't able to decrypt the previous encrypted_inputs field, and instead of returing None or a dict, it returned the encrypted string. Then followup code that expects a dict crashed.

I committed a patch to just return None instead in this case. Then everything worked and I could print the secret again (showed up as redacted).

@@ -191,6 +191,7 @@ jobs:
GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CELERY_METRICS_PORT=8999
CLOUD_DEPLOYMENT=E2E
ENCRYPTION_SALT_KEYS=9bf7f7c13cf2148a23d6b07557f95cb7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProTip™️: deadbeef is legit hex, as is 00beef0000beef0000beef0000beef00 if you want something that looks less like a real key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

benjackwhite and others added 5 commits September 18, 2024 13:19
# Conflicts:
#	plugin-server/package.json
#	plugin-server/src/config/config.ts
#	plugin-server/src/types.ts
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@benjackwhite benjackwhite merged commit ad32faf into master Sep 19, 2024
93 checks passed
@benjackwhite benjackwhite deleted the feat/cdp-field-encryption branch September 19, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants