Skip to content

ARROW-9318: [C++] Parquet encryption key management - #8023

Closed
thamht4190 wants to merge 121 commits into
apache:masterfrom
thamht4190:arrow-9318-encryption-key-management
Closed

thamht4190 wants to merge 121 commits into
apache:masterfrom
thamht4190:arrow-9318-encryption-key-management

Conversation

@thamht4190

Copy link
Copy Markdown
Contributor

This PR is C++ implementation for parquet key tool, based on the Java implementation and the design doc.

The major parts of this PR are:

  • higher level of encryption/decryption configuration, including key management configuration.
  • KMS connection configuration
  • Abstract class KmsClient, KmsClientFactory
  • PropertiesDrivenCryptoFactory class to convert these above configurations to the lower level FileEncryptionProperties, FileDecryptionProperties
  • unit test using InMemoryKms (an sample of KmsClient).

Comparing to Java version, this C++ pull doesn't contain externally storing key material using hadoop file system (only storing key material internally in parquet file is supported for now). The reason is lack of understanding about Hadoop file system, can be implemented it later in another pull.

Thanks!

@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

Could you open an issue for this pull request on JIRA?
https://issues.apache.org/jira/browse/ARROW

Then could you also rename pull request title in the following format?

ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}

See also:

@thamht4190 thamht4190 changed the title Arrow 9318 encryption key management ARROW-9318: [C++] Parquet encryption key management Aug 22, 2020
@github-actions

Copy link
Copy Markdown

Comment thread cpp/src/parquet/encryption.h Resolved
Comment thread cpp/src/parquet/key_toolkit.h Resolved
Comment thread cpp/src/parquet/kms_client.h Resolved
Comment thread cpp/src/parquet/kms_client.h Resolved
Comment thread cpp/src/parquet/kms_client_factory.h Resolved
Comment thread cpp/src/parquet/string_util.h Resolved

@emkornfield emkornfield left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I made some style comments but didn't flag every place that they were an issue. Please self review to fix (it also looks like you might need to run clang-format as the lint is failing).

I would expect additional tests around individual files and not just end-to-end tests (any place with non trivial implementations should probably have at least one or two tests. excercising of error conditions on json parsing I think would also be useful.

Another issue is thread-safey. It would be good to clarify which classes are expected/not-expected to be thread safe. For instance, I would at lease expect client caches to be thread safe but it doesn't look like they were implemented to be.

Also this PR is quite large is there any way that it could possibly be broken up into smaller units?

Comment thread cpp/src/parquet/test_encryption_util.h Resolved
Comment thread cpp/src/parquet/CMakeLists.txt Resolved
Comment thread cpp/src/parquet/encryption.h Resolved
Comment thread cpp/src/parquet/encryption_internal.h Resolved
@thamht4190
thamht4190 force-pushed the arrow-9318-encryption-key-management branch from a96c7e4 to 7206be0 Compare September 3, 2020 14:54
@pitrou

pitrou commented Sep 3, 2020

Copy link
Copy Markdown
Member

Just a drive-by comment for now, but given the number of files added I think we should create a src/parquet/encryption subdirectory.

Comment thread cpp/src/parquet/file_key_wrapper.h Resolved
Comment thread cpp/src/parquet/file_key_wrapper.h Resolved
Comment thread cpp/src/parquet/file_key_wrapper.h Resolved
Comment thread cpp/src/parquet/key_toolkit.h Resolved
Comment thread cpp/src/parquet/key_toolkit.h Resolved
Comment thread cpp/src/parquet/key_toolkit.h Resolved
Comment thread cpp/src/parquet/key_toolkit.h Resolved
@thamht4190
thamht4190 force-pushed the arrow-9318-encryption-key-management branch from 794ece0 to c8c5aa2 Compare February 27, 2021 15:39
@thamht4190

thamht4190 commented Feb 28, 2021 •

Copy link
Copy Markdown
Contributor Author

I fixed all the comments in this pull, can you please take a look? @emkornfield @pitrou @bkietz cc @ggershinsky

@pitrou

pitrou commented Mar 10, 2021

Copy link
Copy Markdown
Member

Ok, I've pushed some updates to try and conform with coding conventions a bit more.

Some high-level comments:

I also don't have a personal interest in this currently and I recognize that the PR implements a useful functionality.
@ggershinsky @thamht4190 Do you plan to address some of these concerns in this PR? Otherwise, I may merge this and users of this code will have to be mindful of potential issues.

@ggershinsky

Copy link
Copy Markdown
Contributor

@pitrou My personal preference is the latter - merging this pr and letting the users of this code to be mindful of potential issues. This is safer than proceeding with the current low-level interface work, which has many more security and other issues. When this pr is merged, it will unblock the users who'd create the high-level interface in Python and address the API point (I'll add a link to this thread in the Python design doc; the Python API is to be reviewed; the C++ API could be synced accordingly).

Regarding the second point - we'll be testing the interop with the Java counterpart, to make sure the spec is implemented properly. Regarding the third point, I think the code is safe, as per our discussion in that jira.

@pitrou

pitrou commented Mar 11, 2021 •

Copy link
Copy Markdown
Member

As for testing, I'd still welcome unit tests with actual pieces of JSON as per the spec, but I won't insist on it here :-)

Last question: do we want to mark those APIs experimental so that we feel free to change them in the future?

@ggershinsky

Copy link
Copy Markdown
Contributor

Thanks! Yep, I think it's a good idea to mark them as experimental, there is a chance they'll be updated in the course of the Python API work.

@emkornfield

Copy link
Copy Markdown
Contributor

I also don't have a personal interest in this currently and I recognize that the PR implements a useful functionality.
@ggershinsky @thamht4190 Do you plan to address some of these concerns in this PR? Otherwise, I may merge this and users of this code will have to be mindful of potential issues.

I'll try to look tonight but this makes it sound like there are general concerns around quality here, and that doesn't seem like something we want to merge (especially if it is security related). If I get distracted and don't give feedback by monday, it is OK not to block on me.

@ggershinsky

Copy link
Copy Markdown
Contributor

Thanks. To clarify - the security concerns I've mentioned above, relate to low level encryption, not to this pull request.

@pitrou

pitrou commented Mar 15, 2021

Copy link
Copy Markdown
Member

@emkornfield Feel free to take a last look.

@emkornfield

Copy link
Copy Markdown
Contributor

It looks like there are JSON changes in here? does this need a rebase?

@pitrou

pitrou commented Mar 16, 2021

Copy link
Copy Markdown
Member

@emkornfield The JSON changes are expected, the encryption layer needs to parse and generate some JSON.

@emkornfield

Copy link
Copy Markdown
Contributor

@emkornfield The JSON changes are expected, the encryption layer needs to parse and generate some JSON.

Ah right, I forgot, will start looking again.

@emkornfield

Copy link
Copy Markdown
Contributor

Sorry didn't get a chance to look. @pitrou if you are comfortable with changes please go ahead and merge

@pitrou

pitrou commented Mar 17, 2021

Copy link
Copy Markdown
Member

I'll merge then. Thank you @thamht4190 and @ggershinsky for contributing this!

@pitrou pitrou closed this in 5b14d53 Mar 17, 2021
pitrou added a commit that referenced this pull request Mar 2, 2022
…files.

Exposes in PyArrow the high-level C++ API for Parquet encryption that was added in #8023.
Design document:  https://docs.google.com/document/d/1i1M5f5azLEmASj9XQZ_aQLl5Fr5F0CvnyPPVu1xaD9U
A test is added for writing and reading encrypted parquet files using a simple in-memory KMS for testing, that is not to be used as an example of a KMS client. In addition, there is an example KMS client using Vault KMS.

This PR handles only the file-level encryption and decryption.
Dataset is handled in separate PRs.
The investigation of the multithreading model of PME is separated into a separate issue, independent of this one.

Closes #10450 from andersonm-ibm/encryption

Lead-authored-by: Maya Anderson <[email protected]>
Co-authored-by: andersonm-ibm <[email protected]>
Co-authored-by: roee88 <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: C++ Component: Parquet needs-rebase A PR that needs to be rebased by the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants