Skip to content

feat(TAP-13018): audit log enhancement (web) - #665

Merged
feynmx merged 12 commits into
developfrom
hardy/TAP-13018-6ae07214
Nov 13, 2026
Merged

feynmx merged 12 commits into
developfrom
hardy/TAP-13018-6ae07214

Conversation

@weiliang110100

@weiliang110100 weiliang110100 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

概要

TAP-13018 TapData 审计日志增强——前端。

  • /operation-audit 升级为「审计日志」:发生时间、事件类型、操作人、来源、来源 IP、操作、对象、结果(文字+状态)列;全部审计查询条件;异步操作聚合为一行;详情抽屉含必填字段、时间线、批量对象结果、变更详情与脱敏说明;显示时区;导出 CSV 按钮受 v2_audit_log_export 控制。
  • 结构化渲染,不出现 null、undefined 或未替换变量;历史记录缺失字段显示「不可用(历史记录)」。
  • 系统设置:审计日志保留时间 30–3650 校验,缩短时二次确认。
  • 角色权限树新增「导出审计日志」按钮权限。
  • 访问码与 API 客户端密钥改为掩码显示,复制时经审计接口取得。
  • 审查修复统一查看权限码、同时展示操作人名称和 ID、避免详情切换竞态,并让 CSV 导出使用应用配置的 API 地址。
  • 导出失败兼容直接响应对象、JSON Blob 和 AxiosError,保留服务端错误原因。

配套主仓 PR: tapdata/tapdata#3599(待审,尚未合并)。普通响应隐藏访问码与客户端密钥,显式 reveal 受权限控制并记录审计;客户端返回 clientSecretConfigured,编辑其他字段保留原密钥。凭据相关 P1 需待配套合入、完整联调和 reviewer 复核,不应独立部署本 PR。

Review 核对

  • 查看权限码、操作人 ID、详情切换竞态和导出 base URL:前端修复已提交,审查线程已关闭;非根路径部署仍待实测。
  • 访问码与客户端密钥普通响应泄露:前端已改为显式 reveal;服务端修复见 #3599,两条 P1 线程仍开放,待配套联调及 reviewer 复核。
  • 导出错误解析:当前提交兼容直接对象、JSON Blob(含无 content-type)和 AxiosError;定向测试通过,该线程仍待 reviewer 复核。

测试总结(候选 6e5b1e8)

范围 结果
审计页面逻辑与导出错误测试 15 项通过
Prettier / ESLint 本次修改文件通过
daas 生产构建 通过
daas 类型检查 4435 条错误,检查未通过;审计抽屉原有 3 条诊断已消除

本地浏览器已验证普通用户和客户端查询不返回凭据明文、显式读取产生审计、编辑客户端后原密钥保留、审计列表和详情以及导出;运行环境的构建产物 SHA 尚未独立核实,不能作为本提交完整联调通过的依据。

待验收

  • 配套主仓修复发布后,验证普通接口不返回明文、显式 reveal 的权限和审计、编辑保留原值、API 调试、导出和角色权限。
  • 手工验收(开发环境):审计日志页面全流程、导出与导出权限、保留期设置、真实 Engine/API Server 启停与失联——待研发提供 Docker 与外部 MongoDB 后执行。
  • Story Test Design Review Result 待评审人给出。

AgenticOps 版本 main-v1.6-23-6a2a279b

🤖 Generated with Claude Code

…tial reveal

- /operation-audit becomes the Audit Logs page: table with time, event type,
  operator, source, source IP, action, object and outcome (text + status),
  filters for all audit query conditions, logical-operation rows, detail drawer
  with required fields, timeline, batch results, change details and secret
  notes; CSV export gated by v2_audit_log_export; time zone shown.
- Structured rendering never shows null/undefined or unresolved placeholders;
  legacy records show an explicit "unavailable (legacy record)" value.
- System settings validate the audit log retention (30-3650 days) and confirm
  before shortening it.
- Role permission tree adds the export audit logs button permission.
- Access code and API client secret are masked and copied through the audit
  reveal endpoints.
- Pure page logic in views/audit/audit-log.ts with node --test coverage; three
  locale texts generated from the backend audit catalog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@weiliang110100
weiliang110100 requested a review from feynmx October 29, 2026 03:39
weiliang110100 and others added 4 commits October 29, 2026 14:30
- F-01: the role page enables the audit page node v2_audit_log_list (export
  button attached there), matching the module permission point checked by
  the audit API.
- F-03: router guard returns after redirecting to the dashboard when access
  is denied, instead of issuing a second next(false) that left a blank page.
- F-04: legacy records are rendered by the existing operation component, so
  placeholders such as {user}/{parameter1} are replaced.
- F-05: retention input is a plain number field with an explicit range hint,
  so out-of-range values are reported instead of being silently clamped.
- F-06: change field names are shown with the setting labels.
- New unit test for the change field label mapping.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…F-06)

- F-05: the Options API template cannot read the module-scope RETENTION_KEY
  import, so the retention branch never matched and the control stayed an
  el-input-number that silently clamped out-of-range values. The check now
  goes through a method, so the plain number field with the 30-3650 hint is
  actually rendered and out-of-range input is reported.
- F-06: change details use the readable label provided by the backend instead
  of guessing an i18n key from the internal field name.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…05 registry)

- Remove the TypeScript annotation from the plain JS <script> of Setting.vue
  (the previous commit broke the whole settings page); add
  scripts/check-vue-sfc.mjs and run it in lint-staged so SFC syntax errors are
  caught before commit.
- Change details translate the backend key_label with the settings i18n
  convention (case preserved) and fall back to the label, then the field.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@weiliang110100
weiliang110100 marked this pull request as ready for review October 30, 2026 04:10
- F-11:详情「结果」与列表一致,取操作聚合结果,不再停留在请求阶段的「已受理」
- F-10:服务节点补充 instance,同主机多实例可区分;拼接逻辑抽到 nodeText 便于测试
- 新增 nodeText 单测

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@feynmx feynmx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

审查意见:以下问题会影响审计权限、敏感凭据保护和记录追溯,请修复后再合并。

Comment thread apps/daas/src/views/role/Role.vue Resolved
Comment thread apps/daas/src/views/audit/audit-log.ts Resolved
Comment thread packages/api/src/core/audit-events.ts Resolved
Align role permissions with the TM authorization check, preserve operator identities, ignore stale detail responses, and use the configured API client for exports.

Tested: Audit logic tests, Vue SFC compilation, ESLint and Prettier
Not-tested: Deployment under a non-root base URL and role permissions in a running environment
Not-tested: Credential exposure in ordinary backend responses remains unresolved
Use audited reveal operations for copying and API debugging; preserve existing credentials when an edit does not supply a replacement.

Constraint: Requires the companion TM credential-response changes.
Tested: Vue SFC compilation and audit logic tests; lint diagnostics match the pre-existing baseline.
Not-tested: Running browser flow and external API client compatibility.
@weiliang110100

Copy link
Copy Markdown
Contributor Author

审查问题已在前端提交 87189eed2ba52930d5ac6e9d6e7dd3630a627090 中处理:

  • 统一审计日志查看权限码;列表和详情同时展示操作人名称与 ID。
  • 普通界面不再保存访问码或客户端密钥明文,显式复制时调用 reveal 接口;编辑其他字段时保留原有凭据。
  • 切换详情时清空旧内容并忽略过期请求;CSV 导出使用应用配置的 API 地址。

验证:审计逻辑测试 11 项通过;Vue SFC 编译、格式、多语言检查及 daas 生产构建通过;当前提交的 GitHub 3 项检查通过。daas 类型检查仍有 4439 条既有错误,与合并前逐条一致,未新增。

配套依赖: 主仓普通接口的凭据脱敏和用户访问码 reveal 接口目前仅在本地候选 3e05116841ad8c2c383cf886d11147a5f16118c9,尚无有效 PR。前后端配套的浏览器验收尚未执行;请待主仓修复提交并完成联调后再按完整方案合入。

@weiliang110100
weiliang110100 requested a review from feynmx November 9, 2026 03:18

@feynmx feynmx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

复审新增问题,请修复导出失败原因的解析。

Comment thread packages/api/src/core/audit-events.ts Resolved
Handle unwrapped JSON responses, Blob responses, and Axios-style errors while retaining the original error when the body is not JSON.

Tested: audit export error and audit log tests; targeted ESLint and Prettier
@weiliang110100

Copy link
Copy Markdown
Contributor Author

配套主仓 PR:tapdata/tapdata#3599,当前为 Draft,提交 1ffca87a23efb02bf49ae242d10a662503c5dd4b。

该 PR 为访问码和客户端密钥两条 P1 提供后端配套:普通查询不返回明文,显式 reveal 受权限控制并记录审计;客户端返回 clientSecretConfigured,支持字段投影和编辑时保留原密钥。前端当前提交 04a60129d41c25edec284a8cd9098f51ab5df038 已使用显式 reveal;两条线程仍待配套合入、联调及 reviewer 复核。

其他 review 中,查看权限码、操作人 ID、详情切换竞态和导出 base URL 的线程已关闭;导出错误解析已兼容直接对象、JSON Blob 和 AxiosError,代码及测试已提交,线程待 reviewer 复核。当前前端定向测试 15 项通过,3 项 CI 检查通过;前后端浏览器联调和非根路径部署实测尚未执行,前端类型检查仍有既存诊断。

Tested: Audit logic and export tests; targeted ESLint; full type check still has existing errors
@feynmx
feynmx merged commit b7c79c2 into develop Nov 13, 2026
@feynmx
feynmx deleted the hardy/TAP-13018-6ae07214 branch November 13, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants