Skip to content

Commit 61a8118

Browse files
committed
Escape mongocryptd path before calling it
1 parent 8a8bdd4 commit 61a8118

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/DataCollector/EncryptionDiagnostic.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composer\InstalledVersions;
88
use ReflectionExtension;
99

10+
use function escapeshellarg;
1011
use function exec;
1112
use function explode;
1213
use function extension_loaded;
@@ -71,7 +72,7 @@ private function getMongocryptdVersion(?string $mongocryptdPath): ?string
7172
}
7273

7374
$output = [];
74-
exec($mongocryptdPath . ' --version', $output);
75+
exec(escapeshellarg($mongocryptdPath) . ' --version', $output);
7576

7677
if (isset($output[0])) {
7778
return trim($output[0]);

src/DependencyInjection/DoctrineMongoDBExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ private function normalizeAutoEncryption(array $autoEncryption, string $defaultD
542542

543543
if (isset($autoEncryption['encryptedFieldsMap'])) {
544544
foreach ($autoEncryption['encryptedFieldsMap'] as &$value) {
545+
// Wrap the encrypted fields in a 'fields' key as required the encryptedFieldsMap structure.
546+
// Some values can be BSON binary, date or numbers, the extended JSON format is used to convert them BSON document.
545547
$value = (new Definition(BsonDocument::class))->setFactory([BsonDocument::class, 'fromJSON'])->setArguments([json_encode(['fields' => $value])]);
546548
}
547549
}

0 commit comments

Comments
 (0)