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.

1023 lines
37 KiB

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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
10 years ago
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 :wink:). 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.
10 years ago
10 years ago
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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
10 years ago
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 :wink:). 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.
10 years ago
10 years ago
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 :wink:). 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.
10 years ago
10 years ago
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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
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 :wink:). 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.
10 years ago
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Tests\Settings\Controller;
  22. use OC\Settings\Controller\CheckSetupController;
  23. use OCP\AppFramework\Http;
  24. use OCP\AppFramework\Http\DataDisplayResponse;
  25. use OCP\AppFramework\Http\DataResponse;
  26. use OCP\AppFramework\Http\RedirectResponse;
  27. use OCP\Http\Client\IClientService;
  28. use OCP\IConfig;
  29. use OCP\IL10N;
  30. use OCP\ILogger;
  31. use OCP\IRequest;
  32. use OCP\IURLGenerator;
  33. use OC_Util;
  34. use Test\TestCase;
  35. use OC\IntegrityCheck\Checker;
  36. /**
  37. * Class CheckSetupControllerTest
  38. *
  39. * @package Tests\Settings\Controller
  40. */
  41. class CheckSetupControllerTest extends TestCase {
  42. /** @var CheckSetupController | \PHPUnit_Framework_MockObject_MockObject */
  43. private $checkSetupController;
  44. /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */
  45. private $request;
  46. /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
  47. private $config;
  48. /** @var IClientService | \PHPUnit_Framework_MockObject_MockObject*/
  49. private $clientService;
  50. /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
  51. private $urlGenerator;
  52. /** @var OC_Util */
  53. private $util;
  54. /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
  55. private $l10n;
  56. /** @var ILogger */
  57. private $logger;
  58. /** @var Checker | \PHPUnit_Framework_MockObject_MockObject */
  59. private $checker;
  60. public function setUp() {
  61. parent::setUp();
  62. $this->request = $this->getMockBuilder('\OCP\IRequest')
  63. ->disableOriginalConstructor()->getMock();
  64. $this->config = $this->getMockBuilder('\OCP\IConfig')
  65. ->disableOriginalConstructor()->getMock();
  66. $this->config = $this->getMockBuilder('\OCP\IConfig')
  67. ->disableOriginalConstructor()->getMock();
  68. $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')
  69. ->disableOriginalConstructor()->getMock();
  70. $this->util = $this->getMockBuilder('\OC_Util')
  71. ->disableOriginalConstructor()->getMock();
  72. $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
  73. ->disableOriginalConstructor()->getMock();
  74. $this->l10n = $this->getMockBuilder('\OCP\IL10N')
  75. ->disableOriginalConstructor()->getMock();
  76. $this->l10n->expects($this->any())
  77. ->method('t')
  78. ->will($this->returnCallback(function($message, array $replace) {
  79. return vsprintf($message, $replace);
  80. }));
  81. $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
  82. ->disableOriginalConstructor()->getMock();
  83. $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
  84. $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  85. ->setConstructorArgs([
  86. 'settings',
  87. $this->request,
  88. $this->config,
  89. $this->clientService,
  90. $this->urlGenerator,
  91. $this->util,
  92. $this->l10n,
  93. $this->checker,
  94. $this->logger
  95. ])
  96. ->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
  97. }
  98. public function testIsInternetConnectionWorkingDisabledViaConfig() {
  99. $this->config->expects($this->once())
  100. ->method('getSystemValue')
  101. ->with('has_internet_connection', true)
  102. ->will($this->returnValue(false));
  103. $this->assertFalse(
  104. self::invokePrivate(
  105. $this->checkSetupController,
  106. 'isInternetConnectionWorking'
  107. )
  108. );
  109. }
  110. public function testIsInternetConnectionWorkingCorrectly() {
  111. $this->config->expects($this->once())
  112. ->method('getSystemValue')
  113. ->with('has_internet_connection', true)
  114. ->will($this->returnValue(true));
  115. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  116. ->disableOriginalConstructor()->getMock();
  117. $client->expects($this->any())
  118. ->method('get');
  119. $this->clientService->expects($this->once())
  120. ->method('newClient')
  121. ->will($this->returnValue($client));
  122. $this->assertTrue(
  123. self::invokePrivate(
  124. $this->checkSetupController,
  125. 'isInternetConnectionWorking'
  126. )
  127. );
  128. }
  129. public function testIsInternetConnectionFail() {
  130. $this->config->expects($this->once())
  131. ->method('getSystemValue')
  132. ->with('has_internet_connection', true)
  133. ->will($this->returnValue(true));
  134. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  135. ->disableOriginalConstructor()->getMock();
  136. $client->expects($this->any())
  137. ->method('get')
  138. ->will($this->throwException(new \Exception()));
  139. $this->clientService->expects($this->exactly(3))
  140. ->method('newClient')
  141. ->will($this->returnValue($client));
  142. $this->assertFalse(
  143. self::invokePrivate(
  144. $this->checkSetupController,
  145. 'isInternetConnectionWorking'
  146. )
  147. );
  148. }
  149. public function testIsMemcacheConfiguredFalse() {
  150. $this->config->expects($this->once())
  151. ->method('getSystemValue')
  152. ->with('memcache.local', null)
  153. ->will($this->returnValue(null));
  154. $this->assertFalse(
  155. self::invokePrivate(
  156. $this->checkSetupController,
  157. 'isMemcacheConfigured'
  158. )
  159. );
  160. }
  161. public function testIsMemcacheConfiguredTrue() {
  162. $this->config->expects($this->once())
  163. ->method('getSystemValue')
  164. ->with('memcache.local', null)
  165. ->will($this->returnValue('SomeProvider'));
  166. $this->assertTrue(
  167. self::invokePrivate(
  168. $this->checkSetupController,
  169. 'isMemcacheConfigured'
  170. )
  171. );
  172. }
  173. public function testIsPhpSupportedFalse() {
  174. $this->checkSetupController
  175. ->expects($this->once())
  176. ->method('isPhpOutdated')
  177. ->willReturn(true);
  178. $this->assertEquals(
  179. ['eol' => true, 'version' => PHP_VERSION],
  180. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  181. );
  182. }
  183. public function testIsPhpSupportedTrue() {
  184. $this->checkSetupController
  185. ->expects($this->exactly(2))
  186. ->method('isPhpOutdated')
  187. ->willReturn(false);
  188. $this->assertEquals(
  189. ['eol' => false, 'version' => PHP_VERSION],
  190. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  191. );
  192. $this->assertEquals(
  193. ['eol' => false, 'version' => PHP_VERSION],
  194. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  195. );
  196. }
  197. public function testForwardedForHeadersWorkingFalse() {
  198. $this->config->expects($this->once())
  199. ->method('getSystemValue')
  200. ->with('trusted_proxies', [])
  201. ->willReturn(['1.2.3.4']);
  202. $this->request->expects($this->once())
  203. ->method('getRemoteAddress')
  204. ->willReturn('1.2.3.4');
  205. $this->assertFalse(
  206. self::invokePrivate(
  207. $this->checkSetupController,
  208. 'forwardedForHeadersWorking'
  209. )
  210. );
  211. }
  212. public function testForwardedForHeadersWorkingTrue() {
  213. $this->config->expects($this->once())
  214. ->method('getSystemValue')
  215. ->with('trusted_proxies', [])
  216. ->willReturn(['1.2.3.4']);
  217. $this->request->expects($this->once())
  218. ->method('getRemoteAddress')
  219. ->willReturn('4.3.2.1');
  220. $this->assertTrue(
  221. self::invokePrivate(
  222. $this->checkSetupController,
  223. 'forwardedForHeadersWorking'
  224. )
  225. );
  226. }
  227. public function testCheck() {
  228. $this->config->expects($this->at(0))
  229. ->method('getSystemValue')
  230. ->with('has_internet_connection', true)
  231. ->will($this->returnValue(true));
  232. $this->config->expects($this->at(1))
  233. ->method('getSystemValue')
  234. ->with('memcache.local', null)
  235. ->will($this->returnValue('SomeProvider'));
  236. $this->config->expects($this->at(2))
  237. ->method('getSystemValue')
  238. ->with('has_internet_connection', true)
  239. ->will($this->returnValue(false));
  240. $this->config->expects($this->at(3))
  241. ->method('getSystemValue')
  242. ->with('trusted_proxies', [])
  243. ->willReturn(['1.2.3.4']);
  244. $this->request->expects($this->once())
  245. ->method('getRemoteAddress')
  246. ->willReturn('4.3.2.1');
  247. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  248. ->disableOriginalConstructor()->getMock();
  249. $client->expects($this->at(0))
  250. ->method('get')
  251. ->with('http://www.nextcloud.com/', [])
  252. ->will($this->throwException(new \Exception()));
  253. $client->expects($this->at(1))
  254. ->method('get')
  255. ->with('http://www.google.com/', [])
  256. ->will($this->throwException(new \Exception()));
  257. $client->expects($this->at(2))
  258. ->method('get')
  259. ->with('http://www.github.com/', [])
  260. ->will($this->throwException(new \Exception()));
  261. $this->clientService->expects($this->exactly(3))
  262. ->method('newClient')
  263. ->will($this->returnValue($client));
  264. $this->urlGenerator->expects($this->at(0))
  265. ->method('linkToDocs')
  266. ->with('admin-performance')
  267. ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance');
  268. $this->urlGenerator->expects($this->at(1))
  269. ->method('linkToDocs')
  270. ->with('admin-security')
  271. ->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
  272. $this->checkSetupController
  273. ->expects($this->once())
  274. ->method('isPhpOutdated')
  275. ->willReturn(true);
  276. $this->urlGenerator->expects($this->at(2))
  277. ->method('linkToDocs')
  278. ->with('admin-reverse-proxy')
  279. ->willReturn('reverse-proxy-doc-link');
  280. $expected = new DataResponse(
  281. [
  282. 'serverHasInternetConnection' => false,
  283. 'isMemcacheConfigured' => true,
  284. 'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance',
  285. 'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
  286. 'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html',
  287. 'isUsedTlsLibOutdated' => '',
  288. 'phpSupported' => [
  289. 'eol' => true,
  290. 'version' => PHP_VERSION
  291. ],
  292. 'forwardedForHeadersWorking' => true,
  293. 'reverseProxyDocs' => 'reverse-proxy-doc-link',
  294. 'isCorrectMemcachedPHPModuleInstalled' => true,
  295. 'hasPassedCodeIntegrityCheck' => null,
  296. 'codeIntegrityCheckerDocumentation' => null,
  297. ]
  298. );
  299. $this->assertEquals($expected, $this->checkSetupController->check());
  300. }
  301. public function testGetCurlVersion() {
  302. $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  303. ->setConstructorArgs([
  304. 'settings',
  305. $this->request,
  306. $this->config,
  307. $this->clientService,
  308. $this->urlGenerator,
  309. $this->util,
  310. $this->l10n,
  311. $this->checker,
  312. $this->logger
  313. ])
  314. ->setMethods(null)->getMock();
  315. $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion'));
  316. }
  317. public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
  318. $this->config->expects($this->any())
  319. ->method('getSystemValue')
  320. ->will($this->returnValue(true));
  321. $this->checkSetupController
  322. ->expects($this->once())
  323. ->method('getCurlVersion')
  324. ->will($this->returnValue(['ssl_version' => 'SSLlib']));
  325. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  326. }
  327. public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
  328. $this->config->expects($this->any())
  329. ->method('getSystemValue')
  330. ->will($this->returnValue(true));
  331. $this->checkSetupController
  332. ->expects($this->once())
  333. ->method('getCurlVersion')
  334. ->will($this->returnValue([]));
  335. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  336. }
  337. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
  338. $this->config->expects($this->any())
  339. ->method('getSystemValue')
  340. ->will($this->returnValue(true));
  341. $this->checkSetupController
  342. ->expects($this->once())
  343. ->method('getCurlVersion')
  344. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  345. $this->assertSame('cURL is using an outdated OpenSSL version (OpenSSL/1.0.1c). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  346. }
  347. public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() {
  348. $this->config
  349. ->expects($this->at(0))
  350. ->method('getSystemValue')
  351. ->with('has_internet_connection', true)
  352. ->will($this->returnValue(true));
  353. $this->checkSetupController
  354. ->expects($this->once())
  355. ->method('getCurlVersion')
  356. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  357. $this->assertSame('cURL is using an outdated OpenSSL version (OpenSSL/1.0.1c). Please update your operating system or features such as Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  358. }
  359. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
  360. $this->config->expects($this->any())
  361. ->method('getSystemValue')
  362. ->will($this->returnValue(true));
  363. $this->checkSetupController
  364. ->expects($this->once())
  365. ->method('getCurlVersion')
  366. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2a']));
  367. $this->assertSame('cURL is using an outdated OpenSSL version (OpenSSL/1.0.2a). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  368. }
  369. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
  370. $this->config->expects($this->any())
  371. ->method('getSystemValue')
  372. ->will($this->returnValue(true));
  373. $this->checkSetupController
  374. ->expects($this->once())
  375. ->method('getCurlVersion')
  376. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1d']));
  377. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  378. }
  379. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
  380. $this->config->expects($this->any())
  381. ->method('getSystemValue')
  382. ->will($this->returnValue(true));
  383. $this->checkSetupController
  384. ->expects($this->once())
  385. ->method('getCurlVersion')
  386. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2b']));
  387. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  388. }
  389. public function testIsBuggyNss400() {
  390. $this->config->expects($this->any())
  391. ->method('getSystemValue')
  392. ->will($this->returnValue(true));
  393. $this->checkSetupController
  394. ->expects($this->once())
  395. ->method('getCurlVersion')
  396. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  397. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  398. ->disableOriginalConstructor()->getMock();
  399. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  400. ->disableOriginalConstructor()->getMock();
  401. $response = $this->getMockBuilder('\GuzzleHttp\Message\ResponseInterface')
  402. ->disableOriginalConstructor()->getMock();
  403. $response->expects($this->once())
  404. ->method('getStatusCode')
  405. ->will($this->returnValue(400));
  406. $exception->expects($this->once())
  407. ->method('getResponse')
  408. ->will($this->returnValue($response));
  409. $client->expects($this->at(0))
  410. ->method('get')
  411. ->with('https://www.owncloud.org/', [])
  412. ->will($this->throwException($exception));
  413. $this->clientService->expects($this->once())
  414. ->method('newClient')
  415. ->will($this->returnValue($client));
  416. $this->assertSame('cURL is using an outdated NSS version (NSS/1.0.2b). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  417. }
  418. public function testIsBuggyNss200() {
  419. $this->config->expects($this->any())
  420. ->method('getSystemValue')
  421. ->will($this->returnValue(true));
  422. $this->checkSetupController
  423. ->expects($this->once())
  424. ->method('getCurlVersion')
  425. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  426. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  427. ->disableOriginalConstructor()->getMock();
  428. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  429. ->disableOriginalConstructor()->getMock();
  430. $response = $this->getMockBuilder('\GuzzleHttp\Message\ResponseInterface')
  431. ->disableOriginalConstructor()->getMock();
  432. $response->expects($this->once())
  433. ->method('getStatusCode')
  434. ->will($this->returnValue(200));
  435. $exception->expects($this->once())
  436. ->method('getResponse')
  437. ->will($this->returnValue($response));
  438. $client->expects($this->at(0))
  439. ->method('get')
  440. ->with('https://www.owncloud.org/', [])
  441. ->will($this->throwException($exception));
  442. $this->clientService->expects($this->once())
  443. ->method('newClient')
  444. ->will($this->returnValue($client));
  445. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  446. }
  447. public function testIsUsedTlsLibOutdatedWithInternetDisabled() {
  448. $this->config
  449. ->expects($this->at(0))
  450. ->method('getSystemValue')
  451. ->with('has_internet_connection', true)
  452. ->will($this->returnValue(false));
  453. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  454. }
  455. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() {
  456. $this->config
  457. ->expects($this->at(0))
  458. ->method('getSystemValue')
  459. ->with('has_internet_connection', true)
  460. ->will($this->returnValue(true));
  461. $this->config
  462. ->expects($this->at(1))
  463. ->method('getSystemValue')
  464. ->with('appstoreenabled', true)
  465. ->will($this->returnValue(false));
  466. $this->config
  467. ->expects($this->at(2))
  468. ->method('getAppValue')
  469. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  470. ->will($this->returnValue('no'));
  471. $this->config
  472. ->expects($this->at(3))
  473. ->method('getAppValue')
  474. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  475. ->will($this->returnValue('yes'));
  476. $this->checkSetupController
  477. ->expects($this->once())
  478. ->method('getCurlVersion')
  479. ->will($this->returnValue([]));
  480. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  481. }
  482. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() {
  483. $this->config
  484. ->expects($this->at(0))
  485. ->method('getSystemValue')
  486. ->with('has_internet_connection', true)
  487. ->will($this->returnValue(true));
  488. $this->config
  489. ->expects($this->at(1))
  490. ->method('getSystemValue')
  491. ->with('appstoreenabled', true)
  492. ->will($this->returnValue(false));
  493. $this->config
  494. ->expects($this->at(2))
  495. ->method('getAppValue')
  496. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  497. ->will($this->returnValue('no'));
  498. $this->config
  499. ->expects($this->at(3))
  500. ->method('getAppValue')
  501. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  502. ->will($this->returnValue('no'));
  503. $this->checkSetupController
  504. ->expects($this->never())
  505. ->method('getCurlVersion')
  506. ->will($this->returnValue([]));
  507. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  508. }
  509. public function testRescanFailedIntegrityCheck() {
  510. $this->checker
  511. ->expects($this->once())
  512. ->method('runInstanceVerification');
  513. $this->urlGenerator
  514. ->expects($this->once())
  515. ->method('linkToRoute')
  516. ->with('settings.AdminSettings.index')
  517. ->will($this->returnValue('/admin'));
  518. $expected = new RedirectResponse('/admin');
  519. $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
  520. }
  521. public function testGetFailedIntegrityCheckDisabled() {
  522. $this->checker
  523. ->expects($this->once())
  524. ->method('isCodeCheckEnforced')
  525. ->willReturn(false);
  526. $expected = new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  527. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  528. }
  529. public function testGetFailedIntegrityCheckFilesWithNoErrorsFound() {
  530. $this->checker
  531. ->expects($this->once())
  532. ->method('isCodeCheckEnforced')
  533. ->willReturn(true);
  534. $this->checker
  535. ->expects($this->once())
  536. ->method('getResults')
  537. ->will($this->returnValue([]));
  538. $expected = new DataDisplayResponse(
  539. 'No errors have been found.',
  540. Http::STATUS_OK,
  541. [
  542. 'Content-Type' => 'text/plain',
  543. ]
  544. );
  545. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  546. }
  547. public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() {
  548. $this->checker
  549. ->expects($this->once())
  550. ->method('isCodeCheckEnforced')
  551. ->willReturn(true);
  552. $this->checker
  553. ->expects($this->once())
  554. ->method('getResults')
  555. ->will($this->returnValue(array ( 'core' => array ( 'EXTRA_FILE' => array('/testfile' => array()), 'INVALID_HASH' => array ( '/.idea/workspace.xml' => array ( 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ), '/lib/private/integritycheck/checker.php' => array ( 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ), '/settings/controller/checksetupcontroller.php' => array ( 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ), ), ), 'bookmarks' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'dav' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'encryption' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'federation' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_antivirus' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_drop' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_pdfviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_sharing' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_trashbin' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_versions' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_videoviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'firstrunwizard' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'gitsmart' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'logreader' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ), ), 'password_policy' => array ( 'EXCEPTION' => array ( 'class' => 'OC\
  556. $expected = new DataDisplayResponse(
  557. 'Technical information
  558. =====================
  559. The following list covers which files have failed the integrity check. Please read
  560. the previous linked documentation to learn more about the errors and how to fix
  561. them.
  562. Results
  563. =======
  564. - core
  565. - EXTRA_FILE
  566. - /testfile
  567. - INVALID_HASH
  568. - /.idea/workspace.xml
  569. - /lib/private/integritycheck/checker.php
  570. - /settings/controller/checksetupcontroller.php
  571. - bookmarks
  572. - EXCEPTION
  573. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  574. - Signature data not found.
  575. - dav
  576. - EXCEPTION
  577. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  578. - Signature data not found.
  579. - encryption
  580. - EXCEPTION
  581. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  582. - Signature data not found.
  583. - external
  584. - EXCEPTION
  585. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  586. - Signature data not found.
  587. - federation
  588. - EXCEPTION
  589. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  590. - Signature data not found.
  591. - files
  592. - EXCEPTION
  593. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  594. - Signature data not found.
  595. - files_antivirus
  596. - EXCEPTION
  597. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  598. - Signature data not found.
  599. - files_drop
  600. - EXCEPTION
  601. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  602. - Signature data not found.
  603. - files_external
  604. - EXCEPTION
  605. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  606. - Signature data not found.
  607. - files_pdfviewer
  608. - EXCEPTION
  609. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  610. - Signature data not found.
  611. - files_sharing
  612. - EXCEPTION
  613. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  614. - Signature data not found.
  615. - files_trashbin
  616. - EXCEPTION
  617. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  618. - Signature data not found.
  619. - files_versions
  620. - EXCEPTION
  621. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  622. - Signature data not found.
  623. - files_videoviewer
  624. - EXCEPTION
  625. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  626. - Signature data not found.
  627. - firstrunwizard
  628. - EXCEPTION
  629. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  630. - Signature data not found.
  631. - gitsmart
  632. - EXCEPTION
  633. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  634. - Signature data not found.
  635. - logreader
  636. - EXCEPTION
  637. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  638. - Signature could not get verified.
  639. - password_policy
  640. - EXCEPTION
  641. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  642. - Signature data not found.
  643. - provisioning_api
  644. - EXCEPTION
  645. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  646. - Signature data not found.
  647. - sketch
  648. - EXCEPTION
  649. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  650. - Signature data not found.
  651. - threatblock
  652. - EXCEPTION
  653. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  654. - Signature data not found.
  655. - two_factor_auth
  656. - EXCEPTION
  657. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  658. - Signature data not found.
  659. - user_ldap
  660. - EXCEPTION
  661. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  662. - Signature data not found.
  663. - user_shibboleth
  664. - EXCEPTION
  665. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  666. - Signature data not found.
  667. Raw output
  668. ==========
  669. Array
  670. (
  671. [core] => Array
  672. (
  673. [EXTRA_FILE] => Array
  674. (
  675. [/testfile] => Array
  676. (
  677. )
  678. )
  679. [INVALID_HASH] => Array
  680. (
  681. [/.idea/workspace.xml] => Array
  682. (
  683. [expected] => f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216
  684. [current] => ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094
  685. )
  686. [/lib/private/integritycheck/checker.php] => Array
  687. (
  688. [expected] => c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea
  689. [current] => 88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585
  690. )
  691. [/settings/controller/checksetupcontroller.php] => Array
  692. (
  693. [expected] => 3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4
  694. [current] => 09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a
  695. )
  696. )
  697. )
  698. [bookmarks] => Array
  699. (
  700. [EXCEPTION] => Array
  701. (
  702. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  703. [message] => Signature data not found.
  704. )
  705. )
  706. [dav] => Array
  707. (
  708. [EXCEPTION] => Array
  709. (
  710. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  711. [message] => Signature data not found.
  712. )
  713. )
  714. [encryption] => Array
  715. (
  716. [EXCEPTION] => Array
  717. (
  718. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  719. [message] => Signature data not found.
  720. )
  721. )
  722. [external] => Array
  723. (
  724. [EXCEPTION] => Array
  725. (
  726. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  727. [message] => Signature data not found.
  728. )
  729. )
  730. [federation] => Array
  731. (
  732. [EXCEPTION] => Array
  733. (
  734. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  735. [message] => Signature data not found.
  736. )
  737. )
  738. [files] => Array
  739. (
  740. [EXCEPTION] => Array
  741. (
  742. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  743. [message] => Signature data not found.
  744. )
  745. )
  746. [files_antivirus] => Array
  747. (
  748. [EXCEPTION] => Array
  749. (
  750. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  751. [message] => Signature data not found.
  752. )
  753. )
  754. [files_drop] => Array
  755. (
  756. [EXCEPTION] => Array
  757. (
  758. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  759. [message] => Signature data not found.
  760. )
  761. )
  762. [files_external] => Array
  763. (
  764. [EXCEPTION] => Array
  765. (
  766. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  767. [message] => Signature data not found.
  768. )
  769. )
  770. [files_pdfviewer] => Array
  771. (
  772. [EXCEPTION] => Array
  773. (
  774. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  775. [message] => Signature data not found.
  776. )
  777. )
  778. [files_sharing] => Array
  779. (
  780. [EXCEPTION] => Array
  781. (
  782. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  783. [message] => Signature data not found.
  784. )
  785. )
  786. [files_trashbin] => Array
  787. (
  788. [EXCEPTION] => Array
  789. (
  790. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  791. [message] => Signature data not found.
  792. )
  793. )
  794. [files_versions] => Array
  795. (
  796. [EXCEPTION] => Array
  797. (
  798. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  799. [message] => Signature data not found.
  800. )
  801. )
  802. [files_videoviewer] => Array
  803. (
  804. [EXCEPTION] => Array
  805. (
  806. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  807. [message] => Signature data not found.
  808. )
  809. )
  810. [firstrunwizard] => Array
  811. (
  812. [EXCEPTION] => Array
  813. (
  814. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  815. [message] => Signature data not found.
  816. )
  817. )
  818. [gitsmart] => Array
  819. (
  820. [EXCEPTION] => Array
  821. (
  822. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  823. [message] => Signature data not found.
  824. )
  825. )
  826. [logreader] => Array
  827. (
  828. [EXCEPTION] => Array
  829. (
  830. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  831. [message] => Signature could not get verified.
  832. )
  833. )
  834. [password_policy] => Array
  835. (
  836. [EXCEPTION] => Array
  837. (
  838. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  839. [message] => Signature data not found.
  840. )
  841. )
  842. [provisioning_api] => Array
  843. (
  844. [EXCEPTION] => Array
  845. (
  846. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  847. [message] => Signature data not found.
  848. )
  849. )
  850. [sketch] => Array
  851. (
  852. [EXCEPTION] => Array
  853. (
  854. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  855. [message] => Signature data not found.
  856. )
  857. )
  858. [threatblock] => Array
  859. (
  860. [EXCEPTION] => Array
  861. (
  862. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  863. [message] => Signature data not found.
  864. )
  865. )
  866. [two_factor_auth] => Array
  867. (
  868. [EXCEPTION] => Array
  869. (
  870. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  871. [message] => Signature data not found.
  872. )
  873. )
  874. [user_ldap] => Array
  875. (
  876. [EXCEPTION] => Array
  877. (
  878. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  879. [message] => Signature data not found.
  880. )
  881. )
  882. [user_shibboleth] => Array
  883. (
  884. [EXCEPTION] => Array
  885. (
  886. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  887. [message] => Signature data not found.
  888. )
  889. )
  890. )
  891. ',
  892. Http::STATUS_OK,
  893. [
  894. 'Content-Type' => 'text/plain',
  895. ]
  896. );
  897. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  898. }
  899. }