You are here

function security_review_check_upload_extensions in Security Review 6

Same name and namespace in other branches
  1. 7 security_review.inc \security_review_check_upload_extensions()

Check for unsafe allowed extensions.

1 call to security_review_check_upload_extensions()
security_review_check_upload_extensions_help in ./security_review.help.inc
1 string reference to 'security_review_check_upload_extensions'
_security_review_security_checks in ./security_review.inc
Checks for security_review_security_checks() or security_review_get_checks().

File

./security_review.inc, line 413
Stand-alone security checks and review system.

Code

function security_review_check_upload_extensions() {
  $result = TRUE;
  $check_result_value = array();
  if (module_exists('upload')) {

    // First, check if any unsafe extensions are even allowed.
    $extensions = variable_get('upload_extensions_default', NULL);
    if (!is_null($extensions)) {
      $unsafe_extensions = security_review_unsafe_extensions();
      foreach ($unsafe_extensions as $unsafe_extension) {
        if (strpos($extensions, $unsafe_extension) !== FALSE) {

          // Found an unsafe extension.
          $check_result_value[] = $unsafe_extension;
        }
      }
    }
    if (!empty($check_result_value)) {
      $result = FALSE;
    }
  }
  else {
    $result = NULL;
  }
  return array(
    'result' => $result,
    'value' => $check_result_value,
  );
}