Merged
# Audit Framework and Schema Definition #512
# Audit Framework and Schema Definition #512
Merged
zhangxiangAdd on Sep 10
zhangxiang
zhangxiangCollaborators
Sep 10

Paired: GitHub #169 ↔ GitCode !512

What type of PR is this?

/kind feature

Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)

Linked Closing Issues:

likedislike
Pull Request has been successfully merged by 曹玉哲.
(Thank you for zhangxiang's contribution.)
atomgit-bot
atomgit-bot
Sep 10 Comments:

变更摘要

本 PR 新增安全审计日志框架 foundation/openjiuwen_runtime/foundation/audit/ 包,实现 SRS FR1(schema 驱动的日志格式、合规校验门、NTP 时钟同步)并为其后续 FR2–FR8(脱敏、异步输出、存储、外送、访问控制、配置下发、打点)提供配置骨架与接口占位。核心包括:AuditLogSchema(头部 HeaderSchema + 内容 ContentSchema)、validate_schema 合规校验门、SyncedClock NTP 同步时钟、format_audit_line/parse_audit_line 格式化与解析、AuditLogConfig 配置聚合及 AuditFacade 打点门面,并随附三份单元测试(test_audit_clock.py、test_audit_formatter.py、test_audit_schema.py)。

主要改动

  • Schema 定义与默认常量: 新增 schema.py 与 constants.py,定义 11 字段头部(DEFAULT_HEADER_FIELDS,| 分隔、- 占位)与内容层(#UA:/#EVT: 关键字、|@| 要素分隔、= KV 分隔、replace/escape 两种转义模式),并声明不可削弱的红线字段 DEFAULT_REDLINE_FIELDS 与 RSPCD 码表 RSPCD_KNOWN。
  • 合规校验门: 新增 validator.py 的 validate_schema,在自定义 schema 生效前强制校验 semver 版本、红线字段齐全、timestamp 保留、占位符/分隔符/转义模式声明、NTP 配置合法性及 command_force_redact 不被关闭,不通过则抛 SchemaValidationError,并拒绝占位符形式的 NTP 地址。
  • NTP 同步时钟: 新增 clock.py 的 SyncedClock/UdpNtpClient/SequenceNtpClient,实现启动同步与周期同步,时间源由配置注入(禁止硬编码),全部源不可达时降级本地时钟不阻断调用方,主源 failover 或偏差超阈值时产生 ClockEvent 事件。
  • 日志行格式化与解析: 新增 formatter.py 的 format_audit_line/parse_audit_line,自动补全头部 pid/tid/caller/时间戳,required 字段缺失时占位、校验 RSPCD 格式与 caller 行号,沙箱要素(ACTION/SANDBOXID/RESULT)转入 EXT(x_ 前缀),format_clock_event 将 NTP 事件落成 #EVT 管道行。
  • 配置聚合与未实现接口占位: 新增 config.py 的 AuditLogConfig/default_config 聚合 format/ntp/identity/redaction 等子配置并在加载时过校验门;writer.py/storage.py/shipper.py/access.py/deploy.py/redaction.py/linkpoint.py 及 facade.py 的 log_audit 仅提供接口骨架,明确以 AuditNotImplementedError 拒绝假装落盘。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 10 Comments:

🤖 AI 代码检视正在进行中,请稍候…

likedislike
Incorrect?
openJiuwen-botCollaborators
Sep 10 Comments:

欢迎来到 openJiuwen 社区

Hey @seanzhang_cn , 感谢你对社区的贡献.

机器人使用手册

有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。

likedislike
atomgit-bot
atomgit-bot
Sep 10 Comments:

AtomGit AI 助手使用指南

在 PR 评论中使用命令即可触发。支持在普通评论和代码行评论中使用。

功能 命令 说明
代码审查 /ai review 检查代码质量、潜在问题、安全风险
PR 摘要 /ai summary 生成 PR 变更内容的结构化摘要
代码解释 /ai explain 解释代码变更的逻辑和意图
自由提问 @atomgit-bot <问题> 询问关于本 PR 的任何问题
帮助 /ai help 显示此帮助信息

免责声明

AI 助手可能存在误判,请结合自身判断。可以对评论点 👍 或 👎 帮助我们改进。

likedislike
Incorrect?
OopenJiuwen-botCollaborators
Sep 10 Added label: openJiuwen-cla/yes
openJiuwen-botCollaborators
Sep 10 Comments:

CLA 签署成功

seanzhang_cn, 感谢您的代码贡献。 所有的代码贡献者都已完成了 CLA 签署。 👍

likedislike
Oopenjiuwen-syncCollaborators
Sep 10 Modify description of pull request
曹曹玉哲Collaborators
Sep 10 Associated issue: [Feature]: 企业级架构:提供通用审计日志框架
Oopenjiuwen-syncCollaborators
Sep 10 Modify description of pull request
openJiuwen-botCollaborators
Sep 10 Comments:
任务名称 结果 日志操作
静态检查 ❌FAILED 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 N/A N/A
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck {{ruff_codecheck_result}} {{ruff_codecheck_link_text}}
issue关联检查 {{issue_linked_result}} {{issue_linked_link_text}}
pr size检查 {{pr_size_result}} {{pr_size_link_text}}
likedislike
OopenJiuwen-botCollaborators
Sep 10 Added label: ci-failed
曹玉哲Collaborators
Sep 10 Comments:

ci-pipeline

likedislike
OopenJiuwen-botCollaborators
Sep 10 Removed label: ci-failed
openJiuwen-botCollaborators
Sep 10 Comments:
任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 N/A N/A
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck {{ruff_codecheck_result}} {{ruff_codecheck_link_text}}
issue关联检查 {{issue_linked_result}} {{issue_linked_link_text}}
pr size检查 {{pr_size_result}} {{pr_size_link_text}}
likedislike
OopenJiuwen-botCollaborators
Sep 10 Added label: ci-successful
曹曹玉哲Collaborators
Sep 10 Merged pull request
OopenJiuwen-botCollaborators
Sep 10 Removed label: ci-successful