-
Notifications
You must be signed in to change notification settings - Fork 84
Feat: add venus maf service #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gorlone
wants to merge
1
commit into
chaitin:main
Choose a base branch
from
gorlone:feat/venus-maf-service
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| }, | ||
| "dependencies": { | ||
| "@chaitin-ai/octobus-sdk": "^0.5.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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:
Recommendation:
将 @chaitin-ai/octobus-sdk 升级到 ^0.6.0,与仓库其他服务保持一致。
Suggested diff: