You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CheckApp.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Georg Ehrke <oc.list@georgehrke.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OC\Core\Command\Integrity;
  29. use OC\Core\Command\Base;
  30. use OC\IntegrityCheck\Checker;
  31. use Symfony\Component\Console\Input\InputArgument;
  32. use Symfony\Component\Console\Input\InputInterface;
  33. use Symfony\Component\Console\Input\InputOption;
  34. use Symfony\Component\Console\Output\OutputInterface;
  35. /**
  36. * Class CheckApp
  37. *
  38. * @package OC\Core\Command\Integrity
  39. */
  40. class CheckApp extends Base {
  41. private Checker $checker;
  42. public function __construct(Checker $checker) {
  43. parent::__construct();
  44. $this->checker = $checker;
  45. }
  46. /**
  47. * {@inheritdoc }
  48. */
  49. protected function configure() {
  50. parent::configure();
  51. $this
  52. ->setName('integrity:check-app')
  53. ->setDescription('Check integrity of an app using a signature.')
  54. ->addArgument('appid', InputArgument::REQUIRED, 'Application to check')
  55. ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
  56. }
  57. /**
  58. * {@inheritdoc }
  59. */
  60. protected function execute(InputInterface $input, OutputInterface $output): int {
  61. $appid = $input->getArgument('appid');
  62. $path = (string)$input->getOption('path');
  63. $result = $this->checker->verifyAppSignature($appid, $path, true);
  64. $this->writeArrayInOutputFormat($input, $output, $result);
  65. if (count($result) > 0) {
  66. $output->writeln('<error>' . count($result) . ' errors found</error>', OutputInterface::VERBOSITY_VERBOSE);
  67. return 1;
  68. }
  69. $output->writeln('<info>No errors found</info>', OutputInterface::VERBOSITY_VERBOSE);
  70. return 0;
  71. }
  72. }