Factor malware checks into its own pass.
This commit is contained in:
parent
3807edbeb8
commit
76d681761d
@ -930,40 +930,8 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **aResult, const char *path, bool de
|
|||||||
if (pPlugin->m_status == Plugin_Uncompiled) {
|
if (pPlugin->m_status == Plugin_Uncompiled) {
|
||||||
pPlugin->TryCompile(error, maxlength);
|
pPlugin->TryCompile(error, maxlength);
|
||||||
}
|
}
|
||||||
|
if (pPlugin->m_status == Plugin_Created) {
|
||||||
if (pPlugin->GetStatus() == Plugin_Created)
|
MalwareCheckPass(pPlugin, error, maxlength);
|
||||||
{
|
|
||||||
unsigned char *pCodeHash = pPlugin->m_pRuntime->GetCodeHash();
|
|
||||||
|
|
||||||
char codeHashBuf[40];
|
|
||||||
ke::SafeSprintf(codeHashBuf, 40, "plugin_");
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
ke::SafeSprintf(codeHashBuf + 7 + (i * 2), 3, "%02x", pCodeHash[i]);
|
|
||||||
|
|
||||||
const char *bulletinUrl = g_pGameConf->GetKeyValue(codeHashBuf);
|
|
||||||
if (bulletinUrl != NULL)
|
|
||||||
{
|
|
||||||
if (m_bBlockBadPlugins)
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
if (bulletinUrl[0] != '\0')
|
|
||||||
{
|
|
||||||
ke::SafeSprintf(error, maxlength, "Known malware detected and blocked. See %s for more info", bulletinUrl);
|
|
||||||
} else {
|
|
||||||
ke::SafeSprintf(error, maxlength, "Possible malware or illegal plugin detected and blocked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pPlugin->m_status = Plugin_BadLoad;
|
|
||||||
} else {
|
|
||||||
if (bulletinUrl[0] != '\0')
|
|
||||||
{
|
|
||||||
g_Logger.LogMessage("%s: Known malware detected. See %s for more info, blocking disabled in core.cfg", pPlugin->GetFilename(), bulletinUrl);
|
|
||||||
} else {
|
|
||||||
g_Logger.LogMessage("%s: Possible malware or illegal plugin detected, blocking disabled in core.cfg", pPlugin->GetFilename());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadRes loadFailure = LoadRes_Failure;
|
LoadRes loadFailure = LoadRes_Failure;
|
||||||
@ -1274,6 +1242,37 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPluginManager::MalwareCheckPass(CPlugin *pPlugin, char *error, size_t maxlength)
|
||||||
|
{
|
||||||
|
unsigned char *pCodeHash = pPlugin->GetRuntime()->GetCodeHash();
|
||||||
|
|
||||||
|
char codeHashBuf[40];
|
||||||
|
ke::SafeSprintf(codeHashBuf, 40, "plugin_");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
ke::SafeSprintf(codeHashBuf + 7 + (i * 2), 3, "%02x", pCodeHash[i]);
|
||||||
|
|
||||||
|
const char *bulletinUrl = g_pGameConf->GetKeyValue(codeHashBuf);
|
||||||
|
if (!bulletinUrl)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (m_bBlockBadPlugins) {
|
||||||
|
if (bulletinUrl[0] != '\0') {
|
||||||
|
ke::SafeSprintf(error, maxlength, "Known malware detected and blocked. See %s for more info", bulletinUrl);
|
||||||
|
} else {
|
||||||
|
ke::SafeSprintf(error, maxlength, "Possible malware or illegal plugin detected and blocked");
|
||||||
|
}
|
||||||
|
pPlugin->m_status = Plugin_BadLoad;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bulletinUrl[0] != '\0') {
|
||||||
|
g_Logger.LogMessage("%s: Known malware detected. See %s for more info, blocking disabled in core.cfg", pPlugin->GetFilename(), bulletinUrl);
|
||||||
|
} else {
|
||||||
|
g_Logger.LogMessage("%s: Possible malware or illegal plugin detected, blocking disabled in core.cfg", pPlugin->GetFilename());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength)
|
bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
/* Second pass for extension requirements */
|
/* Second pass for extension requirements */
|
||||||
|
@ -459,6 +459,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
void AddPlugin(CPlugin *pPlugin);
|
void AddPlugin(CPlugin *pPlugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First pass for loading a plugin, and its helpers.
|
||||||
|
*/
|
||||||
|
bool MalwareCheckPass(CPlugin *pPlugin, char *error, size_t maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the second loading pass on a plugin.
|
* Runs the second loading pass on a plugin.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user