Skip to content

Commit fe69d55

Browse files
authored
fix: identify M0 publisher at ingress
1 parent c37a1ef commit fe69d55

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

docs/m0_research_publisher_envelope_contract.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ Environment 保护的 fallback。控制台部署会在部署前验证该 secret
159159
URL、发布 token 和 QAR 读取 token 不会写进封套、`GITHUB_STEP_SUMMARY` 或 workflow 输出。该
160160
workflow 不读取运行时、平台、selector、策略或券商配置;其唯一网络写入是构建器在
161161
`--publish` 明确指定时,对上述研究接收地址发送经过校验的 no-order 封套。
162+
请求还带固定的非敏感 `User-Agent: QSL-M0-Research-Publisher/1.0`,避免边缘防护把 Python
163+
默认标识误判为自动化攻击;它不包含 token、策略、账户或载荷内容。
162164

163165
若已存 current 与来件的 `source_artifact.sha256` 完全相同,接收端返回 `200`
164166
`replayed: true`,且不再写 KV。这只确认同一不可变来源已经收到,供网络重试或重复人工触发

python/scripts/build_m0_research_publisher_envelope.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ def publish_m0_research_publisher_envelope(
335335
"Authorization": f"Bearer {token}",
336336
"Content-Type": "application/json",
337337
"Accept": "application/json",
338+
# Avoid generic Python-client bot filtering at the dedicated
339+
# ingress boundary; this value carries no credential or payload.
340+
"User-Agent": "QSL-M0-Research-Publisher/1.0",
338341
},
339342
)
340343
try:

python/tests/test_build_m0_research_publisher_envelope.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def fake_urlopen(request, timeout):
272272
)
273273
self.assertEqual(len(captured), 1)
274274
self.assertEqual(captured[0][1], 15)
275+
self.assertEqual(captured[0][0].get_header("User-agent"), "QSL-M0-Research-Publisher/1.0")
275276
self.assertNotIn(secret, publisher.canonical_json(envelope))
276277
self.assertNotIn("BROKER_API_TOKEN", publisher.canonical_json(envelope))
277278

0 commit comments

Comments
 (0)