Skip to content

Commit

Permalink
Fix for critical security error related to file include
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Jun 13, 2024
1 parent 564bfd4 commit 1bfb337
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions Classes/Controller/Backend/NewTenantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function initializeAction(): void
public function addFormatAction(): void
{
// Include formats definition file.
$formatsDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/FormatDefaults.php');
$formatsDefaults = $this->getRecords('Format');;

Check notice on line 182 in Classes/Controller/Backend/NewTenantController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Classes/Controller/Backend/NewTenantController.php#L182

Each PHP statement must be on a line by itself

$frameworkConfiguration = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK);
// tx_dlf_formats are stored on PID = 0
Expand Down Expand Up @@ -221,7 +221,7 @@ public function addFormatAction(): void
public function addMetadataAction(): void
{
// Include metadata definition file.
$metadataDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php');
$metadataDefaults = $this->getRecords('Metadata');;

Check notice on line 224 in Classes/Controller/Backend/NewTenantController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Classes/Controller/Backend/NewTenantController.php#L224

Each PHP statement must be on a line by itself

// load language file in own array
$metadataLabels = $this->languageFactory->getParsedData('EXT:dlf/Resources/Private/Language/locallang_metadata.xlf', $this->siteLanguages[0]->getTypo3Language());
Expand Down Expand Up @@ -344,7 +344,7 @@ public function addSolrCoreAction(): void
public function addStructureAction(): void
{
// Include structure definition file.
$structureDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php');
$structureDefaults = $this->getRecords('Structure');

// load language file in own array
$structureLabels = $this->languageFactory->getParsedData('EXT:dlf/Resources/Private/Language/locallang_structure.xlf', $this->siteLanguages[0]->getTypo3Language());
Expand Down Expand Up @@ -459,15 +459,15 @@ public function errorAction(): void
/**
* Get language label for given key and language.
*
* @access protected
* @access private
*
* @param string $index
* @param string $lang
* @param array $langArray
*
* @return string
*/
protected function getLLL(string $index, string $lang, array $langArray): string
private function getLLL(string $index, string $lang, array $langArray): string
{
if (isset($langArray[$lang][$index][0]['target'])) {
return $langArray[$lang][$index][0]['target'];
Expand All @@ -477,4 +477,25 @@ protected function getLLL(string $index, string $lang, array $langArray): string
return 'Missing translation for ' . $index;
}
}

/**
* Get records from file for given record type.
*
* @access private
*
* @param string $recordType
*
* @return array
*/
private function getRecords(string $recordType): array
{
$filePath = GeneralUtility::getFileAbsFileName(
ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/' . $recordType . 'Defaults.php'
);

if ($filePath) {
return include $filePath;

Check failure on line 497 in Classes/Controller/Backend/NewTenantController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Classes/Controller/Backend/NewTenantController.php#L497

"include" statement detected. File manipulations are discouraged. Variables inside are insecure.

Check warning on line 497 in Classes/Controller/Backend/NewTenantController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Classes/Controller/Backend/NewTenantController.php#L497

"include" statement detected. File manipulations are discouraged. Variables inside are insecure.
}
return [];
}
}

0 comments on commit 1bfb337

Please sign in to comment.