From 0a29f295a8ee4b58b4067e9d4ff55d0e2a22b3c1 Mon Sep 17 00:00:00 2001 From: 4t145 Date: Wed, 15 Jan 2025 11:14:52 +0800 Subject: [PATCH 1/2] update default skip methods --- backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs | 2 +- backend/gateways/spacegate-plugins/src/plugin/content_filter.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs index a5b4f03b..f793b266 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs @@ -35,7 +35,7 @@ impl Default for AntiReplayPlugin { Self { cache_key: "sg:plugin:anti_replay".into(), time: 5000, - skip_methods: vec!["header".to_owned()], + skip_methods: vec!["HEADER".to_owned(), "GET".to_owned(), "CONNECT".to_owned(), "TRACE".to_owned(), "OPTIONS".to_owned()], skip_paths: Vec::new(), } } diff --git a/backend/gateways/spacegate-plugins/src/plugin/content_filter.rs b/backend/gateways/spacegate-plugins/src/plugin/content_filter.rs index 3565445e..6ac82c36 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/content_filter.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/content_filter.rs @@ -95,9 +95,9 @@ impl Default for ContentFilterConfig { Method::GET.to_string(), Method::HEAD.to_string(), Method::DELETE.to_string(), - Method::HEAD.to_string(), Method::TRACE.to_string(), Method::CONNECT.to_string(), + Method::OPTIONS.to_string(), ], } } From ccaff3e033341cbf7a1bb402460af207e1e13041 Mon Sep 17 00:00:00 2001 From: 4t145 Date: Wed, 15 Jan 2025 11:19:35 +0800 Subject: [PATCH 2/2] use standard method name --- .../spacegate-plugins/src/plugin/anti_replay.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs index f793b266..cc5241ca 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs @@ -2,19 +2,17 @@ use std::hash::DefaultHasher; use std::sync::Arc; use std::time::Duration; +use http::Method; use serde::{Deserialize, Serialize}; use spacegate_shell::ext_redis::{redis::AsyncCommands, RedisClient}; use spacegate_shell::hyper::{Request, Response, StatusCode}; use spacegate_shell::kernel::extension::{IsEastWestTraffic, PeerAddr}; use spacegate_shell::kernel::helper_layers::function::Inner; -use spacegate_shell::plugin::{ - plugins::east_west_traffic_white_list::{EastWestTrafficWhiteListConfig, EastWestTrafficWhiteListPlugin}, - schemars, Plugin, PluginError, PluginSchemaExt, -}; +use spacegate_shell::plugin::{schemars, Plugin, PluginSchemaExt}; use spacegate_shell::{BoxError, BoxResult, SgBody, SgRequest, SgRequestExt, SgResponseExt}; use tardis::serde_json; -use tardis::{basic::result::TardisResult, tokio}; +use tardis::tokio; use crate::extension::notification::AntiReplayReport; @@ -35,7 +33,13 @@ impl Default for AntiReplayPlugin { Self { cache_key: "sg:plugin:anti_replay".into(), time: 5000, - skip_methods: vec!["HEADER".to_owned(), "GET".to_owned(), "CONNECT".to_owned(), "TRACE".to_owned(), "OPTIONS".to_owned()], + skip_methods: vec![ + Method::GET.to_string(), + Method::HEAD.to_string(), + Method::TRACE.to_string(), + Method::CONNECT.to_string(), + Method::OPTIONS.to_string(), + ], skip_paths: Vec::new(), } }