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

[stable30] fix: Remove legacy optimization when checking encryption status #873

Merged
merged 2 commits into from
Jan 20, 2025
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
110 changes: 110 additions & 0 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Node tests

on:
pull_request:
push:
branches:
- main
- master
- stable*

permissions:
contents: read

concurrency:
group: node-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest-low
permissions:
contents: read
pull-requests: read

outputs:
src: ${{ steps.changes.outputs.src}}

steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- '__tests__/**'
- '__mocks__/**'
- 'src/**'
- 'appinfo/info.xml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- '**.js'
- '**.ts'
- '**.vue'

test:
runs-on: ubuntu-latest

needs: changes
if: needs.changes.outputs.src != 'false'

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
with:
fallbackNode: '^20'
fallbackNpm: '^10'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'

- name: Install dependencies & build
env:
CYPRESS_INSTALL_BINARY: 0
run: |
npm ci
npm run build --if-present

- name: Test
run: npm run test --if-present

- name: Test and process coverage
run: npm run test:coverage --if-present

- name: Collect coverage
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
files: ./coverage/lcov.info

summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, test]

if: always()

name: test-summary

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.test.result != 'success' }}; then exit 1; fi
12 changes: 7 additions & 5 deletions lib/Connector/Sabre/APlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\EndToEndEncryption\E2EEnabledPathCache;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IUserSession;
use Sabre\DAV\Exception\Conflict;
Expand All @@ -37,7 +37,6 @@ abstract class APlugin extends ServerPlugin {
protected ?Server $server = null;
protected IRootFolder $rootFolder;
protected IUserSession $userSession;
protected E2EEnabledPathCache $pathCache;

/**
* Should plugin be applied to the current node?
Expand All @@ -51,11 +50,9 @@ abstract class APlugin extends ServerPlugin {
public function __construct(
IRootFolder $rootFolder,
IUserSession $userSession,
E2EEnabledPathCache $pathCache
) {
$this->rootFolder = $rootFolder;
$this->userSession = $userSession;
$this->pathCache = $pathCache;
}

/**
Expand Down Expand Up @@ -100,7 +97,12 @@ protected function getNodeForPath(string $path): INode {
*/
protected function isE2EEnabledPath(INode $node): bool {
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
return $this->pathCache->isE2EEnabledPath($node->getNode());
$node = $node->getNode();
if ($node instanceof Folder) {
return $node->isEncrypted();
} else {
return $node->getParent()->isEncrypted();
}
}
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Connector/Sabre/LockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Upload\FutureFile;
use OCA\EndToEndEncryption\E2EEnabledPathCache;
use OCA\EndToEndEncryption\LockManager;
use OCA\EndToEndEncryption\UserAgentManager;
use OCP\AppFramework\Http;
Expand All @@ -49,8 +48,8 @@ public function __construct(IRootFolder $rootFolder,
IUserSession $userSession,
LockManager $lockManager,
UserAgentManager $userAgentManager,
E2EEnabledPathCache $pathCache) {
parent::__construct($rootFolder, $userSession, $pathCache);
) {
parent::__construct($rootFolder, $userSession);
$this->lockManager = $lockManager;
$this->userAgentManager = $userAgentManager;
}
Expand Down
7 changes: 3 additions & 4 deletions lib/Connector/Sabre/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\EndToEndEncryption\E2EEnabledPathCache;
use OCA\EndToEndEncryption\UserAgentManager;
use OCP\Files\IRootFolder;
use OCP\IRequest;
Expand All @@ -47,8 +46,8 @@ public function __construct(IRootFolder $rootFolder,
IUserSession $userSession,
UserAgentManager $userAgentManager,
IRequest $request,
E2EEnabledPathCache $pathCache) {
parent::__construct($rootFolder, $userSession, $pathCache);
) {
parent::__construct($rootFolder, $userSession);
$this->userAgentManager = $userAgentManager;
$this->request = $request;
}
Expand All @@ -69,7 +68,7 @@ public function setEncryptedProperty(PropFind $propFind, \Sabre\DAV\INode $node)
// Only folders can be e2e encrypted, so we only respond for directories.
if ($node instanceof Directory) {
$propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->isEncrypted() ? '1' : '0';
return $this->isE2EEnabledPath($node) ? '1' : '0';
});
}
}
Expand Down
126 changes: 0 additions & 126 deletions lib/E2EEnabledPathCache.php

This file was deleted.

Loading
Loading