diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index eabf3899..bbdef9f3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -34,7 +34,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/CoseHandler.Tests/CoseHandler.Tests.csproj b/CoseHandler.Tests/CoseHandler.Tests.csproj index da0909ef..d4a473d8 100644 --- a/CoseHandler.Tests/CoseHandler.Tests.csproj +++ b/CoseHandler.Tests/CoseHandler.Tests.csproj @@ -1,6 +1,7 @@  + Exe net8.0 enable enable @@ -12,6 +13,7 @@ True enable ..\StrongNameKeys\35MSSharedLib1024.snk + CoseSignUnitTests @@ -22,10 +24,10 @@ - - - + + + diff --git a/CoseHandler.Tests/CoseSignValidateTests.cs b/CoseHandler.Tests/CoseSignValidateTests.cs index b259dafb..ae377dc8 100644 --- a/CoseHandler.Tests/CoseSignValidateTests.cs +++ b/CoseHandler.Tests/CoseSignValidateTests.cs @@ -11,12 +11,9 @@ public class CoseHandlerSignValidateTests // Certificates and chains as objects private static readonly X509Certificate2 SelfSignedCert = TestCertificateUtils.CreateCertificate(nameof(CoseHandlerSignValidateTests) + " self signed"); // A self-signed cert private static readonly X509Certificate2Collection CertChain1 = TestCertificateUtils.CreateTestChain(nameof(CoseHandlerSignValidateTests) + " set 1"); // Two complete cert chains - private static readonly X509Certificate2Collection CertChain2= TestCertificateUtils.CreateTestChain(nameof(CoseHandlerSignValidateTests) + " set 2"); private static readonly X509Certificate2 Root1Priv = CertChain1[0]; // Roots from the chains - private static readonly X509Certificate2 Root2Priv = CertChain2[0]; private static readonly X509Certificate2 Int1Priv = CertChain1[1]; private static readonly X509Certificate2 Leaf1Priv = CertChain1[^1]; // Leaf node certs - private static readonly X509Certificate2 Leaf2Priv = CertChain2[^1]; // As byte arrays private static readonly byte[] Root1Cer = Root1Priv.Export(X509ContentType.Cert); @@ -49,9 +46,9 @@ public CoseHandlerSignValidateTests() { // export generated certs to files File.WriteAllBytes(PrivateKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Pkcs12)); - File.WriteAllBytes(PublicKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Cert)); - File.WriteAllBytes(PrivateKeyRootCertFile, Root1Priv.Export(X509ContentType.Pkcs12)); - File.WriteAllBytes(PublicKeyRootCertFile, Root1Priv.Export(X509ContentType.Cert)); + File.WriteAllBytes(PublicKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Cert)); + File.WriteAllBytes(PrivateKeyRootCertFile, Root1Priv.Export(X509ContentType.Pkcs12)); + File.WriteAllBytes(PublicKeyRootCertFile, Root1Priv.Export(X509ContentType.Cert)); File.WriteAllBytes(PrivateKeyCertFileChained, Leaf1Priv.Export(X509ContentType.Pkcs12)); } @@ -103,7 +100,7 @@ public void PayloadFile_SignatureFile() { FileInfo f = new(FileSystemUtils.GeneratePayloadFile()); string signaturePath = f.FullName.Replace("spdx.json", "cose"); - FileInfo signatureFile = new (signaturePath); + FileInfo signatureFile = new(signaturePath); byte[] signedBytes = CoseHandler.Sign(f, Leaf1Priv, false, signatureFile).ToArray(); signedBytes.Should().NotBeNull(); @@ -116,7 +113,7 @@ public void PayloadFile_SignatureFile() .Success.Should().Be(true); // Validate from stream - FileInfo sigFile = new (signaturePath); + FileInfo sigFile = new(signaturePath); sigFile.Should().NotBeNull(); CoseHandler.Validate(sigFile.GetStreamResilient()!, Payload1Bytes, ValidRootSetPriv, RevMode) .Success.Should().Be(true); @@ -307,7 +304,7 @@ public void DetachedValidationWithoutPayload() public void SignWithoutPayload() { #pragma warning disable CS8600, CS8625 // Converting null literal -- deliberate null convetrsion for test purposes. - _ = CoseHandler.Sign((byte[]) null, Leaf1Priv); + _ = CoseHandler.Sign((byte[])null, Leaf1Priv); #pragma warning restore CS8600, CS8625 // Converting null literal or possible null value to non-nullable type. } diff --git a/CoseHandler.Tests/TestsForTheUnderlyingAPI.cs b/CoseHandler.Tests/TestsForTheUnderlyingAPI.cs index ab017a2b..61789853 100644 --- a/CoseHandler.Tests/TestsForTheUnderlyingAPI.cs +++ b/CoseHandler.Tests/TestsForTheUnderlyingAPI.cs @@ -3,7 +3,8 @@ namespace CoseSignUnitTests; -internal class TestsForTheUnderlyingAPI +[TestClass] +public class TestsForTheUnderlyingAPI { private readonly byte[] Payload1 = Encoding.ASCII.GetBytes("Payload1!"); private const string SubjectName1 = $"{nameof(TestsForTheUnderlyingAPI)}_Cert1"; diff --git a/CoseIndirectSignature.Tests/CoseIndirectSignature.Tests.csproj b/CoseIndirectSignature.Tests/CoseIndirectSignature.Tests.csproj index bfaf4813..c7634ac2 100644 --- a/CoseIndirectSignature.Tests/CoseIndirectSignature.Tests.csproj +++ b/CoseIndirectSignature.Tests/CoseIndirectSignature.Tests.csproj @@ -1,6 +1,7 @@  + Exe enable false true @@ -21,12 +22,11 @@ - - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CoseSign1.Certificates.Tests/CoseSign1.Certificates.Tests.csproj b/CoseSign1.Certificates.Tests/CoseSign1.Certificates.Tests.csproj index 91ad2fc7..12369ad7 100644 --- a/CoseSign1.Certificates.Tests/CoseSign1.Certificates.Tests.csproj +++ b/CoseSign1.Certificates.Tests/CoseSign1.Certificates.Tests.csproj @@ -1,6 +1,7 @@  + Exe net8.0 enable false @@ -19,10 +20,10 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CoseSign1.Headers.Tests/CoseSign1.Headers.Tests.csproj b/CoseSign1.Headers.Tests/CoseSign1.Headers.Tests.csproj index 4fe80485..c8521455 100644 --- a/CoseSign1.Headers.Tests/CoseSign1.Headers.Tests.csproj +++ b/CoseSign1.Headers.Tests/CoseSign1.Headers.Tests.csproj @@ -1,6 +1,7 @@  + Exe net8.0 enable false @@ -18,10 +19,9 @@ - - + - + diff --git a/CoseSign1.Tests/CoseSign1.Tests.csproj b/CoseSign1.Tests/CoseSign1.Tests.csproj index c5c4e625..6042b109 100644 --- a/CoseSign1.Tests/CoseSign1.Tests.csproj +++ b/CoseSign1.Tests/CoseSign1.Tests.csproj @@ -1,6 +1,7 @@  + Exe net8.0 enable false @@ -18,12 +19,12 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CoseSignTool.Tests/CoseSignTool.Tests.csproj b/CoseSignTool.Tests/CoseSignTool.Tests.csproj index f418733c..ef9d026b 100644 --- a/CoseSignTool.Tests/CoseSignTool.Tests.csproj +++ b/CoseSignTool.Tests/CoseSignTool.Tests.csproj @@ -1,5 +1,6 @@  + Exe net8.0 AnyCPU @@ -26,9 +27,9 @@ - - - + + + diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..c54f4691 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,8 @@ + + + true + true + true + true + +