function FileSecurity::htaccessPreventExecution

Same name in this branch
  1. 9 core/lib/Drupal/Component/FileSecurity/FileSecurity.php \Drupal\Component\FileSecurity\FileSecurity::htaccessPreventExecution()
Same name in other branches
  1. 8.9.x composer/Plugin/VendorHardening/FileSecurity.php \Drupal\Composer\Plugin\VendorHardening\FileSecurity::htaccessPreventExecution()
  2. 8.9.x core/lib/Drupal/Component/FileSecurity/FileSecurity.php \Drupal\Component\FileSecurity\FileSecurity::htaccessPreventExecution()
  3. 10 composer/Plugin/VendorHardening/FileSecurity.php \Drupal\Composer\Plugin\VendorHardening\FileSecurity::htaccessPreventExecution()
  4. 10 core/lib/Drupal/Component/FileSecurity/FileSecurity.php \Drupal\Component\FileSecurity\FileSecurity::htaccessPreventExecution()
  5. 11.x composer/Plugin/VendorHardening/FileSecurity.php \Drupal\Composer\Plugin\VendorHardening\FileSecurity::htaccessPreventExecution()
  6. 11.x core/lib/Drupal/Component/FileSecurity/FileSecurity.php \Drupal\Component\FileSecurity\FileSecurity::htaccessPreventExecution()

Returns htaccess directives to deny execution in a given directory.

Return value

string Apache htaccess directives to prevent execution of files in a location.

1 call to FileSecurity::htaccessPreventExecution()
FileSecurity::htaccessLines in composer/Plugin/VendorHardening/FileSecurity.php
Returns the standard .htaccess lines that Drupal writes.

File

composer/Plugin/VendorHardening/FileSecurity.php, line 64

Class

FileSecurity
Provides file security functions.

Namespace

Drupal\Composer\Plugin\VendorHardening

Code

protected static function htaccessPreventExecution() {
    return <<<EOF
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php7.c>
  php_flag engine off
</IfModule>
<IfModule mod_php.c>
  php_flag engine off
</IfModule>
EOF;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.