CheckApp.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Carla Schroder <carla@owncloud.com>
  6. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\Core\Command\Integrity;
  24. use OC\IntegrityCheck\Checker;
  25. use OC\Core\Command\Base;
  26. use Symfony\Component\Console\Input\InputInterface;
  27. use Symfony\Component\Console\Input\InputArgument;
  28. use Symfony\Component\Console\Input\InputOption;
  29. use Symfony\Component\Console\Output\OutputInterface;
  30. /**
  31. * Class CheckApp
  32. *
  33. * @package OC\Core\Command\Integrity
  34. */
  35. class CheckApp 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-app')
  51. ->setDescription('Check integrity of an app using a signature.')
  52. ->addArgument('appid', InputArgument::REQUIRED, 'Application to check')
  53. ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
  54. }
  55. /**
  56. * {@inheritdoc }
  57. */
  58. protected function execute(InputInterface $input, OutputInterface $output) {
  59. $appid = $input->getArgument('appid');
  60. $path = (string)$input->getOption('path');
  61. $result = $this->checker->verifyAppSignature($appid, $path);
  62. $this->writeArrayInOutputFormat($input, $output, $result);
  63. if (count($result)>0){
  64. return 1;
  65. }
  66. }
  67. }