diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-01-15 14:14:32 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-01-20 20:38:18 +0100 |
commit | ea367b598a98f8889383c917ceb7a6deb0c6ab7f (patch) | |
tree | 251f6f3f274081b51496379a6d5816f90bd011f5 /core | |
parent | 647d8ea5decad8140f9c280ae90039aa71c4eb93 (diff) | |
download | nextcloud-server-ea367b598a98f8889383c917ceb7a6deb0c6ab7f.tar.gz nextcloud-server-ea367b598a98f8889383c917ceb7a6deb0c6ab7f.zip |
Use path instead of app id
This change requires the usage of a path instead of the App ID when signing code. This has the advantage that developers can also sign code under a different location to make it easier. (e.g. remove `.git`, …)
Also it adds an example command usage as well as a link to the documentation
Diffstat (limited to 'core')
-rw-r--r-- | core/command/integrity/signapp.php | 25 | ||||
-rw-r--r-- | core/register_command.php | 3 |
2 files changed, 19 insertions, 9 deletions
diff --git a/core/command/integrity/signapp.php b/core/command/integrity/signapp.php index a203b9ad1da..53df9619c6d 100644 --- a/core/command/integrity/signapp.php +++ b/core/command/integrity/signapp.php @@ -23,6 +23,7 @@ namespace OC\Core\Command\Integrity; use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Helpers\FileAccessHelper; +use OCP\IURLGenerator; use phpseclib\Crypt\RSA; use phpseclib\File\X509; use Symfony\Component\Console\Command\Command; @@ -40,23 +41,28 @@ class SignApp extends Command { private $checker; /** @var FileAccessHelper */ private $fileAccessHelper; + /** @var IURLGenerator */ + private $urlGenerator; /** * @param Checker $checker * @param FileAccessHelper $fileAccessHelper + * @param IURLGenerator $urlGenerator */ public function __construct(Checker $checker, - FileAccessHelper $fileAccessHelper) { + FileAccessHelper $fileAccessHelper, + IURLGenerator $urlGenerator) { parent::__construct(null); $this->checker = $checker; $this->fileAccessHelper = $fileAccessHelper; + $this->urlGenerator = $urlGenerator; } protected function configure() { $this ->setName('integrity:sign-app') - ->setDescription('Sign app using a private key.') - ->addOption('appId', null, InputOption::VALUE_REQUIRED, 'Application to sign') + ->setDescription('Signs an app using a private key.') + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); } @@ -65,11 +71,14 @@ class SignApp extends Command { * {@inheritdoc } */ protected function execute(InputInterface $input, OutputInterface $output) { - $appId = $input->getOption('appId'); + $path = $input->getOption('path'); $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); - if(is_null($appId) || is_null($privateKeyPath) || is_null($keyBundlePath)) { - $output->writeln('--appId, --privateKey and --certificate are required.'); + if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { + $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); + $output->writeln('This command requires the --path, --privateKey and --certificate.'); + $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); + $output->writeln('For more information please consult the documentation: '. $documentationUrl); return null; } @@ -91,8 +100,8 @@ class SignApp extends Command { $x509 = new X509(); $x509->loadX509($keyBundle); $x509->setPrivateKey($rsa); - $this->checker->writeAppSignature($appId, $x509, $rsa); + $this->checker->writeAppSignature($path, $x509, $rsa); - $output->writeln('Successfully signed "'.$appId.'"'); + $output->writeln('Successfully signed "'.$path.'"'); } } diff --git a/core/register_command.php b/core/register_command.php index e43994530b9..5f9a2675873 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -36,7 +36,8 @@ $application->add(new OC\Core\Command\App\CheckCode($infoParser)); $application->add(new OC\Core\Command\L10n\CreateJs()); $application->add(new \OC\Core\Command\Integrity\SignApp( \OC::$server->getIntegrityCodeChecker(), - new \OC\IntegrityCheck\Helpers\FileAccessHelper() + new \OC\IntegrityCheck\Helpers\FileAccessHelper(), + \OC::$server->getURLGenerator() )); $application->add(new \OC\Core\Command\Integrity\SignCore( \OC::$server->getIntegrityCodeChecker(), |