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.

1274 lines
44 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
9 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
9 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
9 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
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
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. * @copyright Copyright (c) 2015, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author John Molakvoæ <skjnldsv@protonmail.com>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Michael Weimann <mail@michael-weimann.eu>
  12. * @author Morris Jobke <hey@morrisjobke.de>
  13. * @author nhirokinet <nhirokinet@nhiroki.net>
  14. * @author Robin Appelman <robin@icewind.nl>
  15. * @author Robin McCorkell <robin@mccorkell.me.uk>
  16. * @author Roeland Jago Douma <roeland@famdouma.nl>
  17. * @author Sylvia van Os <sylvia@hackerchick.me>
  18. * @author Timo Förster <tfoerster@webfoersterei.de>
  19. *
  20. * @license AGPL-3.0
  21. *
  22. * This code is free software: you can redistribute it and/or modify
  23. * it under the terms of the GNU Affero General Public License, version 3,
  24. * as published by the Free Software Foundation.
  25. *
  26. * This program is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU Affero General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU Affero General Public License, version 3,
  32. * along with this program. If not, see <http://www.gnu.org/licenses/>
  33. *
  34. */
  35. namespace OCA\Settings\Tests\Controller;
  36. use bantu\IniGetWrapper\IniGetWrapper;
  37. use Doctrine\DBAL\Platforms\SqlitePlatform;
  38. use OC;
  39. use OC\DB\Connection;
  40. use OC\IntegrityCheck\Checker;
  41. use OC\MemoryInfo;
  42. use OCA\Settings\Controller\CheckSetupController;
  43. use OCP\App\IAppManager;
  44. use OCP\AppFramework\Http;
  45. use OCP\AppFramework\Http\DataDisplayResponse;
  46. use OCP\AppFramework\Http\DataResponse;
  47. use OCP\AppFramework\Http\RedirectResponse;
  48. use OCP\EventDispatcher\IEventDispatcher;
  49. use OCP\Http\Client\IClientService;
  50. use OCP\IConfig;
  51. use OCP\IDateTimeFormatter;
  52. use OCP\IDBConnection;
  53. use OCP\IL10N;
  54. use OCP\IRequest;
  55. use OCP\IServerContainer;
  56. use OCP\ITempManager;
  57. use OCP\IURLGenerator;
  58. use OCP\Lock\ILockingProvider;
  59. use OCP\Notification\IManager;
  60. use OCP\Security\Bruteforce\IThrottler;
  61. use OCP\SetupCheck\ISetupCheckManager;
  62. use PHPUnit\Framework\MockObject\MockObject;
  63. use Psr\Http\Message\ResponseInterface;
  64. use Psr\Log\LoggerInterface;
  65. use Test\TestCase;
  66. /**
  67. * Class CheckSetupControllerTest
  68. *
  69. * @backupStaticAttributes
  70. * @package Tests\Settings\Controller
  71. */
  72. class CheckSetupControllerTest extends TestCase {
  73. /** @var CheckSetupController | \PHPUnit\Framework\MockObject\MockObject */
  74. private $checkSetupController;
  75. /** @var IRequest | \PHPUnit\Framework\MockObject\MockObject */
  76. private $request;
  77. /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */
  78. private $config;
  79. /** @var IClientService | \PHPUnit\Framework\MockObject\MockObject*/
  80. private $clientService;
  81. /** @var IURLGenerator | \PHPUnit\Framework\MockObject\MockObject */
  82. private $urlGenerator;
  83. /** @var IL10N | \PHPUnit\Framework\MockObject\MockObject */
  84. private $l10n;
  85. /** @var LoggerInterface */
  86. private $logger;
  87. /** @var Checker|\PHPUnit\Framework\MockObject\MockObject */
  88. private $checker;
  89. /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
  90. private $dispatcher;
  91. /** @var Connection|\PHPUnit\Framework\MockObject\MockObject */
  92. private $db;
  93. private IThrottler $throttler;
  94. /** @var ILockingProvider|\PHPUnit\Framework\MockObject\MockObject */
  95. private $lockingProvider;
  96. /** @var IDateTimeFormatter|\PHPUnit\Framework\MockObject\MockObject */
  97. private $dateTimeFormatter;
  98. /** @var MemoryInfo|MockObject */
  99. private $memoryInfo;
  100. /** @var IniGetWrapper|\PHPUnit\Framework\MockObject\MockObject */
  101. private $iniGetWrapper;
  102. /** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
  103. private $connection;
  104. /** @var ITempManager|\PHPUnit\Framework\MockObject\MockObject */
  105. private $tempManager;
  106. /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
  107. private $notificationManager;
  108. /** @var IAppManager|MockObject */
  109. private $appManager;
  110. /** @var IServerContainer|MockObject */
  111. private $serverContainer;
  112. /** @var ISetupCheckManager|MockObject */
  113. private $setupCheckManager;
  114. /**
  115. * Holds a list of directories created during tests.
  116. *
  117. * @var array
  118. */
  119. private $dirsToRemove = [];
  120. protected function setUp(): void {
  121. parent::setUp();
  122. $this->request = $this->getMockBuilder(IRequest::class)
  123. ->disableOriginalConstructor()->getMock();
  124. $this->config = $this->getMockBuilder(IConfig::class)
  125. ->disableOriginalConstructor()->getMock();
  126. $this->clientService = $this->getMockBuilder(IClientService::class)
  127. ->disableOriginalConstructor()->getMock();
  128. $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
  129. ->disableOriginalConstructor()->getMock();
  130. $this->l10n = $this->getMockBuilder(IL10N::class)
  131. ->disableOriginalConstructor()->getMock();
  132. $this->l10n->expects($this->any())
  133. ->method('t')
  134. ->willReturnCallback(function ($message, array $replace) {
  135. return vsprintf($message, $replace);
  136. });
  137. $this->dispatcher = $this->createMock(IEventDispatcher::class);
  138. $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
  139. ->disableOriginalConstructor()->getMock();
  140. $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
  141. $this->db = $this->getMockBuilder(Connection::class)
  142. ->disableOriginalConstructor()->getMock();
  143. $this->throttler = $this->createMock(IThrottler::class);
  144. $this->lockingProvider = $this->getMockBuilder(ILockingProvider::class)->getMock();
  145. $this->dateTimeFormatter = $this->getMockBuilder(IDateTimeFormatter::class)->getMock();
  146. $this->memoryInfo = $this->getMockBuilder(MemoryInfo::class)
  147. ->setMethods(['isMemoryLimitSufficient',])
  148. ->getMock();
  149. $this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class)->getMock();
  150. $this->connection = $this->getMockBuilder(IDBConnection::class)
  151. ->disableOriginalConstructor()->getMock();
  152. $this->tempManager = $this->getMockBuilder(ITempManager::class)->getMock();
  153. $this->notificationManager = $this->getMockBuilder(IManager::class)->getMock();
  154. $this->appManager = $this->createMock(IAppManager::class);
  155. $this->serverContainer = $this->createMock(IServerContainer::class);
  156. $this->setupCheckManager = $this->createMock(ISetupCheckManager::class);
  157. $this->checkSetupController = $this->getMockBuilder(CheckSetupController::class)
  158. ->setConstructorArgs([
  159. 'settings',
  160. $this->request,
  161. $this->config,
  162. $this->clientService,
  163. $this->urlGenerator,
  164. $this->l10n,
  165. $this->checker,
  166. $this->logger,
  167. $this->dispatcher,
  168. $this->db,
  169. $this->lockingProvider,
  170. $this->dateTimeFormatter,
  171. $this->memoryInfo,
  172. $this->iniGetWrapper,
  173. $this->connection,
  174. $this->throttler,
  175. $this->tempManager,
  176. $this->notificationManager,
  177. $this->appManager,
  178. $this->serverContainer,
  179. $this->setupCheckManager,
  180. ])
  181. ->setMethods([
  182. 'getLastCronInfo',
  183. 'getSuggestedOverwriteCliURL',
  184. 'getCurlVersion',
  185. 'isPhpOutdated',
  186. 'getOpcacheSetupRecommendations',
  187. 'hasMissingIndexes',
  188. 'hasMissingPrimaryKeys',
  189. 'isSqliteUsed',
  190. 'isPHPMailerUsed',
  191. 'getAppDirsWithDifferentOwner',
  192. 'isImagickEnabled',
  193. 'areWebauthnExtensionsEnabled',
  194. 'hasBigIntConversionPendingColumns',
  195. 'isMysqlUsedWithoutUTF8MB4',
  196. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
  197. ])->getMock();
  198. }
  199. /**
  200. * Removes directories created during tests.
  201. *
  202. * @after
  203. * @return void
  204. */
  205. public function removeTestDirectories() {
  206. foreach ($this->dirsToRemove as $dirToRemove) {
  207. rmdir($dirToRemove);
  208. }
  209. $this->dirsToRemove = [];
  210. }
  211. /**
  212. * @dataProvider dataForwardedForHeadersWorking
  213. *
  214. * @param array $trustedProxies
  215. * @param string $remoteAddrNotForwarded
  216. * @param string $remoteAddr
  217. * @param bool $result
  218. */
  219. public function testForwardedForHeadersWorking(array $trustedProxies, string $remoteAddrNotForwarded, string $remoteAddr, bool $result): void {
  220. $this->config->expects($this->once())
  221. ->method('getSystemValue')
  222. ->with('trusted_proxies', [])
  223. ->willReturn($trustedProxies);
  224. $this->request->expects($this->atLeastOnce())
  225. ->method('getHeader')
  226. ->willReturnMap([
  227. ['REMOTE_ADDR', $remoteAddrNotForwarded],
  228. ['X-Forwarded-Host', '']
  229. ]);
  230. $this->request->expects($this->any())
  231. ->method('getRemoteAddress')
  232. ->willReturn($remoteAddr);
  233. $this->assertEquals(
  234. $result,
  235. self::invokePrivate($this->checkSetupController, 'forwardedForHeadersWorking')
  236. );
  237. }
  238. public function dataForwardedForHeadersWorking(): array {
  239. return [
  240. // description => trusted proxies, getHeader('REMOTE_ADDR'), getRemoteAddr, expected result
  241. 'no trusted proxies' => [[], '2.2.2.2', '2.2.2.2', true],
  242. 'trusted proxy, remote addr not trusted proxy' => [['1.1.1.1'], '2.2.2.2', '2.2.2.2', true],
  243. 'trusted proxy, remote addr is trusted proxy, x-forwarded-for working' => [['1.1.1.1'], '1.1.1.1', '2.2.2.2', true],
  244. 'trusted proxy, remote addr is trusted proxy, x-forwarded-for not set' => [['1.1.1.1'], '1.1.1.1', '1.1.1.1', false],
  245. ];
  246. }
  247. public function testForwardedHostPresentButTrustedProxiesNotAnArray(): void {
  248. $this->config->expects($this->once())
  249. ->method('getSystemValue')
  250. ->with('trusted_proxies', [])
  251. ->willReturn('1.1.1.1');
  252. $this->request->expects($this->atLeastOnce())
  253. ->method('getHeader')
  254. ->willReturnMap([
  255. ['REMOTE_ADDR', '1.1.1.1'],
  256. ['X-Forwarded-Host', 'nextcloud.test']
  257. ]);
  258. $this->request->expects($this->any())
  259. ->method('getRemoteAddress')
  260. ->willReturn('1.1.1.1');
  261. $this->assertEquals(
  262. false,
  263. self::invokePrivate($this->checkSetupController, 'forwardedForHeadersWorking')
  264. );
  265. }
  266. public function testForwardedHostPresentButTrustedProxiesEmpty(): void {
  267. $this->config->expects($this->once())
  268. ->method('getSystemValue')
  269. ->with('trusted_proxies', [])
  270. ->willReturn([]);
  271. $this->request->expects($this->atLeastOnce())
  272. ->method('getHeader')
  273. ->willReturnMap([
  274. ['REMOTE_ADDR', '1.1.1.1'],
  275. ['X-Forwarded-Host', 'nextcloud.test']
  276. ]);
  277. $this->request->expects($this->any())
  278. ->method('getRemoteAddress')
  279. ->willReturn('1.1.1.1');
  280. $this->assertEquals(
  281. false,
  282. self::invokePrivate($this->checkSetupController, 'forwardedForHeadersWorking')
  283. );
  284. }
  285. public function testCheck() {
  286. $this->config->expects($this->any())
  287. ->method('getAppValue')
  288. ->willReturnMap([
  289. ['files_external', 'user_certificate_scan', '', '["a", "b"]'],
  290. ['core', 'cronErrors', '', ''],
  291. ['dav', 'needs_system_address_book_sync', 'no', 'no'],
  292. ]);
  293. $this->config->expects($this->any())
  294. ->method('getSystemValue')
  295. ->willReturnMap([
  296. ['connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'], ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']],
  297. ['memcache.local', null, 'SomeProvider'],
  298. ['has_internet_connection', true, true],
  299. ['appstoreenabled', true, false],
  300. ]);
  301. $this->request->expects($this->atLeastOnce())
  302. ->method('getHeader')
  303. ->willReturnMap([
  304. ['REMOTE_ADDR', '4.3.2.1'],
  305. ['X-Forwarded-Host', '']
  306. ]);
  307. $this->clientService->expects($this->never())
  308. ->method('newClient');
  309. $this->checkSetupController
  310. ->expects($this->once())
  311. ->method('getOpcacheSetupRecommendations')
  312. ->willReturn(['recommendation1', 'recommendation2']);
  313. $this->checkSetupController
  314. ->method('hasMissingIndexes')
  315. ->willReturn([]);
  316. $this->checkSetupController
  317. ->method('hasMissingPrimaryKeys')
  318. ->willReturn([]);
  319. $this->checkSetupController
  320. ->method('isSqliteUsed')
  321. ->willReturn(false);
  322. $this->checkSetupController
  323. ->expects($this->once())
  324. ->method('getSuggestedOverwriteCliURL')
  325. ->willReturn('');
  326. $this->checkSetupController
  327. ->expects($this->once())
  328. ->method('getLastCronInfo')
  329. ->willReturn([
  330. 'diffInSeconds' => 123,
  331. 'relativeTime' => '2 hours ago',
  332. 'backgroundJobsUrl' => 'https://example.org',
  333. ]);
  334. $this->checker
  335. ->expects($this->once())
  336. ->method('hasPassedCheck')
  337. ->willReturn(true);
  338. $this->memoryInfo
  339. ->method('isMemoryLimitSufficient')
  340. ->willReturn(true);
  341. $this->checkSetupController
  342. ->expects($this->once())
  343. ->method('getAppDirsWithDifferentOwner')
  344. ->willReturn([]);
  345. $this->checkSetupController
  346. ->expects($this->once())
  347. ->method('isImagickEnabled')
  348. ->willReturn(false);
  349. $this->checkSetupController
  350. ->expects($this->once())
  351. ->method('areWebauthnExtensionsEnabled')
  352. ->willReturn(false);
  353. $this->checkSetupController
  354. ->expects($this->once())
  355. ->method('hasBigIntConversionPendingColumns')
  356. ->willReturn([]);
  357. $this->checkSetupController
  358. ->expects($this->once())
  359. ->method('isMysqlUsedWithoutUTF8MB4')
  360. ->willReturn(false);
  361. $this->checkSetupController
  362. ->expects($this->once())
  363. ->method('isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed')
  364. ->willReturn(true);
  365. $this->urlGenerator->method('linkToDocs')
  366. ->willReturnCallback(function (string $key): string {
  367. if ($key === 'admin-performance') {
  368. return 'http://docs.example.org/server/go.php?to=admin-performance';
  369. }
  370. if ($key === 'admin-security') {
  371. return 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html';
  372. }
  373. if ($key === 'admin-reverse-proxy') {
  374. return 'reverse-proxy-doc-link';
  375. }
  376. if ($key === 'admin-code-integrity') {
  377. return 'http://docs.example.org/server/go.php?to=admin-code-integrity';
  378. }
  379. if ($key === 'admin-db-conversion') {
  380. return 'http://docs.example.org/server/go.php?to=admin-db-conversion';
  381. }
  382. return '';
  383. });
  384. $this->urlGenerator->method('getAbsoluteURL')
  385. ->willReturnCallback(function (string $url): string {
  386. if ($url === 'index.php/settings/admin') {
  387. return 'https://server/index.php/settings/admin';
  388. }
  389. if ($url === 'index.php') {
  390. return 'https://server/index.php';
  391. }
  392. return '';
  393. });
  394. $sqlitePlatform = $this->getMockBuilder(SqlitePlatform::class)->getMock();
  395. $this->connection->method('getDatabasePlatform')
  396. ->willReturn($sqlitePlatform);
  397. $expected = new DataResponse(
  398. [
  399. 'suggestedOverwriteCliURL' => '',
  400. 'cronInfo' => [
  401. 'diffInSeconds' => 123,
  402. 'relativeTime' => '2 hours ago',
  403. 'backgroundJobsUrl' => 'https://example.org',
  404. ],
  405. 'cronErrors' => [],
  406. 'isUsedTlsLibOutdated' => '',
  407. 'forwardedForHeadersWorking' => false,
  408. 'reverseProxyDocs' => 'reverse-proxy-doc-link',
  409. 'isCorrectMemcachedPHPModuleInstalled' => true,
  410. 'hasPassedCodeIntegrityCheck' => true,
  411. 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity',
  412. 'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'],
  413. 'isSettimelimitAvailable' => true,
  414. 'isSqliteUsed' => false,
  415. 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
  416. 'missingIndexes' => [],
  417. 'missingPrimaryKeys' => [],
  418. 'missingColumns' => [],
  419. 'isMemoryLimitSufficient' => true,
  420. 'appDirsWithDifferentOwner' => [],
  421. 'isImagickEnabled' => false,
  422. 'areWebauthnExtensionsEnabled' => false,
  423. 'pendingBigIntConversionColumns' => [],
  424. 'isMysqlUsedWithoutUTF8MB4' => false,
  425. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,
  426. 'reverseProxyGeneratedURL' => 'https://server/index.php',
  427. 'imageMagickLacksSVGSupport' => false,
  428. 'isFairUseOfFreePushService' => false,
  429. 'temporaryDirectoryWritable' => false,
  430. 'isBruteforceThrottled' => false,
  431. 'bruteforceRemoteAddress' => '',
  432. 'generic' => [],
  433. ]
  434. );
  435. $this->assertEquals($expected, $this->checkSetupController->check());
  436. }
  437. public function testGetCurlVersion() {
  438. $checkSetupController = $this->getMockBuilder(CheckSetupController::class)
  439. ->setConstructorArgs([
  440. 'settings',
  441. $this->request,
  442. $this->config,
  443. $this->clientService,
  444. $this->urlGenerator,
  445. $this->l10n,
  446. $this->checker,
  447. $this->logger,
  448. $this->dispatcher,
  449. $this->db,
  450. $this->lockingProvider,
  451. $this->dateTimeFormatter,
  452. $this->memoryInfo,
  453. $this->iniGetWrapper,
  454. $this->connection,
  455. $this->throttler,
  456. $this->tempManager,
  457. $this->notificationManager,
  458. $this->appManager,
  459. $this->serverContainer,
  460. $this->setupCheckManager,
  461. ])
  462. ->setMethods(null)->getMock();
  463. $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion'));
  464. }
  465. public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
  466. $this->config->expects($this->any())
  467. ->method('getSystemValue')
  468. ->willReturn(true);
  469. $this->checkSetupController
  470. ->expects($this->once())
  471. ->method('getCurlVersion')
  472. ->willReturn(['ssl_version' => 'SSLlib']);
  473. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  474. }
  475. public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
  476. $this->config->expects($this->any())
  477. ->method('getSystemValue')
  478. ->willReturn(true);
  479. $this->checkSetupController
  480. ->expects($this->once())
  481. ->method('getCurlVersion')
  482. ->willReturn([]);
  483. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  484. }
  485. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
  486. $this->config->expects($this->any())
  487. ->method('getSystemValue')
  488. ->willReturn(true);
  489. $this->checkSetupController
  490. ->expects($this->once())
  491. ->method('getCurlVersion')
  492. ->willReturn(['ssl_version' => 'OpenSSL/1.0.1d']);
  493. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  494. }
  495. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
  496. $this->config->expects($this->any())
  497. ->method('getSystemValue')
  498. ->willReturn(true);
  499. $this->checkSetupController
  500. ->expects($this->once())
  501. ->method('getCurlVersion')
  502. ->willReturn(['ssl_version' => 'OpenSSL/1.0.2b']);
  503. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  504. }
  505. /**
  506. * Setups a temp directory and some subdirectories.
  507. * Then calls the 'getAppDirsWithDifferentOwner' method.
  508. * The result is expected to be empty since
  509. * there are no directories with different owners than the current user.
  510. *
  511. * @return void
  512. */
  513. public function testAppDirectoryOwnersOk() {
  514. $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
  515. mkdir($tempDir);
  516. mkdir($tempDir . DIRECTORY_SEPARATOR . 'app1');
  517. mkdir($tempDir . DIRECTORY_SEPARATOR . 'app2');
  518. $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app1';
  519. $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app2';
  520. $this->dirsToRemove[] = $tempDir;
  521. OC::$APPSROOTS = [
  522. [
  523. 'path' => $tempDir,
  524. 'url' => '/apps',
  525. 'writable' => true,
  526. ],
  527. ];
  528. $this->assertSame(
  529. [],
  530. $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner')
  531. );
  532. }
  533. /**
  534. * Calls the check for a none existing app root that is marked as not writable.
  535. * It's expected that no error happens since the check shouldn't apply.
  536. *
  537. * @return void
  538. */
  539. public function testAppDirectoryOwnersNotWritable() {
  540. $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
  541. OC::$APPSROOTS = [
  542. [
  543. 'path' => $tempDir,
  544. 'url' => '/apps',
  545. 'writable' => false,
  546. ],
  547. ];
  548. $this->assertSame(
  549. [],
  550. $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner')
  551. );
  552. }
  553. public function testIsBuggyNss400() {
  554. $this->config->expects($this->any())
  555. ->method('getSystemValue')
  556. ->willReturn(true);
  557. $this->checkSetupController
  558. ->expects($this->once())
  559. ->method('getCurlVersion')
  560. ->willReturn(['ssl_version' => 'NSS/1.0.2b']);
  561. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  562. ->disableOriginalConstructor()->getMock();
  563. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  564. ->disableOriginalConstructor()->getMock();
  565. $response = $this->getMockBuilder(ResponseInterface::class)
  566. ->disableOriginalConstructor()->getMock();
  567. $response->expects($this->once())
  568. ->method('getStatusCode')
  569. ->willReturn(400);
  570. $exception->expects($this->once())
  571. ->method('getResponse')
  572. ->willReturn($response);
  573. $client->expects($this->once())
  574. ->method('get')
  575. ->with('https://nextcloud.com/', [])
  576. ->will($this->throwException($exception));
  577. $this->clientService->expects($this->once())
  578. ->method('newClient')
  579. ->willReturn($client);
  580. $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'));
  581. }
  582. public function testIsBuggyNss200() {
  583. $this->config->expects($this->any())
  584. ->method('getSystemValue')
  585. ->willReturn(true);
  586. $this->checkSetupController
  587. ->expects($this->once())
  588. ->method('getCurlVersion')
  589. ->willReturn(['ssl_version' => 'NSS/1.0.2b']);
  590. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  591. ->disableOriginalConstructor()->getMock();
  592. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  593. ->disableOriginalConstructor()->getMock();
  594. $response = $this->getMockBuilder(ResponseInterface::class)
  595. ->disableOriginalConstructor()->getMock();
  596. $response->expects($this->once())
  597. ->method('getStatusCode')
  598. ->willReturn(200);
  599. $exception->expects($this->once())
  600. ->method('getResponse')
  601. ->willReturn($response);
  602. $client->expects($this->once())
  603. ->method('get')
  604. ->with('https://nextcloud.com/', [])
  605. ->will($this->throwException($exception));
  606. $this->clientService->expects($this->once())
  607. ->method('newClient')
  608. ->willReturn($client);
  609. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  610. }
  611. public function testIsUsedTlsLibOutdatedWithInternetDisabled() {
  612. $this->config
  613. ->expects($this->once())
  614. ->method('getSystemValue')
  615. ->with('has_internet_connection', true)
  616. ->willReturn(false);
  617. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  618. }
  619. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() {
  620. $this->config
  621. ->expects($this->exactly(2))
  622. ->method('getSystemValue')
  623. ->willReturnMap([
  624. ['has_internet_connection', true, true],
  625. ['appstoreenabled', true, false],
  626. ]);
  627. $this->config
  628. ->expects($this->exactly(2))
  629. ->method('getAppValue')
  630. ->willReturnMap([
  631. ['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'],
  632. ['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'yes'],
  633. ]);
  634. $this->checkSetupController
  635. ->expects($this->once())
  636. ->method('getCurlVersion')
  637. ->willReturn([]);
  638. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  639. }
  640. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() {
  641. $this->config
  642. ->expects($this->exactly(2))
  643. ->method('getSystemValue')
  644. ->willReturnMap([
  645. ['has_internet_connection', true, true],
  646. ['appstoreenabled', true, false],
  647. ]);
  648. $this->config
  649. ->expects($this->exactly(2))
  650. ->method('getAppValue')
  651. ->willReturnMap([
  652. ['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'],
  653. ['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'no'],
  654. ]);
  655. $this->checkSetupController
  656. ->expects($this->never())
  657. ->method('getCurlVersion')
  658. ->willReturn([]);
  659. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  660. }
  661. public function testRescanFailedIntegrityCheck() {
  662. $this->checker
  663. ->expects($this->once())
  664. ->method('runInstanceVerification');
  665. $this->urlGenerator
  666. ->expects($this->once())
  667. ->method('linkToRoute')
  668. ->with('settings.AdminSettings.index')
  669. ->willReturn('/admin');
  670. $expected = new RedirectResponse('/admin');
  671. $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
  672. }
  673. public function testGetFailedIntegrityCheckDisabled() {
  674. $this->checker
  675. ->expects($this->once())
  676. ->method('isCodeCheckEnforced')
  677. ->willReturn(false);
  678. $expected = new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  679. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  680. }
  681. public function testGetFailedIntegrityCheckFilesWithNoErrorsFound() {
  682. $this->checker
  683. ->expects($this->once())
  684. ->method('isCodeCheckEnforced')
  685. ->willReturn(true);
  686. $this->checker
  687. ->expects($this->once())
  688. ->method('getResults')
  689. ->willReturn([]);
  690. $expected = new DataDisplayResponse(
  691. 'No errors have been found.',
  692. Http::STATUS_OK,
  693. [
  694. 'Content-Type' => 'text/plain',
  695. ]
  696. );
  697. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  698. }
  699. public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() {
  700. $this->checker
  701. ->expects($this->once())
  702. ->method('isCodeCheckEnforced')
  703. ->willReturn(true);
  704. $this->checker
  705. ->expects($this->once())
  706. ->method('getResults')
  707. ->willReturn([ 'core' => [ 'EXTRA_FILE' => ['/testfile' => []], 'INVALID_HASH' => [ '/.idea/workspace.xml' => [ 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ], '/lib/private/integritycheck/checker.php' => [ 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ], '/settings/controller/checksetupcontroller.php' => [ 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ], ], ], 'bookmarks' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'dav' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'encryption' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'federation' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_antivirus' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_drop' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_pdfviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_sharing' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_trashbin' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_versions' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_videoviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'firstrunwizard' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'gitsmart' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'logreader' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ], ], 'password_policy' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'provisioning_api' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'sketch'
  708. $expected = new DataDisplayResponse(
  709. 'Technical information
  710. =====================
  711. The following list covers which files have failed the integrity check. Please read
  712. the previous linked documentation to learn more about the errors and how to fix
  713. them.
  714. Results
  715. =======
  716. - core
  717. - EXTRA_FILE
  718. - /testfile
  719. - INVALID_HASH
  720. - /.idea/workspace.xml
  721. - /lib/private/integritycheck/checker.php
  722. - /settings/controller/checksetupcontroller.php
  723. - bookmarks
  724. - EXCEPTION
  725. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  726. - Signature data not found.
  727. - dav
  728. - EXCEPTION
  729. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  730. - Signature data not found.
  731. - encryption
  732. - EXCEPTION
  733. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  734. - Signature data not found.
  735. - external
  736. - EXCEPTION
  737. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  738. - Signature data not found.
  739. - federation
  740. - EXCEPTION
  741. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  742. - Signature data not found.
  743. - files
  744. - EXCEPTION
  745. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  746. - Signature data not found.
  747. - files_antivirus
  748. - EXCEPTION
  749. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  750. - Signature data not found.
  751. - files_drop
  752. - EXCEPTION
  753. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  754. - Signature data not found.
  755. - files_external
  756. - EXCEPTION
  757. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  758. - Signature data not found.
  759. - files_pdfviewer
  760. - EXCEPTION
  761. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  762. - Signature data not found.
  763. - files_sharing
  764. - EXCEPTION
  765. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  766. - Signature data not found.
  767. - files_trashbin
  768. - EXCEPTION
  769. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  770. - Signature data not found.
  771. - files_versions
  772. - EXCEPTION
  773. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  774. - Signature data not found.
  775. - files_videoviewer
  776. - EXCEPTION
  777. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  778. - Signature data not found.
  779. - firstrunwizard
  780. - EXCEPTION
  781. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  782. - Signature data not found.
  783. - gitsmart
  784. - EXCEPTION
  785. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  786. - Signature data not found.
  787. - logreader
  788. - EXCEPTION
  789. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  790. - Signature could not get verified.
  791. - password_policy
  792. - EXCEPTION
  793. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  794. - Signature data not found.
  795. - provisioning_api
  796. - EXCEPTION
  797. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  798. - Signature data not found.
  799. - sketch
  800. - EXCEPTION
  801. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  802. - Signature data not found.
  803. - threatblock
  804. - EXCEPTION
  805. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  806. - Signature data not found.
  807. - two_factor_auth
  808. - EXCEPTION
  809. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  810. - Signature data not found.
  811. - user_ldap
  812. - EXCEPTION
  813. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  814. - Signature data not found.
  815. - user_shibboleth
  816. - EXCEPTION
  817. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  818. - Signature data not found.
  819. Raw output
  820. ==========
  821. Array
  822. (
  823. [core] => Array
  824. (
  825. [EXTRA_FILE] => Array
  826. (
  827. [/testfile] => Array
  828. (
  829. )
  830. )
  831. [INVALID_HASH] => Array
  832. (
  833. [/.idea/workspace.xml] => Array
  834. (
  835. [expected] => f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216
  836. [current] => ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094
  837. )
  838. [/lib/private/integritycheck/checker.php] => Array
  839. (
  840. [expected] => c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea
  841. [current] => 88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585
  842. )
  843. [/settings/controller/checksetupcontroller.php] => Array
  844. (
  845. [expected] => 3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4
  846. [current] => 09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a
  847. )
  848. )
  849. )
  850. [bookmarks] => Array
  851. (
  852. [EXCEPTION] => Array
  853. (
  854. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  855. [message] => Signature data not found.
  856. )
  857. )
  858. [dav] => Array
  859. (
  860. [EXCEPTION] => Array
  861. (
  862. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  863. [message] => Signature data not found.
  864. )
  865. )
  866. [encryption] => Array
  867. (
  868. [EXCEPTION] => Array
  869. (
  870. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  871. [message] => Signature data not found.
  872. )
  873. )
  874. [external] => Array
  875. (
  876. [EXCEPTION] => Array
  877. (
  878. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  879. [message] => Signature data not found.
  880. )
  881. )
  882. [federation] => Array
  883. (
  884. [EXCEPTION] => Array
  885. (
  886. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  887. [message] => Signature data not found.
  888. )
  889. )
  890. [files] => Array
  891. (
  892. [EXCEPTION] => Array
  893. (
  894. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  895. [message] => Signature data not found.
  896. )
  897. )
  898. [files_antivirus] => Array
  899. (
  900. [EXCEPTION] => Array
  901. (
  902. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  903. [message] => Signature data not found.
  904. )
  905. )
  906. [files_drop] => Array
  907. (
  908. [EXCEPTION] => Array
  909. (
  910. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  911. [message] => Signature data not found.
  912. )
  913. )
  914. [files_external] => Array
  915. (
  916. [EXCEPTION] => Array
  917. (
  918. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  919. [message] => Signature data not found.
  920. )
  921. )
  922. [files_pdfviewer] => Array
  923. (
  924. [EXCEPTION] => Array
  925. (
  926. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  927. [message] => Signature data not found.
  928. )
  929. )
  930. [files_sharing] => Array
  931. (
  932. [EXCEPTION] => Array
  933. (
  934. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  935. [message] => Signature data not found.
  936. )
  937. )
  938. [files_trashbin] => Array
  939. (
  940. [EXCEPTION] => Array
  941. (
  942. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  943. [message] => Signature data not found.
  944. )
  945. )
  946. [files_versions] => Array
  947. (
  948. [EXCEPTION] => Array
  949. (
  950. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  951. [message] => Signature data not found.
  952. )
  953. )
  954. [files_videoviewer] => Array
  955. (
  956. [EXCEPTION] => Array
  957. (
  958. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  959. [message] => Signature data not found.
  960. )
  961. )
  962. [firstrunwizard] => Array
  963. (
  964. [EXCEPTION] => Array
  965. (
  966. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  967. [message] => Signature data not found.
  968. )
  969. )
  970. [gitsmart] => Array
  971. (
  972. [EXCEPTION] => Array
  973. (
  974. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  975. [message] => Signature data not found.
  976. )
  977. )
  978. [logreader] => Array
  979. (
  980. [EXCEPTION] => Array
  981. (
  982. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  983. [message] => Signature could not get verified.
  984. )
  985. )
  986. [password_policy] => Array
  987. (
  988. [EXCEPTION] => Array
  989. (
  990. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  991. [message] => Signature data not found.
  992. )
  993. )
  994. [provisioning_api] => Array
  995. (
  996. [EXCEPTION] => Array
  997. (
  998. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  999. [message] => Signature data not found.
  1000. )
  1001. )
  1002. [sketch] => Array
  1003. (
  1004. [EXCEPTION] => Array
  1005. (
  1006. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1007. [message] => Signature data not found.
  1008. )
  1009. )
  1010. [threatblock] => Array
  1011. (
  1012. [EXCEPTION] => Array
  1013. (
  1014. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1015. [message] => Signature data not found.
  1016. )
  1017. )
  1018. [two_factor_auth] => Array
  1019. (
  1020. [EXCEPTION] => Array
  1021. (
  1022. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1023. [message] => Signature data not found.
  1024. )
  1025. )
  1026. [user_ldap] => Array
  1027. (
  1028. [EXCEPTION] => Array
  1029. (
  1030. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1031. [message] => Signature data not found.
  1032. )
  1033. )
  1034. [user_shibboleth] => Array
  1035. (
  1036. [EXCEPTION] => Array
  1037. (
  1038. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1039. [message] => Signature data not found.
  1040. )
  1041. )
  1042. )
  1043. ',
  1044. Http::STATUS_OK,
  1045. [
  1046. 'Content-Type' => 'text/plain',
  1047. ]
  1048. );
  1049. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  1050. }
  1051. public function dataForIsMysqlUsedWithoutUTF8MB4() {
  1052. return [
  1053. ['sqlite', false, false],
  1054. ['sqlite', true, false],
  1055. ['postgres', false, false],
  1056. ['postgres', true, false],
  1057. ['oci', false, false],
  1058. ['oci', true, false],
  1059. ['mysql', false, true],
  1060. ['mysql', true, false],
  1061. ];
  1062. }
  1063. /**
  1064. * @dataProvider dataForIsMysqlUsedWithoutUTF8MB4
  1065. */
  1066. public function testIsMysqlUsedWithoutUTF8MB4(string $db, bool $useUTF8MB4, bool $expected) {
  1067. $this->config->method('getSystemValue')
  1068. ->willReturnCallback(function ($key, $default) use ($db, $useUTF8MB4) {
  1069. if ($key === 'dbtype') {
  1070. return $db;
  1071. }
  1072. if ($key === 'mysql.utf8mb4') {
  1073. return $useUTF8MB4;
  1074. }
  1075. return $default;
  1076. });
  1077. $checkSetupController = new CheckSetupController(
  1078. 'settings',
  1079. $this->request,
  1080. $this->config,
  1081. $this->clientService,
  1082. $this->urlGenerator,
  1083. $this->l10n,
  1084. $this->checker,
  1085. $this->logger,
  1086. $this->dispatcher,
  1087. $this->db,
  1088. $this->lockingProvider,
  1089. $this->dateTimeFormatter,
  1090. $this->memoryInfo,
  1091. $this->iniGetWrapper,
  1092. $this->connection,
  1093. $this->throttler,
  1094. $this->tempManager,
  1095. $this->notificationManager,
  1096. $this->appManager,
  1097. $this->serverContainer,
  1098. $this->setupCheckManager,
  1099. );
  1100. $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isMysqlUsedWithoutUTF8MB4'));
  1101. }
  1102. public function dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed() {
  1103. return [
  1104. ['singlebucket', 'OC\\Files\\ObjectStore\\Swift', true],
  1105. ['multibucket', 'OC\\Files\\ObjectStore\\Swift', true],
  1106. ['singlebucket', 'OC\\Files\\ObjectStore\\Custom', true],
  1107. ['multibucket', 'OC\Files\\ObjectStore\\Custom', true],
  1108. ['singlebucket', 'OC\Files\ObjectStore\Swift', true],
  1109. ['multibucket', 'OC\Files\ObjectStore\Swift', true],
  1110. ['singlebucket', 'OC\Files\ObjectStore\Custom', true],
  1111. ['multibucket', 'OC\Files\ObjectStore\Custom', true],
  1112. ];
  1113. }
  1114. /**
  1115. * @dataProvider dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed
  1116. */
  1117. public function testIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(string $mode, string $className, bool $expected) {
  1118. $this->config->method('getSystemValue')
  1119. ->willReturnCallback(function ($key, $default) use ($mode, $className) {
  1120. if ($key === 'objectstore' && $mode === 'singlebucket') {
  1121. return ['class' => $className];
  1122. }
  1123. if ($key === 'objectstore_multibucket' && $mode === 'multibucket') {
  1124. return ['class' => $className];
  1125. }
  1126. return $default;
  1127. });
  1128. $checkSetupController = new CheckSetupController(
  1129. 'settings',
  1130. $this->request,
  1131. $this->config,
  1132. $this->clientService,
  1133. $this->urlGenerator,
  1134. $this->l10n,
  1135. $this->checker,
  1136. $this->logger,
  1137. $this->dispatcher,
  1138. $this->db,
  1139. $this->lockingProvider,
  1140. $this->dateTimeFormatter,
  1141. $this->memoryInfo,
  1142. $this->iniGetWrapper,
  1143. $this->connection,
  1144. $this->throttler,
  1145. $this->tempManager,
  1146. $this->notificationManager,
  1147. $this->appManager,
  1148. $this->serverContainer,
  1149. $this->setupCheckManager,
  1150. );
  1151. $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed'));
  1152. }
  1153. }