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

Transparent encryption and decryption for all tables that contain secrets or tokens #14214

Merged
merged 47 commits into from Sep 30, 2020

Conversation

unknwon
Copy link
Member

@unknwon unknwon commented Sep 26, 2020

Encrypts and decrypts secrets columns in our database transparently.

Notes:

  • event_logs.argument is left out, see discussions in Slack.
  • repo.metadata is not encrypted because we normalized most of its value and decided not worth encrypting.

Co-authored-by: Dax McDonald 31839142+daxmc99@users.noreply.github.com

chayim and others added 30 commits September 10, 2020 19:00
Co-authored-by: Asdine El Hrychy <asdine.elhrychy@gmail.com>
Co-authored-by: Asdine El Hrychy <asdine.elhrychy@gmail.com>
This allow for types that can decrypt and encrypt themselves.
However, it causes an issue with what encryptor to use
Co-authored-by: Asdine El Hrychy <asdine.elhrychy@gmail.com>
Ensuring the new types honour ConfiguredToEncrypt so that they can transparently encrypt and decrypt in the future.
…/encoding

# Conflicts:
#	internal/secret/encryptor.go
#	internal/secret/encryptor_test.go
#	internal/secret/init.go
@unknwon unknwon requested review from chayim and a team September 26, 2020 04:19
@unknwon unknwon changed the title ripping saved_searches and secrets into its own branch to be PRed once unit tests exist Transparent encryption and decryption for all tables that contain secrets or tokens Sep 26, 2020
@daxmc99 daxmc99 mentioned this pull request Sep 26, 2020
47 tasks
Copy link
Contributor

@asdine asdine left a comment

Choose a reason for hiding this comment

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

This looks good to me but I feel like the boilerplate needed to encrypt a single field is still a bit too big.
We could leverage the fact that the encryption functions are available from everywhere to try to make it as transparent as possible. I have proposed a lead in a comment but not sure if that's enough

cmd/repo-updater/repos/store.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #14214 into main will decrease coverage by 0.33%.
The diff coverage is 60.91%.

@@            Coverage Diff             @@
##             main   #14214      +/-   ##
==========================================
- Coverage   52.08%   51.74%   -0.34%     
==========================================
  Files        1536     1536              
  Lines       78644    77819     -825     
  Branches     7024     6939      -85     
==========================================
- Hits        40958    40266     -692     
+ Misses      33986    33925      -61     
+ Partials     3700     3628      -72     
Flag Coverage Δ
#go 51.93% <60.91%> (-0.48%) ⬇️
#integration 30.31% <ø> (ø)
#storybook 18.06% <ø> (ø)
#typescript 51.29% <ø> (ø)
#unit 33.90% <ø> (ø)
Impacted Files Coverage Δ
internal/db/external_services.go 59.44% <33.33%> (-5.02%) ⬇️
enterprise/internal/db/perms_store.go 78.51% <40.00%> (-2.18%) ⬇️
internal/db/saved_searches.go 64.82% <50.00%> (-0.92%) ⬇️
internal/secret/scanner.go 47.72% <55.55%> (-4.00%) ⬇️
internal/db/external_accounts.go 40.33% <62.50%> (-8.10%) ⬇️
cmd/repo-updater/repos/store.go 83.03% <100.00%> (-3.79%) ⬇️
internal/authz/register.go 20.00% <100.00%> (+1.48%) ⬆️
... and 5 more

@unknwon
Copy link
Member Author

unknwon commented Sep 30, 2020

Since no real encryption is in place yet, there will be no harm to data if any application code behaves unexpected. Merging as-is and happy to address any post-merge comments!

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.

RFC-214: Transparent encryption and decryption for all tables that contain secrets or tokens
4 participants