mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
feat: add more encryption checks to info:file
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
c7430d5cb8
commit
d9c53ef748
2 changed files with 22 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ declare(strict_types=1);
|
|||
namespace OC\Core\Command\Info;
|
||||
|
||||
use OC\Files\ObjectStore\ObjectStoreStorage;
|
||||
use OC\Files\Storage\Wrapper\Encryption;
|
||||
use OC\Files\View;
|
||||
use OCA\Files_External\Config\ExternalMountPoint;
|
||||
use OCA\GroupFolders\Mount\GroupMountPoint;
|
||||
|
|
@ -71,6 +72,15 @@ class File extends Command {
|
|||
} else {
|
||||
$output->writeln(' <error>encryption key not found</error> should be located at: ' . $keyPath);
|
||||
}
|
||||
$storage = $node->getStorage();
|
||||
if ($storage->instanceOfStorage(Encryption::class)) {
|
||||
/** @var Encryption $storage */
|
||||
if (!$storage->hasValidHeader($node->getInternalPath())) {
|
||||
$output->writeln(' <error>file doesn\'t have a valid encryption header</error>');
|
||||
}
|
||||
} else {
|
||||
$output->writeln(' <error>file is marked as encrypted, but encryption doesn\'t seem to be setup</error>');
|
||||
}
|
||||
}
|
||||
|
||||
if ($node instanceof Folder && $node->isEncrypted() || $node instanceof OCPFile && $node->getParent()->isEncrypted()) {
|
||||
|
|
|
|||
|
|
@ -894,4 +894,16 @@ class Encryption extends Wrapper {
|
|||
public function setEnabled(bool $enabled): void {
|
||||
$this->enabled = $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the on-disk data for a file has a valid encrypted header
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function hasValidHeader(string $path): bool {
|
||||
$firstBlock = $this->readFirstBlock($path);
|
||||
$header = $this->util->parseRawHeader($firstBlock);
|
||||
return (count($header) > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue