setName('backup:target:trust-current') ->setDescription('Accept the current state of a location that was refused as rolled back') ->addArgument('target', InputArgument::REQUIRED, 'Location name or id') ->setHelp("NG Backup refuses a location whose backup catalog is older than what this server saw\n" . "before, because an attacker could have restored an old state. If you restored the location\n" . "yourself (e.g. from the provider's snapshot), accept it with this command."); } protected function execute(InputInterface $input, OutputInterface $output): int { $t = $this->targets->get($input->getArgument('target')); $output->writeln('Only continue if you know why the location shows an older state.'); $answer = (string)$this->getHelper('question')->ask($input, $output, new Question('Type the location name to accept its current state: ')); if ($answer !== $t->getName()) { $output->writeln('Not confirmed.'); return 1; } $this->appConfig->deleteKey('ng_backup', 'catalog_' . preg_replace('/[^a-f0-9]/', '', (string)$t->getRepositoryId())); $repo = $this->targets->repository($t); // re-anchors on the newest valid catalog $this->alerts->securityEvent('catalog_trusted', ['target' => $t->getName(), 'generation' => (string)$repo->catalogGeneration()]); $output->writeln(sprintf('Accepted generation %d of %s (%d snapshots).', $repo->catalogGeneration(), $t->getName(), count($repo->listSnapshots()))); return 0; } }