Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PG-1661 Validate key coming from key providers #448

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

Open
wants to merge 2 commits into
base: TDE_REL_17_STABLE
Choose a base branch
from

Conversation

artemgavrilov
Copy link
Collaborator

@artemgavrilov artemgavrilov commented Jun 20, 2025

https://perconadev.atlassian.net/browse/PG-1661

  • Check that key that we retrieved from key provider is valid (has name, data length within range)
  • Free memory once key KeyInfo object no longer needed
  • Unify and improve error messages
  • Fix potential null pointer de-reference in vault key provider

@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 51.61290% with 30 lines in your changes missing coverage. Please review.

Project coverage is 84.12%. Comparing base (600172d) to head (cddf796).
Report is 1 commits behind head on TDE_REL_17_STABLE.

❌ Your project status has failed because the head coverage (84.12%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           TDE_REL_17_STABLE     #448      +/-   ##
=====================================================
- Coverage              84.65%   84.12%   -0.54%     
=====================================================
  Files                     21       21              
  Lines                   2588     2639      +51     
  Branches                 401      411      +10     
=====================================================
+ Hits                    2191     2220      +29     
- Misses                   316      336      +20     
- Partials                  81       83       +2     
Components Coverage Δ
access 81.11% <ø> (ø)
catalog 87.90% <43.75%> (-0.33%) ⬇️
common 77.77% <ø> (ø)
encryption 73.45% <ø> (ø)
keyring 71.42% <54.34%> (-1.46%) ⬇️
src 91.44% <ø> (ø)
smgr 94.85% <ø> (ø)
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@artemgavrilov artemgavrilov force-pushed the PG-1661-key-validation branch 2 times, most recently from 1bd74da to 4f1e571 Compare June 21, 2025 13:57
@artemgavrilov artemgavrilov marked this pull request as ready for review June 21, 2025 13:57
@artemgavrilov artemgavrilov force-pushed the PG-1661-key-validation branch from 25c5bf8 to 55d69e4 Compare June 24, 2025 09:57
@artemgavrilov artemgavrilov requested review from dutow and removed request for jeltz, AndersAstrand and dAdAbird June 24, 2025 10:26
@dutow
Copy link
Collaborator

dutow commented Jun 25, 2025

There's also a typo in the pr title / commit message

@artemgavrilov artemgavrilov changed the title PG-1661 Validate key comming from key providers PG-1661 Validate key coming from key providers Jun 25, 2025
@artemgavrilov artemgavrilov force-pushed the PG-1661-key-validation branch 3 times, most recently from 2930442 to f192413 Compare June 25, 2025 16:15
@@ -252,7 +252,7 @@ WARNING: The WAL encryption feature is currently in beta and may be unstable. D
(1 row)

SELECT pg_tde_change_global_key_provider_file('global-provider','/tmp/global-provider-file-2');
ERROR: could not fetch key "server-key" used as server key from modified key provider "global-provider": 0
ERROR: key "server-key" not found in key provider "global-provider"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This message doesn't seem correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We expect that new key provider has key with the same name as current one. This error happens in some internal function that checks that new key provider has the same key as previous one.

Will proposed key provider "global-provider" doesn't have expected key "server key" be better error message for that?

Copy link
Collaborator

@AndersAstrand AndersAstrand Jun 27, 2025

Choose a reason for hiding this comment

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

I originally went with "proposed" for the key providers settings that weren't yet in effect. Zsolt suggested "modified" and I agreed.

I'm not sure this message needs to be changed at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before there was no difference if we got an error from key provider of if the key not found. Now it's two separate error messages. I updated PR to restore original meaning, but kept "key not found" part. What do you think?

Check that key that we retreived from key provider is valid.
Key provider may return json without expected fields. Check key field
for non-null value before processing.
@artemgavrilov artemgavrilov force-pushed the PG-1661-key-validation branch from f192413 to 903fc4d Compare June 27, 2025 10:34
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