2016-02-05 13:09:27 -05:00
|
|
|
<?php
|
2024-05-24 13:43:47 -04:00
|
|
|
|
2016-02-05 13:09:27 -05:00
|
|
|
/**
|
2024-05-24 13:43:47 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-02-05 13:09:27 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Core\Command\Integrity;
|
|
|
|
|
|
|
|
|
|
use OC\Core\Command\Base;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OC\IntegrityCheck\Checker;
|
2016-02-05 13:09:27 -05:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
|
|
/**
|
2016-02-05 13:18:02 -05:00
|
|
|
* Class CheckCore
|
2016-02-05 13:09:27 -05:00
|
|
|
*
|
|
|
|
|
* @package OC\Core\Command\Integrity
|
|
|
|
|
*/
|
|
|
|
|
class CheckCore extends Base {
|
2023-06-13 08:31:34 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private Checker $checker,
|
|
|
|
|
) {
|
2016-02-05 13:09:27 -05:00
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritdoc }
|
|
|
|
|
*/
|
|
|
|
|
protected function configure() {
|
|
|
|
|
parent::configure();
|
|
|
|
|
$this
|
|
|
|
|
->setName('integrity:check-core')
|
2016-03-16 19:14:25 -04:00
|
|
|
->setDescription('Check integrity of core code using a signature.');
|
2016-02-05 13:09:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritdoc }
|
|
|
|
|
*/
|
2020-06-26 08:54:51 -04:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2021-01-15 10:37:46 -05:00
|
|
|
if (!$this->checker->isCodeCheckEnforced()) {
|
|
|
|
|
$output->writeln('<comment>integrity:check-core can not be used on git checkouts</comment>');
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-05 13:09:27 -05:00
|
|
|
$result = $this->checker->verifyCoreSignature();
|
|
|
|
|
$this->writeArrayInOutputFormat($input, $output, $result);
|
2020-10-05 09:12:57 -04:00
|
|
|
if (count($result) > 0) {
|
2021-07-08 15:17:29 -04:00
|
|
|
$output->writeln('<error>' . count($result) . ' errors found</error>', OutputInterface::VERBOSITY_VERBOSE);
|
2016-12-01 10:50:27 -05:00
|
|
|
return 1;
|
|
|
|
|
}
|
2021-07-08 15:17:29 -04:00
|
|
|
$output->writeln('<info>No errors found</info>', OutputInterface::VERBOSITY_VERBOSE);
|
2020-06-26 08:54:51 -04:00
|
|
|
return 0;
|
2016-02-05 13:09:27 -05:00
|
|
|
}
|
|
|
|
|
}
|