Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(encryption): Migrate from hooks to events #48560

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Oct 3, 2024

Part of #32128

Summary

This is not half as clean as I would’ve liked, because original code is convoluted.
The owner thing in the event listener is ugly and probably incorrect but it was there before in HookManager class.

Checklist

@come-nc come-nc added the 3. to review Waiting for reviews label Oct 3, 2024
@come-nc come-nc added this to the Nextcloud 31 milestone Oct 3, 2024
@come-nc come-nc self-assigned this Oct 3, 2024
@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch 2 times, most recently from 7b456c7 to fc22188 Compare November 5, 2024 15:53
@come-nc
Copy link
Contributor Author

come-nc commented Nov 26, 2024

Getting there, only one more failure. For some reason it’s not the same one locally and in the CI 🤷

@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch from 1d2e3f4 to f392a55 Compare December 16, 2024 14:45
@blizzz blizzz mentioned this pull request Jan 8, 2025
@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch from efb5812 to 4a3def9 Compare January 13, 2025 08:58
@skjnldsv skjnldsv mentioned this pull request Jan 14, 2025
…ffects

It was clearing the hooks with the same results before

Signed-off-by: Côme Chilliet <[email protected]>
…ects

Adapt tests a bit to make them pass with Encryption wrapper registered

Signed-off-by: Côme Chilliet <[email protected]>
…ith encryption registered

Signed-off-by: Côme Chilliet <[email protected]>
…ems in files_versions tests

Signed-off-by: Côme Chilliet <[email protected]>
@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch from 314010a to 14b8770 Compare January 16, 2025 17:05
@skjnldsv skjnldsv mentioned this pull request Jan 16, 2025
@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch from d47a006 to bfbc787 Compare January 20, 2025 09:40
@come-nc come-nc added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jan 20, 2025
@@ -521,15 +522,31 @@
// - remove $this->copyBetweenStorage

if (!$sourceStorage->isDeletable($sourceInternalPath)) {
echo "[DEBUG] $sourceInternalPath $targetInternalPath not deletable " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
@@ -521,15 +522,31 @@
// - remove $this->copyBetweenStorage

if (!$sourceStorage->isDeletable($sourceInternalPath)) {
echo "[DEBUG] $sourceInternalPath $targetInternalPath not deletable " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
return false;
}

$result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true);
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy:$result " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
return false;
}

$result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true);
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy:$result " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
$result = $sourceStorage->rmdir($sourceInternalPath);
} else {
$result = $sourceStorage->unlink($sourceInternalPath);
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy success " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
$result = $sourceStorage->rmdir($sourceInternalPath);
} else {
$result = $sourceStorage->unlink($sourceInternalPath);
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy success " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
@@ -609,10 +626,12 @@
bool $preserveMtime,
bool $isRename,
): bool {
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
@@ -609,10 +626,12 @@
bool $preserveMtime,
bool $isRename,
): bool {
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
// for versions we have nothing to do, because versions should always use the
// key from the original file. Just create a 1:1 copy and done
if ($this->isVersion($targetInternalPath) ||
$this->isVersion($sourceInternalPath)) {
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
// for versions we have nothing to do, because versions should always use the
// key from the original file. Just create a 1:1 copy and done
if ($this->isVersion($targetInternalPath) ||
$this->isVersion($sourceInternalPath)) {
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
Signed-off-by: Côme Chilliet <[email protected]>
@come-nc come-nc force-pushed the fix/migrate-encryption-away-from-hooks branch from bfbc787 to f299305 Compare January 20, 2025 10:24
@@ -176,13 +176,17 @@
}

public function unlink(string $path): bool {
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
@@ -176,13 +176,17 @@
}

public function unlink(string $path): bool {
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
@@ -168,8 +169,11 @@
}

public function unlink(string $path): bool {
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
@@ -168,8 +169,11 @@
}

public function unlink(string $path): bool {
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
$fullPath = $this->getFullPath($path);
echo "[DEBUG] unlink($fullPath) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
$fullPath = $this->getFullPath($path);
echo "[DEBUG] unlink($fullPath) " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
if ($this->util->isExcluded($fullPath)) {
echo "[DEBUG] excluded $fullPath " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
if ($this->util->isExcluded($fullPath)) {
echo "[DEBUG] excluded $fullPath " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
@Altahrim Altahrim mentioned this pull request Jan 21, 2025
*/
public function postShared($params) {
public function postShared(string $nodeType, int $nodeId): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you're touching the params anyway, might as well pass a FileInfo or Node here to save having to query the filecache again in the body.

(same for the other post... methods below)

@Altahrim Altahrim mentioned this pull request Jan 23, 2025
@come-nc come-nc modified the milestones: Nextcloud 31, Nextcloud 32 Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants