summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-08 21:42:34 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-08 21:42:34 +0100
commit850ac0cf84f2492b16204b811f58a0dc7dc43b6e (patch)
treea63570eab9ec3febc0b316386cb895106824b1d2
parentb77a4b0c6a3c34587316350dbf0ee222fd681b49 (diff)
parent5910b82de1fe7c19fd47a4cd1bf77093f437264a (diff)
downloadnextcloud-server-850ac0cf84f2492b16204b811f58a0dc7dc43b6e.tar.gz
nextcloud-server-850ac0cf84f2492b16204b811f58a0dc7dc43b6e.zip
Merge pull request #22170 from owncloud/occ-check-signature
CLI commands to check app and core signatures
-rw-r--r--core/command/integrity/checkapp.php69
-rw-r--r--core/command/integrity/checkcore.php62
-rw-r--r--core/register_command.php7
3 files changed, 138 insertions, 0 deletions
diff --git a/core/command/integrity/checkapp.php b/core/command/integrity/checkapp.php
new file mode 100644
index 00000000000..87b8eb47687
--- /dev/null
+++ b/core/command/integrity/checkapp.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * @author Victor Dubiniuk <dubiniuk@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OC\Core\Command\Integrity;
+
+use OC\IntegrityCheck\Checker;
+use OC\Core\Command\Base;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Class CheckApp
+ *
+ * @package OC\Core\Command\Integrity
+ */
+class CheckApp extends Base {
+
+ /**
+ * @var Checker
+ */
+ private $checker;
+
+ public function __construct(Checker $checker) {
+ parent::__construct();
+ $this->checker = $checker;
+ }
+
+ /**
+ * {@inheritdoc }
+ */
+ protected function configure() {
+ parent::configure();
+ $this
+ ->setName('integrity:check-app')
+ ->setDescription('Check an app integrity using a signature.')
+ ->addArgument('appid', null, InputArgument::REQUIRED, 'Application to check')
+ ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
+ }
+
+ /**
+ * {@inheritdoc }
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $appid = $input->getArgument('appid');
+ $path = strval($input->getOption('path'));
+ $result = $this->checker->verifyAppSignature($appid, $path);
+ $this->writeArrayInOutputFormat($input, $output, $result);
+ }
+
+}
diff --git a/core/command/integrity/checkcore.php b/core/command/integrity/checkcore.php
new file mode 100644
index 00000000000..ac29937e2ed
--- /dev/null
+++ b/core/command/integrity/checkcore.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * @author Victor Dubiniuk <dubiniuk@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Core\Command\Integrity;
+
+use OC\IntegrityCheck\Checker;
+use OC\Core\Command\Base;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Class CheckCore
+ *
+ * @package OC\Core\Command\Integrity
+ */
+class CheckCore extends Base {
+ /**
+ * @var Checker
+ */
+ private $checker;
+
+ public function __construct(Checker $checker) {
+ parent::__construct();
+ $this->checker = $checker;
+ }
+
+ /**
+ * {@inheritdoc }
+ */
+ protected function configure() {
+ parent::configure();
+ $this
+ ->setName('integrity:check-core')
+ ->setDescription('Check a core integrity using a signature.');
+ }
+
+ /**
+ * {@inheritdoc }
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $result = $this->checker->verifyCoreSignature();
+ $this->writeArrayInOutputFormat($input, $output, $result);
+ }
+}
diff --git a/core/register_command.php b/core/register_command.php
index 5f9a2675873..2e9e80fe8d7 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -43,6 +43,13 @@ $application->add(new \OC\Core\Command\Integrity\SignCore(
\OC::$server->getIntegrityCodeChecker(),
new \OC\IntegrityCheck\Helpers\FileAccessHelper()
));
+$application->add(new \OC\Core\Command\Integrity\CheckApp(
+ \OC::$server->getIntegrityCodeChecker()
+));
+$application->add(new \OC\Core\Command\Integrity\CheckCore(
+ \OC::$server->getIntegrityCodeChecker()
+));
+
if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));