Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions services/bin/octobus-tentacles.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ const services = {
entryFile: "../venus__ads_v3-6/bin/venus-ads-v3-6.js",
serviceModule: "../venus__ads_v3-6/src/service.js",
},
"venus-maf": {
entryFile: "../venus__maf/bin/venus-maf.js",
serviceModule: "../venus__maf/src/service.js",
},
"volcengine-cloud-firewall": {
entryFile: "../volcengine__cloud-firewall/bin/volcengine-cloud-firewall.js",
serviceModule: "../volcengine__cloud-firewall/src/service.js",
Expand Down
10 changes: 10 additions & 0 deletions services/bin/venus-maf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env node

import { fileURLToPath } from "node:url";
import { runServiceMain } from "@chaitin-ai/octobus-sdk";

import { service } from "../venus__maf/src/service.js";

runServiceMain(service, {
entryFile: fileURLToPath(new URL("../venus__maf/bin/venus-maf.js", import.meta.url)),
});
3 changes: 3 additions & 0 deletions services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"topsec-fw-2u": "bin/topsec-fw-2u.js",
"topsec-waf-v3-2294-20238": "bin/topsec-waf-v3-2294-20238.js",
"venus-ads-v3-6": "bin/venus-ads-v3-6.js",
"venus-maf": "bin/venus-maf.js",
"volcengine-cloud-firewall": "bin/volcengine-cloud-firewall.js",
"wangsu-label-ip": "bin/wangsu-label-ip.js",
"wd-k01": "bin/wd-k01.js",
Expand Down Expand Up @@ -124,6 +125,7 @@
"bin/topsec-fw-v3-7-6.js",
"bin/topsec-waf-v3-2294-20238.js",
"bin/venus-ads-v3-6.js",
"bin/venus-maf.js",
"bin/volcengine-cloud-firewall.js",
"bin/wd-k01.js",
"bin/tencent-bh.js",
Expand Down Expand Up @@ -186,6 +188,7 @@
"topsec__fw_v3-7-6",
"topsec__waf_v3-2294-20238",
"venus__ads_v3-6",
"venus__maf",
"volcengine__cloud-firewall",
"wd__k01",
"tencent__bh",
Expand Down
76 changes: 76 additions & 0 deletions services/venus__maf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Venus-MAF

OctoBus service for Venus-MAF application firewall operations.

## Supported Capabilities

- `HealthCheck`: login probe.
- `CreateSite`: create a virtual site through `POST /api/v3/protect/vs/add`.
- `DeleteSite`: delete a virtual site through `POST /api/v3/protect/vs/delete`. If `id` is omitted, the service resolves it by site name.
- `ListSites`: query virtual sites through `GET /api/v3/protect/vs/find`.
- `UploadCustomSensitiveWords`: upload a custom sensitive word file through `POST /api/v3/protect/tmpl/llm/customize/file`.

## Configuration

`baseUrl` is required. UI URLs such as `https://host/monitor` are accepted; the service uses the origin and appends `apiPrefix`.

Optional fields:

- `apiPrefix`: defaults to `/api/v3`.
- `authToken`: defaults to `CMCC_NFV`.
- `deviceType`: defaults to `api`.
- `timeoutMs`: defaults to `10000`.
- `insecureSkipTlsVerify`: enable only for lab self-signed TLS.

## Secret

- `username`
- `password`

The password is SHA-256 hashed for `POST /api/v3/login`.

## Create Site Example

```json
{
"name": "octobus-maf-site",
"description": "OctoBus integration test site",
"enable": 1,
"http_type": "http",
"ip": "192.0.2.10",
"port": 8080,
"server_name": ["maf.example.local"],
"net_mode": 1,
"safe_mode": 1,
"upstream": {
"http_type": "http",
"load_balance_algo": "round_robin",
"server_addr": [
{ "ip": "198.51.100.1", "port": 8080, "weight": 100 }
]
}
}
```

## Delete Site Example

```json
{
"name": "octobus-maf-site"
}
```

## Upload Custom Sensitive Words Example

```json
{
"filename": "octobus-sensitive-words.txt",
"content": "secret-word-1\nsecret-word-2\n"
}
```

## Notes

- Write methods verify results where the product exposes a query endpoint.
- `UploadCustomSensitiveWords` returns the upload response from the product; the API document does not define a separate file-list verification endpoint.
- Do not store credentials, tokens, cookies, or real internal device addresses in repository files or PR evidence.
7 changes: 7 additions & 0 deletions services/venus__maf/bin/venus-maf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node

import { runServiceMain } from "@chaitin-ai/octobus-sdk";

import { service } from "../src/service.js";

runServiceMain(service);
41 changes: 41 additions & 0 deletions services/venus__maf/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"baseUrl"
],
"properties": {
"baseUrl": {
"type": "string",
"title": "MAF base URL",
"description": "Device URL. UI paths such as /monitor are accepted; the service uses the origin and appends apiPrefix."
},
"apiPrefix": {
"type": "string",
"title": "API prefix",
"default": "/api/v3"
},
"authToken": {
"type": "string",
"title": "auth-token header",
"default": "CMCC_NFV"
},
"deviceType": {
"type": "string",
"title": "Device-Type header",
"default": "api"
},
"timeoutMs": {
"type": "integer",
"title": "Request timeout in milliseconds",
"default": 10000,
"minimum": 1000
},
"insecureSkipTlsVerify": {
"type": "boolean",
"title": "Skip TLS certificate verification",
"default": false
}
},
"additionalProperties": false
}
12 changes: 12 additions & 0 deletions services/venus__maf/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "venus-maf",
"version": "0.0.0",
"private": true,
"type": "module",
"bin": {
"venus-maf": "bin/venus-maf.js"
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新服务 octobus-sdk 版本与仓库升级策略不一致

services/venus__maf/package.json 中声明的依赖为 @chaitin-ai/octobus-sdk ^0.5.0,而仓库中同类服务(如 venus-ads-v3-6)已统一升级到 ^0.6.0,且最近的合并提交 f0c1fb7 完成了全仓库 SDK 升级。新服务使用旧版本 SDK,可能引入 API 不兼容、行为差异或缺失 0.6.0 中已修复的问题,造成运行时隐患。

Problem code:

Changed code at services/venus__maf/package.json:8-10

Recommendation:
将 @chaitin-ai/octobus-sdk 升级到 ^0.6.0,与仓库其他服务保持一致。

Suggested diff:

--- a/services/venus__maf/package.json
+++ b/services/venus__maf/package.json
@@ -6,6 +6,6 @@
     "venus-maf": "bin/venus-maf.js"
   },
   "dependencies": {
-    "@chaitin-ai/octobus-sdk": "^0.5.0"
+    "@chaitin-ai/octobus-sdk": "^0.6.0"
   }
 }

"dependencies": {
"@chaitin-ai/octobus-sdk": "^0.5.0"
}
}
89 changes: 89 additions & 0 deletions services/venus__maf/proto/venus_maf.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
syntax = "proto3";

package Venus_MAF;

option go_package = "miner/grpc-service/Venus_MAF";

service Venus_MAF {
rpc HealthCheck(HealthCheckRequest) returns (OperationResponse) {}
rpc CreateSite(CreateSiteRequest) returns (OperationResponse) {}
rpc DeleteSite(DeleteSiteRequest) returns (OperationResponse) {}
rpc ListSites(ListSitesRequest) returns (ListSitesResponse) {}
rpc UploadCustomSensitiveWords(UploadCustomSensitiveWordsRequest) returns (UploadCustomSensitiveWordsResponse) {}
}

message HealthCheckRequest {}

message OperationResponse {
bool ok = 1;
int32 code = 2;
string message = 3;
}

message UpstreamServer {
string ip = 1;
int32 port = 2;
int32 weight = 3;
}

message UpstreamConfig {
string http_type = 1;
string load_balance_algo = 2;
repeated UpstreamServer server_addr = 3;
}

message CreateSiteRequest {
string name = 1;
string description = 2;
int32 enable = 3;
string http_type = 4;
string ip = 5;
int32 port = 6;
repeated string server_name = 7;
int32 net_mode = 8;
int32 safe_mode = 9;
UpstreamConfig upstream = 10;
}

message DeleteSiteRequest {
int32 id = 1;
string name = 2;
}

message ListSitesRequest {
int32 page = 1;
int32 page_size = 2;
string name = 3;
}

message Site {
int32 id = 1;
string name = 2;
string ip = 3;
int32 port = 4;
string http_type = 5;
int32 enable = 6;
repeated string server_name = 7;
}

message ListSitesResponse {
repeated Site sites = 1;
int32 total = 2;
int32 page = 3;
int32 page_size = 4;
int32 code = 5;
string message = 6;
}

message UploadCustomSensitiveWordsRequest {
string filename = 1;
string content = 2;
}

message UploadCustomSensitiveWordsResponse {
bool ok = 1;
int32 code = 2;
string message = 3;
string file_name = 4;
string origin_file_name = 5;
}
20 changes: 20 additions & 0 deletions services/venus__maf/secret.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"username",
"password"
],
"properties": {
"username": {
"type": "string",
"title": "Username"
},
"password": {
"type": "string",
"title": "Password",
"format": "password"
}
},
"additionalProperties": false
}
19 changes: 19 additions & 0 deletions services/venus__maf/service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"schema": "chaitin.octobus.service.v1",
"name": "venus-maf",
"displayName": "Venus-MAF",
"description": "Venus-MAF site management and custom sensitive word upload",
"runtime": {
"mode": "long-running"
},
"proto": {
"roots": [
"proto"
],
"files": [
"proto/venus_maf.proto"
]
},
"configSchema": "config.schema.json",
"secretSchema": "secret.schema.json"
}
7 changes: 7 additions & 0 deletions services/venus__maf/src/service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineService } from "@chaitin-ai/octobus-sdk";

import { handlers } from "./venus-maf.js";

export { handlers } from "./venus-maf.js";

export const service = defineService({ handlers });
Loading