[0.6.8] - 2025-10-03
Some checks failed
Deploy quoter Microservice on push / deploy (push) Failing after 37m50s
Some checks failed
Deploy quoter Microservice on push / deploy (push) Failing after 37m50s
### 🔒 Security: Early Scan Rejection - **⚡ Ранний reject**: Проверка suspicious patterns ДО вызова proxy_handler (минимум логов) - **🎯 Расширенные паттерны**: Добавлены `wp-includes`, `wlwmanifest` (без слешей для любых подпапок) - **📦 CMS защита**: Joomla, Drupal, Magento paths в blacklist - **🔕 Zero-log policy**: Silent 404 для всех сканов - нулевое логирование ### Changed - **security.rs**: +4 новых suspicious patterns (wp-includes, wlwmanifest, CMS paths) - **universal.rs**: Двойная проверка - ранний reject в handle_get ДО proxy - **auth.rs**: - Added `Clone` derive для `TokenClaims` (требование jsonwebtoken v10) - **Tests**: ✅ Все тесты проходят (3/3 passed)
This commit is contained in:
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::{error::Error, time::Duration};
|
||||
|
||||
// Структуры для JWT токенов
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct TokenClaims {
|
||||
user_id: String,
|
||||
username: Option<String>,
|
||||
@@ -30,7 +30,7 @@ pub struct Author {
|
||||
fn decode_jwt_token(token: &str) -> Result<TokenClaims, Box<dyn Error>> {
|
||||
// NOTE: Используем JWT_SECRET_KEY для совместимости с @core и другими сервисами
|
||||
let secret = std::env::var("JWT_SECRET_KEY")
|
||||
.or_else(|_| std::env::var("JWT_SECRET_KEY"))
|
||||
.or_else(|_| std::env::var("JWT_SECRET"))
|
||||
.unwrap_or_else(|_| "your-secret-key".to_string());
|
||||
let key = DecodingKey::from_secret(secret.as_ref());
|
||||
|
||||
|
||||
@@ -59,6 +59,13 @@ async fn handle_get(
|
||||
crate::handlers::user::get_current_user_handler(req, state).await
|
||||
}
|
||||
_ => {
|
||||
// 🔒 Ранняя проверка на сканы ДО вызова proxy (минимизируем логи)
|
||||
let security_config = SecurityConfig::default();
|
||||
if security_config.check_suspicious_patterns(path) {
|
||||
// Silent 404 для сканов - без логирования
|
||||
return Ok(HttpResponse::NotFound().finish());
|
||||
}
|
||||
|
||||
// GET /{path} - получение файла через proxy
|
||||
let path_without_slash = path.trim_start_matches('/');
|
||||
let requested_res = web::Path::from(path_without_slash.to_string());
|
||||
|
||||
@@ -108,6 +108,8 @@ impl SecurityConfig {
|
||||
"/wlwmanifest.xml",
|
||||
"/wp-json/",
|
||||
"/wordpress/",
|
||||
"wp-includes", // Добавлено для любых подпапок
|
||||
"wlwmanifest", // Добавлено без слеша
|
||||
// Admin panels
|
||||
"/admin",
|
||||
"/phpmyadmin",
|
||||
@@ -128,6 +130,11 @@ impl SecurityConfig {
|
||||
"javascript:",
|
||||
"data:",
|
||||
"eval(",
|
||||
// Common CMS paths
|
||||
"/joomla",
|
||||
"/drupal",
|
||||
"/magento",
|
||||
"/.well-known/security.txt",
|
||||
];
|
||||
|
||||
let path_lower = path.to_lowercase();
|
||||
|
||||
Reference in New Issue
Block a user