Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/API/CustomEmployeeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,13 @@ private static void SetPortrait(Transform card, string employeeId)
var portraitTransform = card.Find("Image");
if (portraitTransform == null) return;

// [Security] Prevent path traversal on dynamically constructed image path
if (employeeId.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || employeeId.Contains(".."))
{
CrashLog.Log($"[Security] SetPortrait: Invalid characters in employeeId={employeeId}");
return;
}

string assetsDir = Path.Combine(MelonEnvironment.UserDataDirectory, "ModAssets");
string? imagePath = null;
foreach (var ext in new[] { ".jpg", ".png" })
Expand Down
8 changes: 7 additions & 1 deletion src/GameLayer/Patches/Networking/CablePositionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@
}
while (Interlocked.CompareExchange(ref _nextCableId, baseId + 1, current) != current);

MelonLogger.Msg($"[CablePatch] Cable ID counter set to {baseId + 1}");
try { LogSetBaseId(baseId + 1); } catch { }

Check warning on line 70 in src/GameLayer/Patches/Networking/CablePositionsPatch.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/GameLayer/Patches/Networking/CablePositionsPatch.cs#L70

Handle the exception or explain in a comment why it can be ignored.
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static void LogSetBaseId(int val)
{
MelonLogger.Msg($"[CablePatch] Cable ID counter set to {val}");
}

public static int PeekNextId() => _nextCableId;
Expand Down
Loading