From d2998963fad15cee2985c03dbf0a269dbc59f810 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 25 Jul 2022 08:12:14 +0000 Subject: [PATCH] formatting --- app/init.php | 10 +++++----- app/tasks/maintenance.php | 1 - app/workers/encryption.php | 10 ++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/init.php b/app/init.php index 781fcbfdfb..3411237119 100644 --- a/app/init.php +++ b/app/init.php @@ -381,11 +381,11 @@ Database::addFilter( Database::addFilter( 'masterEncrypt', - function(mixed $value, Document $document, Database $database) { + function (mixed $value, Document $document, Database $database) { $keyId = $document->getAttribute('keyId', ''); $database->setNamespace('_console'); $key = Authorization::skip(fn() => $database->getDocument('secrets', $keyId)); - if($key->isEmpty()) { + if ($key->isEmpty()) { throw new Exception("Unable to find master key with ID ($keyId} to encrypt."); } @@ -400,15 +400,15 @@ Database::addFilter( 'version' => $keyId, ]); }, - function(mixed $value, Document $document, Database $database) { - if(is_null($value)) { + function (mixed $value, Document $document, Database $database) { + if (is_null($value)) { return null; } $value = json_decode($value, true); $keyId = $value['version']; $database->setNamespace('_console'); $key = Authorization::skip(fn() => $database->getDocument('secrets', $keyId)); - if($key->isEmpty()) { + if ($key->isEmpty()) { throw new Exception("Unable to find master key with ID {$keyId} to decrypt."); } $secret = $key->getAttribute('secret'); diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index 4c7163e1ec..9235b52b38 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -148,7 +148,6 @@ $cli } else { Console::info("[{$time}] No projects for key rotation."); } - } // # of days in seconds (1 day = 86400s) diff --git a/app/workers/encryption.php b/app/workers/encryption.php index 582953ac36..136b8eac4c 100644 --- a/app/workers/encryption.php +++ b/app/workers/encryption.php @@ -28,7 +28,7 @@ class EncryptionV1 extends Worker { $type = $this->args['type'] ?? ''; - switch($type) { + switch ($type) { case APP_ENCRYPTION_TYPE_PROJECT_MASTER_KEY: $project = new Document($this->args['project'] ?? []); $this->rotateMasterKeyForProject($project); @@ -50,10 +50,12 @@ class EncryptionV1 extends Worker '$collection' => 'secrets', 'secret' => OpenSSL::secretString(), ]))); - $dbForConsole->updateDocument('projects', $projectId, + $dbForConsole->updateDocument( + 'projects', + $projectId, $project ->setAttribute('keyId', $secret->getId()) ->setAttribute('keyRotationDate', time() + App::getEnv('_APP_KEY_ROTATION_INTERVAL', 60 * 60 * 24 * 90)) - ); + ); } -} \ No newline at end of file +}