v0.25.1
This commit is contained in:
1 parent
87e571c170
commit
fa7abc9e53
308 files changed
+49746
-50237
No files matched your search
@@ -0,0 +1,76 @@
|
||||
use super::{filesystem::path_components, CompiledService};
|
||||
use axum::response::Response;
|
||||
use http::Method;
|
||||
|
||||
pub(super) fn hardening_denied_path(service: &CompiledService, path: &str) -> bool {
|
||||
if !service.hardening.block_common_attacks {
|
||||
return false;
|
||||
}
|
||||
let lower = path.to_ascii_lowercase();
|
||||
if [
|
||||
"/vendor/phpunit/",
|
||||
"/_ignition/execute-solution",
|
||||
"/server-status",
|
||||
"/server-info",
|
||||
"/cgi-bin/",
|
||||
]
|
||||
.iter()
|
||||
.any(|needle| lower.contains(*needle))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
let sensitive_names = [
|
||||
"wp-config.php",
|
||||
"wp-config-sample.php",
|
||||
"configuration.php",
|
||||
"settings.php",
|
||||
"services.yml",
|
||||
"php.ini",
|
||||
"web.config",
|
||||
"composer.json",
|
||||
"composer.lock",
|
||||
"auth.json",
|
||||
"id_rsa",
|
||||
"id_dsa",
|
||||
"id_ed25519",
|
||||
];
|
||||
let backup_suffixes = [
|
||||
".bak", ".backup", ".old", ".orig", ".save", ".swp", ".swo", ".sql",
|
||||
".sqlite", ".sqlite3", ".db",
|
||||
];
|
||||
path_components(path).ok().is_some_and(|components| {
|
||||
components.iter().any(|component| {
|
||||
let component = component.to_ascii_lowercase();
|
||||
(component.starts_with('.') && component != ".well-known")
|
||||
|| component == ".env"
|
||||
|| component.starts_with(".env.")
|
||||
|| sensitive_names.contains(&component.as_str())
|
||||
|| component.ends_with('~')
|
||||
|| backup_suffixes.iter().any(|suffix| component.ends_with(*suffix))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn hardening_denied_method(service: &CompiledService, method: &Method) -> bool {
|
||||
service.hardening.block_common_attacks
|
||||
&& (method == Method::CONNECT || method == Method::TRACE || method.as_str().eq_ignore_ascii_case("TRACK"))
|
||||
}
|
||||
|
||||
pub(super) fn strip_unnecessary_headers(response: &mut Response, service: &CompiledService) {
|
||||
if !service.hardening.strip_unnecessary_headers {
|
||||
return;
|
||||
}
|
||||
for name in [
|
||||
"server",
|
||||
"x-powered-by",
|
||||
"x-aspnet-version",
|
||||
"x-aspnetmvc-version",
|
||||
"x-runtime",
|
||||
"x-generator",
|
||||
"x-drupal-cache",
|
||||
"x-drupal-dynamic-cache",
|
||||
] {
|
||||
response.headers_mut().remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user