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
108 changes: 108 additions & 0 deletions services/360__360-epp_v10-0-0-08331/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# 360终端安全管理系统 (EPP) OctoBus Service

360 Enterprise Endpoint Protection Platform (EPP) v10.0.0.08331 的 OctoBus 适配服务,提供终端管理、告警查询、病毒扫描统计、漏洞修复统计等 API。

## 导入 OctoBus

```bash
octobus service import --id 360-epp ./services/360__360-epp_v10-0-0-08331
```

## 包文件说明

- `service.json`: OctoBus 服务描述文件
- `proto/360_epp.proto`: gRPC API 定义
- `config.schema.json`: 非敏感配置(endpoint、超时、TLS)
- `secret.schema.json`: 敏感配置(管理员账号密码)
- `src/360-epp.js`: 360 EPP REST API 代理实现
- `src/service.js`: OctoBus SDK `defineService` wrapper
- `bin/360-epp.js`: 服务入口
- `test/360-epp.test.js`: 单元测试(参数校验、API 映射、错误映射)
- `test/mock_upstream.js`: 本地 mock 服务器

## 配置

### Config(非敏感配置)

```json
{
"endpoint": "https://192.168.0.109",
"timeoutMs": 30000,
"skipTlsVerify": true
}
```

| 字段 | 说明 | 默认值 |
|------|------|--------|
| `endpoint` | 360 EPP 管理控制台地址 | 必填 |
| `timeoutMs` | HTTP 请求超时(毫秒) | 30000 |
| `skipTlsVerify` | 跳过 TLS 证书验证 | true |

### Secret(敏感配置)

```json
{
"username": "eppadmin",
"password": "your-password"
}
```

| 字段 | 说明 |
|------|------|
| `username` | 360 EPP 管理员账号 |
| `password` | 360 EPP 管理员密码(明文) |

## RPC 方法

| 方法 | 说明 |
|------|------|
| `Qihoo360_EPP.Qihoo360_EPP/GetDashboardInfo` | 获取仪表盘概览信息 |
| `Qihoo360_EPP.Qihoo360_EPP/ListTerminals` | 查询终端列表(分页、关键词搜索) |
| `Qihoo360_EPP.Qihoo360_EPP/GetTerminalDetail` | 获取终端详细信息 |
| `Qihoo360_EPP.Qihoo360_EPP/ListAlarms` | 查询告警日志列表 |
| `Qihoo360_EPP.Qihoo360_EPP/GetVirusStats` | 获取病毒扫描统计数据 |
| `Qihoo360_EPP.Qihoo360_EPP/GetLeakFixStats` | 获取漏洞修复统计数据 |
| `Qihoo360_EPP.Qihoo360_EPP/GetTerminalHardware` | 获取终端硬件配置信息 |

## 认证流程

本服务使用 360 EPP 的 Web 管理后台认证流程:

1. 调用 `GET /user/getPubKey?username=xxx` 获取 RSA 公钥
2. 使用 RSA 公钥加密密码,同时对密码做 MD5 哈希
3. 调用 `POST /user/login` 提交 `username` / `password`(MD5) / `rPassword`(RSA加密)
4. 获取会话 Cookie (`PN`) 用于后续 API 调用

会话 Cookie 在服务运行期间缓存复用。若会话过期(errno=10401),会自动重新登录。

## 错误映射

| 场景 | gRPC Status |
|------|-------------|
| 认证失败 | `UNAUTHENTICATED` |
| 参数无效 | `INVALID_ARGUMENT` |
| 会话过期 | `UNAUTHENTICATED` |
| 上游 API 错误 | `FAILED_PRECONDITION` |
| 网络/超时 | `UNAVAILABLE` / `DEADLINE_EXCEEDED` |

## 支持版本

- 360终端安全管理系统 v10.0.0.08331
- 认证方式:Web 管理后台 RSA 加密登录

## 注意事项

- 本服务使用 Web 管理后台的认证接口,需要具有管理权限的账号
- 密码通过 RSA 非对称加密传输,不在网络中明文传递
- 会话 Cookie 在内存中缓存,实例重启后需要重新登录
- 建议为 OctoBus 创建专用的管理员账号
- 写操作(如终端隔离、策略下发)暂未实现,仅提供查询能力

## 本地验证

```bash
cd services
npm run validate -- --service-dir 360__360-epp_v10-0-0-08331
npm test -- --service-dir 360__360-epp_v10-0-0-08331
npm run pack:check
```
7 changes: 7 additions & 0 deletions services/360__360-epp_v10-0-0-08331/bin/360-epp.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);
27 changes: 27 additions & 0 deletions services/360__360-epp_v10-0-0-08331/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": true,
"properties": {
"endpoint": {
"type": "string",
"description": "360 EPP 管理系统 REST API 基地址,例如 https://192.168.0.109"
},
"baseUrl": {
"type": "string",
"description": "Legacy alias for endpoint."
},
"timeoutMs": {
"type": "integer",
"minimum": 1,
"default": 30000,
"description": "HTTP 请求超时时间(毫秒)"
},
"skipTlsVerify": {
"type": "boolean",
"default": false,
"description": "跳过 TLS 证书验证(适用于自签名证书部署)"
}
},
"required": ["endpoint"]
}
12 changes: 12 additions & 0 deletions services/360__360-epp_v10-0-0-08331/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "360-epp",
"version": "0.0.0",
"private": true,
"type": "module",
"bin": {
"360-epp": "bin/360-epp.js"
},
"dependencies": {
"@chaitin-ai/octobus-sdk": "^0.5.0"
}
}
151 changes: 151 additions & 0 deletions services/360__360-epp_v10-0-0-08331/proto/360_epp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
syntax = "proto3";

package Qihoo360_EPP;

import "google/protobuf/wrappers.proto";
import "google/protobuf/struct.proto";

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

service Qihoo360_EPP {
// 获取仪表盘概览信息(终端数量、病毒数量、漏洞数量等)
rpc GetDashboardInfo(GetDashboardInfoRequest) returns (GetDashboardInfoResponse) {}

// 查询终端列表
rpc ListTerminals(ListTerminalsRequest) returns (ListTerminalsResponse) {}

// 获取终端详情
rpc GetTerminalDetail(GetTerminalDetailRequest) returns (GetTerminalDetailResponse) {}

// 查询告警日志列表
rpc ListAlarms(ListAlarmsRequest) returns (ListAlarmsResponse) {}

// 查询病毒扫描统计
rpc GetVirusStats(GetVirusStatsRequest) returns (GetVirusStatsResponse) {}

// 查询漏洞修复统计
rpc GetLeakFixStats(GetLeakFixStatsRequest) returns (GetLeakFixStatsResponse) {}

// 查询终端硬件信息
rpc GetTerminalHardware(GetTerminalHardwareRequest) returns (GetTerminalHardwareResponse) {}
}

// ========== Dashboard ==========

message GetDashboardInfoRequest {}

message GetDashboardInfoResponse {
google.protobuf.Struct data = 1; // 仪表盘原始数据,透传
}

// ========== Terminal Management ==========

message ListTerminalsRequest {
google.protobuf.Int64Value page = 1; // 页码,默认 1
google.protobuf.Int64Value page_size = 2; // 每页条数,默认 20
string keyword = 3; // 搜索关键词(IP/主机名/MAC)
string group_id = 4; // 终端分组 ID
string status = 5; // 在线状态:online/offline
}

message TerminalInfo {
string id = 1;
string name = 2;
string ip = 3;
string mac = 4;
string os = 5;
string status = 6; // 在线状态
string group_name = 7; // 所属分组
string last_online_time = 8;
string antivirus_status = 9; // 杀毒软件状态
}

message ListTerminalsResponse {
repeated TerminalInfo terminals = 1;
int64 total = 2;
}

message GetTerminalDetailRequest {
string terminal_id = 1; // 终端 ID
}

message GetTerminalDetailResponse {
string id = 1;
string name = 2;
string ip = 3;
string mac = 4;
string os = 5;
string os_version = 6;
string status = 7;
string group_name = 8;
string last_online_time = 9;
string antivirus_version = 10;
string antivirus_status = 11;
string cpu = 12;
string memory = 13;
string disk = 14;
google.protobuf.Struct raw = 15; // 原始数据透传
}

// ========== Alarm Management ==========

message ListAlarmsRequest {
google.protobuf.Int64Value page = 1;
google.protobuf.Int64Value page_size = 2;
string alarm_type = 3; // 告警类型:virus/attack/vulnerability/abnormal_login
string start_time = 4; // 开始时间
string end_time = 5; // 结束时间
string severity = 6; // 严重程度:high/medium/low
}

message AlarmInfo {
string id = 1;
string type = 2;
string severity = 3;
string title = 4;
string description = 5;
string terminal_name = 6;
string terminal_ip = 7;
string created_time = 8;
string status = 9; // 处理状态
}

message ListAlarmsResponse {
repeated AlarmInfo alarms = 1;
int64 total = 2;
google.protobuf.Struct statistics = 3; // 各状态统计
}

// ========== Virus Management ==========

message GetVirusStatsRequest {}

message GetVirusStatsResponse {
google.protobuf.Struct data = 1; // 病毒统计数据,透传
}

// ========== Leak Fix Management ==========

message GetLeakFixStatsRequest {}

message GetLeakFixStatsResponse {
google.protobuf.Struct data = 1; // 漏洞统计数据,透传
}

// ========== Terminal Hardware ==========

message GetTerminalHardwareRequest {
string terminal_id = 1;
}

message GetTerminalHardwareResponse {
string terminal_id = 1;
string cpu_model = 2;
string cpu_cores = 3;
string memory_size = 4;
string disk_size = 5;
string gpu_model = 6;
string motherboard = 7;
repeated string network_adapters = 8;
google.protobuf.Struct raw = 9;
}
16 changes: 16 additions & 0 deletions services/360__360-epp_v10-0-0-08331/secret.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": true,
"properties": {
"username": {
"type": "string",
"description": "360 EPP 管理员账号"
},
"password": {
"type": "string",
"description": "360 EPP 管理员密码"
}
},
"required": ["username", "password"]
}
53 changes: 53 additions & 0 deletions services/360__360-epp_v10-0-0-08331/service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"schema": "chaitin.octobus.service.v1",
"name": "360-epp",
"displayName": "360终端安全管理系统(EPP)",
"description": "OctoBus package for 360 Enterprise Endpoint Protection Platform (360 EPP v10.0.0.08331). Provides terminal management, alarm query, virus scan stats, and vulnerability fix stats APIs.",
"runtime": {
"mode": "long-running"
},
"proto": {
"roots": [
"proto"
],
"files": [
"proto/360_epp.proto"
]
},
"configSchema": "config.schema.json",
"secretSchema": "secret.schema.json",
"sdk": {
"cli": {
"commands": {
"Qihoo360_EPP.Qihoo360_EPP/GetDashboardInfo": {
"name": "get-dashboard-info",
"description": "获取 360 EPP 仪表盘概览信息(终端数量、病毒数量、漏洞数量等)"
},
"Qihoo360_EPP.Qihoo360_EPP/ListTerminals": {
"name": "list-terminals",
"description": "查询 360 EPP 终端列表,支持分页和关键词搜索"
},
"Qihoo360_EPP.Qihoo360_EPP/GetTerminalDetail": {
"name": "get-terminal-detail",
"description": "获取终端详细信息"
},
"Qihoo360_EPP.Qihoo360_EPP/ListAlarms": {
"name": "list-alarms",
"description": "查询 360 EPP 告警日志列表"
},
"Qihoo360_EPP.Qihoo360_EPP/GetVirusStats": {
"name": "get-virus-stats",
"description": "获取病毒扫描统计数据"
},
"Qihoo360_EPP.Qihoo360_EPP/GetLeakFixStats": {
"name": "get-leakfix-stats",
"description": "获取漏洞修复统计数据"
},
"Qihoo360_EPP.Qihoo360_EPP/GetTerminalHardware": {
"name": "get-terminal-hardware",
"description": "获取终端硬件配置信息"
}
}
}
}
}
Loading