mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-11-04 09:56:28 +00:00 
			
		
		
		
	made changes to ensure its not allowing everything through
This commit is contained in:
		@@ -27,15 +27,24 @@ macro_rules! make_setting_routes {
 | 
			
		||||
    ($({route: $route:literal, update_verb: $update_verb:ident, value_type: $type:ty, err_type: $err_ty:ty, attr: $attr:ident, camelcase_attr: $camelcase_attr:literal, analytics: $analytics:ident},)*) => {
 | 
			
		||||
        #[allow(dead_code)]
 | 
			
		||||
        const _: () = {
 | 
			
		||||
            #[allow(dead_code)]
 | 
			
		||||
            // First, verify that all fields in Settings are listed in the macro
 | 
			
		||||
            const fn __verify_settings_exist() {
 | 
			
		||||
                let _: fn() = || {
 | 
			
		||||
                    let meilisearch_types::settings::Settings { $($attr: _,)* .. }:
 | 
			
		||||
                        meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>;
 | 
			
		||||
                // This pattern match will fail at compile time if any field is missing from the macro
 | 
			
		||||
                // or if a field exists in the macro but not in Settings
 | 
			
		||||
                let _: fn(meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>) = |s| {
 | 
			
		||||
                    match s {
 | 
			
		||||
                        meilisearch_types::settings::Settings {
 | 
			
		||||
                            $($attr: _,)*
 | 
			
		||||
                            _kind: _,
 | 
			
		||||
                        } => {}
 | 
			
		||||
                    }
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                // if any field is missing or has the wrong type
 | 
			
		||||
                let _: fn(meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>) = |_| {};
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        $(
 | 
			
		||||
            make_setting_route!($route, $update_verb, $type, $err_ty, $attr, $camelcase_attr, $analytics);
 | 
			
		||||
        )*
 | 
			
		||||
@@ -56,7 +65,7 @@ macro_rules! make_setting_routes {
 | 
			
		||||
 | 
			
		||||
#[macro_export]
 | 
			
		||||
macro_rules! make_setting_route {
 | 
			
		||||
    ($route:literal, $update_verb:ident, $type:ty, $err_ty:ty, $attr:ident, $camelcase_attr:literal, $analytics:ident) => {
 | 
			
		||||
    ($route:literal, $update_verb:ident, $type:ty, $err_type:ty, $attr:ident, $camelcase_attr:literal, $analytics:ident) => {
 | 
			
		||||
        pub mod $attr {
 | 
			
		||||
            use actix_web::web::Data;
 | 
			
		||||
            use actix_web::{web, HttpRequest, HttpResponse, Resource};
 | 
			
		||||
@@ -113,7 +122,7 @@ macro_rules! make_setting_route {
 | 
			
		||||
                    Data<IndexScheduler>,
 | 
			
		||||
                >,
 | 
			
		||||
                index_uid: actix_web::web::Path<String>,
 | 
			
		||||
                body: deserr::actix_web::AwebJson<Option<$type>, $err_ty>,
 | 
			
		||||
                body: deserr::actix_web::AwebJson<Option<$type>, $err_type>,
 | 
			
		||||
                req: HttpRequest,
 | 
			
		||||
                opt: web::Data<Opt>,
 | 
			
		||||
                analytics: web::Data<Analytics>,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user