- added ISSUE_TEMPLATE.md

- added null reference checks
This commit is contained in:
makikvues
2021-08-27 21:19:16 +02:00
parent 24884a1d7e
commit dbfd0be62e
6 changed files with 48 additions and 7 deletions
@@ -139,7 +139,7 @@ namespace winPEAS.Checks
// get our properties
// ref - https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdatehistoryentry
var title = searcherObj.GetType().InvokeMember("Title", BindingFlags.GetProperty, null, item, new object[] { }).ToString();
var title = searcherObj.GetType().InvokeMember("Title", BindingFlags.GetProperty, null, item, new object[] { })?.ToString() ?? string.Empty;
var date = searcherObj.GetType().InvokeMember("Date", BindingFlags.GetProperty, null, item, new object[] { });
var description = searcherObj.GetType().InvokeMember("Description", BindingFlags.GetProperty, null, item, new object[] { });
var clientApplicationID = searcherObj.GetType().InvokeMember("ClientApplicationID", BindingFlags.GetProperty, null, item, new object[] { });
@@ -80,12 +80,15 @@ namespace winPEAS.Helpers.AppLocker
Beaprint.NoColorPrint($" AppLockerPolicy version: {appLockerSettings.Version}\n listing rules:\n\n");
foreach (var rule in appLockerSettings.RuleCollection)
if (appLockerSettings.RuleCollection != null)
{
PrintFileHashRules(rule);
PrintFilePathRules(rule);
PrintFilePublisherRules(rule);
}
foreach (var rule in appLockerSettings.RuleCollection)
{
PrintFileHashRules(rule);
PrintFilePathRules(rule);
PrintFilePublisherRules(rule);
}
}
}
catch (COMException)
{
@@ -143,6 +143,12 @@ namespace winPEAS.Helpers.Registry
{
myKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(path);
}
if (myKey == null)
{
return new string[0];
}
String[] subkeyNames = myKey.GetSubKeyNames();
return myKey.GetSubKeyNames();
}
@@ -92,6 +92,12 @@ namespace winPEAS.Info.SystemInfo.SysMon
try
{
var key = registryKey.OpenSubKey(paramsKey);
if (key == null)
{
return null;
}
byte[] result = (byte[])key.GetValue(val);
return result;
@@ -90,7 +90,10 @@ namespace winPEAS.Wifi.NativeWifiApi
~WlanClient()
{
WlanApi.WlanCloseHandle(clientHandle, IntPtr.Zero);
if (clientHandle != IntPtr.Zero)
{
WlanApi.WlanCloseHandle(clientHandle, IntPtr.Zero);
}
}
/// <summary>