dsh-project-flow 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/index.js +21 -0
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -14,6 +14,21 @@ dsh-project-flow 的版本变更。版本号遵循语义化版本。
14
14
 
15
15
  ---
16
16
 
17
+ ## [0.8.3] - 2026-12-04
18
+
19
+ 四个 HTTP 路由再接一层宿主自己的准入检查。界面和功能不变。
20
+
21
+ ### 修复
22
+
23
+ **0.8.2 那层只看浏览器自愿交代的来源**
24
+
25
+ - 0.8.2 靠 `Sec-Fetch-Site` 和 `Origin` 判来源。这两个头由浏览器自己填,DNS rebinding 的时候 Host 指攻击者域名、socket 打到 127.0.0.1,这两条都可能缺席。
26
+ - 现在四个 handler 先问宿主:`connection.requestRejection(req)`。宿主判跨站(403)就直接拒;宿主回 401 只表示这个请求没带浏览器会话——地址栏直开、curl、桌面端都可能没有那个 cookie,本地诊断还要用,所以照旧放行。宿主没有 `connection` 服务(老版本)时跳过这一步,退回 0.8.2 那层。
27
+
28
+ ### 说明
29
+
30
+ - 市场那条收录描述里写了一句「它的 HTTP 路由没有 DSH 的访问检查」,说的是 0.8.2 之前的状态。接上宿主准入之后这句不成立了,已另外提一个 PR 摘掉。
31
+
17
32
  ## [0.8.2] - 2026-12-04
18
33
 
19
34
  给插件自己的四个 HTTP 路由加来源检查。界面和功能没动。
package/index.js CHANGED
@@ -4880,6 +4880,21 @@ async function decorateCost(result, settings, requirements, cwd) {
4880
4880
  // 都能对 127.0.0.1 发一条简单请求。跨域拿不到响应体,可 ?cwd= 是请求方
4881
4881
  // 可控的,靠响应大小和耗时就能一位一位地问出某个路径下有没有项目。
4882
4882
  // 这层壳只放同源页面和地址栏直开,别的来源一律 403。
4883
+ // 宿主的准入检查。DSH 的 connection 服务自己有 Host/Origin 围栏和浏览器
4884
+ // 会话,它比下面这层更权威:它判跨站就一律拒。
4885
+ // 它回 401 只表示「这个请求没带浏览器会话」——地址栏直开、curl、桌面端
4886
+ // 都可能没有那个 cookie,本地诊断还要用,所以不拿 401 当拒绝。
4887
+ // 老版本宿主没有这个服务,就只靠下面这层自己判。
4888
+ const hostRejection = req => {
4889
+ try {
4890
+ const connection = webCtx.get('connection')
4891
+ if (connection === undefined || typeof connection.requestRejection !== 'function') return undefined
4892
+ return connection.requestRejection(req)
4893
+ } catch {
4894
+ return undefined
4895
+ }
4896
+ }
4897
+
4883
4898
  const localOnly = handler => (req, res) => {
4884
4899
  const site = req.headers['sec-fetch-site']
4885
4900
  if (typeof site === 'string' && site !== 'same-origin' && site !== 'none') {
@@ -4903,6 +4918,12 @@ async function decorateCost(result, settings, requirements, cwd) {
4903
4918
  return
4904
4919
  }
4905
4920
  }
4921
+ // 宿主说是跨站,就按跨站拒;401 不算拒绝,见上面 hostRejection 的说明。
4922
+ if (hostRejection(req) === 403) {
4923
+ res.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' })
4924
+ res.end('cross-site blocked')
4925
+ return
4926
+ }
4906
4927
  return handler(req, res)
4907
4928
  }
4908
4929
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-project-flow",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "private": false,
5
5
  "description": "Four-stage project workflow: requirement, plan, build, QA, with an intent gate, a rework loop, self-healing recovery, a watchdog that stops runaway runs, snapshot rollback, a single status light, and a machine-readable Completion_Evidence.json.",
6
6
  "type": "module",