feat(encryption): Add integration tests for occ commands and fix them#54316
feat(encryption): Add integration tests for occ commands and fix them#54316
Conversation
fc10598 to
9621c6d
Compare
|
Tests are working, but code is not. decrypt-all does not work, encrypted version is not set to 0. When doing only encrypt-all, the cleanup in the end run in "Inconsistent data, File unshared, but owner not found. Should not happen": {
"reqId": "yUsdYhahv4ySuATDznYS",
"level": 3,
"time": "2025-08-07T14:38:57+00:00",
"remoteAddr": "",
"user": "--",
"app": "no app in context",
"method": "",
"url": "--",
"message": "Inconsistent data, File unshared, but owner not found. Should not happen",
"userAgent": "--",
"version": "32.0.0.2",
"exception": {
"Exception": "Exception",
"Message": "Inconsistent data, File unshared, but owner not found. Should not happen",
"Code": 0,
"Trace": [
{
"file": "/nextcloud/lib/private/Encryption/EncryptionEventListener.php",
"line": 52,
"function": "getUpdate",
"class": "OC\\Encryption\\EncryptionEventListener",
"type": "->"
},
{
"file": "/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php",
"line": 57,
"function": "handle",
"class": "OC\\Encryption\\EncryptionEventListener",
"type": "->"
},
{
"file": "/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 220,
"function": "__invoke",
"class": "OC\\EventDispatcher\\ServiceEventListener",
"type": "->"
},
{
"file": "/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 56,
"function": "callListeners",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 67,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 79,
"function": "dispatch",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/nextcloud/lib/private/Files/Node/HookConnector.php",
"line": 169,
"function": "dispatchTyped",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/nextcloud/lib/private/legacy/OC_Hook.php",
"line": 85,
"function": "postRename",
"class": "OC\\Files\\Node\\HookConnector",
"type": "->"
},
{
"file": "/nextcloud/lib/private/Files/View.php",
"line": 836,
"function": "emit",
"class": "OC_Hook",
"type": "::"
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/EncryptAll.php",
"line": 257,
"function": "rename",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/EncryptAll.php",
"line": 218,
"function": "encryptFile",
"class": "OCA\\Encryption\\Crypto\\EncryptAll",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/EncryptAll.php",
"line": 183,
"function": "encryptUsersFiles",
"class": "OCA\\Encryption\\Crypto\\EncryptAll",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/EncryptAll.php",
"line": 157,
"function": "encryptAllUserFilesWithMasterKey",
"class": "OCA\\Encryption\\Crypto\\EncryptAll",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/EncryptAll.php",
"line": 107,
"function": "encryptAllUsersFiles",
"class": "OCA\\Encryption\\Crypto\\EncryptAll",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/apps/encryption/lib/Crypto/Encryption.php",
"line": 468,
"function": "encryptAll",
"class": "OCA\\Encryption\\Crypto\\EncryptAll",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/core/Command/Encryption/EncryptAll.php",
"line": 92,
"function": "encryptAll",
"class": "OCA\\Encryption\\Crypto\\Encryption",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/nextcloud/3rdparty/symfony/console/Command/Command.php",
"line": 326,
"function": "execute",
"class": "OC\\Core\\Command\\Encryption\\EncryptAll",
"type": "->"
},
{
"file": "/nextcloud/3rdparty/symfony/console/Application.php",
"line": 1078,
"function": "run",
"class": "Symfony\\Component\\Console\\Command\\Command",
"type": "->"
},
{
"file": "/nextcloud/3rdparty/symfony/console/Application.php",
"line": 324,
"function": "doRunCommand",
"class": "Symfony\\Component\\Console\\Application",
"type": "->"
},
{
"file": "/nextcloud/3rdparty/symfony/console/Application.php",
"line": 175,
"function": "doRun",
"class": "Symfony\\Component\\Console\\Application",
"type": "->"
},
{
"file": "/nextcloud/lib/private/Console/Application.php",
"line": 187,
"function": "run",
"class": "Symfony\\Component\\Console\\Application",
"type": "->"
},
{
"file": "/nextcloud/console.php",
"line": 90,
"function": "run",
"class": "OC\\Console\\Application",
"type": "->"
}
],
"File": "/nextcloud/lib/private/Encryption/EncryptionEventListener.php",
"Line": 76,
"message": "Inconsistent data, File unshared, but owner not found. Should not happen",
"exception": {},
"CustomMessage": "Inconsistent data, File unshared, but owner not found. Should not happen"
}
}
|
|
Notes regarding the uid thing:
I think we should remove or ignore this uid parameter, and just use the user in session for user key, and bail out if there is none. |
d7684b8 to
6d149de
Compare
|
For decrypt-all, the root of the issue is from #48651 I’m not sure I understand the original PR explanation, because the encryption wrapper calls I do not know how to cleanly fix that, since the storage wrapper does not get called after the copyUpdate happens. |
d8f97a9 to
9f613a7
Compare
9f613a7 to
09647bf
Compare
|
So after investigating with Louis we decided to simply fix copyFromCache for the specific case of encryption being disabled and set encrypted to |
69bd471 to
e23dfe9
Compare
Add tests for encrypt-all and decrypt-all. Signed-off-by: Côme Chilliet <[email protected]>
…essary Should fix a bunch of stuff when encryption listener is triggered by events from occ commands or background jobs Signed-off-by: Côme Chilliet <[email protected]>
Signed-off-by: Côme Chilliet <[email protected]>
If encryption got disabled, copying should set encrypted to 0 for the new unencrypted copy. For instance when using encryption:decrypt-all Signed-off-by: Côme Chilliet <[email protected]>
shouldEncrypt now returns false for all paths if encryption is disabled. Signed-off-by: Côme Chilliet <[email protected]>
Signed-off-by: Côme Chilliet <[email protected]>
…ger.php Co-authored-by: Louis <[email protected]> Signed-off-by: Côme Chilliet <[email protected]>
…eKey It’s a private API in the application, no need to keep an unused attribute. Signed-off-by: Côme Chilliet <[email protected]>
5eb2661 to
8330f14
Compare
|
/backport to stable32 |
|
/backport to stable31 |
|
/backport to stable30 |
Summary
TODO
Checklist