> ## 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` は検出した問題ごとに 1 つずつストリームで送出します。

```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` は、偽のエポック時刻として送られるのではなく、送信データから省略されます。ツールが時刻を提供しない場合は未設定のままにしてください。

## 検証

すべての検出結果は送信前に検証されます。無効な検出結果は **ノイズではなくプロトコル違反** であり、実行は停止して致命的なエラーを報告します。

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

ルール:

* `Name` は必須です。
* `Severity` は許可された 5 つの値のいずれかである必要があります。

## 深刻度

`Severity` は閉じた集合です。それ以外の値は検証に失敗します。

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

## 深刻度のマッピング

ツール独自の尺度を、明示的な対応表で 5 つの値の enum に集約します。推測は禁物です。また、マッピングされていない値を `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]
>
> スキャナーが enum 外の深刻度（たとえば nuclei の `unknown`）を出力した場合は、検出結果を捨てずに `info` にマッピングしてください。カタログはすべての検出結果の値を厳格に扱います。アダプターの境界で正規化してください。

## 出力を検出結果にマッピングする

ツールの生の結果 1 件を `connector.Finding` にマッピングする `toFinding` 関数を 1 つ用意します。使える名前のない結果にはエラーを返し、呼び出し側が実行全体を失敗させずにそれをスキップできるようにします。

```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.