Your project uses non-strict array lookups 10

More information: https://insight.symfony.com/what-we-analyse/php.strict_array_lookup

  1. foreach ($dir_content as $key => $content) {
  2. $path = $root_dir . DIRECTORY_SEPARATOR . $content;
  3. if (is_file($path) && is_readable($path)) {
  4. // skip ignored files
  5. if (!\in_array($content, $ignore_files)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. if (preg_match($ignore_regex, $content) == 0) {
  7. $content_chunks = explode(".", $content);
  8. $ext = $content_chunks[\count($content_chunks) - 1];
  9. // only include files with desired extensions
  10. if (\in_array($ext, $allow_extensions)) {
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. }
  2. }
  3. } // if content is a directory and readable, add path and name
  4. elseif (is_dir($path) && is_readable($path)) {
  5. // skip any ignored dirs
  6. if (!\in_array($content, $ignore_dirs)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  7. // recursive callback to open new directory
  8. $all_data = get_files($path, $all_data);
  9. }
  10. }
  11. } // end foreach
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. if (!\in_array($content, $ignore_files)) {
  2. if (preg_match($ignore_regex, $content) == 0) {
  3. $content_chunks = explode(".", $content);
  4. $ext = $content_chunks[\count($content_chunks) - 1];
  5. // only include files with desired extensions
  6. if (\in_array($ext, $allow_extensions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  7. // save file name with path
  8. $all_data[] = $path;
  9. }
  10. }
  11. }
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. $file_array = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($template_directory));
  2. foreach ($file_array as $filename => $current) {
  3. $fileInfo = pathinfo($current->getFileName());
  4. if (array_key_exists('extension', $fileInfo) && in_array($fileInfo['extension'], $fileTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $found[] = $current->getFileName();
  6. }
  7. }
  8. if ($found) { // Check the $found array is not empty
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. }
  2. // Optional: Whitelist specific domains (e.g., GitHub)
  3. // Uncomment and modify as needed:
  4. $allowed_domains = ['github.com', 'api.github.com'];
  5. if (!in_array($parsed_url['host'] ?? '', $allowed_domains)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $this->messageStack->add('Download from unauthorized domain', 'error');
  7. CLICSHOPPING::redirect('Upgrade&Marketplace');
  8. return null;
  9. }
  1. $file_array = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory_selected));
  2. foreach ($file_array as $filename => $current) {
  3. $fileInfo = pathinfo($current->getFileName());
  4. if (array_key_exists('extension', $fileInfo) && in_array($fileInfo['extension'], $fileTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $found[] = $current->getFileName();
  6. }
  7. }
  8. if ($found) { // Check the $found array is not empty
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. $flags['session_id'] = false;
  2. }
  3. // Security: Validate method against whitelist
  4. $allowed_methods = ['post', 'get'];
  5. $safe_method = in_array(strtolower($method ?? 'post'), $allowed_methods) ? strtolower($method ?? 'post') : 'post';
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. // Security: Sanitize form action URL
  7. $safe_action = static::sanitizeUrl($action);
  8. $form = '<form name="' . static::outputProtected($name) . '" action="' . $safe_action . '" method="' . $safe_method . '"';
  1. // Extract statement type
  2. $stmt_type = strtoupper(trim(explode(' ', $sql)[0]));
  3. // Whitelist allowed SQL types
  4. if (!in_array($stmt_type, $allowed_statements)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $CLICSHOPPING_MessageStack->add('Restore skipped: unsupported SQL statement type (' . $stmt_type . ')', 'warning');
  6. continue;
  7. }
  8. // Validate DROP TABLE statements to prevent SQL injection
  1. /* if empty error is produced : Fatal error: Uncaught exception 'RuntimeException'*/
  2. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($template_directory)) as $filename => $current) {
  3. $fileInfo = pathinfo($current->getFileName());
  4. if (array_key_exists('extension', $fileInfo) && \in_array($fileInfo['extension'], $fileTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $found[] = $current->getFileName();
  6. }
  7. }
  8. if ($found) { // Check the $found array is not empty
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented
  1. $file_array = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($filename_selected));
  2. foreach ($file_array as $filename => $current) {
  3. $fileInfo = pathinfo($current->getFileName());
  4. if (array_key_exists('extension', $fileInfo) && in_array($fileInfo['extension'], $fileTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $found[] = $current->getFileName();
  6. }
  7. }
  8. if ($found) { // Check the $found array is not empty
  • gyakutsuki

    not implemented
  • gyakutsuki

    not included
  • gyakutsuki

    no included
  • gyakutsuki

    no implemented

Your project should use dedicated PHP string functions 7

More information: https://insight.symfony.com/what-we-analyse/php.use_string_function

  1. $baseDir = CLICSHOPPING::getConfig('dir_root', 'Shop') . $CLICSHOPPING_Template->getDynamicTemplateDirectory() . '/files/';
  2. $filePath = realpath($baseDir . $filename_selected);
  3. // Sécuriser le chemin pour éviter directory traversal
  4. if ($filePath === false || strpos($filePath, realpath($baseDir)) !== 0) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_EditDesign->getDef('error_file_does_not_exist'), 'error');
  6. $CLICSHOPPING_EditDesign->redirect('EditModuleContent&action=directory&directory_html=' . $directory_selected);
  7. return false;
  8. }
  • gyakutsuki

    not included
  1. $basePathFallback = CLICSHOPPING::getConfig('dir_root', 'Shop') . $CLICSHOPPING_Template->getDynamicTemplateDirectory() . "/css/english/{$directory_selected}/";
  2. $filePath = realpath($basePathLang . $filename_selected);
  3. if ($filePath === false || strpos($filePath, realpath($basePathLang)) !== 0 || !is_file($filePath)) {
  4. $filePath = realpath($basePathFallback . $filename_selected);
  5. if ($filePath === false || strpos($filePath, realpath($basePathFallback)) !== 0 || !is_file($filePath)) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_EditDesign->getDef('error_file_does_not_exist'), 'error');
  7. $CLICSHOPPING_EditDesign->redirect('EditCss&action=directory&directory_css=' . $directory_selected);
  8. return false;
  9. }
  10. }
  • gyakutsuki

    not included
  1. $lang_dir = $CLICSHOPPING_Language->get('directory');
  2. $basePathLang = CLICSHOPPING::getConfig('dir_root', 'Shop') . $CLICSHOPPING_Template->getDynamicTemplateDirectory() . "/css/{$lang_dir}/{$directory_selected}/";
  3. $basePathFallback = CLICSHOPPING::getConfig('dir_root', 'Shop') . $CLICSHOPPING_Template->getDynamicTemplateDirectory() . "/css/english/{$directory_selected}/";
  4. $filePath = realpath($basePathLang . $filename_selected);
  5. if ($filePath === false || strpos($filePath, realpath($basePathLang)) !== 0 || !is_file($filePath)) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. $filePath = realpath($basePathFallback . $filename_selected);
  7. if ($filePath === false || strpos($filePath, realpath($basePathFallback)) !== 0 || !is_file($filePath)) {
  8. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_EditDesign->getDef('error_file_does_not_exist'), 'error');
  9. $CLICSHOPPING_EditDesign->redirect('EditCss&action=directory&directory_css=' . $directory_selected);
  10. return false;
  • gyakutsuki

    not included
  1. $CLICSHOPPING_templateCss->logSecurityError("CSS file not accessible", $cssFile);
  2. continue;
  3. }
  4. // Directory Traversal protection: ensure the file is within the allowed root directory
  5. if (strpos($real_path, $root_dir . DIRECTORY_SEPARATOR) !== 0) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $CLICSHOPPING_templateCss->logSecurityError("CSS file outside allowed directory", $cssFile);
  7. continue;
  8. }
  9. // Check individual file size
  • gyakutsuki

    not included
  1. $this->logSecurityError("Invalid path detected", $path);
  2. continue;
  3. }
  4. // Ensure the resolved path is still within the root directory
  5. if (strpos($real_path, $root_dir) !== 0) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $this->logSecurityError("Path traversal attempt detected", $real_path);
  7. continue;
  8. }
  9. if (is_file($real_path) && is_readable($real_path)) {
  • gyakutsuki

    not included
  1. $basePath = CLICSHOPPING::getConfig('dir_root', 'Shop') . $CLICSHOPPING_Template->getDynamicTemplateDirectory() . '/modules/' . $directory_selected . '/content/';
  2. $filePath = realpath($basePath . $filename_selected);
  3. // Sécurité chemin
  4. if ($filePath === false || strpos($filePath, realpath($basePath)) !== 0 || !is_file($filePath)) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_EditDesign->getDef('error_file_does_not_exist'), 'error');
  6. $CLICSHOPPING_EditDesign->redirect('EditModuleContent&action=directory&directory_html=' . $directory_selected);
  7. return false;
  8. }
  • gyakutsuki

    not included
  1. . $CLICSHOPPING_Template->getDynamicTemplateDirectory()
  2. . '/modules/' . $directory_selected . '/template_html/';
  3. $filePath = realpath($basePath . $filename_selected);
  4. if ($filePath === false || strpos($filePath, realpath($basePath)) !== 0 || !is_file($filePath)) {
    Consider replacing strpos() with str_starts_with() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_EditDesign->getDef('error_file_does_not_exist'), 'error');
  6. $CLICSHOPPING_EditDesign->redirect('EditListing&action=directory&directory_html=' . $directory_selected);
  7. return false;
  8. }
  • gyakutsuki

    not included