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

Move excluded files to config array #29126

Merged
merged 1 commit into from
Nov 8, 2017
Merged

Conversation

sharidas
Copy link
Contributor

@sharidas sharidas commented Sep 29, 2017

Moving excluded files to config array.
Instead of populating in the ExcludeFile*
php files, we can have it in config.php.

Signed-off-by: Sujith H sharidasan@owncloud.com

Description

This change would help users to mention folders/files to be excluded during integrity check to the config.php. In the config.php it will be represented as an array.

Related Issue

#23186
https://github.com/owncloud/enterprise/issues/1874

Motivation and Context

Instead of hard coding the files/folders in the files, its better to move them to the config.php. Also this change would help the integrity check to exclude files/folders mentioned in the config.php

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sharidas sharidas self-assigned this Sep 29, 2017
@sharidas sharidas added this to the development milestone Sep 29, 2017
@sharidas sharidas changed the title [WIP] Move excluded files/folders to config array Move excluded files/folders to config array Oct 3, 2017
@sharidas sharidas changed the title Move excluded files/folders to config array [WIP] Move excluded files/folders to config array Oct 3, 2017
@tomneedham
Copy link
Contributor

should also include a sample entry in config.sample.php

@@ -398,13 +398,21 @@ private function verify($signaturePath, $basePath, $certificateCN, $force = fals
throw new InvalidSignatureException('Signature could not get verified.');
}

//Exclude files which shouldn't fall for comparison
$excludeFiles = \OC::$server->getSystemConfig()->getValue('excludedFiles', '');
Copy link
Contributor

Choose a reason for hiding this comment

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

default should be an array since we use it in in_array later

@sharidas sharidas changed the title [WIP] Move excluded files/folders to config array Move excluded files/folders to config array Oct 4, 2017
'excludedFolders' =>
array (
0 => '/home/sujith/test/owncloud/data',
1 => '/home/sujith/test/owncloud/themes',
Copy link
Member

Choose a reason for hiding this comment

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

better use OC::$SERVERROOT

example

OC::$SERVERROOT . '/assets'

Copy link
Member

Choose a reason for hiding this comment

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

and we shall find good example folders - maybe two are enough.
/apps/my-theme might be a good example and /assets

/**
* Exclude file name patterns from the integrity checker command
*/
'excludedFilenamePatterns' =>
Copy link
Member

Choose a reason for hiding this comment

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

isn't the pattern enough to also properly exclude folders and files from above?

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure... maybe some files could have prefixes/suffixes ? I'd also prefer the simpler solution.

@sharidas Did anyone report such cases in the original ticket ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PVince81 No I didn't find any cases related to exclude filename patterns in the original ticket. I think we can stick on with exclude file names and remove exclude filename patterns from the PR.

@@ -398,13 +398,21 @@ private function verify($signaturePath, $basePath, $certificateCN, $force = fals
throw new InvalidSignatureException('Signature could not get verified.');
}

//Exclude files which shouldn't fall for comparison
$excludeFiles = \OC::$server->getSystemConfig()->getValue('excludedFiles', []);
Copy link
Member

Choose a reason for hiding this comment

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

inject config instance - no use of \OC::$server inside any class please

@@ -78,4 +85,12 @@ public function accept() {

return true;
}

protected function getExcludedFileNames() {
return \OC::$server->getConfig()->getSystemValue('excludedFiles', '');
Copy link
Member

Choose a reason for hiding this comment

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

keep proper defaults - basically just like before

@@ -317,6 +340,9 @@ public function install($options) {
'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT,
'dbtype' => $dbType,
'version' => implode('.', \OCP\Util::getVersion()),
'excludedFolders' => $excludeFolders,
Copy link
Member

Choose a reason for hiding this comment

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

I would no set them during setup. the defaults will be in our code base and people can extend/change the list if they like.

@@ -497,114 +497,6 @@ public function testWriteCoreSignature() {
$this->checker->writeCoreSignature($x509, $rsa, \OC::$SERVERROOT . '/tests/data/integritycheck/app/');
}

public function testWriteCoreSignatureWithUnmodifiedHtaccess() {
Copy link
Member

Choose a reason for hiding this comment

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

where did these tests go?

@PVince81
Copy link
Contributor

I heard from @Peter-Prochaska that it might not be a good idea to allow excluding whole folders, so not sure... See #29094 (comment)

@PVince81
Copy link
Contributor

  • Please only allow excluding files, not folders, as discussed with @Peter-Prochaska

@mmattel
Copy link
Contributor

mmattel commented Oct 23, 2017

Maybe only a small detail to avoid naming confusion:
excludedFolders --> integrityExcludedFolders also valid for the others.

Reason: https://doc.owncloud.org/server/latest/admin_manual/configuration/server/excluded_blacklisted_files.html

@sharidas
Copy link
Contributor Author

sharidas commented Nov 3, 2017

Updated this PR to exclude files only and not folders.

@codecov
Copy link

codecov bot commented Nov 3, 2017

Codecov Report

Merging #29126 into master will increase coverage by 0.23%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #29126      +/-   ##
============================================
+ Coverage     60.84%   61.08%   +0.23%     
- Complexity    17238    17239       +1     
============================================
  Files          1032     1031       -1     
  Lines         57365    57145     -220     
============================================
+ Hits          34904    34907       +3     
+ Misses        22461    22238     -223
Impacted Files Coverage Δ Complexity Δ
lib/private/IntegrityCheck/Checker.php 92.69% <100%> (+0.1%) 61 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3da7b8e...bbf96e9. Read the comment docs.

* Exclude directories from the integrity checker command
*/
'excludedFiles' =>
array (
Copy link
Contributor

Choose a reason for hiding this comment

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

Description text: Exclude directories --> Exclude files

Copy link
Contributor

Choose a reason for hiding this comment

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

Also see my comment above to avoid confusion:
This variable should be renamed from excludedFiles to integrityExcludedFiles

@sharidas sharidas force-pushed the exclude-files-and-folders branch 2 times, most recently from 365aff4 to ba236b6 Compare November 6, 2017 05:03
@sharidas sharidas changed the title Move excluded files/folders to config array Move excluded files to config array Nov 6, 2017
@sharidas
Copy link
Contributor Author

sharidas commented Nov 6, 2017

Not sure how to make codecov happy for config.sample.php. Any pointers would be helpful. Thanks.

*/
'integrityExcludedFiles' =>
array (
0 => '.DS_Store',
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for the numeric index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the config.sample.php by removing numeric index.

@sharidas
Copy link
Contributor Author

sharidas commented Nov 6, 2017

Backport PR to stable10 branch: #29460

@@ -1210,6 +1210,25 @@
'~snapshot',
),
/**
* Exclude directories from the integrity checker command
*/
'integrityExcludedFiles' =>
Copy link
Contributor

Choose a reason for hiding this comment

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

why camel case ? all of the other config entries are either dot separated, underscore separated or have no separator for all-lowercase. The latest trend is to use dots as separators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to integrity.excluded.files

@PVince81
Copy link
Contributor

PVince81 commented Nov 6, 2017

@Peter-Prochaska second review ?

@@ -230,7 +230,7 @@ private function generateHashes(\RecursiveIteratorIterator $iterator,
* @param array $hashes
* @param X509 $certificate
* @param RSA $privateKey
* @return string
* @return mixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Why mixed? it's an array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Peter-Prochaska Updated the PR.

Moving excluded files to config array.
Instead of populating in the ExcludeFile*
php files, we can have it in config.php.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
@PVince81 PVince81 merged commit 94e2727 into master Nov 8, 2017
@PVince81 PVince81 deleted the exclude-files-and-folders branch November 8, 2017 08:42
@@ -1210,6 +1210,18 @@
'~snapshot',
),
/**
* Exclude directories from the integrity checker command
*/
'integrity.excluded.files' =>
Copy link
Contributor

Choose a reason for hiding this comment

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

@PVince81 we still have the description text mismatch stating that we exclude directories while we exclude files ...
This inconsistancy needs to be fixed and backported

Copy link
Contributor

Choose a reason for hiding this comment

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

@PVince81 just seen that is has been fixed ...

@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants