JamieMagee/openvex.net
GitHub: JamieMagee/openvex.net
为 .NET 开发者提供 OpenVEX 文档的强类型支持,简化漏洞适用性声明的创建与解析。
Stars: 1 | Forks: 1
# OpenVEX.NET
[]( )
[]( )
用于 [OpenVEX 文档][1] 的 .NET 类型
## 什么是 VEX?
**漏洞利用性交换 (VEX)** 是一种漏洞文档格式,旨在补充软件物料清单 (SBOM),告知软件产品的用户一个或多个漏洞发现的适用性。
安全扫描器通常会检测并标记软件中已被识别为存在漏洞的组件。然而,由于各种原因,软件实际上可能不会受到这些漏洞的影响:
- 易受攻击的组件可能已被修补
- 易受攻击的代码可能不存在于最终产品中
- 易受攻击的代码路径在特定上下文中可能无法执行
VEX 文档通过提供关于哪些漏洞实际上影响特定产品的权威信息,有助于减少误报。
## 什么是 OpenVEX?
**OpenVEX** 是 VEX 规范的一个最小化、合规、可互操作且可嵌入的实现。它具有以下特点:
- **SBOM 无关**:适用于任何 SBOM 格式(SPDX、CycloneDX 等)
- **最小化**:专注于 CISA 定义的核心 VEX 用例
- **可互操作**:与其他 VEX 实现兼容
- **可嵌入**:可以集成到各种安全工具链中
OpenVEX 文档是 JSON-LD 文件,包含表达漏洞与产品之间关系的漏洞声明。
## 安装
将 OpenVEX 包添加到您的 .NET 项目中:
```
dotnet add package OpenVEX
```
## 用法
### 创建 VEX 文档
```
using OpenVEX;
using System.Text.Json;
var vex = new Vex
{
Context = "https://openvex.dev/ns/v0.2.0",
Id = "https://example.com/vex/my-vex-document",
Author = "security@example.com",
AuthorRole = "Security Team",
Timestamp = DateTimeOffset.UtcNow,
Version = "1",
Statements = new[]
{
new Statement
{
Vulnerability = new Vulnerability { Name = "CVE-2023-12345" },
Products = new[]
{
new Product { Id = "pkg:npm/my-package@1.0.0" }
},
Status = Status.NotAffected,
Justification = Justification.VulnerableCodeNotPresent,
StatusNotes = "This vulnerability affects a dependency that is not included in our build."
}
}
};
// Serialize to JSON
var json = JsonSerializer.Serialize(vex, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(json);
```
### 读取 VEX 文档
```
using OpenVEX;
using System.Text.Json;
// Deserialize from JSON
var json = File.ReadAllText("my-vex-document.json");
var vex = JsonSerializer.Deserialize(json);
// Access the data
Console.WriteLine($"VEX Document: {vex.Id}");
Console.WriteLine($"Author: {vex.Author}");
Console.WriteLine($"Statements: {vex.Statements.Count()}");
foreach (var statement in vex.Statements)
{
Console.WriteLine($" Vulnerability: {statement.Vulnerability.Name}");
Console.WriteLine($" Status: {statement.Status}");
if (statement.Justification.HasValue)
{
Console.WriteLine($" Justification: {statement.Justification}");
}
}
```
### VEX 声明状态
OpenVEX 规范定义了漏洞的四种可能状态:
- **`NotAffected`**:产品不受该漏洞影响
- **`Affected`**:产品受该漏洞影响
- **`Fixed`**:该漏洞在此版本中已修复
- **`UnderInvestigation`**:尚不清楚产品是否受影响
### 使用 Products
VEX 文档中的 Products 使用 [Package URLs (PURL)](https://github.com/package-url/purl-spec) 进行标识:
```
var statement = new Statement
{
Vulnerability = new Vulnerability { Name = "CVE-2023-12345" },
Products = new[]
{
new Product
{
Id = "pkg:npm/lodash@4.17.20",
Identifiers = new Dictionary
{
["purl"] = "pkg:npm/lodash@4.17.20",
["cpe23"] = "cpe:2.3:a:lodash:lodash:4.17.20:*:*:*:*:node.js:*:*"
},
Hashes = new Dictionary
{
["sha-256"] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
}
},
Status = Status.Fixed
};
```
## 许可证
此仓库中的所有包均根据 [MIT 许可证](https://opensource.org/licenses/MIT) 授权。
标签:CISA, CycloneDX, DevSecOps, GPT, JSON-LD, NuGet, OpenVEX, SBOM, SPDX, VEX, 上游代理, 多人体追踪, 安全合规, 库, 应急响应, 漏洞利用性交换, 漏洞管理, 硬件无关, 类型定义, 网络代理, 网络安全, 误报处理, 跌倒检测, 软件物料清单, 隐私保护