File tree Expand file tree Collapse file tree
crates/locality-connector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -861,22 +861,42 @@ fn is_sensitive_setting_key(key: &str) -> bool {
861861 } ) {
862862 return true ;
863863 }
864- if segments
865- . windows ( 2 )
866- . any ( |pair| matches ! ( pair, [ "api" | "private" , "key" ] ) )
867- {
864+ if segments. windows ( 2 ) . any ( |pair| {
865+ matches ! (
866+ pair,
867+ [ "api" , "key" ]
868+ | [ "private" , "key" ]
869+ | [ "access" , "token" ]
870+ | [ "client" , "secret" ]
871+ | [ "bearer" , "token" ]
872+ )
873+ } ) {
868874 return true ;
869875 }
870876
871- let compact = segments. concat ( ) ;
872- compact. ends_with ( "token" )
873- || compact. ends_with ( "secret" )
874- || compact. ends_with ( "password" )
875- || compact. ends_with ( "credential" )
876- || compact. ends_with ( "credentials" )
877- || compact. ends_with ( "authorization" )
878- || compact. starts_with ( "bearer" )
879- || [ "apikey" , "privatekey" , "secretkey" ]
880- . iter ( )
881- . any ( |marker| compact. contains ( marker) )
877+ let [ compact] = segments. as_slice ( ) else {
878+ return false ;
879+ } ;
880+ const SENSITIVE_COMPOUNDS : & [ & str ] = & [
881+ "apikey" ,
882+ "privatekey" ,
883+ "accesstoken" ,
884+ "clientsecret" ,
885+ "bearertoken" ,
886+ ] ;
887+ const METADATA_SUFFIXES : & [ & str ] = & [
888+ "value" ,
889+ "id" ,
890+ "ref" ,
891+ "reference" ,
892+ "handle" ,
893+ "path" ,
894+ "file" ,
895+ "name" ,
896+ ] ;
897+ SENSITIVE_COMPOUNDS . iter ( ) . any ( |compound| {
898+ compact
899+ . strip_prefix ( compound)
900+ . is_some_and ( |suffix| suffix. is_empty ( ) || METADATA_SUFFIXES . contains ( & suffix) )
901+ } )
882902}
Original file line number Diff line number Diff line change @@ -180,20 +180,18 @@ fn sensitive_setting_keys_are_rejected_across_common_naming_styles() {
180180 "authorizationHeader" ,
181181 "credentials" ,
182182 "apikey" ,
183- "serviceapikey" ,
184183 "PRIVATEKEY" ,
185- "privatekeypem" ,
186184 "accesstoken" ,
187- "RefreshTOKEN" ,
188- "sessiontoken" ,
189185 "clientsecret" ,
190- "SIGNINGSECRET" ,
191- "databasepassword" ,
192- "servicecredential" ,
193- "customauthorization" ,
194- "bearerheader" ,
195- "BEARERCREDENTIAL" ,
196- "secretkey" ,
186+ "bearertoken" ,
187+ "accesstokenvalue" ,
188+ "ACCESSTOKENVALUE" ,
189+ "apikeyid" ,
190+ "privatekeypath" ,
191+ "clientsecrethandle" ,
192+ "bearertokenreference" ,
193+ "access_token_value" ,
194+ "AccessTokenValue" ,
197195 ] {
198196 let mut invalid = registry_value ( ) ;
199197 invalid[ "connectors" ] [ 0 ] [ "mount" ] [ "default_settings" ] = json ! ( { key: "sentinel" } ) ;
@@ -218,6 +216,16 @@ fn sensitive_setting_keys_are_rejected_across_common_naming_styles() {
218216 "accessibility" ,
219217 "private_mode" ,
220218 "api_latency" ,
219+ "api_keyboard_layout" ,
220+ "private_keynote" ,
221+ "privatekeynote" ,
222+ "PrivateKeynote" ,
223+ "apikeyboard" ,
224+ "accesstokenizer" ,
225+ "clientsecretary" ,
226+ "serviceapikey" ,
227+ "sessiontoken" ,
228+ "databasepassword" ,
221229 ] {
222230 let mut valid = registry_value ( ) ;
223231 valid[ "connectors" ] [ 0 ] [ "mount" ] [ "default_settings" ] = json ! ( { key: true } ) ;
You can’t perform that action at this time.
0 commit comments