Compare commits

...

8 Commits

Author SHA1 Message Date
beu
9b5411bc43 update hash 2025-03-12 09:34:29 +01:00
beu
9cfd157fd2 bump version 2025-03-12 00:31:46 +01:00
beu
a559009ee5 update hash list 2025-03-12 00:30:43 +01:00
beu
381e31f663 bump version 2025-01-16 22:11:26 +01:00
beu
be3b6d225c add Anonymised TMWC 2024 mode 2025-01-16 22:11:17 +01:00
beu
c8f7948246 add gitignore 2025-01-13 22:49:19 +01:00
beu
1ae76e7674 Add support of hashes 2025-01-13 22:48:36 +01:00
beu
f2cfefda0f fix sanity check warning 2025-01-13 22:38:24 +01:00
7 changed files with 43 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.op

View File

@@ -1,6 +1,7 @@
class LayerConfig { class LayerConfig {
string Name; string Name;
string Path; string Path;
string Hash;
CGameUILayer::EUILayerType LayerType = CGameUILayer::EUILayerType::Normal; CGameUILayer::EUILayerType LayerType = CGameUILayer::EUILayerType::Normal;
string AttachId = ''; string AttachId = '';
@@ -9,6 +10,7 @@ class LayerConfig {
LayerConfig(const string &in _ParentPath, const Json::Value &in _Data) { LayerConfig(const string &in _ParentPath, const Json::Value &in _Data) {
Path = Path::Join(_ParentPath, _Data['Path']); Path = Path::Join(_ParentPath, _Data['Path']);
Hash = _Data['Hash'];
const string Manialink = GetManialink(); const string Manialink = GetManialink();
Name = PacksManager::GetLayerName(Manialink); Name = PacksManager::GetLayerName(Manialink);
@@ -33,6 +35,22 @@ class LayerConfig {
IO::File File(Path, IO::FileMode::Read); IO::File File(Path, IO::FileMode::Read);
const string Manialink = File.ReadToEnd(); const string Manialink = File.ReadToEnd();
const string FileHash = Crypto::Sha256(Manialink);
if (Hash != FileHash) {
print('Cannot load layer "'+ Path +'": Invalid hash');
trace('info.json Layer hash: '+ Hash);
trace('file hash: '+ FileHash);
if (S_DisplayHashWarning) {
RenderManager::NotifyWarning('Cannot load layer "'+ Path +'": Invalid hash');
}
if (!Meta::IsDeveloperMode()) {
throw('Cannot load layer "'+ Path +'": Invalid hash');
}
}
return Manialink; return Manialink;
} }

4
Hashes.as Normal file
View File

@@ -0,0 +1,4 @@
const array<string> C_InterfacesPacksHashes = {
"c48796635bd234a22214336def4397bebb22a0f483ed6b30a4f412a1953be60e", // Anonymised TMWC 2024 - 1.0
"2a542ea483db750bb7a6240ea885e23eb34add0f88fbdfa38b5daa816d094cef" // Beacon Duo League - 1.0
};

View File

@@ -41,6 +41,21 @@ namespace PacksManager {
const string FileContent = File.ReadToEnd(); const string FileContent = File.ReadToEnd();
const string InfoFileHash = Crypto::Sha256(FileContent);
if (C_InterfacesPacksHashes.Find(InfoFileHash) < 0) {
print('Invalid Pack Config "'+ Id +'": Invalid hash');
trace('info.json hash: '+ InfoFileHash);
if (S_DisplayHashWarning) {
RenderManager::NotifyWarning('Invalid Pack Config "'+ Id +'": Invalid hash');
}
if (!Meta::IsDeveloperMode()) {
trace('Invalid Pack Config "'+ Id +'": Invalid hash');
continue;
}
}
try { try {
const PackConfig Config(Path, FileContent); const PackConfig Config(Path, FileContent);
G_Configs[Id] = Config; G_Configs[Id] = Config;

View File

@@ -28,7 +28,7 @@ namespace RenderManager {
vec2 RightAlignedButtonsCursorPos = UI::GetCursorPos(); vec2 RightAlignedButtonsCursorPos = UI::GetCursorPos();
if (UI::Button(Icons::Info + ' Info')) { if (UI::Button(Icons::Info + ' Info')) {
OpenBrowserURL('https://openplanet.dev/plugin/' + Meta::ExecutingPlugin().get_SiteID()); OpenBrowserURL('https://openplanet.dev/plugin/' + Meta::ExecutingPlugin().SiteID);
} }
UI::SameLine(); UI::SameLine();

View File

@@ -1,3 +1,6 @@
[Setting name="Display hash mismatch warning"]
bool S_DisplayHashWarning = true;
[Setting hidden] [Setting hidden]
string S_EnabledConfigs = ''; string S_EnabledConfigs = '';

View File

@@ -3,4 +3,4 @@ name = "Custom Interfaces Loader"
siteid = 671 siteid = 671
author = "Beu" author = "Beu"
category = "Interfaces" category = "Interfaces"
version = "0.1" version = "0.3"