up
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-12-13 00:20:26 +02:00
parent e1f1bef4c1
commit 564df71bfb
2376 changed files with 334389 additions and 328032 deletions

View File

@@ -1,73 +1,73 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Logging.Abstractions;
using StellaOps.Concelier.Connector.Vndr.Cisco.Internal;
using Xunit;
namespace StellaOps.Concelier.Connector.Vndr.Cisco.Tests;
public sealed class CiscoDtoFactoryTests
{
[Fact]
public async Task CreateAsync_MergesRawAndCsafProducts()
{
const string CsafPayload = @"
{
""product_tree"": {
""full_product_names"": [
{ ""product_id"": ""PID-1"", ""name"": ""Cisco Widget"" }
]
},
""vulnerabilities"": [
{
""product_status"": {
""known_affected"": [""PID-1""]
}
}
]
}";
var csafClient = new StubCsafClient(CsafPayload);
var factory = new CiscoDtoFactory(csafClient, NullLogger<CiscoDtoFactory>.Instance);
var raw = new CiscoRawAdvisory
{
AdvisoryId = "CISCO-SA-TEST",
AdvisoryTitle = "Test Advisory",
Summary = "Summary",
Sir = "High",
FirstPublished = "2025-10-01T00:00:00Z",
LastUpdated = "2025-10-02T00:00:00Z",
PublicationUrl = "https://example.com/advisory",
CsafUrl = "https://sec.cloudapps.cisco.com/csaf/test.json",
Cves = new List<string> { "CVE-2024-0001" },
BugIds = new List<string> { "BUG123" },
ProductNames = new List<string> { "Cisco Widget" },
Version = "1.2.3",
CvssBaseScore = "9.8"
};
var dto = await factory.CreateAsync(raw, CancellationToken.None);
dto.Should().NotBeNull();
dto.Severity.Should().Be("high");
dto.CvssBaseScore.Should().Be(9.8);
dto.Products.Should().HaveCount(1);
var product = dto.Products[0];
product.Name.Should().Be("Cisco Widget");
product.ProductId.Should().Be("PID-1");
product.Statuses.Should().Contain("known_affected");
}
private sealed class StubCsafClient : ICiscoCsafClient
{
private readonly string? _payload;
public StubCsafClient(string? payload) => _payload = payload;
public Task<string?> TryFetchAsync(string? url, CancellationToken cancellationToken)
=> Task.FromResult(_payload);
}
}
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Logging.Abstractions;
using StellaOps.Concelier.Connector.Vndr.Cisco.Internal;
using Xunit;
namespace StellaOps.Concelier.Connector.Vndr.Cisco.Tests;
public sealed class CiscoDtoFactoryTests
{
[Fact]
public async Task CreateAsync_MergesRawAndCsafProducts()
{
const string CsafPayload = @"
{
""product_tree"": {
""full_product_names"": [
{ ""product_id"": ""PID-1"", ""name"": ""Cisco Widget"" }
]
},
""vulnerabilities"": [
{
""product_status"": {
""known_affected"": [""PID-1""]
}
}
]
}";
var csafClient = new StubCsafClient(CsafPayload);
var factory = new CiscoDtoFactory(csafClient, NullLogger<CiscoDtoFactory>.Instance);
var raw = new CiscoRawAdvisory
{
AdvisoryId = "CISCO-SA-TEST",
AdvisoryTitle = "Test Advisory",
Summary = "Summary",
Sir = "High",
FirstPublished = "2025-10-01T00:00:00Z",
LastUpdated = "2025-10-02T00:00:00Z",
PublicationUrl = "https://example.com/advisory",
CsafUrl = "https://sec.cloudapps.cisco.com/csaf/test.json",
Cves = new List<string> { "CVE-2024-0001" },
BugIds = new List<string> { "BUG123" },
ProductNames = new List<string> { "Cisco Widget" },
Version = "1.2.3",
CvssBaseScore = "9.8"
};
var dto = await factory.CreateAsync(raw, CancellationToken.None);
dto.Should().NotBeNull();
dto.Severity.Should().Be("high");
dto.CvssBaseScore.Should().Be(9.8);
dto.Products.Should().HaveCount(1);
var product = dto.Products[0];
product.Name.Should().Be("Cisco Widget");
product.ProductId.Should().Be("PID-1");
product.Statuses.Should().Contain("known_affected");
}
private sealed class StubCsafClient : ICiscoCsafClient
{
private readonly string? _payload;
public StubCsafClient(string? payload) => _payload = payload;
public Task<string?> TryFetchAsync(string? url, CancellationToken cancellationToken)
=> Task.FromResult(_payload);
}
}

View File

@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using StellaOps.Concelier.Bson;
using StellaOps.Concelier.Documents;
using StellaOps.Concelier.Models;
using StellaOps.Concelier.Connector.Common;
using StellaOps.Concelier.Connector.Vndr.Cisco;
@@ -54,7 +54,7 @@ public sealed class CiscoMapperTests
LastModified: updated,
PayloadId: null);
var dtoRecord = new DtoRecord(Guid.NewGuid(), document.Id, VndrCiscoConnectorPlugin.SourceName, "cisco.dto.test", new BsonDocument(), updated);
var dtoRecord = new DtoRecord(Guid.NewGuid(), document.Id, VndrCiscoConnectorPlugin.SourceName, "cisco.dto.test", new DocumentObject(), updated);
var advisory = CiscoMapper.Map(dto, document, dtoRecord);