Bug #82060
closed
File Abstraction Layer: Extract metadata in storage (scheduler) failing on indexing files that matches denied patterns(['BE']['fileDenyPattern'])
Added by Ricky Mathew over 7 years ago.
Updated about 6 years ago.
Description
File Abstraction Layer: Extract metadata in storage (scheduler) fails on trying to index the files in denied pattern(['BE']['fileDenyPattern']) by throwing an exception like following::
_TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsExceptionprototypeobject
message => 'You are not allowed to access that file: "browserdetect.inc.php"' (64 chars)
code => 1375955429 (integer)_
And my ['BE']['fileDenyPattern'] is "\.(php[3-7]?|phpsh|phtml)(\..*)?$|^\.htaccess$"
We can avoid this by just adding a condition check in runMetaDataExtraction() function in TYPO3\CMS\Core\Resource\Index\Indexer class as follows
$isAllowed = GeneralUtility::verifyFilenameAgainstDenyPattern($indexRecord['name']);
if($isAllowed){
$fileObject = $this->getResourceFactory()->getFileObject($indexRecord['uid'], $indexRecord);
$this->extractMetaData($fileObject);
}
so can any one please provide a patch with above mentioned solution?
Files
- Complexity changed from hard to easy
The logic is , we need to run the extractMetaData() function only if the file is of allowable type and that is what the condition check will do.
- Category set to scheduler
- Target version set to Candidate for patchlevel
Attaching the patch file here.
--- Indexer_orig.php 2017-08-09 16:02:52.912607837 +0530
+++ Indexer.php 2017-08-09 16:10:08.404625955 +0530
@@ -106,8 +106,12 @@
{
$fileIndexRecords = $this->getFileIndexRepository()->findInStorageWithIndexOutstanding($this->storage, $maximumFileCount);
foreach ($fileIndexRecords as $indexRecord) {
+ $isAllowed = GeneralUtility::verifyFilenameAgainstDenyPattern($indexRecord['name']);
+ if ($isAllowed) {
$fileObject = $this->getResourceFactory()->getFileObject($indexRecord['uid'], $indexRecord);
$this->extractMetaData($fileObject);
+ }
}
}
- Assignee set to Ricky Mathew
As my membership in core project is still pending, can anyone please take this task and apply this patch?
btw maybe is't easier to just catch the InsufficientFileAccessPermissionsException. So add a
try {
...
} catch(InsufficientFileAccessPermissionsException $e) {}
arround the call
Frans Saris wrote:
btw maybe is't easier to just catch the InsufficientFileAccessPermissionsException. So add a
[...]
arround the call
But that will throw the exception and stops the scheduler execution..But we just need to skip the denied files. that's all
No it does mainly the same as your solution
$fileIndexRecords = $this->getFileIndexRepository()->findInStorageWithIndexOutstanding($this->storage, $maximumFileCount);
foreach ($fileIndexRecords as $indexRecord) {
try {
$fileObject = $this->getResourceFactory()->getFileObject($indexRecord['uid'], $indexRecord);
$this->extractMetaData($fileObject);
} catch(InsufficientFileAccessPermissionsException $e) {}
}
It will still loop thought all items
Frans Saris wrote:
No it does mainly the same as your solution
[...]
It will still loop thought all items
Okay.Let me check whether it works for me.
- Status changed from New to Under Review
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Under Review
- Status changed from Under Review to Resolved
- Status changed from Resolved to Closed
Also available in: Atom
PDF