dsh-git-push 0.0.0-stage → 2.8.6

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 (279) hide show
  1. package/.auditignore +30 -0
  2. package/.gitignore +39 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1486 -2
  5. package/cli.mjs +360 -0
  6. package/cordis.patch.yml +14 -0
  7. package/lib/ARCHITECTURE.md +34 -0
  8. package/lib/BUGFIX-NOTES-2026-09-14.md +278 -0
  9. package/lib/app/apply.js +275 -0
  10. package/lib/app/audit-api.js +158 -0
  11. package/lib/app/command-registry.js +266 -0
  12. package/lib/app/constants.js +16 -0
  13. package/lib/app/handlers/account.js +166 -0
  14. package/lib/app/handlers/clone.js +168 -0
  15. package/lib/app/handlers/http-constants.js +9 -0
  16. package/lib/app/handlers/identity-rewrite.js +94 -0
  17. package/lib/app/handlers/meta.js +175 -0
  18. package/lib/app/handlers/npm.js +169 -0
  19. package/lib/app/handlers/repo-actions.js +143 -0
  20. package/lib/app/handlers/repos.js +231 -0
  21. package/lib/app/handlers/settings.js +62 -0
  22. package/lib/app/host-doc-checks.js +25 -0
  23. package/lib/app/http-handlers.js +131 -0
  24. package/lib/app/index.js +30 -0
  25. package/lib/app/inject-text.js +192 -0
  26. package/lib/app/scan-root.js +23 -0
  27. package/lib/app/schema.js +150 -0
  28. package/lib/app/settings-bridge.js +167 -0
  29. package/lib/app/slash-commands.js +395 -0
  30. package/lib/app/slot-stats.js +35 -0
  31. package/lib/app/tool-call.js +672 -0
  32. package/lib/app/tools.js +34 -0
  33. package/lib/ast/brace.js +105 -0
  34. package/lib/ast/callgraph.js +135 -0
  35. package/lib/ast/code-lines.js +114 -0
  36. package/lib/ast/consts.js +12 -0
  37. package/lib/ast/control-flow.js +461 -0
  38. package/lib/ast/credential.js +199 -0
  39. package/lib/ast/dataflow.js +274 -0
  40. package/lib/ast/dup-code.js +165 -0
  41. package/lib/ast/index.js +36 -0
  42. package/lib/ast/io-risk-const.js +95 -0
  43. package/lib/ast/io-risk-fn.js +208 -0
  44. package/lib/ast/io-risk-loop.js +308 -0
  45. package/lib/ast/io-risk.js +314 -0
  46. package/lib/ast/lang.js +156 -0
  47. package/lib/ast/line-count.js +52 -0
  48. package/lib/ast/magic-number.js +272 -0
  49. package/lib/ast/naming.js +284 -0
  50. package/lib/ast/perf.js +472 -0
  51. package/lib/ast/scope.js +241 -0
  52. package/lib/ast/shell.js +131 -0
  53. package/lib/ast/size.js +378 -0
  54. package/lib/ast/symbol-index.js +399 -0
  55. package/lib/ast/tokenizer.js +341 -0
  56. package/lib/audit/analysis-coverage.js +98 -0
  57. package/lib/audit/audit-file.js +182 -0
  58. package/lib/audit/checks.js +17 -0
  59. package/lib/audit/client-entry.js +93 -0
  60. package/lib/audit/collector.js +477 -0
  61. package/lib/audit/ext-runner.js +80 -0
  62. package/lib/audit/file-context.js +138 -0
  63. package/lib/audit/finding.js +50 -0
  64. package/lib/audit/gitignore-match.js +113 -0
  65. package/lib/audit/glob.js +63 -0
  66. package/lib/audit/history-report.js +100 -0
  67. package/lib/audit/history.js +126 -0
  68. package/lib/audit/ignore-blind.js +101 -0
  69. package/lib/audit/index.js +33 -0
  70. package/lib/audit/orchestrate.js +476 -0
  71. package/lib/audit/public.js +24 -0
  72. package/lib/audit/repo-level.js +30 -0
  73. package/lib/audit/report-yaml.js +86 -0
  74. package/lib/audit/slot.js +65 -0
  75. package/lib/audit-defaults.js +18 -0
  76. package/lib/audit-rules/audit-rules-comment.yml +247 -0
  77. package/lib/audit-rules/audit-rules-cpp.yml +22 -0
  78. package/lib/audit-rules/audit-rules-docs.yml +32 -0
  79. package/lib/audit-rules/audit-rules-dsh.yml +162 -0
  80. package/lib/audit-rules/audit-rules-filehealth.yml +42 -0
  81. package/lib/audit-rules/audit-rules-folder.yml +99 -0
  82. package/lib/audit-rules/audit-rules-frontend.yml +335 -0
  83. package/lib/audit-rules/audit-rules-go.yml +22 -0
  84. package/lib/audit-rules/audit-rules-i18n.yml +45 -0
  85. package/lib/audit-rules/audit-rules-java.yml +105 -0
  86. package/lib/audit-rules/audit-rules-nodejs.yml +647 -0
  87. package/lib/audit-rules/audit-rules-npm.yml +187 -0
  88. package/lib/audit-rules/audit-rules-paths.yml +92 -0
  89. package/lib/audit-rules/audit-rules-performance.yml +215 -0
  90. package/lib/audit-rules/audit-rules-php.yml +22 -0
  91. package/lib/audit-rules/audit-rules-private.yml +24 -0
  92. package/lib/audit-rules/audit-rules-python.yml +106 -0
  93. package/lib/audit-rules/audit-rules-robustness.yml +27 -0
  94. package/lib/audit-rules/audit-rules-rust.yml +22 -0
  95. package/lib/audit-rules/audit-rules-structure.yml +159 -0
  96. package/lib/audit-rules/audit-rules-swift.yml +22 -0
  97. package/lib/audit-rules/audit-rules-template.yml +108 -0
  98. package/lib/checks/button-bind.js +276 -0
  99. package/lib/checks/common.js +170 -0
  100. package/lib/checks/credential-file.js +43 -0
  101. package/lib/checks/dataflow.js +40 -0
  102. package/lib/checks/dispatch.js +112 -0
  103. package/lib/checks/dup-code.js +69 -0
  104. package/lib/checks/dup-const.js +232 -0
  105. package/lib/checks/file-health.js +150 -0
  106. package/lib/checks/filter.js +137 -0
  107. package/lib/checks/folder.js +173 -0
  108. package/lib/checks/hardcoded-path.js +98 -0
  109. package/lib/checks/index.js +46 -0
  110. package/lib/checks/io.js +66 -0
  111. package/lib/checks/magic-number.js +42 -0
  112. package/lib/checks/npm-json.js +273 -0
  113. package/lib/checks/private.js +63 -0
  114. package/lib/checks/regex.js +256 -0
  115. package/lib/checks/semantic.js +134 -0
  116. package/lib/checks/structural.js +274 -0
  117. package/lib/cli/commands-account.mjs +107 -0
  118. package/lib/cli/commands-audit.mjs +144 -0
  119. package/lib/cli/commands-doc.mjs +127 -0
  120. package/lib/cli/commands-vcs.mjs +175 -0
  121. package/lib/client/index.js +162 -0
  122. package/lib/client-parts/00-loader.js +33 -0
  123. package/lib/client-parts/01-const.js +207 -0
  124. package/lib/client-parts/02-utils.js +62 -0
  125. package/lib/client-parts/03-icons.js +12 -0
  126. package/lib/client-parts/10-account.js +83 -0
  127. package/lib/client-parts/11-browser.js +95 -0
  128. package/lib/client-parts/20-repo.js +374 -0
  129. package/lib/client-parts/21-audit.js +301 -0
  130. package/lib/client-parts/22-settings.js +146 -0
  131. package/lib/client-parts/23-npm.js +383 -0
  132. package/lib/client-parts/30-page.js +56 -0
  133. package/lib/client-parts/40-controller.js +1092 -0
  134. package/lib/client-parts/41-actions.js +279 -0
  135. package/lib/client-parts/99-apply.js +72 -0
  136. package/lib/client.js +3195 -0
  137. package/lib/commit-push.js +148 -0
  138. package/lib/context/index.js +363 -0
  139. package/lib/core/atomic-json.js +98 -0
  140. package/lib/core/config.js +40 -0
  141. package/lib/core/credentials.js +274 -0
  142. package/lib/core/endpoints.js +109 -0
  143. package/lib/core/exec.js +162 -0
  144. package/lib/exempt/index.js +292 -0
  145. package/lib/fs/edit-after-read.js +103 -0
  146. package/lib/fsx.js +87 -0
  147. package/lib/git/account-status.js +140 -0
  148. package/lib/git/account.js +233 -0
  149. package/lib/git/api.js +136 -0
  150. package/lib/git/atomic-json.js +6 -0
  151. package/lib/git/browse.js +38 -0
  152. package/lib/git/clone-download.js +397 -0
  153. package/lib/git/clone-history-mode.js +143 -0
  154. package/lib/git/clone-history.js +175 -0
  155. package/lib/git/clone-jobs.js +250 -0
  156. package/lib/git/clone-replay-io.js +172 -0
  157. package/lib/git/clone-replay.js +275 -0
  158. package/lib/git/clone.js +445 -0
  159. package/lib/git/cloud.js +46 -0
  160. package/lib/git/commit-message.js +141 -0
  161. package/lib/git/config.js +6 -0
  162. package/lib/git/cred-env.js +88 -0
  163. package/lib/git/credentials.js +6 -0
  164. package/lib/git/endpoints.js +6 -0
  165. package/lib/git/exec.js +6 -0
  166. package/lib/git/identity-rewrite.js +297 -0
  167. package/lib/git/identity.js +150 -0
  168. package/lib/git/ignore.js +69 -0
  169. package/lib/git/index.js +41 -0
  170. package/lib/git/module-splitter.js +47 -0
  171. package/lib/git/post-push.js +101 -0
  172. package/lib/git/push-diagnose.js +142 -0
  173. package/lib/git/push.js +476 -0
  174. package/lib/git/remote-resolve.js +146 -0
  175. package/lib/git/remote.js +128 -0
  176. package/lib/git/repo-index.js +512 -0
  177. package/lib/git/repos.js +235 -0
  178. package/lib/git/scan-runner.js +159 -0
  179. package/lib/git/sensitive.js +134 -0
  180. package/lib/git/transport.js +430 -0
  181. package/lib/git/visibility.js +35 -0
  182. package/lib/git/wrapped-git.js +68 -0
  183. package/lib/http/index.js +170 -0
  184. package/lib/index.js +24 -0
  185. package/lib/link-check/index.js +187 -0
  186. package/lib/npm/account.js +64 -0
  187. package/lib/npm/install.js +211 -0
  188. package/lib/npm/npmrc.js +56 -0
  189. package/lib/npm/publish.js +171 -0
  190. package/lib/npm/registry.js +168 -0
  191. package/lib/plugin/auto-detect.js +92 -0
  192. package/lib/plugin/auto-push.js +154 -0
  193. package/lib/plugin/index.js +250 -0
  194. package/lib/readme-templates/readme.yml +38 -0
  195. package/lib/rule/compilers/credential.js +62 -0
  196. package/lib/rule/compilers/dataflow.js +38 -0
  197. package/lib/rule/compilers/file-health.js +75 -0
  198. package/lib/rule/compilers/frontend.js +86 -0
  199. package/lib/rule/compilers/func.js +35 -0
  200. package/lib/rule/compilers/helpers.js +71 -0
  201. package/lib/rule/compilers/index.js +29 -0
  202. package/lib/rule/compilers/link-semantic.js +45 -0
  203. package/lib/rule/compilers/list-kinds.js +12 -0
  204. package/lib/rule/compilers/numeric-kinds.js +66 -0
  205. package/lib/rule/compilers/regex.js +78 -0
  206. package/lib/rule/compilers/structure.js +80 -0
  207. package/lib/rule/compilers.js +17 -0
  208. package/lib/rule/homoglyph.js +45 -0
  209. package/lib/rule/loader.js +270 -0
  210. package/lib/rule/registry.js +115 -0
  211. package/lib/rule/scope.js +67 -0
  212. package/lib/score/docs-score.js +166 -0
  213. package/lib/score/index.js +140 -0
  214. package/lib/self/index.js +196 -0
  215. package/lib/skip-dirs.js +64 -0
  216. package/lib/tool-probes.json +50 -0
  217. package/lib/user-requirements.json +14 -0
  218. package/lib/vendor/js-yaml/LICENSE +21 -0
  219. package/lib/vendor/js-yaml/js-yaml.mjs +3073 -0
  220. package/package.json +95 -4
  221. package/scripts/__pycache__/module-splitter.cpython-38.pyc +0 -0
  222. package/scripts/audit-ext/_example-readme-present.mjs +34 -0
  223. package/scripts/audit-ext/variable-min-length.mjs +102 -0
  224. package/scripts/audit-runner.mjs +35 -0
  225. package/scripts/audit-runtime-check.mjs +129 -0
  226. package/scripts/browser-page-probe.mjs +271 -0
  227. package/scripts/build-client.mjs +119 -0
  228. package/scripts/check.mjs +88 -0
  229. package/scripts/clean-date-comments.py +102 -0
  230. package/scripts/cpu-sample.mjs +188 -0
  231. package/scripts/doc-drift.mjs +200 -0
  232. package/scripts/doc-func.mjs +212 -0
  233. package/scripts/doc-tree.mjs +456 -0
  234. package/scripts/doc-version.mjs +220 -0
  235. package/scripts/frontend-preview-check.mjs +124 -0
  236. package/scripts/hot-path-probe-cjs.cjs +71 -0
  237. package/scripts/hot-path-probe-fs-shim.mjs +28 -0
  238. package/scripts/hot-path-probe-fsp-shim.mjs +31 -0
  239. package/scripts/hot-path-probe.mjs +153 -0
  240. package/scripts/module-splitter.py +800 -0
  241. package/scripts/platform-scan.mjs +168 -0
  242. package/scripts/preview-gen.mjs +489 -0
  243. package/scripts/preview-local-runner.mjs +55 -0
  244. package/scripts/preview-server-direct.mjs +116 -0
  245. package/scripts/preview-server.mjs +305 -0
  246. package/scripts/preview-slot-data.mjs +123 -0
  247. package/scripts/probe-recheck.mjs +47 -0
  248. package/scripts/readme-gen.mjs +268 -0
  249. package/scripts/rename-locator.mjs +97 -0
  250. package/scripts/rule-switch.mjs +97 -0
  251. package/scripts/rules-solo-audit.mjs +173 -0
  252. package/scripts/scan-file-io.mjs +713 -0
  253. package/scripts/scan-hardcoded-paths.mjs +125 -0
  254. package/scripts/scan-repos.mjs +167 -0
  255. package/scripts/scan-version.mjs +122 -0
  256. package/scripts/scrub-user-wording.mjs +420 -0
  257. package/scripts/symbol-index.mjs +85 -0
  258. package/scripts/sync-plugin-install.mjs +223 -0
  259. package/scripts/sync-plugin.mjs +279 -0
  260. package/scripts/verify-prestep.mjs +100 -0
  261. package/skills/dev/audit-rule-authoring.md +58 -0
  262. package/skills/dev/dsh-git-push.md +323 -0
  263. package/skills/dev/git-push-live-fix.md +45 -0
  264. package/skills/dsh-repo-index.md +35 -0
  265. package/skills/guide/guide-audit.md +167 -0
  266. package/skills/guide/guide-cli-scripts.md +104 -0
  267. package/skills/guide/guide-clone-repos.md +173 -0
  268. package/skills/guide/guide-commit-push.md +156 -0
  269. package/skills/guide/guide-inject-ui.md +166 -0
  270. package/skills/guide/guide-slash-completion.md +118 -0
  271. package/skills/workflow/README.md +21 -0
  272. package/skills/workflow/git-commit-discipline.md +68 -0
  273. package/skills/workflow/git-project-startup.md +85 -0
  274. package/skills/workflow/git-rebuild-process.md +57 -0
  275. package/skills/workflow/github-operations.md +91 -0
  276. package/skills/workflow/readme-sync-git-md.md +28 -0
  277. package/skills/workflow/task-completion-report.md +73 -0
  278. package/skills/workflow/tool-json-add-ask.md +35 -0
  279. package/skills/workflow/versioning-rule.md +211 -0
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Git 执行层 · 仓库扫描与展示
3
+ *
4
+ * 职责:扫描工作区的 git 仓库、汇总状态(分支/远端/未提交/活动时间)、
5
+ * 远端 URL 脱敏(maskRemoteUrl 去掉内嵌凭据)。
6
+ */
7
+
8
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
9
+ import { join, basename } from 'node:path';
10
+ import { runGit, runGitAsync } from './exec.js';
11
+
12
+ /* ───────── 仓库扫描常量 ───────── */
13
+ const LS_IGNORED_TIMEOUT_MS = 15_000; // git ls-files --ignored 超时
14
+ // 扫描下钻深度默认值:与 lib/plugin/auto-push.js 共用同一来源(lib/audit-defaults.js)
15
+ import { DEFAULT_SCAN_DEPTH } from '../audit-defaults.js';
16
+
17
+ /**
18
+ * 扫描目录下的 git 仓库(1.0.0 接线:git_scan 工具用)。
19
+ * 逐层下钻查找 .git;返回分支/remote/未提交变更数/最近提交。
20
+ * @param {string} root 扫描根目录
21
+ * @param {object} [opts] { depth=20, extraRepos=[], extraReposFile='', maxRepos=200 }
22
+ * 遍历**所有** .git 文件夹——发现 .git 后继续下钻(仓库内嵌套的
23
+ * submodule/worktree/子仓库也列出),depth 默认提到 20(防爆靠 maxRepos + 排除
24
+ * node_modules/隐藏目录/.git 自身;Dirent.isDirectory 不跟随符号链接,无环)。
25
+ * extraReposFile:额外仓库清单文件(每行一个绝对路径,# 开头为注释,运行时实时读取;
26
+ * 文件缺失/不可读静默忽略——不因配置缺失让扫描失败)
27
+ * @returns {Array<object>} 仓库信息列表
28
+ */
29
+ export function scanRepos(root = '.', opts = {}) {
30
+ return collectRepoPaths(root, opts).map((p) => describeRepo(p));
31
+ }
32
+
33
+ /**
34
+ * 并发版仓库扫描:与 `scanRepos` **同一 walk、同一字段口径**,只把「逐仓 describe」改成有界并发。
35
+ *
36
+ * 为什么:`describeRepo` 每仓要起 6 次 git 子进程(实测单次约 8ms);27 仓串行 **2718ms**。
37
+ * 这些都是**只读**命令(rev-parse/remote/status/log/rev-list),并发安全;
38
+ * 有界并发避免把 NAS 打满(低负载纪律)。
39
+ * 并发数:opts.concurrency → 环境变量 DSH_GIT_PUSH_SCAN_CONCURRENCY → 默认 8(不硬编码)。
40
+ * 输出顺序与 `scanRepos` 完全一致(Promise.all 保持下标)。
41
+ * @returns {Promise<Array<object>>}
42
+ */
43
+ export async function scanReposAsync(root = '.', opts = {}) {
44
+ const paths = collectRepoPaths(root, opts);
45
+ const limit = Math.max(1, Number(opts.concurrency ?? process.env.DSH_GIT_PUSH_SCAN_CONCURRENCY ?? 8) || 8);
46
+ return mapLimit(paths, limit, (p) => describeRepoAsync(p));
47
+ }
48
+
49
+ /** 有界并发 map(保持输出顺序;**只读任务专用**,写任务禁止并发)。 */
50
+ async function mapLimit(items, limit, fn) {
51
+ const out = new Array(items.length);
52
+ let next = 0;
53
+ const workers = Array.from({ length: Math.max(1, Math.min(limit, items.length || 1)) }, async () => {
54
+ for (;;) {
55
+ const i = next++;
56
+ if (i >= items.length) return;
57
+ out[i] = await fn(items[i], i);
58
+ }
59
+ });
60
+ await Promise.all(workers);
61
+ return out;
62
+ }
63
+
64
+ /**
65
+ * 收集仓库根路径(**与描述解耦**):先走目录树拿路径,再由调用方决定同步或并发去描述。
66
+ * 这样「同步扫描」与「并发扫描」共用同一套遍历 + 忽略清单 + extras 逻辑,不会出现两套口径。
67
+ * @returns {string[]} 仓库绝对路径(顺序 = 遍历顺序 + extras 追加顺序)
68
+ */
69
+ export function collectRepoPaths(root = '.', { depth = DEFAULT_SCAN_DEPTH, extraRepos = [], extraReposFile = '', maxRepos = 200 } = {}) {
70
+ const out = [];
71
+ const seen = new Set();
72
+ // 修复:扫描**尊重 .gitignore**——被 git 忽略的目录(如 NAS 仓的 src/、assets/、
73
+ // build/master-build/ 官方源码/产物)不再被当独立仓库登记。
74
+ // 实现:每进入一个仓库根(含 .git 的目录)时,用**一次** `git ls-files --others --ignored
75
+ // --exclude-standard --directory` 拿到该仓库下所有「被忽略的目录」集合,walk 时整棵跳过
76
+ // ——单次 git 调用、无逐目录 spawn,性能可控。
77
+ const ignoredCache = new Map(); // repoRoot → Set(绝对路径,被忽略的目录)
78
+ const loadIgnoredDirs = (repoRoot) => {
79
+ if (ignoredCache.has(repoRoot)) return ignoredCache.get(repoRoot);
80
+ const set = new Set();
81
+ try {
82
+ const r = runGit(['ls-files', '--others', '--ignored', '--exclude-standard', '--directory'], { cwd: repoRoot, timeoutMs: LS_IGNORED_TIMEOUT_MS });
83
+ if (r.ok) {
84
+ for (const line of (r.stdout || '').split('\n')) {
85
+ const t = line.trim().replace(/\/+$/, '');
86
+ if (t) set.add(join(repoRoot, t));
87
+ }
88
+ }
89
+ } catch { /* 取不到忽略清单则不跳过(保守) */ }
90
+ ignoredCache.set(repoRoot, set);
91
+ return set;
92
+ };
93
+ // 判断某绝对路径是否落在任一「被忽略目录」之下(含自身)
94
+ const isIgnored = (abs) => {
95
+ for (const [, set] of ignoredCache) {
96
+ if (set.has(abs)) return true;
97
+ for (const ig of set) {
98
+ if (abs.startsWith(ig + '/')) return true;
99
+ }
100
+ }
101
+ return false;
102
+ };
103
+ const walk = (dir, level) => {
104
+ if (out.length >= maxRepos || level > depth) return;
105
+ let entries = [];
106
+ try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return; }
107
+ if (entries.some((e) => e.name === '.git')) {
108
+ if (!seen.has(dir)) { seen.add(dir); out.push(dir); }
109
+ loadIgnoredDirs(dir); // 该仓库的忽略清单(整仓一次)
110
+ // 记录后继续下钻:遍历所有 .git 文件夹(子文件夹/仓库内嵌套仓库都算)
111
+ }
112
+ for (const e of entries) {
113
+ // 跳过 node_modules / 隐藏目录(含 .git 自身)
114
+ if (!e.isDirectory() || e.name === 'node_modules' || e.name.startsWith('.')) continue;
115
+ const child = join(dir, e.name);
116
+ // 被 git 忽略的目录整棵跳过(不入仓列表)
117
+ if (isIgnored(child)) continue;
118
+ walk(child, level + 1);
119
+ }
120
+ };
121
+ walk(String(root || '.'), 0);
122
+ // 清单文件追加(# 注释 / 空行跳过;读不到就忽略)
123
+ const extras = [...(extraRepos || [])];
124
+ if (extraReposFile) {
125
+ try {
126
+ for (const line of readFileSync(extraReposFile, 'utf8').split('\n')) {
127
+ const t = line.trim();
128
+ if (t && !t.startsWith('#')) extras.push(t);
129
+ }
130
+ } catch { /* 清单文件缺失/不可读:忽略 */ }
131
+ }
132
+ for (const extra of extras) {
133
+ const extraPath = String(extra || '').trim();
134
+ if (!extraPath || seen.has(extraPath) || !existsSync(extraPath)) continue; // dsh-skip-residue(extraRepos 清单条数少)
135
+ seen.add(extraPath);
136
+ out.push(extraPath);
137
+ }
138
+ return out;
139
+ }
140
+
141
+ /**
142
+ * 脱敏 remote URL:userinfo 内嵌凭据(https://user:token@...)→ user:****@;
143
+ * query 参数 token/access_token/private_token=xxx → ****。防 token 进会话/日志/HTTP 输出。
144
+ */
145
+ export function maskRemoteUrl(url = '') {
146
+ const s = String(url || '');
147
+ if (!s) return '';
148
+ const masked = s.replace(/^(https?:\/\/)([^/@\s]*)@/i, (m, proto, userinfo) => {
149
+ if (!userinfo) return m;
150
+ const i = userinfo.indexOf(':');
151
+ return i >= 0 ? `${proto}${userinfo.slice(0, i)}:****@` : `${proto}****@`;
152
+ });
153
+ return masked.replace(/([?&](?:token|access_token|private_token)=)[^&\s]+/gi, '$1****');
154
+ }
155
+
156
+ /**
157
+ * 解析仓库摘要(**纯函数**,同步/并发两条取数路径共用同一套字段与判定口径)。
158
+ *
159
+ * 为什么抽出来:`describeRepo`(同步)与 `describeRepoAsync`(并发)必须给出**完全相同**的字段;
160
+ * 历史教训是"两处各写一份解析"必然漂移。取数方式不同,判定与字段一律走这里。
161
+ * @param {string} repoPath 仓库绝对路径
162
+ * @param {{branch:string,remote:string,status:string,last:string,upOk:boolean,upOut:string,rcOk:boolean,rcOut:string}} raw
163
+ */
164
+ function parseRepoInfo(repoPath, raw) {
165
+ const branch = String(raw.branch || '').trim() || '(空仓)';
166
+ const remote = maskRemoteUrl(String(raw.remote || '').trim());
167
+ const status = String(raw.status || '');
168
+ const changed = status ? status.split('\n').filter(Boolean).length : 0;
169
+ const last = String(raw.last || '').trim();
170
+ const hasRemote = !!remote;
171
+ let upstream = '';
172
+ if (raw.upOk && String(raw.upOut || '').trim()) upstream = String(raw.upOut).trim();
173
+ let ahead = null, behind = null;
174
+ // 无 @{u} 但有远端(本地 init/未 -u 常见)时,用 origin/<当前分支> 做比较
175
+ // 基准——账号卡片仍能显示「领先/落后」、手动 push 可用;远端无同名分支(无法比较)
176
+ // 时 ahead/behind 保持 null(前端显示「未跟踪上游」)。
177
+ const base = upstream || (hasRemote && branch && !branch.startsWith('(') ? `origin/${branch}` : '');
178
+ if (base && raw.rcOk) {
179
+ const parts = String(raw.rcOut || '').trim().split(/\s+/).map(Number);
180
+ ahead = Number(parts[0]) || 0;
181
+ behind = Number(parts[1]) || 0;
182
+ }
183
+ return { name: basename(repoPath), path: repoPath, branch, remote, changed, lastCommit: last, hasRemote, upstream, ahead, behind };
184
+ }
185
+
186
+ /** 读取单个仓库的状态摘要(git_scan 输出项)。remote 一律脱敏防 token 泄漏。
187
+ * 扩展 ahead/behind/hasRemote/upstream:账号卡片「本地仓库领先 → 手动 push」
188
+ * 需要区分「领先/落后/同步/未跟踪上游」;ahead/behind 为 null = 无法判定(无上游)。
189
+ */
190
+ export function describeRepo(repoPath = '') {
191
+ const branch = runGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: repoPath }).stdout;
192
+ const remote = runGit(['remote', 'get-url', 'origin'], { cwd: repoPath }).stdout;
193
+ const status = runGit(['status', '--porcelain'], { cwd: repoPath }).stdout;
194
+ const last = runGit(['log', '-1', '--format=%h %s'], { cwd: repoPath }).stdout;
195
+ const up = runGit(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], { cwd: repoPath });
196
+ const upOk = up.status === 0;
197
+ const upOut = up.stdout;
198
+ // base 判定与 parseRepoInfo 保持一致(只读一次),决定是否再取 rev-list
199
+ const probe = parseRepoInfo(repoPath, { branch, remote, status, last, upOk, upOut, rcOk: false, rcOut: '' });
200
+ let rcOk = false, rcOut = '';
201
+ const base = probe.upstream || (probe.hasRemote && probe.branch && !probe.branch.startsWith('(') ? `origin/${probe.branch}` : '');
202
+ if (base) {
203
+ const rc = runGit(['rev-list', '--left-right', '--count', `HEAD...${base}`], { cwd: repoPath });
204
+ rcOk = !!rc.ok; rcOut = rc.stdout;
205
+ }
206
+ return parseRepoInfo(repoPath, { branch, remote, status, last, upOk, upOut, rcOk, rcOut });
207
+ }
208
+
209
+ /**
210
+ * 并发版仓库摘要:与 `describeRepo` **同字段同判定**,只是用异步 git(`runGitAsync`)取数。
211
+ *
212
+ * 为什么需要:`runGit` 走 execFileSync,**在 Promise 里调用并不会真正并行**(一个 worker 独占事件循环
213
+ * 直到子进程结束)。实测 27 仓串行 2718ms;改用异步取数后各仓的子进程才能真正并行等待。
214
+ * 只读命令,故可安全并发(写操作禁止并发)。
215
+ */
216
+ export async function describeRepoAsync(repoPath = '') {
217
+ const [branch, remote, status, last, up] = await Promise.all([
218
+ runGitAsync(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: repoPath }),
219
+ runGitAsync(['remote', 'get-url', 'origin'], { cwd: repoPath }),
220
+ runGitAsync(['status', '--porcelain'], { cwd: repoPath }),
221
+ runGitAsync(['log', '-1', '--format=%h %s'], { cwd: repoPath }),
222
+ runGitAsync(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], { cwd: repoPath }),
223
+ ]);
224
+ const raw = {
225
+ branch: branch.stdout, remote: remote.stdout, status: status.stdout, last: last.stdout,
226
+ upOk: up.status === 0, upOut: up.stdout, rcOk: false, rcOut: '',
227
+ };
228
+ const probe = parseRepoInfo(repoPath, raw);
229
+ const base = probe.upstream || (probe.hasRemote && probe.branch && !probe.branch.startsWith('(') ? `origin/${probe.branch}` : '');
230
+ if (base) {
231
+ const rc = await runGitAsync(['rev-list', '--left-right', '--count', `HEAD...${base}`], { cwd: repoPath });
232
+ raw.rcOk = !!rc.ok; raw.rcOut = rc.stdout;
233
+ }
234
+ return parseRepoInfo(repoPath, raw);
235
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Git 执行层 · 本地仓库「增量扫描运行器」
3
+ *
4
+ * 账号卡片「本地 → 扫描」的运行时:
5
+ * **独立进程后台扫描 + 前端只读新增 diff(非轮询、靠进度文件版本)。**
6
+ *
7
+ * 三要素:
8
+ * 1) spawn 独立进程跑 scripts/scan-repos.mjs(系统级后台,不卡宿主/主进程);
9
+ * 2) 进程每扫到一个 author(owner) 一致的仓库 → 增量写 scan-live.json
10
+ * (version 递增 + found 追加),并同步把该仓库并入 dsh-repo-index.json;
11
+ * 3) 宿主用 fs.watchFile 监听 scan-live.json 变化,变化即唤醒 waiters——
12
+ * 前端「等待新版本」请求挂起,直到 version > 已见数或扫描结束才返回新增
13
+ * (非轮询:有新数据才返回,前端只追加变化部分,不全量重读)。
14
+ *
15
+ * 扫描中不可重复启动:running 标志 + alreadyRunning。
16
+ * 文件:$DSH_HOME/git-push/scan-live.json({ version, found:[..], done, startedAt })
17
+ */
18
+ import { spawn } from 'node:child_process';
19
+ import { join, dirname } from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+ import { readFileSync, mkdirSync, existsSync, watchFile, unwatchFile } from 'node:fs';
22
+ import { credentialsDir } from './credentials.js';
23
+ import { writeJsonAtomic } from './atomic-json.js';
24
+
25
+ const LIVE_FILE = 'scan-live.json';
26
+ const WATCH_INTERVAL = 300;
27
+ const SETTLE_WAIT_MS = 800; // 扫描结束后等最后一个写盘落定的时长
28
+
29
+ /** 扫描运行器模块级单例(跨请求共享状态)。 */
30
+ export const scanRunner = {
31
+ running: false, // 是否有扫描在跑(防重复点击)
32
+ currentScanId: '',
33
+ baseFound: [], // 启动时已见 found(前端从这之后算新增)
34
+ lastError: '',
35
+ waiters: [], // [{ resolve }]
36
+ };
37
+
38
+ /** 进度文件路径。 */
39
+ export function scanLiveFile({ workspaceRoot = '' } = {}) {
40
+ return join(credentialsDir({ workspaceRoot }), LIVE_FILE);
41
+ }
42
+
43
+ /** 空进度快照(scan-live.json 缺失/损坏时兜底)。 */
44
+ function emptyLive() {
45
+ return { version: 0, found: [], startedAt: '', done: false };
46
+ }
47
+
48
+ /** 读当前进度快照。 */
49
+ export function readScanLive({ workspaceRoot = '' } = {}) {
50
+ try {
51
+ const p = scanLiveFile({ workspaceRoot });
52
+ if (!existsSync(p)) return emptyLive();
53
+ const snap = JSON.parse(readFileSync(p, 'utf8'));
54
+ return {
55
+ version: Number(snap.version) || 0,
56
+ found: Array.isArray(snap.found) ? snap.found : [],
57
+ startedAt: String(snap.startedAt || ''),
58
+ done: !!snap.done,
59
+ };
60
+ } catch { return emptyLive(); }
61
+ }
62
+
63
+ /** 重置独立进程的进度起点(扫描启动前调用,清空旧 found)。 */
64
+ export function resetScanLive({ workspaceRoot = '' } = {}) {
65
+ const p = scanLiveFile({ workspaceRoot });
66
+ try {
67
+ mkdirSync(dirname(p), { recursive: true });
68
+ writeJsonAtomic(p, { version: 0, found: [], startedAt: new Date().toISOString(), done: false });
69
+ } catch { /* 尽力而为 */ }
70
+ scanRunner.baseFound = [];
71
+ }
72
+
73
+ /**
74
+ * spawn 独立进程跑离线扫描 scripts/scan-repos.mjs。
75
+ * 立即返回 { ok, started, scanId, baseFound };已有扫描在跑 → { alreadyRunning: true }。
76
+ * 独立进程每写一次 scan-live.json → fs.watchFile 唤醒 waiters(见 waitScanDelta)。
77
+ */
78
+ export function runScan({ root = '', owner = 'EIGHTfs', workspaceRoot = '' } = {}) {
79
+ if (scanRunner.running) return { alreadyRunning: true };
80
+ // 脚本路径:<repo>/scripts/scan-repos.mjs(本文件 <repo>/lib/git/ 上溯两级)
81
+ const script = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'scripts', 'scan-repos.mjs');
82
+ if (!existsSync(script)) return { ok: false, error: `扫描脚本不存在: ${script}` };
83
+
84
+ resetScanLive({ workspaceRoot });
85
+ scanRunner.running = true;
86
+ scanRunner.currentScanId = `scan-${Date.now()}`;
87
+ scanRunner.lastError = '';
88
+ scanRunner.waiters = [];
89
+ const scanId = scanRunner.currentScanId;
90
+
91
+ // detached 独立进程:脱离宿主进程组,宿主退出不影响它继续扫完;offline 隔离网络
92
+ const child = spawn(process.execPath, [script, '--root', String(root || ''), '--owner', String(owner || 'EIGHTfs'), '--max', '200', '--depth', '10'], {
93
+ detached: true,
94
+ stdio: ['ignore', 'pipe', 'ignore'],
95
+ env: { ...process.env, DSH_GIT_PUSH_OFFLINE: '1' },
96
+ });
97
+ child.unref();
98
+ child.stdout?.on('data', (d) => {
99
+ try { process.stdout?.write(`[scan-repos] ${String(d)}`); } catch { /* 日志尽力而为 */ }
100
+ });
101
+ child.on('exit', (code) => {
102
+ scanRunner.lastError = code === 0 ? '' : `扫描退出码 ${code}`;
103
+ scanRunner.running = false;
104
+ // 扫完等 ~800ms 让最后一个写盘落定,再唤醒等待者收尾
105
+ setTimeout(() => notifyWaiters(), SETTLE_WAIT_MS);
106
+ });
107
+
108
+ // fs.watchFile 监听进度文件变化 → 唤醒等待者(非轮询:文件变才通知)
109
+ const fp = scanLiveFile({ workspaceRoot });
110
+ try { watchFile(fp, { interval: WATCH_INTERVAL }, () => notifyWaiters()); } catch { /* 监听失败则靠超时/进程 exit */ }
111
+
112
+ return { ok: true, started: true, scanId, baseFound: scanRunner.baseFound.slice(), running: true };
113
+ }
114
+
115
+ /** 唤醒所有等待者(独立进程写了新进度 / 扫描结束 / 文件变化)。 */
116
+ function notifyWaiters() {
117
+ const ws = scanRunner.waiters;
118
+ if (!ws || !ws.length) return;
119
+ scanRunner.waiters = [];
120
+ for (const waiter of ws) waiter.resolve();
121
+ }
122
+
123
+ /**
124
+ * 等待新版本(非轮询):挂起请求直到 scan-live.json 有新仓库(found 多了)或扫描结束。
125
+ * from 传「已见仓库数」;返回本次新增的仓库名数组(前端只追加这些,不全量重读)。
126
+ */
127
+ export async function waitScanDelta({ from = 0, timeoutMs = 60_000, workspaceRoot = '' } = {}) {
128
+ const fromN = Number(from) || 0;
129
+ return new Promise((resolve) => {
130
+ const collect = () => {
131
+ const live = readScanLive({ workspaceRoot });
132
+ return {
133
+ newest: (live.found || []).slice(fromN),
134
+ version: Number(live.version) || 0,
135
+ done: !!live.done,
136
+ running: scanRunner.running,
137
+ timeout: false,
138
+ };
139
+ };
140
+ let settled = false;
141
+ const settle = () => { if (settled) return; settled = true; cleanup(); resolve(collect()); };
142
+ const timeout = setTimeout(() => {
143
+ if (settled) return; settled = true; cleanup();
144
+ const live = readScanLive({ workspaceRoot });
145
+ resolve({ newest: [], version: Number(live.version) || 0, done: !!live.done, running: scanRunner.running, timeout: true });
146
+ }, timeoutMs);
147
+ const cleanup = () => { clearTimeout(timeout); };
148
+ // 立即查一次:已有新增或已 done 则直接返回
149
+ const live = readScanLive({ workspaceRoot });
150
+ if ((live.found || []).length > fromN || live.done) { settle(); return; }
151
+ scanRunner.waiters.push({ resolve: settle });
152
+ });
153
+ }
154
+
155
+ /** 清理 fs 监听(测试/重置用)。正常运行时进程退出自动收敛,不必显式调。 */
156
+ export function stopScanWatch({ workspaceRoot = '' } = {}) {
157
+ const fp = scanLiveFile({ workspaceRoot });
158
+ try { unwatchFile(fp); } catch { /* 忽略 */ }
159
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Git 执行层 · 敏感信息扫描
3
+ *
4
+ * 职责:提交推送前扫描待入库内容里的密钥/凭据/私密文件,命中即拦。
5
+ * 占位符与示例上下文豁免(SENSITIVE_PLACEHOLDER_VALUE / SENSITIVE_EXAMPLE_CONTEXT)
6
+ * 保证文档里的示范值不被误报成真实凭据。
7
+ */
8
+
9
+ import { readFile, readdir, stat } from 'node:fs/promises';
10
+ import { join } from 'node:path';
11
+ import { isTestExemptDir } from '../exempt/index.js';
12
+ import { getSkipSet } from '../skip-dirs.js';
13
+
14
+ /* ───────────────────────── 敏感文件自动 .gitignore ───────────────────────── */
15
+
16
+ const SENSITIVE_NAMES = new Set(['.env', '.env.local', 'github-token', '.git-push-token', 'id_rsa', 'id_ed25519', 'id_ecdsa', '*.pem', '*.key']);
17
+
18
+ /** 扫描仓库内敏感文件(相对路径列表)。 */
19
+ /** 递归扫描跳过的目录 = 统一跳过目录(node_modules/.git + yml 黑名单关键词, 共用 lib/skip-dirs.js)。 */
20
+ const SENSITIVE_SKIP_DIRS = getSkipSet();
21
+
22
+ /** 明显二进制/图片/压缩/媒体扩展名,不当作文本扫描。 */
23
+ const SENSITIVE_BINARY_EXT = new Set(['png','jpg','jpeg','gif','webp','bmp','ico','svg','zip','7z','rar','gz','tar','xz','pdf','exe','dll','so','dylib','bin','woff','woff2','ttf','otf','mp4','mp3','ogg','wav','flac','db','sqlite','ico']);
24
+
25
+ /** 敏感字段(cookie / 设备 / 用户名 / 密码 / token-secret),键名大小写不敏感。 */
26
+ const SENSITIVE_KEYS = [
27
+ { name: 'cookie', keys: ['cookie', 'cookies'], valueMin: 4 },
28
+ { name: 'device', keys: ['device_id','device-id','deviceid','device_name','device-info','machine_id','machine-id','hardware_id','hardware-id','imei','serial_number','serial-number'], valueMin: 2 },
29
+ { name: 'username', keys: ['username','user_name','user-name','login_name','login-name'], valueMin: 2 },
30
+ { name: 'password', keys: ['password','passwd','pass_word','pass-word','pwd'], valueMin: 3 },
31
+ { name: 'token/secret', keys: ['api_key','api-key','apikey','api_secret','api-secret','access_key','access-key','auth_token','auth-token','refresh_token','refresh-token','secret_key','secret-key','client_secret','client-secret'], valueMin: 6 },
32
+ ];
33
+
34
+ /** 占位符/示例值:值看起来是假的就不报(防 README/示例误伤)。 */
35
+ const SENSITIVE_PLACEHOLDER_VALUE = /^(your[-_ ]?[a-z]+|xxx+\.?\.?|example|changeme|dummy|sample|demo|placeholder|<[^>]+>|\$\{?[A-Z_][A-Z0-9_]*}?|process\.env\.[A-Z_]+|env\.[A-Z_]+|undefined|null|true|false)$/i;
36
+
37
+ /** 行内示例上下文:出现即整行豁免(举例/示例/演示)。 */
38
+ const SENSITIVE_EXAMPLE_CONTEXT = /(例如|举例|示例|样例|演示|比如|fake|sample|demo|example|illustration)/i;
39
+
40
+ /** 豁免标记:行尾注释豁免单行 / 文件头(前 3 行)声明豁免整文件(大小写不敏感)。 */
41
+ const SENSITIVE_EXEMPT_RE = /dsh-skip-sensitive/i;
42
+
43
+ function escapeRegExp(s) {
44
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
45
+ }
46
+
47
+ /** 单行敏感字段匹配:返回字段名或 null(跳过豁免注释/示例行/占位符值)。 */
48
+ function sensitiveLineMatch(line) {
49
+ if (SENSITIVE_EXEMPT_RE.test(line)) return null; // 行内注释豁免
50
+ if (SENSITIVE_EXAMPLE_CONTEXT.test(line)) return null;
51
+ const clean = line.replace(/^[#;/\*\s]+/, ''); // 去掉行首注释标记与空白
52
+ for (const k of SENSITIVE_KEYS) {
53
+ const re = new RegExp(`(?:^|[^A-Za-z0-9_])(?:${k.keys.map(escapeRegExp).join('|')})\\s*[:=]\\s*(.*)$`, 'i');
54
+ const match = clean.match(re);
55
+ if (match) {
56
+ // 值必须是「纯净字符串字面量」才算硬编码凭据:变量/函数调用/表达式/拼接/插值不算
57
+ const raw = match[1].trim();
58
+ const qm = raw.match(/^(["'`])([\s\S]*?)\1\s*[,;)\]}\s]*$/);
59
+ if (!qm) continue;
60
+ let fieldValue = qm[2].trim();
61
+ if (/\+|\$\{/.test(fieldValue)) continue; // 拼接/模板插值 = 表达式
62
+ if (/[\u4e00-\u9fff]/.test(fieldValue)) continue; // 值含中文 = UI 文案/说明,不是凭据(如 account: '账号检查')
63
+ if (fieldValue.length >= k.valueMin && !SENSITIVE_PLACEHOLDER_VALUE.test(fieldValue)) return k.name;
64
+ }
65
+ }
66
+ return null;
67
+ }
68
+
69
+ /**
70
+ * 扫描仓库全部文本文件,找出含敏感字段(cookie/device/username/password/token-secret)的文件。
71
+ * 内容级检测:键值对 + 字符串字面量判定 + 占位符/示例/豁免注释;≤512KB、跳过二进制/图片/忽略目录。
72
+ * 补充文件名黑名单(.env/id_rsa/*.pem 等)——名字本身就是凭据载体,无需读内容。
73
+ * @returns {{path: string, fields: string[]}[]}
74
+ */
75
+ /**
76
+ * 单个文件的敏感检查:文件名黑名单 + 内容级敏感键值(含大小 / 二进制 / 文件头豁免)。
77
+ *
78
+ * 为什么单独成函数:原先内联在 scanSensitiveFiles 的 `walk` 闭包里,把该函数圈复杂度推到
79
+ * 25(阈值 10,自审 max-cyclomatic-complexity)。提取后用**返回值**表达命中,
80
+ * 递归遍历只管「往下走」。
81
+ *
82
+ * @returns {{path:string, fields:string[]}|null} 命中返回条目(fields 含 'filename' 或键名),否则 null
83
+ */
84
+ async function scanOneSensitiveFile(dir, it, relPath) {
85
+ // 文件名黑名单:名字本身就是凭据载体
86
+ for (const n of SENSITIVE_NAMES) {
87
+ if (n.includes('*')) {
88
+ if (new RegExp(`^${n.replace('*', '.*')}$`).test(it.name)) return { path: relPath, fields: ['filename'] };
89
+ } else if (it.name === n) return { path: relPath, fields: ['filename'] };
90
+ }
91
+ // 内容级:文本文件内敏感键值检测
92
+ try {
93
+ const st = await stat(join(dir, it.name));
94
+ if (st.size > 512 * 1024) return null;
95
+ } catch { return null; }
96
+ const dot = it.name.lastIndexOf('.');
97
+ const ext = dot >= 0 ? it.name.slice(dot + 1).toLowerCase() : '';
98
+ if (SENSITIVE_BINARY_EXT.has(ext)) return null;
99
+ let text;
100
+ try { text = await readFile(join(dir, it.name), 'utf8'); } catch { return null; }
101
+ if (/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/.test(text)) return null; // 二进制内容
102
+ if (SENSITIVE_EXEMPT_RE.test(text.split('\n').slice(0, 3).join('\n'))) return null; // 文件头豁免整文件
103
+ const fields = [];
104
+ for (const line of text.split('\n')) {
105
+ const r = sensitiveLineMatch(line);
106
+ if (r && !fields.includes(r)) fields.push(r);
107
+ if (fields.length === SENSITIVE_KEYS.length) break;
108
+ }
109
+ return fields.length ? { path: relPath, fields } : null;
110
+ }
111
+
112
+ export async function scanSensitiveFiles(repoPath) {
113
+ const hits = [];
114
+ // 递归扫描:改异步以免在大仓库上逐文件阻塞事件循环
115
+ // (readdir 带 withFileTypes,目录项类型一次带回;内容读取与 stat 同样异步化)
116
+ const walk = async (dir, rel) => {
117
+ let items;
118
+ try { items = await readdir(dir, { withFileTypes: true }); } catch { return; }
119
+ for (const it of items) {
120
+ const relPath = rel ? `${rel}/${it.name}` : it.name;
121
+ if (it.isDirectory()) {
122
+ if (SENSITIVE_SKIP_DIRS.has(it.name)) continue;
123
+ // .test 空文件豁免:整目录敏感扫描跳过(含子目录)
124
+ if (relPath && isTestExemptDir(repoPath, relPath)) continue;
125
+ await walk(join(dir, it.name), relPath);
126
+ } else if (it.isFile()) {
127
+ const hit = await scanOneSensitiveFile(dir, it, relPath);
128
+ if (hit) hits.push(hit);
129
+ }
130
+ }
131
+ };
132
+ await walk(repoPath, '');
133
+ return hits;
134
+ }