CheckCore.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Carla Schroder <carla@owncloud.com>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Core\Command\Integrity;
  26. use OC\Core\Command\Base;
  27. use OC\IntegrityCheck\Checker;
  28. use Symfony\Component\Console\Input\InputInterface;
  29. use Symfony\Component\Console\Output\OutputInterface;
  30. /**
  31. * Class CheckCore
  32. *
  33. * @package OC\Core\Command\Integrity
  34. */
  35. class CheckCore extends Base {
  36. /**
  37. * @var Checker
  38. */
  39. private $checker;
  40. public function __construct(Checker $checker) {
  41. parent::__construct();
  42. $this->checker = $checker;
  43. }
  44. /**
  45. * {@inheritdoc }
  46. */
  47. protected function configure() {
  48. parent::configure();
  49. $this
  50. ->setName('integrity:check-core')
  51. ->setDescription('Check integrity of core code using a signature.');
  52. }
  53. /**
  54. * {@inheritdoc }
  55. */
  56. protected function execute(InputInterface $input, OutputInterface $output): int {
  57. $result = $this->checker->verifyCoreSignature();
  58. $this->writeArrayInOutputFormat($input, $output, $result);
  59. if (count($result)>0) {
  60. return 1;
  61. }
  62. return 0;
  63. }
  64. }