Merged
sync(A4P/java): 同步 A4P java sdk 实现与编译脚本到 develop 分支 #364
sync(A4P/java): 同步 A4P java sdk 实现与编译脚本到 develop 分支 #364
Merged
machuanAdd on 20 days ago
machuan
machuanCollaborators
20 days ago

Paired: GitHub #167 ↔ GitCode !364

What type of PR is this?

/kind task

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

likedislike
Pull Request has been successfully merged by openJiuwen-bot.
(Thank you for machuan's contribution.)
atomgit-bot
atomgit-bot
20 days ago Comments:

🤖 正在生成合并请求摘要,请稍候…

likedislike
Incorrect?
atomgit-bot
atomgit-bot
20 days ago Comments:

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

likedislike
Incorrect?
OopenJiuwen-botCollaborators
20 days ago Set YiyangShao,xinyu-jiuwen as approver
atomgit-bot
atomgit-bot
20 days ago Comments:

AtomGit AI 助手使用指南

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

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

免责声明

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

likedislike
Incorrect?
OopenJiuwen-botCollaborators
20 days ago Added label: sig/sig-agent-protocol
openJiuwen-botCollaborators
20 days ago Comments:

欢迎来到 openJiuwen 社区

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

机器人使用手册

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

联系指引

有疑问可以联系 SIG: sig-agent-protocol ,
维护者是: @YiyangShao, @xinyu-jiuwen ,
审核者是: @gcw_hx9prznZ, @mingo007 .

likedislike
OopenJiuwen-botCollaborators
20 days ago Added label: stat/needs-squash
OopenJiuwen-botCollaborators
20 days ago Added label: openJiuwen-cla/yes
openJiuwen-botCollaborators
20 days ago Comments:

CLA 签署成功

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

likedislike
atomgit-bot
atomgit-bot
20 days ago Comments:

⚠️ 本次变更过大(49 个可审文件、5586 行,预估需 5 轮分片审查),已超出 AI 代码评审的处理范围,本次跳过。建议拆分为更小的 PR 以获得有效评审。

likedislike
Incorrect?
Oopenjiuwen-syncCollaborators
20 days ago Modify description of pull request
atomgit-bot
atomgit-bot
20 days ago Comments:

⚠️ 本次变更过大(49 个可审文件、5586 行,预估需 5 轮分片审查),已超出 AI 代码评审的处理范围,本次跳过。建议拆分为更小的 PR 以获得有效评审。

likedislike
Incorrect?
openJiuwen-botCollaborators
20 days ago Comments:

The pipeline(pipeline number:364) is running. Please wait a moment...

likedislike
OopenJiuwen-botCollaborators
20 days ago Added label: ci-running
OopenJiuwen-botCollaborators
20 days ago Removed label: ci-running
openJiuwen-botCollaborators
20 days ago Comments:
任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
likedislike
OopenJiuwen-botCollaborators
20 days ago Added label: ci-successful
maoqiming
maoqimingCollaborators20 days agoStart code review1
A4P/src/a4p/intent_mandate.py
@@ -0,0 +25,4 @@
25+_USER_KEY_ID = "user#intent-mandate-v1"
26+_TOKEN_KEY_ID = "server#intent-token-v1"
27+_DEFAULT_SERVER_SIGNING_KEY = "jiuwenclaw-intent-gateway-signing-key-dev-v1"
28+_DEFAULT_USER_SIGNING_KEY = "jiuwenclaw-intent-user-signing-key-dev-v1"
maoqiming
maoqiming20 days agoComments:

【review】安全问题。内置开发签名密钥硬编码在源码中,A4P_ENV 等环境变量未设置时 intent mandate 与 intent token 会用该公开密钥签名,任何拿到仓库的人都可伪造用户授权和 token。不要提供可用的内置密钥默认值:未显式配置密钥时应直接抛错,或用启动时生成的一次性随机密钥并禁止跨进程校验;同时把生产环境判定改为显式白名单(如 A4P_ENV 必须为 dev 才允许默认密钥)。

likedislike
maoqiming
maoqimingCollaborators20 days agoStart code review1
A4P/src/a4p/operation_mandate.py
@@ -0,0 +22,4 @@
22+_USER_SIGN_ALG = "HS256"
23+_SERVER_KEY_ID = "server#operation-mandate-k1"
24+_USER_KEY_ID = "user#operation-mandate-v1"
25+_DEFAULT_SERVER_SIGNING_KEY = "jiuwenclaw-note-mcp-server-signing-key-dev-v1"
maoqiming
maoqiming20 days agoComments:

【review】安全问题。operation mandate 同样硬编码了可公开获得的默认 HMAC 签名密钥,生产环境判定缺失时任何人都能伪造操作授权。与 intent_mandate 一致:未配置 OPERATION_SERVER_SIGNING_KEY / OPERATION_USER_SIGNING_KEY 时直接失败,不要回退到仓库内置的固定密钥。

likedislike
maoqiming
maoqimingCollaborators20 days agoStart code review1
A4P/src/a4p/http_server.py
@@ -0,0 +84,4 @@
84+ await self._send_json(writer, status, response)
85+ except Exception as exc:
86+ logger.exception("[A4PHTTPServer] request failed: %s", exc)
87+ await self._send_json(writer, 500, {"error": "internal_error", "message": str(exc)})
maoqiming
maoqiming20 days agoComments:

【review】错误处理。所有异常都被包装成 500 并把 str(exc) 原样返回给调用方,可能泄露文件路径、解析细节等内部信息。服务端用 logger.exception 记录完整异常,响应只返回固定的 internal_error 文案;对可预期的输入错误(JSON 解析失败、Content-Length 非法)单独返回 400。

likedislike
maoqiming
maoqimingCollaborators20 days agoStart code review1
A4P/src/a4p/http_server.py
@@ -0,0 +75,4 @@
75+ key, _, value = line.decode("iso-8859-1").partition(":")
76+ headers[key.strip().lower()] = value.strip()
77+ content_length = int(headers.get("content-length") or "0")
78+ body = await reader.readexactly(content_length) if content_length else b"{}"
maoqiming
maoqiming20 days agoComments:

【review】健壮性。content-length 直接 int() 转换且 readexactly 没有上限,非法或超大值会分别导致 500 或一次性分配大量内存。校验 Content-Length 为合法非负整数并设置请求体大小上限(超限返回 413/400),解析失败返回 400 而不是走到 500 分支。

likedislike
maoqiming
maoqimingCollaborators20 days agoStart code review2
A4P-java-sdk/src/main/java/io/openjiuwen/a4p/Rsa3072.java
@@ -0,0 +15,4 @@
15+ Validation.text(keyIdentifier);
16+ requireKey(privateKey);
17+ return data -> {
18+ Signature signer = Signature.getInstance("SHA256withRSA");
maoqiming
maoqiming20 days agoComments:

【review】设计建议。签名使用 SHA256withRSA(PKCS#1 v1.5),属于可接受但非首选的 RSA 方案。如果协议可与 ArkTS/Python 对端同步演进,建议迁移到 RSASSA-PSS(SHA256withRSA/PSS)以提升签名方案安全性;若需保持现有互操作可暂不修改,仅记录为协议演进项。

likedislike
machuan
machuanCollaborators
20 days ago Comments:

目前与 python/arkts 的实现保持一致

likedislike
maoqiming
maoqimingCollaborators20 days agoStart code review1
A4P/src/a4p/intent_mandate.py
@@ -0,0 +348,4 @@
348+ for key, expected_value in constraint.items():
349+ if key not in actual_params:
350+ return False, f"Required param '{key}' missing for action '{expected_action}'"
351+ if expected_value != "*" and actual_params[key] != expected_value:
maoqiming
maoqiming20 days agoComments:

【review】细节。params 约束用字符串 "" 表示任意值,导致参数值本身为字面量 "" 时无法精确约束。可考虑用独立的结构化标记(如 {"any": true} 或专用哨兵对象)区分通配与字面量,避免歧义。

likedislike
maoqiming
maoqimingCollaborators
20 days ago Comments:

/lgtm
/approve

likedislike
OopenJiuwen-botCollaborators
20 days ago Added label: approvedlgtm-mingo007
openJiuwen-botCollaborators
20 days ago Comments:

Review Code Feedback

  • The label lgtm-mingo007, approved was added to this pull request. It means that mingo007 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openJiuwen-botCollaborators
20 days ago Comments:

PR Merge Failed

  • reason: {"message":"The MR can not be merged, because of CodeReview discussion not resolved"}
likedislike
openJiuwen-botCollaborators
20 days ago Comments:

PR Merge Failed

  • reason: {"message":"The MR can not be merged, because of CodeReview discussion not resolved"}
likedislike
maoqimingmaoqimingCollaborators
20 days ago Resolved final issue
machuanmachuanCollaborators
20 days ago Resolved final issue
maoqimingmaoqimingCollaborators
20 days ago Resolved final issue
maoqimingmaoqimingCollaborators
20 days ago Resolved final issue
maoqiming
maoqimingCollaborators
20 days ago Comments:

/check-pr

likedislike
OopenJiuwen-botCollaborators
20 days ago Merged pull request
OopenJiuwen-botCollaborators
20 days ago Removed label: ci-successful
machuanmachuanCollaborators
14 days ago Associated issue: [Feature]: A4P 协议提供 java 版本 SDK