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

# 连接器

> 将外部安全工具封装在统一的契约之后，使 OASM 能够调度它并收集发现结果

**连接器**将一个外部安全工具封装在统一的契约之后。它恰好由两部分组成：

* 一个声明式的 **`manifest.yaml`**，描述该工具：名称、能力，以及运维人员提供的输入和配置所对应的 JSON schema。
* 一个 Go **Adapter**，将工具的输出转换为平台标准的 [`Finding`](https://docs.oasm.io/zh/connectors/finding) 流。

同一套骨架适用于各种类型的工具，无论是进程内库、CLI 封装还是远程 API 客户端，因为除了 adapter 之外，没有任何部分需要知道它是哪一种。

> [!NOTE]
>
> 本指南只涵盖你需要编写的**集成层**：manifest、adapter，以及输入/配置的传递。adapter 与平台之间的一切都由 SDK 负责，包括拨号连接、注册、数据流、容器复用和取消，因此你无需接触这些部分。

## 你需要编写的两部分

> [card] manifest.yaml
>
> 声明连接器。在构建时进行校验，未知字段和重复的 slug 会导致构建失败。

> [card] Adapter
>
> 一个包含 `Validate` 和 `Execute` 两个方法的 Go 类型。这是每个连接器唯一必须编写的代码。

## SDK 包

从 `github.com/oasm-platform/oasm-connectors/sdk` 导入 SDK。你只需要三个包。

| 包 | 导入路径 | 提供的功能 |
| - | - | - |
| `connector` | `sdk/connector` | `Adapter` 接口、`Finding` 类型和 `New(adapter)` 封装。 |
| `runtime` | `sdk/runtime` | 用于启动连接器的 `New(connector)` 和 `Run(ctx)`。 |
| `env` | `sdk/env` | 用于读取 `INPUT_*` 默认值的 `LoadInputs()`。 |

> [!WARNING]
>
> 切勿在 adapter 中导入 `sdk/runtime`、`sdk/transport` 或 `sdk/proto` 的内部实现。adapter 包必须只包含与工具相关的代码。

## 仓库结构

连接器位于一个多模块的 Go monorepo 中。每个连接器都是一个独立模块，通过本地 `replace` 指令使用 SDK。

```text theme={null}
.
├── sdk/                      the connector SDK (imported by every connector)
├── <category>/<slug>/        one module per connector
│   ├── manifest.yaml         the connector contract (required)
│   ├── logo.png              optional icon, inlined into manifest.json
│   ├── Dockerfile            build context is the repo root
│   ├── main.go               wiring only
│   └── adapter.go            the tool-specific code
├── manifest.json             generated — never hand-edit
├── go.work                   unifies every module for root-level tooling
└── Taskfile.yml              task runner entry points
```

分类目录用于在目录中对连接器分组，并与连接器的 `capabilities` 条目一致：`vulnerabilities`、`ports_scanner` 或 `url_discovery`。

> [!NOTE]
>
> 为某个连接器添加的依赖只会出现在该连接器的 `go.mod` 中。切勿把特定于工具的依赖提升到 SDK 中。

## 后续步骤

> [card] [快速入门](https://docs.oasm.io/zh/connectors/quickstart.md)
>
> 端到端构建一个最小的连接器。

> [card] [Adapter 参考](https://docs.oasm.io/zh/connectors/adapter.md)
>
> `Validate` 和 `Execute` 方法详解。

> [card] [manifest.yaml 参考](https://docs.oasm.io/zh/connectors/manifest.md)
>
> manifest 接受的所有字段。

> [card] [输入与配置](https://docs.oasm.io/zh/connectors/inputs-and-config.md)
>
> 每次运行的输入和配置档案如何传递到你的 adapter。


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