tam
This commit is contained in:
		| @@ -0,0 +1,43 @@ | ||||
| using System.Text.Json; | ||||
| using StellaOps.Feedser.Source.Ru.Nkcki.Internal; | ||||
| using Xunit; | ||||
|  | ||||
| namespace StellaOps.Feedser.Source.Ru.Nkcki.Tests; | ||||
|  | ||||
| public sealed class RuNkckiJsonParserTests | ||||
| { | ||||
|     [Fact] | ||||
|     public void Parse_WellFormedEntry_ReturnsDto() | ||||
|     { | ||||
|         const string json = """ | ||||
| { | ||||
|   "vuln_id": {"MITRE": "CVE-2025-0001", "FSTEC": "BDU:2025-00001"}, | ||||
|   "date_published": "2025-09-01", | ||||
|   "date_updated": "2025-09-02", | ||||
|   "cvss_rating": "КРИТИЧЕСКИЙ", | ||||
|   "patch_available": true, | ||||
|   "description": "Test description", | ||||
|   "cwe": {"cwe_number": 79, "cwe_description": "Cross-site scripting"}, | ||||
|   "product_category": "Web", | ||||
|   "mitigation": "Apply update", | ||||
|   "vulnerable_software": {"software_text": "ExampleApp 1.0", "cpe": false}, | ||||
|   "cvss": {"cvss_score": 8.8, "cvss_vector": "AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "cvss_score_v4": 5.5, "cvss_vector_v4": "AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H"}, | ||||
|   "impact": "ACE", | ||||
|   "method_of_exploitation": "Special request", | ||||
|   "user_interaction": false, | ||||
|   "urls": ["https://example.com/advisory", "https://cert.gov.ru/materialy/uyazvimosti/2025-00001"] | ||||
| } | ||||
| """; | ||||
|  | ||||
|         using var document = JsonDocument.Parse(json); | ||||
|         var dto = RuNkckiJsonParser.Parse(document.RootElement); | ||||
|  | ||||
|         Assert.Equal("BDU:2025-00001", dto.FstecId); | ||||
|         Assert.Equal("CVE-2025-0001", dto.MitreId); | ||||
|         Assert.Equal(8.8, dto.CvssScore); | ||||
|         Assert.Equal("AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", dto.CvssVector); | ||||
|         Assert.True(dto.PatchAvailable); | ||||
|         Assert.Equal(79, dto.Cwe?.Number); | ||||
|         Assert.Equal(2, dto.Urls.Length); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,13 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>net10.0</TargetFramework> | ||||
|     <ImplicitUsings>enable</ImplicitUsings> | ||||
|     <Nullable>enable</Nullable> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="../StellaOps.Feedser.Models/StellaOps.Feedser.Models.csproj" /> | ||||
|     <ProjectReference Include="../StellaOps.Feedser.Normalization/StellaOps.Feedser.Normalization.csproj" /> | ||||
|     <ProjectReference Include="../StellaOps.Feedser.Source.Ru.Nkcki/StellaOps.Feedser.Source.Ru.Nkcki.csproj" /> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
		Reference in New Issue
	
	Block a user