Skip to content

Commit 5ac3f1d

Browse files
committed
docs: update docs
1 parent 4645a51 commit 5ac3f1d

14 files changed

Lines changed: 155 additions & 69 deletions

README-zhCN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ http://yourserver:9000/hooks/redeploy-webhook
185185

186186
## 关于此 Fork
187187

188-
本项目是原始 [webhook](https://github.com/adnanh/webhook) 项目的维护分支,专注于:
188+
本项目是原始 [webhook](https://github.com/adnanh/webhook) 项目的维护分支。当前支持版本为 5.x,版本支持情况见 [SECURITY.md](SECURITY.md)
189+
190+
该分支专注于:
189191

190192
- **安全性**:定期安全更新、漏洞修复和增强的安全功能
191193
- **维护性**:积极开发、依赖更新和错误修复

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ For more examples and use cases, check out [Hook Examples](docs/en-US/Hook-Examp
185185

186186
## About This Fork
187187

188-
This project is a maintained fork of the original [webhook](https://github.com/adnanh/webhook) project, focused on:
188+
This project is a maintained fork of the original [webhook](https://github.com/adnanh/webhook) project. Current supported versions are 5.x; see [SECURITY.md](SECURITY.md) for the version support table.
189+
190+
The fork is focused on:
189191

190192
- **Security**: Regular security updates, vulnerability fixes, and enhanced security features
191193
- **Maintenance**: Active development, dependency updates, and bug fixes

SECURITY.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ Current support status of each version.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 3.4.x | :white_check_mark: |
10-
| < 3.4.1 | :x: |
9+
| 5.x | :white_check_mark: |
10+
| < 5.0 | :x: |
1111

1212
## Security Features
1313

1414
### Command Injection Protection
1515

1616
Webhook includes several security features to help prevent command injection attacks:
1717

18-
1. **Command Path Whitelist**: Use `--allowed-command-paths` (or `ALLOWED_COMMAND_PATHS` environment variable) to restrict which commands can be executed. Only commands from the whitelist will be allowed to run.
18+
1. **Command Path Whitelist**: Use `-allowed-command-paths` (or `ALLOWED_COMMAND_PATHS` environment variable) to restrict which commands can be executed. Only commands from the whitelist will be allowed to run.
1919

2020
2. **Argument Validation**:
21-
- `--max-arg-length`: Limit the maximum length of a single argument (default: 1MB)
22-
- `--max-total-args-length`: Limit the total length of all arguments (default: 10MB)
23-
- `--max-args-count`: Limit the maximum number of arguments (default: 1000)
21+
- `-max-arg-length`: Limit the maximum length of a single argument (default: 1MB)
22+
- `-max-total-args-length`: Limit the total length of all arguments (default: 10MB)
23+
- `-max-args-count`: Limit the maximum number of arguments (default: 1000)
2424

25-
3. **Strict Mode**: Enable `--strict-mode` to reject arguments containing potentially dangerous characters (shell special characters like `;`, `|`, `&`, `` ` ``, `$`, etc.)
25+
3. **Strict Mode**: Enable `-strict-mode` to reject arguments containing potentially dangerous characters (shell special characters like `;`, `|`, `&`, `` ` ``, `$`, etc.)
2626

2727
4. **Secure Logging**: All command executions are logged with sensitive information (passwords, tokens, keys) automatically sanitized.
2828

@@ -31,8 +31,8 @@ Webhook includes several security features to help prevent command injection att
3131
- Enable strict mode for enhanced security
3232
- Set appropriate limits for argument length and count
3333
- Regularly review and update your whitelist
34-
- Never enable `--allow-auto-chmod` in production (it's a security risk)
35-
- Do not enable `--openapi` or `--config-ui` on publicly reachable servers (they have no authentication; use only for debugging or intranet). Config UI is mounted on the webhook server; restrict access with firewall/reverse proxy.
34+
- Never enable `-allow-auto-chmod` in production (it's a security risk)
35+
- Do not enable `-openapi` or `-config-ui` on publicly reachable servers (they have no authentication; use only for debugging or intranet). Config UI is mounted on the webhook server; restrict access with firewall/reverse proxy.
3636

3737
For more details, see the [Webhook Parameters (English)](docs/en-US/Webhook-Parameters.md) or [配置参数 (中文)](docs/zh-CN/Webhook-Parameters.md).
3838

cmd/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ go build -o webhook .
6565

6666
- 本程序复用 [internal/configui](../internal/configui) 包,静态资源与页面配置仅在该包内维护一份(`internal/configui/config/``internal/configui/static/`),通过包内 `embed` 打入二进制,单二进制即可运行。
6767
- 页面配置来自 `internal/configui/config/page.yaml`(i18n 与表单结构)。
68-
- 生成 API:`POST /api/generate`,请求体为表单对应 JSON,响应为 `{ "yaml", "json", "callUrl", "curlExample" }`;错误时返回 `{ "error": "..." }` 及 4xx 状态码。
68+
- 生成 API:`POST {config-ui-path}/api/generate`,请求体为表单对应 JSON,响应为 `{ "yaml", "json", "callUrl", "curlExample" }`;错误时返回 `{ "error": "..." }` 及 4xx 状态码。此外还有 `GET {config-ui-path}/api/capabilities`(返回是否支持保存到目录)与 `POST {config-ui-path}/api/save`(将配置写入 hooks 目录)。完整端点说明见 [API 参考](../docs/zh-CN/API-Reference.md)(Config UI 章节)
6969

7070
## 故障排查
7171

docs/en-US/API-Reference.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ http://your-server:9000
1212

1313
You can customize the IP address and port using the `-ip` and `-port` command-line arguments or environment variables.
1414

15+
**Reserved paths and path conflicts:** Do not set `-openapi-path` or `-config-ui-path` to a path that conflicts with reserved endpoints. Reserved paths include `/`, `/health`, `/livez`, `/readyz`, `/version`, `/metrics`, and the hook base path (e.g. `/hooks`). If a conflict is detected at startup, the server will skip registering that route and log a warning.
16+
1517
## Endpoints
1618

1719
### 1. Root Endpoint
@@ -53,9 +55,48 @@ curl http://localhost:9000/
5355
curl http://localhost:9000/health
5456
```
5557

58+
**Note:** The exact JSON structure is defined by the health check library (e.g. it may include multiple check results). For the precise schema, see the OpenAPI spec when `-openapi` is enabled.
59+
60+
---
61+
62+
### 3. Liveness and Readiness Endpoints
63+
64+
**Endpoints:** `GET /livez`, `GET /readyz`
65+
66+
**Description:** Kubernetes-style liveness and readiness probes. `/livez` indicates the process is running; `/readyz` reports whether the server is ready to accept traffic (e.g. after loading hooks).
67+
68+
**Response:**
69+
- **Status Code:** `200 OK` when healthy/ready; non-2xx when not.
70+
- **Content-Type:** `application/json`
71+
- **Body:** Implementation-defined JSON (see OpenAPI spec for schema when `-openapi` is enabled).
72+
73+
**Example:**
74+
```bash
75+
curl http://localhost:9000/livez
76+
curl http://localhost:9000/readyz
77+
```
78+
79+
---
80+
81+
### 4. Version Endpoint
82+
83+
**Endpoint:** `GET /version`
84+
85+
**Description:** Returns server version and build information in JSON format, with optional `X-`-prefixed response headers for version details.
86+
87+
**Response:**
88+
- **Status Code:** `200 OK`
89+
- **Content-Type:** `application/json`
90+
- **Body:** JSON with version fields (e.g. `version`, `commit`, `buildDate`, `branch`). Exact structure is defined by the version library; use the OpenAPI spec when `-openapi` is enabled for the full schema.
91+
92+
**Example:**
93+
```bash
94+
curl http://localhost:9000/version
95+
```
96+
5697
---
5798

58-
### 3. Metrics Endpoint
99+
### 5. Metrics Endpoint
59100

60101
**Endpoint:** `GET /metrics`
61102

@@ -81,7 +122,7 @@ curl http://localhost:9000/metrics
81122

82123
---
83124

84-
### 4. OpenAPI Specification Endpoint (Optional)
125+
### 6. OpenAPI Specification Endpoint (Optional)
85126

86127
**Endpoint:** `GET /openapi` (or custom path via `-openapi-path`)
87128

@@ -107,7 +148,7 @@ You can also print the spec to stdout at startup with `-openapi-print` (e.g. `./
107148

108149
---
109150

110-
### 5. Config UI (Optional)
151+
### 7. Config UI (Optional)
111152

112153
**Endpoints:** `GET /config-ui`, `GET /config-ui/`, `POST /config-ui/api/generate` (or custom path via `-config-ui-path`)
113154

@@ -130,7 +171,7 @@ You can also print the spec to stdout at startup with `-openapi-print` (e.g. `./
130171

131172
---
132173

133-
### 6. Hook Execution Endpoint
174+
### 8. Hook Execution Endpoint
134175

135176
**Endpoint:** `POST|GET|PUT|DELETE /hooks/{hook-id}`
136177

docs/en-US/Hook-Definition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Hooks are defined as objects in the JSON or YAML hooks configuration file. Pleas
88
* `execute-command` - specifies the command that should be executed when the hook is triggered
99
* `command-working-directory` - specifies the working directory that will be used for the script when it's executed
1010
* `response-message` - specifies the string that will be returned to the hook initiator
11-
* `response-headers` - specifies the list of headers in format `{"name": "X-Example-Header", "value": "it works"}` that will be returned in HTTP response for the hook
11+
* `response-headers` - list of header objects returned in the HTTP response for the hook; each object has `"name"` and `"value"` (e.g. `{"name": "X-Example-Header", "value": "it works"}`)
1212
* `success-http-response-code` - specifies the HTTP status code to be returned upon success
1313
* `incoming-payload-content-type` - sets the `Content-Type` of the incoming HTTP request (ie. `application/json`); useful when the request lacks a `Content-Type` or sends an erroneous value
1414
* `http-methods` - a list of allowed HTTP methods, such as `POST` and `GET`
1515
* `include-command-output-in-response` - boolean whether webhook should wait for the command to finish and return the raw output as a response to the hook initiator. If the command fails to execute or encounters any errors while executing the response will result in 500 Internal Server Error HTTP status code, otherwise the 200 OK status code will be returned.
1616
* `stream-command-output` - boolean whether webhook should stream the command output to the HTTP response. When enabled, the command's `stdout` and `stderr` are streamed in real-time to the client, rather than waiting for the command to finish before returning. This is useful for long-running commands.
17-
* `include-command-output-in-response-on-error` - boolean whether webhook should include command stdout & stderror as a response in failed executions. It only works if `include-command-output-in-response` is set to `true`.
17+
* `include-command-output-in-response-on-error` - boolean whether webhook should include command stdout & stderr as a response in failed executions. It only works if `include-command-output-in-response` is set to `true`.
1818
* `parse-parameters-as-json` - specifies the list of arguments that contain JSON strings. These parameters will be decoded by webhook and you can access them like regular objects in rules and `pass-arguments-to-command`.
1919
* `pass-arguments-to-command` - specifies the list of arguments that will be passed to the command. Check [Referencing request values page](Referencing-Request-Values.md) to see how to reference the values from the request. If you want to pass a static string value to your command you can specify it as
2020
`{ "source": "string", "name": "argumentvalue" }`

docs/en-US/Migration-Guide.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,26 +332,26 @@ docker run -d \
332332
### New Configuration Options
333333

334334
1. **Security:**
335-
- `--allowed-command-paths`
336-
- `--strict-mode`
337-
- `--max-arg-length`
338-
- `--max-total-args-length`
339-
- `--max-args-count`
335+
- `-allowed-command-paths`
336+
- `-strict-mode`
337+
- `-max-arg-length`
338+
- `-max-total-args-length`
339+
- `-max-args-count`
340340

341341
2. **Performance:**
342-
- `--rate-limit-enabled`
343-
- `--rate-limit-rps`
344-
- `--rate-limit-burst`
345-
- `--max-concurrent-hooks`
346-
- `--hook-timeout-seconds`
347-
- `--hook-execution-timeout`
342+
- `-rate-limit-enabled`
343+
- `-rate-limit-rps`
344+
- `-rate-limit-burst`
345+
- `-max-concurrent-hooks`
346+
- `-hook-timeout-seconds`
347+
- `-hook-execution-timeout`
348348

349349
3. **HTTP Server:**
350-
- `--read-header-timeout-seconds`
351-
- `--read-timeout-seconds`
352-
- `--write-timeout-seconds`
353-
- `--idle-timeout-seconds`
354-
- `--max-header-bytes`
350+
- `-read-header-timeout-seconds`
351+
- `-read-timeout-seconds`
352+
- `-write-timeout-seconds`
353+
- `-idle-timeout-seconds`
354+
- `-max-header-bytes`
355355

356356
### Enhanced Features
357357

docs/en-US/Security-Best-Practices.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This document provides comprehensive security best practices for deploying and u
1919

2020
### 1. Use Command Path Whitelist
2121

22-
**Always** use the `--allowed-command-paths` flag in production to restrict which commands can be executed.
22+
**Always** use the `-allowed-command-paths` flag in production to restrict which commands can be executed.
2323

2424
```bash
2525
webhook -allowed-command-paths="/usr/bin,/opt/scripts"
@@ -77,7 +77,7 @@ webhook \
7777

7878
### 4. Never Enable Auto-Chmod
7979

80-
**Never** use `--allow-auto-chmod` in production. This is a security risk that can lead to privilege escalation.
80+
**Never** use `-allow-auto-chmod` in production. This is a security risk that can lead to privilege escalation.
8181

8282
```bash
8383
# ❌ BAD - Never do this in production
@@ -245,7 +245,7 @@ chown webhook:webhook hooks.json
245245
### 3. Use Least Privilege
246246

247247
- Run webhook with a dedicated, non-privileged user
248-
- Use `--setuid` and `--setgid` to drop privileges after binding to port
248+
- Use `-setuid` and `-setgid` to drop privileges after binding to port
249249

250250
```bash
251251
# Create dedicated user
@@ -494,13 +494,13 @@ If you discover a security vulnerability, please report it responsibly:
494494
- Suggested fix (if you have one)
495495
4. Allow time for the issue to be addressed before public disclosure
496496

497-
For more information, see the [Security Policy](../SECURITY.md).
497+
For more information, see the [Security Policy](../../SECURITY.md).
498498

499499
---
500500

501501
## Additional Resources
502502

503-
- [Security Policy](../SECURITY.md)
503+
- [Security Policy](../../SECURITY.md)
504504
- [Hook Rules](Hook-Rules.md) - Authentication and authorization rules
505505
- [Configuration Parameters](Webhook-Parameters.md) - Security-related parameters
506506
- [API Reference](API-Reference.md) - API security considerations

docs/en-US/Webhook-Parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This document describes all available command-line parameters and environment va
1111
| `-ip string` | IP address the webhook should serve hooks on | `0.0.0.0` |
1212
| `-port int` | Port the webhook should serve hooks on | `9000` |
1313
| `-hooks value` | Explicit single-file mode: path to JSON/YAML hook definitions (can be used multiple times) | - |
14-
| `-hooks-dir string` | Directory mode: scan hook config files (*.json, *.yaml, *.yml); if empty, watch for new files; use with Config UI to enable save-to-dir | `./hooks` |
14+
| `-hooks-dir string` | Directory to scan for hook config files (*.json, *.yaml, *.yml). Default `./hooks`. If explicitly set to an empty string, directory mode is not used; when set to a non-empty path, that directory is scanned and (with `-hotreload` or directory watch) can be watched for new files. With Config UI, enables save-to-dir when in directory mode. | `./hooks` |
1515
| `-urlprefix string` | URL prefix for served hooks (protocol://yourserver:port/PREFIX/:hook-id); also used by Config UI for the generated call URL | `hooks` |
1616

1717
### Logging and Debugging

docs/zh-CN/API-Reference.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ http://your-server:9000
1212

1313
您可以使用 `-ip``-port` 命令行参数或环境变量来自定义 IP 地址和端口。
1414

15+
**保留路径与路径冲突**:请勿将 `-openapi-path``-config-ui-path` 设置为与保留端点冲突的路径。保留路径包括 `/``/health``/livez``/readyz``/version``/metrics` 以及 hook 前缀(如 `/hooks`)。若启动时检测到冲突,服务将跳过该路由注册并记录警告。
16+
1517
## 端点
1618

1719
### 1. 根端点
@@ -53,9 +55,48 @@ curl http://localhost:9000/
5355
curl http://localhost:9000/health
5456
```
5557

58+
**说明**:实际 JSON 结构由健康检查库定义(可能包含多项检查结果)。精确结构请在使用 `-openapi` 时查看 OpenAPI 规范。
59+
60+
---
61+
62+
### 3. 存活与就绪端点
63+
64+
**端点:** `GET /livez``GET /readyz`
65+
66+
**描述:** 类 Kubernetes 的存活与就绪探针。`/livez` 表示进程在运行;`/readyz` 表示服务是否就绪接收流量(如已加载 hooks)。
67+
68+
**响应:**
69+
- **状态码:** 健康/就绪时为 `200 OK`;否则为非 2xx。
70+
- **Content-Type:** `application/json`
71+
- **响应体:** 由实现定义的 JSON(启用 `-openapi` 时可查看 OpenAPI 规范中的 schema)。
72+
73+
**示例:**
74+
```bash
75+
curl http://localhost:9000/livez
76+
curl http://localhost:9000/readyz
77+
```
78+
79+
---
80+
81+
### 4. 版本端点
82+
83+
**端点:** `GET /version`
84+
85+
**描述:** 以 JSON 格式返回服务版本与构建信息,响应头中可能包含以 `X-` 为前缀的版本相关头。
86+
87+
**响应:**
88+
- **状态码:** `200 OK`
89+
- **Content-Type:** `application/json`
90+
- **响应体:** 包含版本相关字段的 JSON(如 `version``commit``buildDate``branch`)。具体结构由版本库定义;启用 `-openapi` 时可查看 OpenAPI 规范获取完整 schema。
91+
92+
**示例:**
93+
```bash
94+
curl http://localhost:9000/version
95+
```
96+
5697
---
5798

58-
### 3. 指标端点
99+
### 5. 指标端点
59100

60101
**端点:** `GET /metrics`
61102

@@ -81,7 +122,7 @@ curl http://localhost:9000/metrics
81122

82123
---
83124

84-
### 4. OpenAPI 规范端点(可选)
125+
### 6. OpenAPI 规范端点(可选)
85126

86127
**端点:** `GET /openapi`(或通过 `-openapi-path` 自定义路径)
87128

@@ -107,7 +148,7 @@ curl http://localhost:9000/openapi
107148

108149
---
109150

110-
### 5. Config UI(可选)
151+
### 7. Config UI(可选)
111152

112153
**端点:** `GET /config-ui``GET /config-ui/``POST /config-ui/api/generate`(或通过 `-config-ui-path` 自定义路径)
113154

@@ -130,7 +171,7 @@ curl http://localhost:9000/openapi
130171

131172
---
132173

133-
### 6. Hook 执行端点
174+
### 8. Hook 执行端点
134175

135176
**端点:** `POST|GET|PUT|DELETE /hooks/{hook-id}`
136177

0 commit comments

Comments
 (0)