tam
This commit is contained in:
		@@ -0,0 +1,58 @@
 | 
			
		||||
using System.Xml.Linq;
 | 
			
		||||
using StellaOps.Feedser.Source.Ru.Bdu.Internal;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace StellaOps.Feedser.Source.Ru.Bdu.Tests;
 | 
			
		||||
 | 
			
		||||
public sealed class RuBduXmlParserTests
 | 
			
		||||
{
 | 
			
		||||
    [Fact]
 | 
			
		||||
    public void TryParse_ValidElement_ReturnsDto()
 | 
			
		||||
    {
 | 
			
		||||
        const string xml = """
 | 
			
		||||
<vul>
 | 
			
		||||
  <identifier>BDU:2025-12345</identifier>
 | 
			
		||||
  <name>Уязвимость тестового продукта</name>
 | 
			
		||||
  <description>Описание уязвимости</description>
 | 
			
		||||
  <solution>Обновить продукт</solution>
 | 
			
		||||
  <identify_date>2025-10-10</identify_date>
 | 
			
		||||
  <severity>Высокий уровень опасности</severity>
 | 
			
		||||
  <exploit_status>Существует эксплойт</exploit_status>
 | 
			
		||||
  <fix_status>Устранена</fix_status>
 | 
			
		||||
  <vul_status>Подтверждена производителем</vul_status>
 | 
			
		||||
  <vul_incident>1</vul_incident>
 | 
			
		||||
  <cvss>
 | 
			
		||||
    <vector score=\"7.5\">AV:N/AC:L/Au:N/C:P/I:P/A:P</vector>
 | 
			
		||||
  </cvss>
 | 
			
		||||
  <vulnerable_software>
 | 
			
		||||
    <soft>
 | 
			
		||||
      <vendor>ООО «Вендор»</vendor>
 | 
			
		||||
      <name>Продукт</name>
 | 
			
		||||
      <version>1.2.3</version>
 | 
			
		||||
      <platform>Windows</platform>
 | 
			
		||||
      <types>
 | 
			
		||||
        <type>ics</type>
 | 
			
		||||
      </types>
 | 
			
		||||
    </soft>
 | 
			
		||||
  </vulnerable_software>
 | 
			
		||||
  <cwes>
 | 
			
		||||
    <cwe>
 | 
			
		||||
      <identifier>CWE-79</identifier>
 | 
			
		||||
      <name>XSS</name>
 | 
			
		||||
    </cwe>
 | 
			
		||||
  </cwes>
 | 
			
		||||
</vul>
 | 
			
		||||
""";
 | 
			
		||||
 | 
			
		||||
        var element = XElement.Parse(xml);
 | 
			
		||||
        var dto = RuBduXmlParser.TryParse(element);
 | 
			
		||||
 | 
			
		||||
        Assert.NotNull(dto);
 | 
			
		||||
        Assert.Equal("BDU:2025-12345", dto!.Identifier);
 | 
			
		||||
        Assert.Equal("Уязвимость тестового продукта", dto.Name);
 | 
			
		||||
        Assert.Equal("AV:N/AC:L/Au:N/C:P/I:P/A:P", dto.CvssVector);
 | 
			
		||||
        Assert.Equal(7.5, dto.CvssScore);
 | 
			
		||||
        Assert.Single(dto.Software);
 | 
			
		||||
        Assert.Single(dto.Cwes);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user