CheckApp.php 2.3 KB

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