fix(cosmos): per-request TLS, secret-only token, complete service registration#183
fix(cosmos): per-request TLS, secret-only token, complete service registration#183kurokoleung wants to merge 9 commits into
Conversation
|
Review 阻塞:这个服务包缺少自动化测试。diff 里没有 |
|
本次变更在 测试覆盖了以下方面:
测试使用 |
|
该 PR 将 |
|
|
|
PR Title: Add: Chaitin Cosmos OctoBus Service Commit: 本次PR移除了两个vendored的Google Protocol Buffers标准库文件( 从diff来看,这两个文件都是Google官方的标准proto定义,protobuf编译器(protoc)本身会自带这些文件。因此,在正常的protobuf编译环境下,移除本地vendored版本不会影响编译。 需要确认的是:项目中其他proto文件若通过 |
|
这个 PR 需要修改后再合并。 目前有两个阻塞问题:
另外,proto request message 中包含 api_token 字段。OctoBus service package 里凭据通常应来自 ctx.secret,而不是放在 request message 中,除非有非常明确的逐次调用覆盖需求。请调整 token 处理方式,并在补齐注册后增加 OctoBus Connect/gRPC/MCP 调用证据。 |
|
PR Title: Add: Chaitin Cosmos OctoBus Service Commit: 本 PR 对 Chaitin COSMOS 服务进行了三项核心变更:
整体评估:安全设计方向正确,代码结构清晰,测试覆盖了凭证来源与 TLS 无副作用场景。但 protobuf 字段重编号存在 wire-format 兼容性与数据完整性风险,建议处理。 |
Add mock-upstream-based test suite covering protocol mapping, error handling, and request construction for all 3 RPC methods (SearchLogInfo, SearchLogList, SearchAggregationStatistics). 73 test cases across 12 suites: - Input validation (api_token, endpoint) - SearchLogInfo: request construction, headers, response mapping, proto3 defaults - SearchLogList: keyword/time/condition/filter/pagination/organization mapping - SearchAggregationStatistics: aggregation key/asc/response mapping - Error handling: HTTP errors (401/403/500), JSON-RPC errors (-32600/-32601/-32000/1), network errors - skipTlsVerify: tlsOptions passed to fetch - timeoutMs: passed to fetch options - Endpoint normalization and headers parsing - handlers export verification Uses node:test + node:assert (zero external test deps). Co-Authored-By: Claude <noreply@anthropic.com>
The previous tlsOptions approach (insecureSkipVerify/tlsInsecureSkipVerify) does not work with standard Node.js fetch (undici) — these are not valid fetch options. Switch to setting NODE_TLS_REJECT_UNAUTHORIZED=0 before the request and restoring it in a finally block, which is the correct way to skip TLS verification with Node.js built-in fetch. Also update tests: replace tlsOptions-based assertions with env var manipulation verification, remove timeoutMs fetch option tests (no longer passed to fetch). Co-Authored-By: Claude <noreply@anthropic.com>
google/protobuf/struct.proto and wrappers.proto are standard well-known types that proto compilers provide by default — they should not be vendored in the service package. Co-Authored-By: Claude <noreply@anthropic.com>
…istration - Replace process.env.NODE_TLS_REJECT_UNAUTHORIZED with undici Agent dispatcher for per-request TLS enforcement (no process-wide downgrade) - Remove skipTlsVerify from config.schema.json and runtime code - Move api_token from proto request messages to ctx.secret only - Re-number proto fields after removing api_token - Add undici as explicit dependency in sub-package - Complete service package registration: add cosmos entry to services/package.json bin/files, services/bin/cosmos.js wrapper, and services/bin/octobus-tentacles.js dispatch table - Update README with TLS requirements and secret-only token docs - Update tests: remove skipTlsVerify tests, add per-request dispatcher tests, update token tests to verify secret-only source (71 pass) Co-Authored-By: Claude <noreply@anthropic.com>
|
PR Title: Add: Chaitin Cosmos OctoBus Service Commit: 本次 PR 是一次大规模的服务包扩容与重构,新增 20+ 个 OctoBus 服务适配器(Cosmos、DBAudit、Huorong ESM、Imperva WAF、Qingteng HIDS v5、Sangfor XDR 等),并将多个现有服务的 webhook/secret 从 config 迁移到 secret schema 以提升密钥安全性。SDK 侧新增 HTTP 工具模块(fetchWithTimeout、createTlsDispatcher)与更完善的错误处理/敏感信息脱敏逻辑。大量现有服务统一接入 SDK 新接口,标准化了超时、TLS 与响应处理。 整体架构趋于统一,但在具体实现中仍发现以下关键问题:
建议优先修复上述安全与可靠性缺陷,并继续推动所有新服务统一使用 SDK 提供的 createTlsDispatcher + fetchWithTimeout 模式,避免重复引入全局 env 修改或超时失效问题。 |
Prevents wire-format misinterpretation by old clients — field 1 is reserved instead of re-numbered, so legacy api_token payloads are safely discarded rather than silently mapped to new fields. Co-Authored-By: Claude <noreply@anthropic.com>
Previously timeoutMs was accepted as a parameter but never passed to fetch, allowing requests to hang indefinitely. Now uses AbortSignal.timeout(timeoutMs) on each fetch call, and maps TimeoutError/AbortError to DEADLINE_EXCEEDED (gRPC code 4). Co-Authored-By: Claude <noreply@anthropic.com>
|
PR Title: fix(cosmos): per-request TLS, secret-only token, c... Commit: 本次 PR 将之前未使用的 |
Prevents RangeError/TypeError from AbortSignal.timeout() when given invalid values. Negative, zero, NaN, Infinity, and non-numeric timeoutMs now throw INVALID_ARGUMENT (gRPC code 3) instead of being silently passed through and wrapped as UNAVAILABLE. Co-Authored-By: Claude <noreply@anthropic.com>
|
PR Title: fix(cosmos): per-request TLS, secret-only token, c... Commit: 本次 PR 为 改动要点:
总体评估:该改动精准修复了历史发现的配置注入风险,校验逻辑严谨,测试充分,无额外副作用。代码和测试均符合预期,未发现新的问题。 |
|
这个 PR 目前还不能合并。 阻塞问题: node --check services/bin/octobus-tentacles.js这会导致 另外,PR 删除了 截图方面已有补充,但建议在 PR 评论里明确说明最新截图分别对应当前 HEAD 的 gRPC / MCP / Connect 调用,并贴出脱敏后的 request/response 文本,方便确认真实 OctoBus 调用证据和当前代码一致。 |
Co-Authored-By: Claude <noreply@anthropic.com>






Chaitin Cosmos (万象) OctoBus Service
OctoBus service package for Chaitin Cosmos (万象) platform log APIs via Pedestal JSON-RPC.
Features
Configuration
endpointhttps://cosmos.example.comheaderstimeoutMsskipTlsVerifySecret
api_tokenQuick Start