feat(cli): Implement crypto plugin CLI architecture with regional compliance
Sprint: SPRINT_4100_0006_0001 Status: COMPLETED Implemented plugin-based crypto command architecture for regional compliance with build-time distribution selection (GOST/eIDAS/SM) and runtime validation. ## New Commands - `stella crypto sign` - Sign artifacts with regional crypto providers - `stella crypto verify` - Verify signatures with trust policy support - `stella crypto profiles` - List available crypto providers & capabilities ## Build-Time Distribution Selection ```bash # International (default - BouncyCastle) dotnet build src/Cli/StellaOps.Cli/StellaOps.Cli.csproj # Russia distribution (GOST R 34.10-2012) dotnet build -p:StellaOpsEnableGOST=true # EU distribution (eIDAS Regulation 910/2014) dotnet build -p:StellaOpsEnableEIDAS=true # China distribution (SM2/SM3/SM4) dotnet build -p:StellaOpsEnableSM=true ``` ## Key Features - Build-time conditional compilation prevents export control violations - Runtime crypto profile validation on CLI startup - 8 predefined profiles (international, russia-prod/dev, eu-prod/dev, china-prod/dev) - Comprehensive configuration with environment variable substitution - Integration tests with distribution-specific assertions - Full migration path from deprecated `cryptoru` CLI ## Files Added - src/Cli/StellaOps.Cli/Commands/CryptoCommandGroup.cs - src/Cli/StellaOps.Cli/Commands/CommandHandlers.Crypto.cs - src/Cli/StellaOps.Cli/Services/CryptoProfileValidator.cs - src/Cli/StellaOps.Cli/appsettings.crypto.yaml.example - src/Cli/__Tests/StellaOps.Cli.Tests/CryptoCommandTests.cs - docs/cli/crypto-commands.md - docs/implplan/SPRINT_4100_0006_0001_COMPLETION_SUMMARY.md ## Files Modified - src/Cli/StellaOps.Cli/StellaOps.Cli.csproj (conditional plugin refs) - src/Cli/StellaOps.Cli/Program.cs (plugin registration + validation) - src/Cli/StellaOps.Cli/Commands/CommandFactory.cs (command wiring) - src/Scanner/__Libraries/StellaOps.Scanner.Core/Configuration/PoEConfiguration.cs (fix) ## Compliance - GOST (Russia): GOST R 34.10-2012, FSB certified - eIDAS (EU): Regulation (EU) No 910/2014, QES/AES/AdES - SM (China): GM/T 0003-2012 (SM2), OSCCA certified ## Migration `cryptoru` CLI deprecated → sunset date: 2025-07-01 - `cryptoru providers` → `stella crypto profiles` - `cryptoru sign` → `stella crypto sign` ## Testing ✅ All crypto code compiles successfully ✅ Integration tests pass ✅ Build verification for all distributions (international/GOST/eIDAS/SM) Next: SPRINT_4100_0006_0002 (eIDAS plugin implementation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
namespace StellaOps.Concelier.SourceIntel.Tests;
|
||||
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.SourceIntel;
|
||||
using Xunit;
|
||||
|
||||
public sealed class ChangelogParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_SingleEntry_ExtractsCveAndMetadata()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"package-name (1.2.3-1) unstable; urgency=high
|
||||
|
||||
* Fix security vulnerability CVE-2024-1234
|
||||
|
||||
-- Maintainer Name <email@example.com> Mon, 15 Jan 2024 10:30:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
var entry = result.Entries[0];
|
||||
entry.PackageName.Should().Be("package-name");
|
||||
entry.Version.Should().Be("1.2.3-1");
|
||||
entry.CveIds.Should().ContainSingle("CVE-2024-1234");
|
||||
entry.Confidence.Should().Be(0.80);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_MultipleCvesInOneEntry_ExtractsAll()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"mypackage (2.0.0-1) stable; urgency=medium
|
||||
|
||||
* Security fixes for CVE-2024-1111 and CVE-2024-2222
|
||||
* Additional fix for CVE-2024-3333
|
||||
|
||||
-- Author <author@example.com> Tue, 20 Feb 2024 14:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].CveIds.Should().HaveCount(3);
|
||||
result.Entries[0].CveIds.Should().Contain("CVE-2024-1111");
|
||||
result.Entries[0].CveIds.Should().Contain("CVE-2024-2222");
|
||||
result.Entries[0].CveIds.Should().Contain("CVE-2024-3333");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_MultipleEntries_ExtractsOnlyThoseWithCves()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"pkg (1.0.0-2) unstable; urgency=low
|
||||
|
||||
* Fix for CVE-2024-9999
|
||||
|
||||
-- Dev <dev@example.com> Mon, 01 Jan 2024 12:00:00 +0000
|
||||
|
||||
pkg (1.0.0-1) unstable; urgency=low
|
||||
|
||||
* Initial release (no CVE)
|
||||
|
||||
-- Dev <dev@example.com> Sun, 31 Dec 2023 12:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].Version.Should().Be("1.0.0-2");
|
||||
result.Entries[0].CveIds.Should().ContainSingle("CVE-2024-9999");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_NoCves_ReturnsEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"pkg (1.0.0-1) unstable; urgency=low
|
||||
|
||||
* Regular update with no security fixes
|
||||
|
||||
-- Dev <dev@example.com> Mon, 01 Jan 2024 12:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseRpmChangelog_SingleEntry_ExtractsCve()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"* Mon Jan 15 2024 Maintainer <maint@example.com> - 1.2.3-1
|
||||
- Fix CVE-2024-5678 vulnerability
|
||||
- Other changes";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseRpmChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
var entry = result.Entries[0];
|
||||
entry.Version.Should().Be("1.2.3-1");
|
||||
entry.CveIds.Should().ContainSingle("CVE-2024-5678");
|
||||
entry.Confidence.Should().Be(0.80);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseRpmChangelog_MultipleCves_ExtractsAll()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"* Tue Feb 20 2024 Dev <dev@example.com> - 2.0.0-1
|
||||
- Security update for CVE-2024-1111
|
||||
- Also fixes CVE-2024-2222 and CVE-2024-3333";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseRpmChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].CveIds.Should().HaveCount(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAlpineSecfixes_SingleVersion_ExtractsCves()
|
||||
{
|
||||
// Arrange
|
||||
var secfixes = @"secfixes:
|
||||
1.2.3-r0:
|
||||
- CVE-2024-1234
|
||||
- CVE-2024-5678";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseAlpineSecfixes(secfixes);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
var entry = result.Entries[0];
|
||||
entry.Version.Should().Be("1.2.3-r0");
|
||||
entry.CveIds.Should().HaveCount(2);
|
||||
entry.CveIds.Should().Contain("CVE-2024-1234");
|
||||
entry.CveIds.Should().Contain("CVE-2024-5678");
|
||||
entry.Confidence.Should().Be(0.85); // Alpine has higher confidence
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAlpineSecfixes_MultipleVersions_ExtractsAll()
|
||||
{
|
||||
// Arrange
|
||||
var secfixes = @"secfixes:
|
||||
2.0.0-r0:
|
||||
- CVE-2024-9999
|
||||
1.5.0-r1:
|
||||
- CVE-2024-8888
|
||||
- CVE-2024-7777";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseAlpineSecfixes(secfixes);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(2);
|
||||
result.Entries.Should().Contain(e => e.Version == "2.0.0-r0" && e.CveIds.Contains("CVE-2024-9999"));
|
||||
result.Entries.Should().Contain(e => e.Version == "1.5.0-r1" && e.CveIds.Count == 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAlpineSecfixes_NoSecfixes_ReturnsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var secfixes = @"secfixes:";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseAlpineSecfixes(secfixes);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_ParsedAtTimestamp_IsRecorded()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"pkg (1.0.0-1) unstable; urgency=low
|
||||
|
||||
* Fix CVE-2024-0001
|
||||
|
||||
-- Dev <dev@example.com> Mon, 01 Jan 2024 12:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var before = DateTimeOffset.UtcNow.AddSeconds(-1);
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
var after = DateTimeOffset.UtcNow.AddSeconds(1);
|
||||
|
||||
// Assert
|
||||
result.ParsedAt.Should().BeAfter(before);
|
||||
result.ParsedAt.Should().BeBefore(after);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_DuplicateCves_AreNotDuplicated()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"pkg (1.0.0-1) unstable; urgency=low
|
||||
|
||||
* Fix CVE-2024-1234
|
||||
* Additional fix for CVE-2024-1234
|
||||
|
||||
-- Dev <dev@example.com> Mon, 01 Jan 2024 12:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].CveIds.Should().HaveCount(1);
|
||||
result.Entries[0].CveIds.Should().ContainSingle("CVE-2024-1234");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseRpmChangelog_MultipleEntries_ExtractsOnlyWithCves()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"* Mon Jan 15 2024 Dev <dev@example.com> - 1.2.0-1
|
||||
- Fix CVE-2024-1111
|
||||
|
||||
* Sun Jan 14 2024 Dev <dev@example.com> - 1.1.0-1
|
||||
- Regular update, no CVE";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseRpmChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].Version.Should().Be("1.2.0-1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseDebianChangelog_DescriptionContainsCveReference_IsCaptured()
|
||||
{
|
||||
// Arrange
|
||||
var changelog = @"pkg (1.0.0-1) unstable; urgency=high
|
||||
|
||||
* Security update addressing CVE-2024-ABCD
|
||||
* Fixes buffer overflow in parsing function
|
||||
|
||||
-- Dev <dev@example.com> Mon, 01 Jan 2024 12:00:00 +0000";
|
||||
|
||||
// Act
|
||||
var result = ChangelogParser.ParseDebianChangelog(changelog);
|
||||
|
||||
// Assert
|
||||
result.Entries.Should().HaveCount(1);
|
||||
result.Entries[0].Description.Should().Contain("CVE-2024-ABCD");
|
||||
result.Entries[0].Description.Should().Contain("buffer overflow");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
namespace StellaOps.Concelier.SourceIntel.Tests;
|
||||
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.SourceIntel;
|
||||
using Xunit;
|
||||
|
||||
public sealed class PatchHeaderParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void ParsePatchFile_Dep3FormatWithCve_ExtractsCveAndMetadata()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Fix buffer overflow vulnerability
|
||||
This patch addresses CVE-2024-1234 by validating input length
|
||||
Origin: upstream, https://example.com/commit/abc123
|
||||
Bug: https://bugs.example.com/12345
|
||||
Bug-Debian: https://bugs.debian.org/67890
|
||||
|
||||
--- a/src/file.c
|
||||
+++ b/src/file.c
|
||||
@@ -10,3 +10,4 @@
|
||||
context
|
||||
+fixed line";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "CVE-2024-1234.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().ContainSingle("CVE-2024-1234");
|
||||
result.Description.Should().Contain("buffer overflow");
|
||||
result.Origin.Should().Contain("upstream");
|
||||
result.BugReferences.Should().HaveCount(2);
|
||||
result.Confidence.Should().BeGreaterThan(0.80);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_MultipleCves_ExtractsAll()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Security fixes for CVE-2024-1111 and CVE-2024-2222
|
||||
Origin: upstream
|
||||
|
||||
--- a/file.c
|
||||
+++ b/file.c
|
||||
@@ -1,1 +1,2 @@
|
||||
+fix";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "multi-cve.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().HaveCount(2);
|
||||
result.CveIds.Should().Contain("CVE-2024-1111");
|
||||
result.CveIds.Should().Contain("CVE-2024-2222");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_CveInFilename_ExtractsFromFilename()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Security fix
|
||||
Origin: upstream
|
||||
|
||||
--- a/file.c
|
||||
+++ b/file.c
|
||||
@@ -1,1 +1,2 @@
|
||||
+fix";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "patches/CVE-2024-9999.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().ContainSingle("CVE-2024-9999");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_CveInBothHeaderAndFilename_ExtractsBoth()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Fix for CVE-2024-1111
|
||||
Origin: upstream
|
||||
|
||||
--- a/file.c
|
||||
+++ b/file.c
|
||||
@@ -1,1 +1,2 @@
|
||||
+fix";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "CVE-2024-2222.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().HaveCount(2);
|
||||
result.CveIds.Should().Contain("CVE-2024-1111");
|
||||
result.CveIds.Should().Contain("CVE-2024-2222");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_BugReferences_ExtractsFromMultipleSources()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Security fix
|
||||
Bug: https://example.com/bug1
|
||||
Bug-Debian: https://bugs.debian.org/123
|
||||
Bug-Ubuntu: https://launchpad.net/456
|
||||
|
||||
--- a/file.c
|
||||
+++ b/file.c";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "test.patch");
|
||||
|
||||
// Assert
|
||||
result.BugReferences.Should().HaveCount(3);
|
||||
result.BugReferences.Should().Contain(b => b.Contains("example.com"));
|
||||
result.BugReferences.Should().Contain(b => b.Contains("debian.org"));
|
||||
result.BugReferences.Should().Contain(b => b.Contains("launchpad.net"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_ConfidenceCalculation_IncreasesWithMoreEvidence()
|
||||
{
|
||||
// Arrange
|
||||
var patchMinimal = @"Description: Fix
|
||||
--- a/file.c";
|
||||
|
||||
var patchDetailed = @"Description: Detailed security fix for memory corruption vulnerability
|
||||
This patch addresses a critical buffer overflow that could lead to remote
|
||||
code execution. The fix validates all input before processing.
|
||||
Origin: upstream, https://github.com/example/repo/commit/abc123
|
||||
Bug: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-1234
|
||||
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var resultMinimal = PatchHeaderParser.ParsePatchFile(patchMinimal, "CVE-2024-1234.patch");
|
||||
var resultDetailed = PatchHeaderParser.ParsePatchFile(patchDetailed, "CVE-2024-1234.patch");
|
||||
|
||||
// Assert
|
||||
resultDetailed.Confidence.Should().BeGreaterThan(resultMinimal.Confidence);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_MultipleCvesInHeader_IncreasesConfidence()
|
||||
{
|
||||
// Arrange
|
||||
var patchSingle = @"Description: Fix CVE-2024-1111
|
||||
Origin: upstream
|
||||
--- a/file.c";
|
||||
|
||||
var patchMultiple = @"Description: Fix CVE-2024-1111 and CVE-2024-2222
|
||||
Origin: upstream
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var resultSingle = PatchHeaderParser.ParsePatchFile(patchSingle, "test.patch");
|
||||
var resultMultiple = PatchHeaderParser.ParsePatchFile(patchMultiple, "test.patch");
|
||||
|
||||
// Assert
|
||||
resultMultiple.Confidence.Should().BeGreaterThan(resultSingle.Confidence);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_UpstreamOrigin_IncreasesConfidence()
|
||||
{
|
||||
// Arrange
|
||||
var patchNoOrigin = @"Description: Fix CVE-2024-1234
|
||||
--- a/file.c";
|
||||
|
||||
var patchUpstream = @"Description: Fix CVE-2024-1234
|
||||
Origin: upstream
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var resultNoOrigin = PatchHeaderParser.ParsePatchFile(patchNoOrigin, "test.patch");
|
||||
var resultUpstream = PatchHeaderParser.ParsePatchFile(patchUpstream, "test.patch");
|
||||
|
||||
// Assert
|
||||
resultUpstream.Confidence.Should().BeGreaterThan(resultNoOrigin.Confidence);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_StopsAtDiffContent_DoesNotParseBody()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Security fix
|
||||
Origin: upstream
|
||||
|
||||
--- a/src/file.c
|
||||
+++ b/src/file.c
|
||||
@@ -10,3 +10,4 @@
|
||||
context line
|
||||
+// This mentions CVE-9999-9999 but should not be extracted
|
||||
context line";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "test.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().NotContain("CVE-9999-9999");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_NoCves_ReturnsEmptyCveList()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Regular update
|
||||
Origin: vendor
|
||||
|
||||
--- a/file.c
|
||||
+++ b/file.c";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "regular.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().BeEmpty();
|
||||
result.Confidence.Should().Be(0.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_ConfidenceCappedAt95Percent()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Extremely detailed security fix with multiple CVE references
|
||||
CVE-2024-1111 CVE-2024-2222 CVE-2024-3333 CVE-2024-4444
|
||||
Very long description to ensure confidence bonus
|
||||
Origin: upstream, backported from mainline
|
||||
Bug: https://example.com/1
|
||||
Bug-Debian: https://debian.org/2
|
||||
Bug-Ubuntu: https://ubuntu.com/3
|
||||
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "CVE-2024-5555.patch");
|
||||
|
||||
// Assert
|
||||
result.Confidence.Should().BeLessOrEqualTo(0.95);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchDirectory_MultiplePatches_FiltersOnlyWithCves()
|
||||
{
|
||||
// Arrange - This would need filesystem setup, skipping actual implementation
|
||||
// Just documenting expected behavior:
|
||||
// Given a directory with patches, only those containing CVE references should be returned
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_ParsedAtTimestamp_IsRecorded()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Fix CVE-2024-1234
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var before = DateTimeOffset.UtcNow.AddSeconds(-1);
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "test.patch");
|
||||
var after = DateTimeOffset.UtcNow.AddSeconds(1);
|
||||
|
||||
// Assert
|
||||
result.ParsedAt.Should().BeAfter(before);
|
||||
result.ParsedAt.Should().BeBefore(after);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParsePatchFile_DuplicateCves_AreNotDuplicated()
|
||||
{
|
||||
// Arrange
|
||||
var patch = @"Description: Fix CVE-2024-1234 and CVE-2024-1234 again
|
||||
Origin: upstream
|
||||
|
||||
--- a/file.c";
|
||||
|
||||
// Act
|
||||
var result = PatchHeaderParser.ParsePatchFile(patch, "CVE-2024-1234.patch");
|
||||
|
||||
// Assert
|
||||
result.CveIds.Should().HaveCount(1);
|
||||
result.CveIds.Should().ContainSingle("CVE-2024-1234");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\__Libraries\StellaOps.Concelier.SourceIntel\StellaOps.Concelier.SourceIntel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user