Commit Graph

248 Commits

Author SHA1 Message Date
Lukas Reschke 4971015544 Add code integrity check
This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository.

Furthermore, there is a basic implementation to display problems with the code integrity on the update screen.

Code signing basically happens the following way:

- There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release 😉). This certificate is not intended to be used for signing directly and only is used to sign new certificates.
- Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`,  apps need to be signed with a certificate that either has a CN of `core` (shipped apps!)  or the AppID.
- The command generates a signature.json file of the following format:
```json
{
    "hashes": {
        "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d",
        "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9"
    },
    "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----",
    "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl"
}
```
`hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the  certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`.

Steps to do in other PRs, this is already a quite huge one:
- Add nag screen in case the code check fails to ensure that administrators are aware of this.
- Add code verification also to OCC upgrade and unify display code more.
- Add enforced code verification to apps shipped from the appstore with a level of "official"
- Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release
- Add some developer documentation on how devs can request their own certificate
- Check when installing ownCloud
- Add support for CRLs to allow revoking certificates

**Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature:

```
➜  master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt
Successfully signed "core"
```

Then increase the version and you should see something like the following:

![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png)

As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen.

For packaging stable releases this requires the following additional steps as a last action before zipping:
1. Run `./occ integrity:sign-core` once
2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
2015-12-01 11:55:20 +01:00
Victor Dubiniuk 8d9353a640 Add cmdline key to show shipped/non-shipped apps only 2015-11-23 09:06:35 +01:00
Joas Schilling fe04451cb1 Do not allow two different version requirements 2015-11-09 11:10:37 +01:00
Morris Jobke f46d531a4f Replace some OC_Config calls with ILogger methods 2015-10-30 09:51:16 +01:00
Joas Schilling e5a7e3124a Add a repair step that checks for group membership on shares 2015-10-29 09:26:26 +01:00
Morris Jobke 3b249f1967 Revert "setting to skip migration tests by default"
This reverts commit 7cbdd9b90b.
2015-10-27 21:25:11 +01:00
Lukas Reschke 8f09d5b67c Update license headers 2015-10-26 14:04:01 +01:00
Joas Schilling 9200bbeaba Update: state which step we are going to start and warn if it might be slow 2015-10-21 09:17:38 +02:00
Thomas Müller 4cb5970947 Always pass in ILogger 2015-10-09 14:08:22 +02:00
Morris Jobke 8366ce2767 deduplicate @xenopathic 2015-10-06 09:52:19 +02:00
Morris Jobke b945d71384 update licence headers via script 2015-10-05 21:15:52 +02:00
Morris Jobke 7cbdd9b90b setting to skip migration tests by default
* if you install owncloud via package it is not
  possible to skip migration tests
* this also allows to disable migration tests for
  an instance by default
2015-10-01 14:23:25 +02:00
Morris Jobke 5acb38b5b3 [upgrade] switch to debug logging on upgrade
* resets afterwards
* adds output about the previous log level
2015-09-29 14:35:32 +02:00
Joas Schilling faba02564a Move the filtering of sensitive data to the config class 2015-09-25 11:08:33 +02:00
Morris Jobke 5a3e57c2f5 encode arrays as string 2015-09-24 12:48:44 +02:00
Morris Jobke 9b652ed5d5 [App Code Check] add check for version and mandatory fields
* ref #17598
* including unit tests for mandatory fields/versions
2015-09-24 11:58:12 +02:00
Bjoern Schiessle 03e05d5dbc improve description and help output for the encrypt-all and decrypt-all command 2015-09-21 16:48:14 +02:00
Joas Schilling 5472a5f455 Also catch exceptions on encryptAll and reset trashbin and singleUser mode 2015-09-18 15:05:18 +02:00
Joas Schilling 2f102c1f0d Do not set single user in constructor 2015-09-18 08:55:59 +02:00
Joas Schilling 82eb3f8027 Fix the singleuser config casing in new encryption code 2015-09-17 08:48:25 +02:00
Bjoern Schiessle 9bd4f2d41e occ script to disable encryption and to decrypt all files again 2015-09-15 22:39:44 +02:00
Bjoern Schiessle 69b64b5b10 use the same pattern for the command name like every other command 2015-09-14 12:00:39 +02:00
Robin McCorkell 19830e6c24 Introduce mimetype DB update occ command 2015-09-04 17:37:09 +01:00
Robin McCorkell 79fceeff33 Move maintenance:mimetypesjs to sublocation, cleanup code 2015-09-01 14:12:07 +01:00
Bjoern Schiessle 289e9130f3 make system root of key storage configurable 2015-08-30 19:00:03 +02:00
Björn Schießle 6e210d960c Merge pull request #18423 from owncloud/occ_encrypt_all
occ command line tool to encrypt all files
2015-08-28 20:44:55 +02:00
Bjoern Schiessle 8c08dd0ac2 occ tool to encrypt all files 2015-08-26 14:58:22 +02:00
Morris Jobke c7b0d50cb2 Merge pull request #18369 from owncloud/occ-log
occ commands to manage logging
2015-08-20 12:57:05 +02:00
Morris Jobke 4c93a07196 Merge pull request #18424 from owncloud/filter-objectstore-password-from-config-list
Filter the objectstore password from the config list as well
2015-08-19 16:24:01 +02:00
Joas Schilling 6231bbdde3 Filter the objectstore password from the config list as well 2015-08-19 14:06:05 +02:00
Robin McCorkell 07e119a3f8 Introduce occ command to manage owncloud log backend
log:owncloud can set/display the log filename and log file rotation size
2015-08-19 12:55:27 +01:00
Robin McCorkell 67536e71aa Introduce occ command for logging management
log:manage can set/display the log backend, log level and log timezone
2015-08-19 12:33:23 +01:00
Vincent Petry 6c8c8a328a No error code when app already enabled/disabled 2015-08-19 10:26:50 +02:00
Vincent Petry 016cf11134 Return error code on failure with occ app:enable/disable 2015-08-18 12:48:03 +02:00
Joas Schilling 49ba7dc05d Mark ldap agent password as sensitive 2015-08-14 09:07:07 +02:00
Thomas Müller c3cac887f5 - more injection
- less static calls
- use params on sql queries
- handle sql exception on database and user creation gracefully
2015-07-30 00:04:30 +02:00
Thomas Müller 5ed38a75d6 Remove remainings of mssql 2015-07-29 18:19:31 +02:00
Joas Schilling 0dd1a785fe Merge pull request #16935 from owncloud/allow-app-check-code-for-deprecated-classes
Allow app check code for deprecated classes
2015-07-20 08:39:53 +02:00
Joas Schilling 3566dcf246 PR #17046 deprecated OCP\Util::mb_(sub)str_replace() 2015-07-17 12:34:56 +02:00
Robin McCorkell 0de5c35dba Allow specifying the checkers used in app:check-code
By default, all are enabled, but specific ones can be selected through command
line options.
2015-07-17 12:34:56 +02:00
Joas Schilling a0c6f2e5e0 Use the decorator pattern 2015-07-17 12:34:56 +02:00
Joas Schilling bba87a2a3b Restructor the code into different classes instead of extending 2015-07-17 12:34:56 +02:00
Joas Schilling 9e469046fa Use non-zero exit code 2015-07-17 12:34:56 +02:00
Joas Schilling 4e95031ec4 Allow app:check-code to check for deprecated methods 2015-07-17 12:34:55 +02:00
Joas Schilling 0a36331cb6 Use constants for the output formats 2015-07-17 09:25:19 +02:00
Joas Schilling 01dc3935d0 Add app and config name to error messages 2015-07-16 17:54:04 +02:00
Joas Schilling d5dcb60e5d Use json_pretty as default for the config lists (for easier export/import) 2015-07-16 17:51:33 +02:00
Roeland Jago Douma 032ffc969e Move mimetypealiases.json to mimetypealiases.dist.json 2015-07-10 10:17:49 +02:00
Morris Jobke 08afce3d7e [command] single user mode - use config object & add tests 2015-07-09 18:33:46 +02:00
Joas Schilling 85f012512e Invert the "public" to a "private" method 2015-07-07 11:30:21 +02:00