Skip to content

Commit 3443216

Browse files
authored
Merge pull request #1 from MattMofDoom/dev
Include properties for integration with other Seq apps
2 parents 134421c + e3697f0 commit 3443216

5 files changed

Lines changed: 55 additions & 2 deletions

File tree

Seq.Client.WindowsLogins/App.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@
1616
<add key="HeartbeatInterval" value="600" />
1717
<!-- Set IsDebug to true for additional heartbeat logging -->
1818
<add key="IsDebug" value="false" />
19+
<add key="ProjectKey" value="PROJECT" />
20+
<add key="Priority" value="Medium" />
21+
<add key="Responders" value="JSmith" />
22+
<add key="Tags" value="Secuurity" />
23+
<add key="InitialTimeEstimate" value="1h" />
24+
<add key="RemainingTimeEstimate" value="1h" />
25+
<add key="DueDate" value="1d" />
1926
</appSettings>
2027
</configuration>

Seq.Client.WindowsLogins/Config.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
24
using System.Configuration;
35
using System.IO;
6+
using System.Linq;
47
using System.Reflection;
8+
using System.ServiceModel.Channels;
59

610
namespace Seq.Client.WindowsLogins
711
{
@@ -15,6 +19,14 @@ static Config()
1519
LogFolder = ConfigurationManager.AppSettings["LogFolder"];
1620
HeartbeatInterval = GetInt(ConfigurationManager.AppSettings["HeartbeatInterval"]);
1721
IsDebug = GetBool(ConfigurationManager.AppSettings["IsDebug"]);
22+
ProjectKey = ConfigurationManager.AppSettings["ProjectKey"];
23+
Responders = ConfigurationManager.AppSettings["Responders"];
24+
Priority = ConfigurationManager.AppSettings["Priority"];
25+
Tags = GetArray(ConfigurationManager.AppSettings["Tags"]);
26+
InitialTimeEstimate = ConfigurationManager.AppSettings["InitialTimeEstimate"];
27+
RemainingTimeEstimate = ConfigurationManager.AppSettings["RemainingTimeEstimate"];
28+
DueDate = ConfigurationManager.AppSettings["DueDate"];
29+
1830
//Must be between 0 and 1 hour in seconds
1931
if (HeartbeatInterval < 0 || HeartbeatInterval > 3600)
2032
HeartbeatInterval = 600000;
@@ -60,6 +72,13 @@ static Config()
6072
public static string LogFolder { get; }
6173
public static int HeartbeatInterval { get; }
6274
public static bool IsDebug { get; }
75+
public static string ProjectKey { get; }
76+
public static string Priority { get; }
77+
public static string Responders { get; }
78+
public static IEnumerable<string> Tags { get; }
79+
public static string InitialTimeEstimate { get; }
80+
public static string RemainingTimeEstimate { get; }
81+
public static string DueDate { get; }
6382

6483
/// <summary>
6584
/// Convert the supplied <see cref="object" /> to an <see cref="int" />
@@ -95,5 +114,13 @@ private static bool GetBool(object sourceObject, bool trueIfEmpty = false)
95114

96115
return bool.TryParse(sourceString, out var destBool) ? destBool : trueIfEmpty;
97116
}
117+
118+
private static IEnumerable<string> GetArray(string value)
119+
{
120+
return (value ?? "")
121+
.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
122+
.Select(t => t.Trim())
123+
.ToArray();
124+
}
98125
}
99126
}

Seq.Client.WindowsLogins/EventLogListener.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,22 @@ private static void HandleEventLogEntry(EventRecord entry)
183183

184184
_logonsDetected++;
185185

186+
var eventTimeLong = string.Empty;
187+
var eventTimeShort = string.Empty;
188+
if (entry.TimeCreated != null)
189+
{
190+
eventTimeLong = ((DateTime) entry.TimeCreated).ToString("F");
191+
eventTimeShort = ((DateTime) entry.TimeCreated).ToString("G");
192+
}
193+
186194
Log.Level(Extensions.MapLogLevel(EventLogEntryType.SuccessAudit))
187195
#pragma warning disable 618
188196
.AddProperty("EventId", (long) entry.Id)
189197
#pragma warning restore 618
190198
.AddProperty("InstanceId", entry.Id)
191199
.AddProperty("EventTime", entry.TimeCreated)
200+
.AddProperty("EventTimeLong", eventTimeLong)
201+
.AddProperty("EventTimeShort", eventTimeShort)
192202
.AddProperty("Source", entry.ProviderName)
193203
.AddProperty("Category", entry.LevelDisplayName)
194204
.AddProperty("EventLogName", entry.LogName)
@@ -215,8 +225,16 @@ private static void HandleEventLogEntry(EventRecord entry)
215225
.AddProperty("IpAddress", eventProperties[18])
216226
.AddProperty("IpPort", eventProperties[19])
217227
.AddProperty("ImpersonationLevel", eventProperties[20])
228+
.AddProperty(nameof(Config.ProjectKey), Config.ProjectKey)
229+
.AddProperty(nameof(Config.Priority), Config.Priority)
230+
.AddProperty(nameof(Config.Responders), Config.Responders)
231+
.AddProperty(nameof(Config.Tags), Config.Tags)
232+
.AddProperty(nameof(Config.InitialTimeEstimate), Config.InitialTimeEstimate)
233+
.AddProperty(nameof(Config.RemainingTimeEstimate), Config.RemainingTimeEstimate)
234+
.AddProperty(nameof(Config.DueDate), Config.DueDate)
218235
.Add(
219236
"[{AppName:l}] New login detected on {MachineName:l} - {TargetDomainName:l}\\{TargetUserName:l} at {EventTime:F}");
237+
220238
}
221239
catch (Exception ex)
222240
{

Seq.Client.WindowsLogins/Seq.Client.WindowsLogins.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
<PropertyGroup>
3838
<StartupObject />
3939
<Authors>Matt Marlor</Authors>
40-
<Version>1.1.2</Version>
40+
<Version>1.1.3</Version>
41+
<ApplicationIcon>login.ico</ApplicationIcon>
4142
</PropertyGroup>
4243
<ItemGroup>
4344
<Reference Include="System" />
@@ -64,7 +65,7 @@
6465
</EmbeddedResource>
6566
</ItemGroup>-->
6667
<ItemGroup>
67-
<PackageReference Include="Lurgle.Logging" Version="1.1.15" />
68+
<PackageReference Include="Lurgle.Logging" Version="1.2.3" />
6869
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
6970
<PackageReference Include="Newtonsoft.Json">
7071
<Version>13.0.1</Version>

Seq.Client.WindowsLogins/login.ico

202 KB
Binary file not shown.

0 commit comments

Comments
 (0)