|
26 | 26 | ///////////////////////////////////////////////////////////////
|
27 | 27 | CDebugHookManager::CDebugHookManager( void )
|
28 | 28 | {
|
| 29 | +#ifndef MTA_CLIENT |
| 30 | + m_MaskArgumentsMap["dbConnect"] = { 1, 2, 3 }; // type, 1=HOST, 2=USERNAME, 3=PASSWORD, options |
| 31 | + m_MaskArgumentsMap["logIn"] = { 2 }; // player, account, 2=PASSWORD |
| 32 | + m_MaskArgumentsMap["addAccount"] = { 1 }; // name, 1=PASSWORD |
| 33 | + m_MaskArgumentsMap["getAccount"] = { 1 }; // name, 1=PASSWORD |
| 34 | + m_MaskArgumentsMap["setAccountPassword"] = { 1 }; // account, 1=PASSWORD |
| 35 | +#endif |
29 | 36 | }
|
30 | 37 |
|
31 | 38 |
|
@@ -219,6 +226,7 @@ bool CDebugHookManager::OnPreFunction( lua_CFunction f, lua_State* luaVM, bool b
|
219 | 226 |
|
220 | 227 | CLuaArguments FunctionArguments;
|
221 | 228 | FunctionArguments.ReadArguments( luaVM );
|
| 229 | + MaybeMaskArgumentValues( strName, FunctionArguments ); |
222 | 230 | NewArguments.PushArguments( FunctionArguments );
|
223 | 231 |
|
224 | 232 | return CallHook( strName, m_PreFunctionHookList, NewArguments, bNameMustBeExplicitlyAllowed );
|
@@ -271,6 +279,7 @@ void CDebugHookManager::OnPostFunction( lua_CFunction f, lua_State* luaVM )
|
271 | 279 |
|
272 | 280 | CLuaArguments FunctionArguments;
|
273 | 281 | FunctionArguments.ReadArguments( luaVM );
|
| 282 | + MaybeMaskArgumentValues( strName, FunctionArguments ); |
274 | 283 | NewArguments.PushArguments( FunctionArguments );
|
275 | 284 |
|
276 | 285 | CallHook( strName, m_PostFunctionHookList, NewArguments, bNameMustBeExplicitlyAllowed );
|
@@ -398,6 +407,28 @@ bool CDebugHookManager::MustNameBeExplicitlyAllowed( const SString& strName )
|
398 | 407 | }
|
399 | 408 |
|
400 | 409 |
|
| 410 | +/////////////////////////////////////////////////////////////// |
| 411 | +// |
| 412 | +// CDebugHookManager::MaybeMaskArgumentValues |
| 413 | +// |
| 414 | +// Mask security sensitive argument values |
| 415 | +// |
| 416 | +/////////////////////////////////////////////////////////////// |
| 417 | +void CDebugHookManager::MaybeMaskArgumentValues( const SString& strFunctionName, CLuaArguments& FunctionArguments ) |
| 418 | +{ |
| 419 | + auto* pArgIndexList = MapFind( m_MaskArgumentsMap, strFunctionName ); |
| 420 | + if ( pArgIndexList ) |
| 421 | + { |
| 422 | + for ( uint uiIndex : *pArgIndexList ) |
| 423 | + { |
| 424 | + CLuaArgument* pArgument = FunctionArguments[uiIndex]; |
| 425 | + if ( pArgument ) |
| 426 | + pArgument->ReadString( "***" ); |
| 427 | + } |
| 428 | + } |
| 429 | +} |
| 430 | + |
| 431 | + |
401 | 432 | ///////////////////////////////////////////////////////////////
|
402 | 433 | //
|
403 | 434 | // CDebugHookManager::CallHook
|
|
0 commit comments