Skip to content
Permalink
Browse files

Updated debug hook restrictions

  • Loading branch information...
ccw808 committed Jul 31, 2019
1 parent 1f5f07a commit fad4684f46a4cefe91789b7ccf9ac19ce7062281
@@ -449,6 +449,17 @@ void CLuaArguments::DeleteArguments()
m_Arguments.clear();
}

// Gets rid of the last argument in the list
void CLuaArguments::Pop()
{
// Delete the last element
CLuaArgument* item = m_Arguments.back();
delete item;

// Pop it out of the vector
m_Arguments.pop_back();
}

void CLuaArguments::ValidateTableKeys()
{
// Iterate over m_Arguments as pairs
@@ -84,6 +84,7 @@ class CLuaArguments

void DeleteArguments();
void ValidateTableKeys();
void Pop();

bool ReadFromBitStream(NetBitStreamInterface& bitStream, std::vector<CLuaArguments*>* pKnownTables = NULL);
bool ReadFromJSONString(const char* szJSON);
@@ -27,11 +27,25 @@
CDebugHookManager::CDebugHookManager()
{
#ifndef MTA_CLIENT
m_MaskArgumentsMap["dbConnect"] = {1, 2, 3}; // type, 1=HOST, 2=USERNAME, 3=PASSWORD, options
m_MaskArgumentsMap["logIn"] = {2}; // player, account, 2=PASSWORD
m_MaskArgumentsMap["addAccount"] = {1}; // name, 1=PASSWORD
m_MaskArgumentsMap["getAccount"] = {1}; // name, 1=PASSWORD
m_MaskArgumentsMap["setAccountPassword"] = {1}; // account, 1=PASSWORD
m_MaskArgumentsMap = {
{"logIn", {{EArgType::Password, 2}}}, // player, account, 2=PASSWORD
{"addAccount", {{EArgType::Password, 1}}}, // name, 1=PASSWORD
{"getAccount", {{EArgType::Password, 1}}}, // name, 1=PASSWORD
{"setAccountPassword", {{EArgType::Password, 1}}}, // account, 1=PASSWORD
{"fetchRemote", {{EArgType::MaxArgs, 1}, {EArgType::Url, 0}}}, // 0=URL, ...
{"callRemote", {{EArgType::MaxArgs, 1}, {EArgType::Url, 0}}}, // 0=URL, ...
{"dbConnect", {{EArgType::MaxArgs, 0}}},
{"dbExec", {{EArgType::MaxArgs, 0}}},
{"dbFree", {{EArgType::MaxArgs, 0}}},
{"dbPoll", {{EArgType::MaxArgs, 0}}},
{"dbPrepareString", {{EArgType::MaxArgs, 0}}},
{"dbQuery", {{EArgType::MaxArgs, 0}}},
{"executeSQLQuery", {{EArgType::MaxArgs, 0}}},
};

This comment has been minimized.

Copy link
@ArranTuna

ArranTuna Jul 31, 2019

Collaborator

Might want to add passwordHash and passwordVerify argument 1 (password) for both.

#else
m_MaskArgumentsMap = {
{"fetchRemote", {{EArgType::MaxArgs, 1}, {EArgType::Url, 0}}}, // 0=URL, ...
};
#endif
}

@@ -540,14 +554,32 @@ bool CDebugHookManager::MustNameBeExplicitlyAllowed(const SString& strName)
///////////////////////////////////////////////////////////////
void CDebugHookManager::MaybeMaskArgumentValues(const SString& strFunctionName, CLuaArguments& FunctionArguments)
{
auto* pArgIndexList = MapFind(m_MaskArgumentsMap, strFunctionName);
if (pArgIndexList)
auto* pMaskArgumentList = MapFind(m_MaskArgumentsMap, strFunctionName);
if (pMaskArgumentList)
{
for (uint uiIndex : *pArgIndexList)
for (const auto& maskArgument : *pMaskArgumentList)
{
CLuaArgument* pArgument = FunctionArguments[uiIndex];
if (pArgument)
pArgument->ReadString("***");
if (maskArgument.argType == EArgType::Password)
{
CLuaArgument* pArgument = FunctionArguments[maskArgument.index];
if (pArgument && !pArgument->GetString().empty())
pArgument->ReadString("***");
}
else if (maskArgument.argType == EArgType::Url)
{
CLuaArgument* pArgument = FunctionArguments[maskArgument.index];
if (pArgument)
{
// Remove query portion of URL
SString strUrlCleaned = SString(pArgument->GetString()).ReplaceI("%3F","?").Replace("#","?").SplitLeft("?");
pArgument->ReadString(strUrlCleaned);
}
}
else if (maskArgument.argType == EArgType::MaxArgs)
{
while(FunctionArguments.Count() > maskArgument.index)
FunctionArguments.Pop();
}
}
}
}
@@ -21,6 +21,19 @@ struct SDebugHookCallInfo
CFastHashSet<SString> allowedNameMap;
};

enum class EArgType
{
Password,
Url,
MaxArgs,
};

struct SMaskArgument
{
EArgType argType;
uint index;
};

///////////////////////////////////////////////////////////////
//
// CDebugHookManager
@@ -65,5 +78,5 @@ class CDebugHookManager
std::vector<SDebugHookCallInfo> m_PostFunctionHookList;
std::vector<SDebugHookCallInfo> m_PreEventFunctionHookList;
std::vector<SDebugHookCallInfo> m_PostEventFunctionHookList;
std::map<SString, std::vector<uint> > m_MaskArgumentsMap;
std::map<SString, std::vector<SMaskArgument> > m_MaskArgumentsMap;
};

0 comments on commit fad4684

Please sign in to comment.
You can’t perform that action at this time.