From 7a8d552267f94b574c77cf9c1254fba1710616cf Mon Sep 17 00:00:00 2001 From: checkymander Date: Thu, 29 Feb 2024 10:18:36 -0500 Subject: [PATCH] skip mac os tests --- .../Tests/Agent.Tests/PluginTests/LsTests.cs | 14 +++++----- .../agent_code/entitlements/entitlements.cs | 26 ++++++++++++++----- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/PluginTests/LsTests.cs b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/PluginTests/LsTests.cs index c543956dd..b88073178 100644 --- a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/PluginTests/LsTests.cs +++ b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/PluginTests/LsTests.cs @@ -36,15 +36,15 @@ public LsTests() [TestMethod] public void TestValidParentPath() { - //if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux()) - //{ - // //Temporary skip until I can fucking test on a mac and see what's going on + if (OperatingSystem.IsMacOS()) + { + //Temporary skip until I can fucking test on a mac and see what's going on - // //For some reason /etc is returning /System/etc + //For some reason /etc is returning /System/etc - // Assert.IsTrue(true); - // return; - //} + Assert.IsTrue(true); + return; + } string path; diff --git a/Payload_Type/athena/athena/agent_code/entitlements/entitlements.cs b/Payload_Type/athena/athena/agent_code/entitlements/entitlements.cs index 8f2dca8e4..8f2b01dca 100644 --- a/Payload_Type/athena/athena/agent_code/entitlements/entitlements.cs +++ b/Payload_Type/athena/athena/agent_code/entitlements/entitlements.cs @@ -24,7 +24,7 @@ public async Task Execute(ServerJob job) string GetProcessEntitlements(int pid) { // Get the process path - string processPath = GetProcessPath(pid);; + string processPath = GetProcessPath(pid); ; return GetEntitlementsFromBundle(processPath); } @@ -55,12 +55,26 @@ string GetProcessPath(int pid) } string GetEntitlementsFromBundle(string bundlePath) { - return bundlePath; - // You can implement your logic to extract entitlements from the bundle path here. - // This might involve reading the Info.plist file of the bundle and extracting the entitlements. + return ReadInfoPlist(bundlePath); + } + string ReadInfoPlist(string bundlePath) + { + Console.WriteLine(bundlePath); + string infoPlistPath = Path.Combine(bundlePath, "../", "../", "../", "Contents", "Info.plist"); + + if (!File.Exists(infoPlistPath)) + { + return "Info.plist file does not exist."; + } - // For simplicity, let's assume a placeholder value for the entitlements. - //return "Placeholder Entitlements"; + try + { + return File.ReadAllText(infoPlistPath); + } + catch (Exception ex) + { + return $"Error reading Info.plist: {ex.Message}"; + } } } }