Skip to content

Commit

Permalink
chore: WIP - debug for CI
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Jan 20, 2025
1 parent 14b8770 commit f299305
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/files_versions/tests/VersioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,20 @@ public function testMoveFileIntoSharedFolderAsRecipient(): void {
// move file into the shared folder as recipient
$success = Filesystem::rename('/test.txt', '/folder1/test.txt');

$this->assertTrue($success);
// TODO: Voir is $v2 existe pour voir si c’est la copie ou la suppression qui foire
// Mettre du debug dans Wrapper/Encrytion::copyBetweenStorage c’est le suspect n-1
$versionsFolder1 = '/' . self::TEST_VERSIONS_USER . '/files_versions';

$v1Renamed = $versionsFolder1 . '/folder1/test.txt.v' . $t1;
$v2Renamed = $versionsFolder1 . '/folder1/test.txt.v' . $t2;
var_dump([
'success' => $success,
'v1 exists' => $this->rootView->file_exists($v1),
'v2 exists' => $this->rootView->file_exists($v2),
'v1Renamed exists' => $this->rootView->file_exists($v1Renamed),
'v2Renamed exists' => $this->rootView->file_exists($v2Renamed),
]);
$this->assertTrue($success); // renvoi true :-O
$this->assertFalse($this->rootView->file_exists($v1));
$this->assertFalse($this->rootView->file_exists($v2));

Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,17 @@ private function rmObjects(ICacheEntry $entry): bool {
}

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

Check failure on line 179 in lib/private/Files/ObjectStore/ObjectStoreStorage.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHtml

lib/private/Files/ObjectStore/ObjectStoreStorage.php:179:8: TaintedHtml: Detected tainted HTML (see https://psalm.dev/245)

Check failure on line 179 in lib/private/Files/ObjectStore/ObjectStoreStorage.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedTextWithQuotes

lib/private/Files/ObjectStore/ObjectStoreStorage.php:179:8: TaintedTextWithQuotes: Detected tainted text with possible quotes (see https://psalm.dev/274)

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

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

if ($entry instanceof ICacheEntry) {
if ($entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
echo "[DEBUG] unlink directory $path " . __FILE__ . ':' . __LINE__ . "\n";
return $this->rmObjects($entry);
} else {
echo "[DEBUG] unlink file $path " . __FILE__ . ':' . __LINE__ . "\n";
return $this->rmObject($entry);
}
}
Expand Down
11 changes: 11 additions & 0 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ public function file_put_contents(string $path, mixed $data): int|float|false {
}

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

Check failure on line 172 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHtml

lib/private/Files/Storage/Wrapper/Encryption.php:172:8: TaintedHtml: Detected tainted HTML (see https://psalm.dev/245)

Check failure on line 172 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedTextWithQuotes

lib/private/Files/Storage/Wrapper/Encryption.php:172:8: TaintedTextWithQuotes: Detected tainted text with possible quotes (see https://psalm.dev/274)

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

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 on line 174 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHtml

lib/private/Files/Storage/Wrapper/Encryption.php:174:8: TaintedHtml: Detected tainted HTML (see https://psalm.dev/245)

Check failure on line 174 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedTextWithQuotes

lib/private/Files/Storage/Wrapper/Encryption.php:174:8: TaintedTextWithQuotes: Detected tainted text with possible quotes (see https://psalm.dev/274)

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

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 on line 176 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHtml

lib/private/Files/Storage/Wrapper/Encryption.php:176:9: TaintedHtml: Detected tainted HTML (see https://psalm.dev/245)

Check failure on line 176 in lib/private/Files/Storage/Wrapper/Encryption.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedTextWithQuotes

lib/private/Files/Storage/Wrapper/Encryption.php:176:9: TaintedTextWithQuotes: Detected tainted text with possible quotes (see https://psalm.dev/274)

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
return $this->storage->unlink($path);
}

Expand Down Expand Up @@ -522,20 +525,25 @@ public function moveFromStorage(
// - 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

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

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
if ($result) {
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy success " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
/** @var ObjectStoreStorage $sourceStorage */
$sourceStorage->setPreserveCacheOnDelete(true);
}
try {
if ($sourceStorage->is_dir($sourceInternalPath)) {
$result = $sourceStorage->rmdir($sourceInternalPath);
echo "[DEBUG] $sourceInternalPath rmdir:$result " . __FILE__ . ':' . __LINE__ . "\n";
} else {
$result = $sourceStorage->unlink($sourceInternalPath);
echo "[DEBUG] $sourceInternalPath unlink:$result " . __FILE__ . ':' . __LINE__ . "\n";
}
} finally {
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
Expand Down Expand Up @@ -621,10 +629,12 @@ private function copyBetweenStorage(
bool $preserveMtime,
bool $isRename,
): bool {
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML

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

Check failure

Code scanning / Psalm

TaintedTextWithQuotes Error

Detected tainted text with possible quotes
// remember that we try to create a version so that we can detect it during
// fopen($sourceInternalPath) and by-pass the encryption in order to
// create a 1:1 copy of the file
Expand All @@ -642,6 +652,7 @@ private function copyBetweenStorage(
}
$this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, true);
}
echo "[DEBUG] $result " . __FILE__ . ':' . __LINE__ . "\n";
return $result;
}

Expand Down

0 comments on commit f299305

Please sign in to comment.