Skip to content

Commit ddd4f3b

Browse files
Addressing review comments
1 parent 5278c27 commit ddd4f3b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

cpp/src/parquet/encryption/crypto_factory.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828

2929
namespace parquet::encryption {
3030

31+
/// Extracting functionality common to both GetFileEncryptionProperties and
32+
/// GetExternalFileEncryptionProperties here for reuse.
3133
namespace {
3234

35+
// Struct to simplify the returned objects in GetFileKeyUtils.
3336
struct FileKeyUtils {
3437
std::shared_ptr<FileKeyMaterialStore> key_material_store;
3538
FileKeyWrapper key_wrapper;
@@ -63,7 +66,7 @@ int ValidateAndGetKeyLength(int32_t dek_length_bits) {
6366
if (!internal::ValidateKeyLength(dek_length_bits)) {
6467
std::ostringstream ss;
6568
ss << "Wrong data key length : " << dek_length_bits;
66-
throw ParquetException (ss.str());
69+
throw ParquetException(ss.str());
6770
}
6871
return dek_length_bits / 8;
6972
}
@@ -126,6 +129,9 @@ CryptoFactory::GetExternalFileEncryptionProperties(
126129
const ExternalEncryptionConfiguration& external_encryption_config,
127130
const std::string& file_path, const std::shared_ptr<::arrow::fs::FileSystem>& file_system) {
128131
// Validate the same rules as FileEncryptionProperties but considering per_column_encryption too.
132+
// If uniform_encryption is not set then either column_keys or per_column_encryption must have
133+
// values.
134+
// If uniform_encryption is set, then both column_keys and per_column_encryption must be empty.
129135
bool no_columns_encrypted = external_encryption_config.column_keys.empty() &&
130136
external_encryption_config.per_column_encryption.empty();
131137
if (!external_encryption_config.uniform_encryption && no_columns_encrypted) {
@@ -167,10 +173,11 @@ CryptoFactory::GetExternalFileEncryptionProperties(
167173
const std::string& column_name = pair.first;
168174
const ColumnEncryptionAttributes& attributes = pair.second;
169175

170-
// Validate column names are not in both collumn_keys and per_column_encryption maps.
176+
// Validate column names are not in both column_keys and per_column_encryption maps.
171177
if (encrypted_columns.find(column_name) != encrypted_columns.end()) {
172178
std::stringstream string_stream;
173-
string_stream << "Multiple keys defined for column [" << column_name << "] \n";
179+
string_stream << "Multiple keys defined for column [" << column_name << "]. ";
180+
string_stream << "Keys found in column_keys and in per_column_encryption.";
174181
throw ParquetException(string_stream.str());
175182
}
176183

cpp/src/parquet/encryption/crypto_factory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ struct PARQUET_EXPORT ExternalEncryptionConfiguration : public EncryptionConfigu
122122
/// enforce robust access control. The values sent to the external service depend on each
123123
/// implementation.
124124
/// This value must be a valid JSON-formatted string.
125+
/// Validation of the string will be done by the external encryption service, Arrow will only
126+
/// forward this value.
125127
/// Format: "{\"user_id\": \"abc123\", \"location\": {\"lat\": 9.7489, \"lon\": -83.7534}}"
126128
std::string app_context;
127129

cpp/src/parquet/encryption/properties_test.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,13 @@ TEST(TestExternalFileEncryptionProperties, SuperClassFieldsSetCorrectly) {
283283

284284
// The subclass adds two additional fields
285285
TEST(TestExternalFileEncryptionProperties, SetExternalContextAndConfig) {
286-
std::string app_context = "String containing valid JSON with app context. Not parsed here";
286+
std::string app_context = "{\n"
287+
" \"user_id\": \"abc123\",\n"
288+
" \"location\": {\n"
289+
" \"lat\": 10.0,\n"
290+
" \"lon\": -84.0\n"
291+
" }\n"
292+
"}";
287293
std::map<std::string, std::string> connection_config;
288294
connection_config["lib_location"] = "path/to/lib.so";
289295
connection_config["config_file"] = "path/to/config/file";

0 commit comments

Comments
 (0)