소스 검색

Apache protect more non-public folders and files (#6881)

* Apache protect more non-public folders

* Also protect root

* Do the same for /p/

* Simplify Require all denied
In case of Apache 2.2, it will just make an error 500 instead of 403

* .htaccess.dist

* Simplify

* Better comment
Alexandre Alapetite 1 년 전
부모
커밋
91624037c7
17개의 변경된 파일67개의 추가작업 그리고 57개의 파일을 삭제
  1. 1 0
      .devcontainer/.htaccess
  2. 1 0
      .github/.htaccess
  3. 3 2
      .gitignore
  4. 7 0
      .htaccess.dist
  5. 1 0
      Docker/.htaccess
  6. 1 11
      app/.htaccess
  7. 1 11
      cli/.htaccess
  8. 1 11
      cli/prepare.php
  9. 1 11
      data/.htaccess
  10. 1 0
      docs/.htaccess
  11. 1 0
      extensions/.htaccess
  12. 13 0
      extensions/index.html
  13. 1 11
      lib/.htaccess
  14. 13 0
      lib/index.html
  15. 7 0
      p/.htaccess
  16. 1 0
      tests/.htaccess
  17. 13 0
      tests/index.html

+ 1 - 0
.devcontainer/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 1 - 0
.github/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 3 - 2
.gitignore

@@ -1,10 +1,11 @@
+/.htaccess
 /bin/
+/constants.local.php
+/data.back/
 /extensions/node_modules/
 /extensions/vendor/
 /node_modules/
 /vendor/
-/data.back/
-/constants.local.php
 
 .vscode/
 

+ 7 - 0
.htaccess.dist

@@ -0,0 +1,7 @@
+# Copy this file to `.htaccess` for additional root-level protection
+# if you cannot set Apache `DocumentRoot` to `./p/` as recommended.
+
+# Deny files starting with a dot, or without extension, or not in a whitelist of extensions
+<FilesMatch "^\.|^[^.]+$|\.(?!css|gif|html|ico|js|php|png|svg|txt|woff|woff2)[^.]*$">
+	Require all denied
+</FilesMatch>

+ 1 - 0
Docker/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 1 - 11
app/.htaccess

@@ -1,11 +1 @@
-# Apache 2.2
-<IfModule !mod_authz_core.c>
-	Order	Allow,Deny
-	Deny	from all
-	Satisfy	all
-</IfModule>
-
-# Apache 2.4
-<IfModule mod_authz_core.c>
-	Require all denied
-</IfModule>
+Require all denied

+ 1 - 11
cli/.htaccess

@@ -1,11 +1 @@
-# Apache 2.2
-<IfModule !mod_authz_core.c>
-	Order	Allow,Deny
-	Deny	from all
-	Satisfy	all
-</IfModule>
-
-# Apache 2.4
-<IfModule mod_authz_core.c>
-	Require all denied
-</IfModule>
+Require all denied

+ 1 - 11
cli/prepare.php

@@ -25,17 +25,7 @@ foreach ($dirs as $dir) {
 }
 
 file_put_contents(DATA_PATH . '/.htaccess', <<<'EOF'
-# Apache 2.2
-<IfModule !mod_authz_core.c>
-	Order	Allow,Deny
-	Deny	from all
-	Satisfy	all
-</IfModule>
-
-# Apache 2.4
-<IfModule mod_authz_core.c>
-	Require all denied
-</IfModule>
+Require all denied
 
 EOF
 );

+ 1 - 11
data/.htaccess

@@ -1,11 +1 @@
-# Apache 2.2
-<IfModule !mod_authz_core.c>
-	Order	Allow,Deny
-	Deny	from all
-	Satisfy	all
-</IfModule>
-
-# Apache 2.4
-<IfModule mod_authz_core.c>
-	Require all denied
-</IfModule>
+Require all denied

+ 1 - 0
docs/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 1 - 0
extensions/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 13 - 0
extensions/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=/" />
+<title>Redirection</title>
+<meta name="robots" content="noindex" />
+</head>
+
+<body>
+<p><a href="/">Redirection</a></p>
+</body>
+</html>

+ 1 - 11
lib/.htaccess

@@ -1,11 +1 @@
-# Apache 2.2
-<IfModule !mod_authz_core.c>
-	Order	Allow,Deny
-	Deny	from all
-	Satisfy	all
-</IfModule>
-
-# Apache 2.4
-<IfModule mod_authz_core.c>
-	Require all denied
-</IfModule>
+Require all denied

+ 13 - 0
lib/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=/" />
+<title>Redirection</title>
+<meta name="robots" content="noindex" />
+</head>
+
+<body>
+<p><a href="/">Redirection</a></p>
+</body>
+</html>

+ 7 - 0
p/.htaccess

@@ -1,3 +1,10 @@
+<IfModule mod_authz_core.c>
+	# Deny files starting with a dot, or without extension, or not in a whitelist of extensions
+	<FilesMatch "^\.|^[^.]+$|\.(?!css|gif|html|ico|js|php|png|svg|txt|woff|woff2)[^.]*$">
+		Require all denied
+	</FilesMatch>
+</IfModule>
+
 <IfModule mod_dir.c>
 	DirectoryIndex	index.php index.html
 </IfModule>

+ 1 - 0
tests/.htaccess

@@ -0,0 +1 @@
+Require all denied

+ 13 - 0
tests/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=/" />
+<title>Redirection</title>
+<meta name="robots" content="noindex" />
+</head>
+
+<body>
+<p><a href="/">Redirection</a></p>
+</body>
+</html>