Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:integration": "cd tests/Integration && ./run.sh"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.82.0",
"nextcloud/coding-standard": "^1.2.1",
"nextcloud/ocp": "dev-master",
"phpunit/phpunit": "^10.5.28",
Expand Down
144 changes: 76 additions & 68 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public function addStorageWrapperCallback($mountPoint, IStorage $storage) {
return $storage;
}

#[\Override]
public function register(IRegistrationContext $context): void {
Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper');
$context->registerEventListener(RegisterOperationsEvent::class, FlowRegisterOperationListener::class);
}

#[\Override]
public function boot(IBootContext $context): void {
}
}
1 change: 1 addition & 0 deletions lib/CacheWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(
& ~Constants::PERMISSION_DELETE;
}

#[\Override]
protected function formatCacheEntry($entry) {
if (isset($entry['path']) && isset($entry['permissions'])) {
try {
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/FlowRegisterOperationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof RegisterOperationsEvent) {
return;
Expand Down
8 changes: 8 additions & 0 deletions lib/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ protected function isCreatingSkeletonFiles(): bool {
* @param string $operation
* @throws UnexpectedValueException
*/
#[\Override]
public function validateOperation(string $name, array $checks, string $operation): void {
if (empty($checks)) {
throw new UnexpectedValueException($this->l->t('No rule given'));
Expand All @@ -187,6 +188,7 @@ public function validateOperation(string $name, array $checks, string $operation
*
* @since 18.0.0
*/
#[\Override]
public function getDisplayName(): string {
return $this->l->t('Block access to a file');
}
Expand All @@ -200,6 +202,7 @@ public function getDisplayName(): string {
*
* @since 18.0.0
*/
#[\Override]
public function getDescription(): string {
return '';
}
Expand All @@ -214,6 +217,7 @@ public function getDescription(): string {
*
* @since 18.0.0
*/
#[\Override]
public function getIcon(): string {
return $this->urlGenerator->imagePath('files_accesscontrol', 'app.svg');
}
Expand All @@ -230,6 +234,7 @@ public function getIcon(): string {
*
* @since 18.0.0
*/
#[\Override]
public function isAvailableForScope(int $scope): bool {
return $scope === IManager::SCOPE_ADMIN;
}
Expand All @@ -241,6 +246,7 @@ public function isAvailableForScope(int $scope): bool {
*
* @since 18.0.0
*/
#[\Override]
public function getEntityId(): string {
return File::class;
}
Expand All @@ -254,10 +260,12 @@ public function getEntityId(): string {
*
* @since 18.0.0
*/
#[\Override]
public function getTriggerHint(): string {
return $this->l->t('File is accessed');
}

#[\Override]
public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void {
// Noop
}
Expand Down
19 changes: 19 additions & 0 deletions lib/StorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected function checkFileAccess(string $path, ?bool $isDir = null): void {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function mkdir($path): bool {
$this->checkFileAccess($path, true);
return $this->storage->mkdir($path);
Expand All @@ -67,6 +68,7 @@ public function mkdir($path): bool {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function rmdir($path): bool {
$this->checkFileAccess($path, true);
return $this->storage->rmdir($path);
Expand All @@ -78,6 +80,7 @@ public function rmdir($path): bool {
* @param string $path
* @return bool
*/
#[\Override]
public function isCreatable($path): bool {
try {
$this->checkFileAccess($path);
Expand All @@ -93,6 +96,7 @@ public function isCreatable($path): bool {
* @param string $path
* @return bool
*/
#[\Override]
public function isReadable($path): bool {
try {
$this->checkFileAccess($path);
Expand All @@ -108,6 +112,7 @@ public function isReadable($path): bool {
* @param string $path
* @return bool
*/
#[\Override]
public function isUpdatable($path): bool {
try {
$this->checkFileAccess($path);
Expand All @@ -123,6 +128,7 @@ public function isUpdatable($path): bool {
* @param string $path
* @return bool
*/
#[\Override]
public function isDeletable($path): bool {
try {
$this->checkFileAccess($path);
Expand All @@ -132,6 +138,7 @@ public function isDeletable($path): bool {
return $this->storage->isDeletable($path);
}

#[\Override]
public function getPermissions($path): int {
try {
$this->checkFileAccess($path);
Expand All @@ -148,6 +155,7 @@ public function getPermissions($path): int {
* @return string
* @throws ForbiddenException
*/
#[\Override]
public function file_get_contents($path): string|false {
$this->checkFileAccess($path, false);
return $this->storage->file_get_contents($path);
Expand All @@ -161,6 +169,7 @@ public function file_get_contents($path): string|false {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function file_put_contents($path, $data): int|float|false {
$this->checkFileAccess($path, false);
return $this->storage->file_put_contents($path, $data);
Expand All @@ -173,6 +182,7 @@ public function file_put_contents($path, $data): int|float|false {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function unlink($path): bool {
$this->checkFileAccess($path, false);
return $this->storage->unlink($path);
Expand All @@ -186,6 +196,7 @@ public function unlink($path): bool {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function rename($source, $target): bool {
$isDir = $this->is_dir($source);
$this->checkFileAccess($source, $isDir);
Expand All @@ -201,6 +212,7 @@ public function rename($source, $target): bool {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function copy($source, $target): bool {
$isDir = $this->is_dir($source);
$this->checkFileAccess($source, $isDir);
Expand All @@ -216,6 +228,7 @@ public function copy($source, $target): bool {
* @return resource
* @throws ForbiddenException
*/
#[\Override]
public function fopen($path, $mode) {
$this->checkFileAccess($path, false);
return $this->storage->fopen($path, $mode);
Expand All @@ -230,6 +243,7 @@ public function fopen($path, $mode) {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function touch($path, $mtime = null): bool {
$this->checkFileAccess($path, false);
return $this->storage->touch($path, $mtime);
Expand All @@ -242,6 +256,7 @@ public function touch($path, $mtime = null): bool {
* @param Storage (optional) the storage to pass to the cache
* @return Cache
*/
#[\Override]
public function getCache($path = '', $storage = null): ICache {
if (!$storage) {
$storage = $this;
Expand All @@ -259,6 +274,7 @@ public function getCache($path = '', $storage = null): ICache {
* @return array
* @throws ForbiddenException
*/
#[\Override]
public function getDirectDownload($path): array|false {
$this->checkFileAccess($path, false);
return $this->storage->getDirectDownload($path);
Expand All @@ -271,6 +287,7 @@ public function getDirectDownload($path): array|false {
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
if ($sourceStorage === $this) {
return $this->copy($sourceInternalPath, $targetInternalPath);
Expand All @@ -287,6 +304,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
* @return bool
* @throws ForbiddenException
*/
#[\Override]
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
if ($sourceStorage === $this) {
return $this->rename($sourceInternalPath, $targetInternalPath);
Expand All @@ -299,6 +317,7 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
/**
* @throws ForbiddenException
*/
#[\Override]
public function writeStream(string $path, $stream, ?int $size = null): int {
if (!$this->isPartFile($path)) {
$this->checkFileAccess($path, false);
Expand Down