input()->getArgument('target') == '@prod') { throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__])); } } /** * Limit rsync operations to production site. */ #[CLI\Hook(type: HookManager::ARGUMENT_VALIDATOR, target: RsyncCommands::RSYNC)] public function rsyncValidate(CommandData $commandData) { if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) { throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__])); } } /** * Unauthorized may not execute updates. */ #[CLI\Hook(type: HookManager::ARGUMENT_VALIDATOR, target: UpdateDBCommands::UPDATEDB)] public function validateUpdateDb(CommandData $commandData) { if (!$commandData->input()->getOption('secret') == 'mysecret') { throw new \Exception(dt('UpdateDb command requires a secret token per site policy.')); } } #[CLI\Hook(type: HookManager::OPTION_HOOK, target: UpdateDBCommands::UPDATEDB)] #[CLI\Option(name: 'secret', description: 'A required token else user may not run updatedb command.')] public function optionsetUpdateDb($options = ['secret' => self::REQ]) { } }