Skip to content

Commit 8c6ab20

Browse files
committed
Minor refactorings and breaking out new rules.
1 parent 34afae2 commit 8c6ab20

19 files changed

+141
-76
lines changed

AuthenticodeLint/AuthenticodeLint.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
<OutputType>WinExe</OutputType>
44
<AssemblyName>authlint</AssemblyName>
55
<TargetFramework>netcoreapp2.1</TargetFramework>
6-
<VersionPrefix>0.11.0</VersionPrefix>
6+
<VersionPrefix>0.12.0</VersionPrefix>
77
<Authors>Kevin Jones</Authors>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9-
<Copyright>Kevin Jones 2016-2017</Copyright>
9+
<Copyright>Kevin Jones 2016-2018</Copyright>
10+
<PackAsTool>true</PackAsTool>
11+
<ToolCommandName>authlint</ToolCommandName>
12+
<Description>Authenticode Lint is a Windows command-line tool for linting an examining an Authenticode signed file.</Description>
13+
<Authors>Kevin Jones</Authors>
14+
<PackageTags>authenticode</PackageTags>
15+
<PackageProjectUrl>https://github.com/vcsjones/AuthenticodeLint</PackageProjectUrl>
16+
<RepositoryUrl>https://github.com/vcsjones/AuthenticodeLint</RepositoryUrl>
17+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
18+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1019
</PropertyGroup>
1120
<ItemGroup>
1221
<PackageReference Include="AuthenticodeExaminer" Version="0.3.0" />

AuthenticodeLint/KnownOids.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ public static class X509Algorithms
88
public const string Ecc = "1.2.840.10045.2.1";
99
}
1010

11-
public static class EccCurves
12-
{
13-
public const string EcdsaP256 = "1.2.840.10045.3.1.7";
14-
public const string EcdsaP384 = "1.3.132.0.34";
15-
public const string EcdsaP521 = "1.3.132.0.35";
16-
}
17-
18-
1911
public const string SHA1 = "1.3.14.3.2.26";
2012
public const string SHA256 = "2.16.840.1.101.3.4.2.1";
2113
public const string SHA384 = "2.16.840.1.101.3.4.2.2";

AuthenticodeLint/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Linq;
6+
using System.Runtime.InteropServices;
67

78
namespace AuthenticodeLint
89
{
910
class Program
1011
{
1112
static int Main(string[] args)
1213
{
14+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
15+
{
16+
Console.Error.WriteLine("AuthenticodeLint is only supported on Windows.");
17+
return ExitCodes.PlatformNotSupported;
18+
}
1319
var cli = Environment.CommandLine;
1420
List<CommandLineParameter> parsedCommandLine;
1521
try
@@ -206,9 +212,10 @@ Checks the Authenticode signature of your binaries.
206212

207213
internal static class ExitCodes
208214
{
209-
public static int Success { get; } = 0;
210-
public static int InvalidInputOrConfig { get; } = 1;
211-
public static int ChecksFailed { get; } = 2;
212-
public static int UnknownResults { get; } = 0xFF;
215+
public static int Success => 0;
216+
public static int InvalidInputOrConfig => 1;
217+
public static int ChecksFailed => 2;
218+
public static int UnknownResults => 0xFF;
219+
public static int PlatformNotSupported => unchecked((int)0x80131539);
213220
}
214221
}

AuthenticodeLint/Rules/10000-Sha1PrimarySignatureRule.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@ namespace AuthenticodeLint.Rules
55
{
66
public class Sha1PrimarySignatureRule : IAuthenticodeSignatureRule
77
{
8-
public int RuleId { get; } = 10000;
8+
public int RuleId => 10000;
99

10-
public string RuleName { get; } = "Primary SHA1";
10+
public string RuleName => "Primary SHA1";
1111

12-
public string ShortDescription { get; } = "Primary signature should be SHA1.";
12+
public string ShortDescription => "Primary signature should be SHA1.";
1313

14-
public RuleSet RuleSet { get; } = RuleSet.Compat;
14+
public RuleSet RuleSet => RuleSet.Compat;
1515

1616
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1717
{
1818
if (graph.Count == 0)
1919
{
2020
return RuleResult.Fail;
2121
}
22-
if (graph.Count > 1)
23-
{
24-
verboseWriter.LogMessage("Multiple primary signatures exist.");
25-
return RuleResult.Fail;
26-
}
2722
var primary = graph[0];
2823
if (primary.DigestAlgorithm.Value != KnownOids.SHA1)
2924
{

AuthenticodeLint/Rules/10001-Sha2SignatureExistsRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace AuthenticodeLint.Rules
66
{
77
public class Sha2SignatureExistsRule : IAuthenticodeSignatureRule
88
{
9-
public int RuleId { get; } = 10001;
9+
public int RuleId => 10001;
1010

11-
public string RuleName { get; } = "SHA2 Signed";
11+
public string RuleName => "SHA2 Signed";
1212

13-
public string ShortDescription { get; } = "A SHA2 signature should exist.";
13+
public string ShortDescription => "A SHA2 signature should exist.";
1414

15-
public RuleSet RuleSet { get; } = RuleSet.All;
15+
public RuleSet RuleSet => RuleSet.All;
1616

1717
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1818
{

AuthenticodeLint/Rules/10002-NoWeakFileDigestAlgorithmsRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace AuthenticodeLint.Rules
55
{
66
public class NoWeakFileDigestAlgorithmsRule : IAuthenticodeSignatureRule
77
{
8-
public int RuleId { get; } = 10002;
8+
public int RuleId => 10002;
99

10-
public string RuleName { get; } = "No Weak File Digests";
10+
public string RuleName => "No Weak File Digests";
1111

12-
public string ShortDescription { get; } = "Checks for weak file digest algorithms.";
12+
public string ShortDescription => "Checks for weak file digest algorithms.";
1313

14-
public RuleSet RuleSet { get; } = RuleSet.All;
14+
public RuleSet RuleSet => RuleSet.All;
1515

1616
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1717
{

AuthenticodeLint/Rules/10003-TimestampedRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace AuthenticodeLint.Rules
77
{
88
public class TimestampedRule : IAuthenticodeSignatureRule
99
{
10-
public int RuleId { get; } = 10003;
10+
public int RuleId => 10003;
1111

12-
public string RuleName { get; } = "Timestamped Rule";
12+
public string RuleName => "Timestamped Rule";
1313

14-
public string ShortDescription { get; } = "Signatures should have a timestamp counter signer.";
14+
public string ShortDescription => "Signatures should have a timestamp counter signer.";
1515

16-
public RuleSet RuleSet { get; } = RuleSet.All;
16+
public RuleSet RuleSet => RuleSet.All;
1717

1818
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1919
{

AuthenticodeLint/Rules/10004-PublisherInformationRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace AuthenticodeLint.Rules
66
{
77
public class PublisherInformationPresentRule : IAuthenticodeSignatureRule
88
{
9-
public int RuleId { get; } = 10004;
9+
public int RuleId => 10004;
1010

11-
public string RuleName { get; } = "Publisher Information Present";
11+
public string RuleName => "Publisher Information Present";
1212

13-
public string ShortDescription { get; } = "Checks that the signature provided publisher information.";
13+
public string ShortDescription => "Checks that the signature provided publisher information.";
1414

15-
public RuleSet RuleSet { get; } = RuleSet.All;
15+
public RuleSet RuleSet => RuleSet.All;
1616

1717
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1818
{

AuthenticodeLint/Rules/10005-PublisherInformationUrlHttpsRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace AuthenticodeLint.Rules
66
{
77
public class PublisherInformationUrlHttpsRule : IAuthenticodeSignatureRule
88
{
9-
public int RuleId { get; } = 10005;
9+
public int RuleId => 10005;
1010

11-
public string RuleName { get; } = "Publisher Information URL HTTPS Rule";
11+
public string RuleName => "Publisher Information URL HTTPS Rule";
1212

13-
public string ShortDescription { get; } = "Checks that the signature uses HTTPS for the publisher's URL.";
13+
public string ShortDescription => "Checks that the signature uses HTTPS for the publisher's URL.";
1414

15-
public RuleSet RuleSet { get; } = RuleSet.All;
15+
public RuleSet RuleSet => RuleSet.All;
1616

1717
public RuleResult Validate(IReadOnlyList<ICmsSignature> graph, SignatureLogger verboseWriter, CheckConfiguration configuration)
1818
{

AuthenticodeLint/Rules/10006-SigningCertificateDigestAlgorithmRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace AuthenticodeLint.Rules
55
{
66
public class SigningCertificateDigestAlgorithmRule : CertificateChainRuleBase
77
{
8-
public override int RuleId { get; } = 10006;
8+
public override int RuleId => 10006;
99

10-
public override string RuleName { get; } = "Strong Certificate Chain";
10+
public override string RuleName => "Strong Certificate Chain";
1111

12-
public override string ShortDescription { get; } = "Checks the signing certificate's and chain's signature algorithm.";
12+
public override string ShortDescription => "Checks the signing certificate's and chain's signature algorithm.";
1313

14-
public override RuleSet RuleSet { get; } = RuleSet.All;
14+
public override RuleSet RuleSet => RuleSet.All;
1515

1616
protected override bool ValidateChain(ICmsSignature signer, X509Chain chain, SignatureLogger verboseWriter)
1717
{

0 commit comments

Comments
 (0)