[mimosa 1.0.4] 硬编码凭据规则三例误报:合成测试夹具被判高危并阻塞 Git 门禁(附最小复现)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- postgresql, python
- Domain
- security, testing-qa
Research direction
Start with the hardcoded-credentials rule (CWE-798) in the mimosa 1.0.4 scanner; the payload does not include its source, so locate it from the scan entry point at payload/dist/cli.js. Reproduce with the three fixture shapes: tests/case.py with a password literal, a userinfo DSN on 127.0.0.1:65534, and an os.environ write in a serve_isolated_workspace.py script. Done means these shapes stop producing high-severity findings without weakening real credential detection. The issue also asks for changes to the git gate's scope, which is a design question.
Written by the indexing model from the issue text.
Description
环境
- ZCode Desktop 3.15.3.8237(Windows 10 19045 x64)
- mimosa 1.0.4:
https://cdn-zcode.z.ai/zcode/official-plugin/plugins/mimosa/1.0.4/plugin.zip,sha25650d4da2cc1a24c63db06b51758699d5ffbf22aa4c79ae001a823e8177f0a1fe7;本机缓存安装为 1.0.3,两版都复现 - 命中位置:私有业务仓的合成测试/验收夹具(无真实凭据、无生产密钥)
现象
项目级扫描对合成夹具报「高危 · 硬编码凭据 / CWE-798」,随后 Git L3 门禁在 git commit 前整仓扫描并强制拦截(口径不是本次 staged/diff 的范围)。结果是:
- 存量误报直接卡住提交:任何与安全无关的改动都提交不了,除非先把测试写法改成扫描器不认识的形态;
- 与 #43(存量 finding 阻塞提交、exclusions 不生效)、#17(全工作区扫描误拦存量)、#59(该类 finding 无法铸 exclusion 锚)、#58(模式黑盒误标把工程实践推向更危险写法)同类,但在 1.0.4 仍复现。
三种误报形态(可最小复现)
| # | 形态 | 为什么是误报 |
|---|---|---|
| A | 单测里把样本口令作为被测输入:password = <字符串字面量>,随后断言"哈希不等于原文、加盐后两次不同、明文不回显" |
该字面量是被测样本而不是任何环境凭据;文件位于 tests/ 单测 |
| B | 测试用隔离 DSN:postgresql://<user>:<placeholder>@127.0.0.1:65534/<db>(65534 无服务,用例只验"预置隔离 DSN 时验收入口能跑完隔离自检") |
userinfo 里的占位口令不连接任何库;隔离自检只比较 host/port/schema |
| C | 隔离验收脚本把内存夹具的合成口令写进 os.environ(脚本头部声明 "Only synthetic in-memory data; no business DB") |
目标是一次性内存夹具主机;口令仅用于本地夹具登录,脚本随仓库公开也无泄露面 |
本机命中示例(行号为当时值):tests/test_principal_credentials.py:11、tests/test_verification_entry.py:31、docs/acceptance/evidence/**/serve_isolated_workspace.py:17。
最小复现命令
# 1) 单文件:造一个同形态的 tests 用例(password = <字符串字面量>,不再使用)
node "<mimosa>/payload/dist/cli.js" scan /tmp/mimosa-fp/tests/case.py --min high --json
# → count=1、severity=high、rule=硬编码凭据
# 2) 门禁实际口径:项目级
node "<mimosa>/payload/dist/cli.js" scan . --min high
对照:把这三处夹具改成"运行时派生、源码无字面量"后,同一命令对 213 个文件报 0 高危,说明这是规则校准(语境判定)问题,不是解析失败或漏检。
与既有 issue 的关系(非重复)
- #43 / #17:门禁"整仓扫描 + 存量 finding 阻塞"的范围问题——本 issue 补充 1.0.4 仍复现的三种具体夹具形态与规则校准建议;
- #59:该类 finding 无法铸 exclusion 锚——本 issue 是同一诉求的另一组实例;
- #58:模式误标会把工程实践推向更危险的写法——本 issue 附上了"为通过门禁而把夹具改成运行时派生"的实际规避证据;
- #84:1.0.4 git-gate
maxBuffer问题,与本 issue 无关。
建议
- 门禁按 staged/diff + 不可变基线判定(#43/#17 已提),不要把整仓存量都算作本次阻塞项;
- 提供 finding 级 exclusion/豁免锚,并让项目
security-policy.json的threatModel.exclusions真正生效(#59 已指出无法铸锚); - 该规则的测试语境校准:识别单测路径(pytest/unittest fixture)、非连接型端口(如 65534)、声明为内存夹具的脚本等;门禁侧的规则集/阈值(
--fail-on)可配置; - 误报 remediation 文案建议区分语境:对合成夹具正确做法是"不要出现字面量(运行时生成/派生)",而不是"改为环境变量或密钥管理服务",否则会把测试代码改得更难读。
附:本机已套用的规避(仅为能提交,未削弱断言)
- 单测样本口令改为运行时随机生成(保留中文成分);
- 测试 DSN 去掉 userinfo;
- 隔离脚本的夹具值改为
sha256(label)确定性派生,并在启动时打印登录用值。
以上都不改变被验证行为,仅用于绕开门禁。
- Dominant language
- Python
- Stars
- 95
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from zai-org/zcode-plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zai-org/zcode-plugins#107 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
zai-org/zcode-plugins#106 ·
Maintainers usually reply within 1 day
-
video-agent-kit (0.4.3): hooks invoke python3, which doesn't exist on Windows — SessionStart/UserPromptSubmit/Stop hooks fail on every triggerPossibly taken @dvd233 claimed this 24 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
zai-org/zcode-plugins#14 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
zai-org/zcode-plugins#88 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
zai-org/zcode-plugins#86 ·
Maintainers usually reply within 1 day
All issues in zai-org/zcode-plugins
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
lidofinance/diffyscan#239 ·
Maintainers usually reply within 1 day
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsOpenarea: tools documentation good first issue ready for a contributor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
eyalgolan/statecraft-israel#873 · 1 comment ·
Maintainers usually reply within 1 day
-
GET rooms API returns 500 due to nonexistent Room.is_active attributePossibly taken @Mars-60 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 5 days
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nasa/harmony-autotester#341 ·