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.3KB

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 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. /**
  42. * @var Checker
  43. */
  44. private $checker;
  45. public function __construct(Checker $checker) {
  46. parent::__construct();
  47. $this->checker = $checker;
  48. }
  49. /**
  50. * {@inheritdoc }
  51. */
  52. protected function configure() {
  53. parent::configure();
  54. $this
  55. ->setName('integrity:check-app')
  56. ->setDescription('Check integrity of an app using a signature.')
  57. ->addArgument('appid', InputArgument::REQUIRED, 'Application to check')
  58. ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
  59. }
  60. /**
  61. * {@inheritdoc }
  62. */
  63. protected function execute(InputInterface $input, OutputInterface $output): int {
  64. $appid = $input->getArgument('appid');
  65. $path = (string)$input->getOption('path');
  66. $result = $this->checker->verifyAppSignature($appid, $path, true);
  67. $this->writeArrayInOutputFormat($input, $output, $result);
  68. if (count($result) > 0) {
  69. return 1;
  70. }
  71. return 0;
  72. }
  73. }