> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oasm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Finding

> 每个适配器输出的标准输出项：字段、校验规则和严重级别映射

`Finding` 是标准输出项。`Execute` 为每个检测到的问题流式输出一个 `Finding`。

```go theme={null}
package connector

type Finding struct {
    Name        string
    Severity    string
    Description string
    Tags        []string
    References  []string
    CVEID       []string
    CWEID       []string
    CVSSScore   float64
    CVSSMetrics string
    EPSSScore   float64
    Solution    string
    MatchedAt   string
    Host        string
    IP          string
    Timestamp   time.Time

    Synopsis         string
    Ports            []string
    Authors          []string
    VPRScore         float64
    BIDID            []string
    CEAID            []string
    IAVAID           []string
    PublicationDate  time.Time
    ModificationDate time.Time
    Confidence       float64
}
```

## 字段

| 分组 | 字段 |
| - | - |
| 标识 | `Name`, `Severity`, `Timestamp` |
| 内容 | `Description`, `Solution`, `Tags`, `References` |
| 评分 | `CVEID`, `CWEID`, `CVSSScore`, `CVSSMetrics`, `EPSSScore`, `VPRScore` |
| 位置 | `MatchedAt`, `Host`, `IP` |
| 扫描器特有 | `Synopsis`, `Ports`, `Authors`, `BIDID`, `CEAID`, `IAVAID`, `PublicationDate`, `ModificationDate`, `Confidence` |

零值 `Timestamp` 在传输时会被省略，而不是作为虚假的 epoch 时间发送。当工具未提供时间戳时，请保持未设置。

## 校验

每个发现在传输前都会经过校验。无效的发现属于 **协议违规，而不是噪声**：运行会停止并报告致命错误。

```go theme={null}
func (f Finding) Validate() error
```

规则：

* `Name` 为必填项。
* `Severity` 必须是五个允许值之一。

## 严重级别

`Severity` 是一个封闭集合。其他任何值都无法通过校验。

```go theme={null}
var Severities = []string{"info", "low", "medium", "high", "critical"}
```

## 映射严重级别

使用明确的映射表，将工具自身的等级归并到这五个枚举值上。不要猜测，也绝不能让未映射的值到达 `Validate`，否则会中断整个流。

```go theme={null}
func normalizeSeverity(s string) string {
    switch strings.ToLower(strings.TrimSpace(s)) {
    case "info", "low", "medium", "high", "critical":
        return strings.ToLower(strings.TrimSpace(s))
    case "unknown", "informational":
        return "info"
    default:
        return "info"
    }
}
```

> [!TIP]
>
> 当扫描器输出枚举之外的严重级别（例如 nuclei 的 `unknown`）时，请将其映射为 `info`，而不是丢弃该发现。目录对每个发现的值都严格校验；请在适配器边界处进行规范化。

## 将输出映射为发现

保留一个单独的 `toFinding` 函数，将一条原始工具结果映射为 `connector.Finding`。对于没有可用名称的结果返回错误，以便调用方跳过它们，而不是使整个运行失败。

```go theme={null}
func toFinding(raw ToolResult) (connector.Finding, error) {
    if raw.Name == "" {
        return connector.Finding{}, fmt.Errorf("finding has no name")
    }
    return connector.Finding{
        Name:        raw.Name,
        Severity:    normalizeSeverity(raw.Severity),
        Description: raw.Description,
        Solution:    raw.Remediation,
        MatchedAt:   raw.Matched,
        Host:        raw.Host,
        IP:          raw.IP,
        Tags:        raw.Tags,
        References:  raw.References,
        CVEID:       raw.CVEs,
        CWEID:       raw.CWEs,
        CVSSScore:   raw.CVSSScore,
        CVSSMetrics: raw.CVSSVector,
        Timestamp:   raw.Timestamp,
    }, nil
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.