feat(cyberhub): 支持加载待审核 / 草稿 / 未启用的 POC 与指纹#13
Open
wuchulonly wants to merge 1 commit into
Open
Conversation
…portFilter
EN TL;DR: ExportFilter now carries Statuses + ReviewStatus, transparently
applied to both POC and fingerprint exports. Old callers see no behavior
change; new callers can opt in to pending/draft/inactive rules via
WithStatuses(...) / WithReviewStatus(...).
为客户端提供显式加载"待审核 / 草稿 / 未启用"规则的能力。
POC 端:
- 去掉 ExportPOCs / ExportPOCsByNames 硬编码的 status=active;
- 新增 applyDefaultPOCStatus 在调用方未指定任何状态条件(Statuses /
status / review_status 全空)时兜底 status=active,保持老 SDK 调用
行为不变;
- ExportPOCsByNames 保留原签名(避免破坏潜在的接口满足关系),新增
ExportPOCsByNamesWithFilter(ctx, names, filter) 承载 filter;
- ExportFilter 加 Statuses / ReviewStatus 字段 + 链式 WithStatuses /
WithReviewStatus 方法(dedup 写法与 Tags/Sources 一致)。
指纹端:
- ExportFingerprints 本来就不强制 active,因此新字段经由共享的
applyFilterParams 自动透传,fingers.Engine 调用方零额外改动;
- 后端默认对指纹是"非 deleted"语义;草稿与空 pending 仍会被后端
shouldHideDraftOnlyFingerprints 隐去,客户端如需拿到要显式
WithStatuses("pending") 等。
合法值:
- Statuses: active / pending / draft / inactive / deprecated
- ReviewStatus: pending / approved / rejected / draft / none
杂项:
- FingerprintResponse.IsActive() 标记为 Deprecated(保留方法体避免源
码级 breaking change),并加注解释 Status 不在 export payload 中;
- 新增 examples/pending_pocs 和 examples/pending_fingerprints,演示
客户端两类用法;
- examples/README.md 增补两节,说明 POC 与指纹默认行为差异。
验证:
- pkg/cyberhub 单测全绿(含 4 个新增 sub-test + httptest mock 端到
端断言 URL query 形态);
- 活体跑过 6 条代码路径(含 ExportPOCs nil filter、ExportPOCsByNames
默认 + WithFilter、显式 WithStatuses 覆盖、ExportFingerprints 默
认 + IsActive() 仍可调),数据与后端 total 对齐。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
EN TL;DR:
ExportFilternow carriesStatuses+ReviewStatus, transparently applied to both POC and fingerprint exports. Old callers see no behavior change; new callers can opt in to pending/draft/inactive rules viaWithStatuses(...)/WithReviewStatus(...).中文:为客户端提供显式加载"待审核 / 草稿 / 未启用"规则的能力。
active,指纹仍走后端默认语义。ExportFilter.WithStatuses(...)/WithReviewStatus(...)显式 opt-in,即可加载 pending / draft / inactive 等规则。改动要点
POC 端
ExportPOCs/ExportPOCsByNames硬编码的status=active;applyDefaultPOCStatus,在调用方未指定任何状态条件(Statuses/status/review_status全空)时兜底status=active,保持向后兼容;ExportPOCsByNames保留原签名(避免破坏潜在的接口满足关系),新增ExportPOCsByNamesWithFilter(ctx, names, filter)承载 filter。指纹端
ExportFingerprints本就不强制 active,新字段经由共享的applyFilterParams自动透传,fingers.Engine调用方零额外改动;shouldHideDraftOnlyFingerprints隐去,客户端如需拿到要显式WithStatuses("pending")等。ExportFilter
Statuses []string/ReviewStatus string字段 + 链式WithStatuses(...)/WithReviewStatus(...)方法;Tags/Sources一致。合法值
Statuses:active/pending/draft/inactive/deprecatedReviewStatus:pending/approved/rejected/draft/none杂项
FingerprintResponse.IsActive()标记为Deprecated(保留方法体避免源码级 breaking change),并加注解释Status不在 export payload 中;examples/pending_pocs/与examples/pending_fingerprints/演示客户端两类用法;examples/README.md增补两节,说明 POC 与指纹默认行为的差异。客户端示例
Test plan
pkg/cyberhub单测全绿(11 个 test + 12 个 sub-test,含 httptest mock 端到端断言 URL query)examples/pending_pocs/examples/pending_fingerprints编译通过total全部对齐):ExportPOCs(nil filter)→ 1(兜底 active)ExportPOCsByNames(name)默认 → 1(兜底 active)ExportPOCsByNames(pending POC)默认 → 0(预期,兜底 active 过滤掉)ExportPOCsByNamesWithFilter(+ Statuses=pending)→ 1(新方法走 filter)ExportPOCs(WithStatuses=pending)→ 956(等于后端 total)ExportFingerprints默认 → 155,IsActive()仍可调examples/pending_pocs× 3 模式 +examples/pending_fingerprints× 3 模式全部对齐基线(1 / 767 / 766 与 155 / 5496 / 5491)兼容性
ExportPOCsByNames不变。新方法ExportPOCsByNamesWithFilter是新增 API。active;指纹仍走后端默认。FingerprintResponse.IsActive():保留为 Deprecated,源码级兼容。🤖 Generated with Claude Code