@whyour/qinglong 2.21.0 → 2.23.0

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 (362) hide show
  1. package/.dockerignore +13 -0
  2. package/.env.example +7 -0
  3. package/AGENTS.md +2 -2
  4. package/README-en.md +24 -0
  5. package/README.md +24 -0
  6. package/back/protos/api.proto +9 -1
  7. package/back/protos/cron.proto +8 -1
  8. package/deploy/kubernetes/README.md +81 -0
  9. package/deploy/kubernetes/base/kustomization.yaml +5 -0
  10. package/deploy/kubernetes/base/qinglong.yaml +95 -0
  11. package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
  12. package/docker/Dockerfile +31 -12
  13. package/docker/Dockerfile.310 +31 -12
  14. package/docker/Dockerfile.debian +22 -14
  15. package/docker/Dockerfile.debian310 +24 -14
  16. package/docker/build-manifest.cjs +28 -0
  17. package/docker/verify-build.cjs +49 -0
  18. package/docs/development/node-cron-migration.md +49 -0
  19. package/docs/development/task-startup.md +78 -0
  20. package/docs/releases/2.22.0-validation.md +49 -0
  21. package/docs/releases/2.22.0.md +62 -0
  22. package/docs/releases/2.23.0.md +33 -0
  23. package/docs/script-history.md +53 -0
  24. package/ecosystem.config.js +10 -1
  25. package/package.json +19 -13
  26. package/sample/config.sample.sh +17 -2
  27. package/sample/notify.js +118 -0
  28. package/sample/notify.py +93 -0
  29. package/scripts/benchmark-execution.cjs +96 -0
  30. package/scripts/benchmark-script-history.cjs +39 -0
  31. package/scripts/publish-static.sh +34 -0
  32. package/scripts/sync-static.sh +20 -0
  33. package/scripts/wait-for-mirror.sh +214 -0
  34. package/scripts/write-build-info.cjs +27 -0
  35. package/shell/api.sh +96 -83
  36. package/shell/check.sh +59 -19
  37. package/shell/lang/en.sh +6 -0
  38. package/shell/lang/zh.sh +6 -0
  39. package/shell/node_path_cache.sh +136 -0
  40. package/shell/otask.sh +17 -10
  41. package/shell/preload/sitecustomize.js +11 -3
  42. package/shell/preload/sitecustomize.py +4 -2
  43. package/shell/share.sh +27 -10
  44. package/shell/start.sh +6 -3
  45. package/shell/task-timeout.sh +63 -0
  46. package/shell/task.sh +21 -9
  47. package/shell/update.sh +104 -98
  48. package/shell/upgrade.cjs +8 -0
  49. package/static/build/api/clientIp.js +42 -0
  50. package/static/build/api/config.js +9 -21
  51. package/static/build/api/cron.js +39 -3
  52. package/static/build/api/dashboard.js +50 -6
  53. package/static/build/api/env.js +17 -16
  54. package/static/build/api/health.js +2 -2
  55. package/static/build/api/index.js +4 -0
  56. package/static/build/api/log.js +39 -19
  57. package/static/build/api/open.js +2 -1
  58. package/static/build/api/retention.js +63 -0
  59. package/static/build/api/script.js +172 -25
  60. package/static/build/api/subscription.js +19 -8
  61. package/static/build/api/system.js +66 -12
  62. package/static/build/api/user.js +75 -15
  63. package/static/build/app.js +63 -54
  64. package/static/build/bootstrap/database.js +51 -0
  65. package/static/build/config/const.js +2 -0
  66. package/static/build/config/grpcCerts.js +93 -44
  67. package/static/build/config/index.js +0 -4
  68. package/static/build/config/share.js +5 -4
  69. package/static/build/config/subscription.js +19 -11
  70. package/static/build/config/util.js +142 -45
  71. package/static/build/data/cron.js +1 -0
  72. package/static/build/data/notify.js +18 -1
  73. package/static/build/data/sock.js +1 -0
  74. package/static/build/loaders/app.js +8 -6
  75. package/static/build/loaders/db.js +5 -35
  76. package/static/build/loaders/deps.js +30 -22
  77. package/static/build/loaders/express.js +46 -32
  78. package/static/build/loaders/initData.js +26 -33
  79. package/static/build/loaders/initFile.js +1 -1
  80. package/static/build/loaders/initTask.js +14 -3
  81. package/static/build/loaders/server.js +1 -1
  82. package/static/build/loaders/sock.js +72 -6
  83. package/static/build/middlewares/monitoring.js +12 -33
  84. package/static/build/middlewares/protectedPathCase.js +17 -0
  85. package/static/build/middlewares/uniqueConstraintError.js +15 -0
  86. package/static/build/protos/api.js +78 -2
  87. package/static/build/protos/cron.js +83 -5
  88. package/static/build/protos/health.js +1 -1
  89. package/static/build/schedule/addCron.js +67 -19
  90. package/static/build/schedule/api.js +5 -2
  91. package/static/build/schedule/client.js +56 -6
  92. package/static/build/schedule/delCron.js +11 -1
  93. package/static/build/schedule/health.js +72 -7
  94. package/static/build/schedule/setConcurrency.js +27 -0
  95. package/static/build/services/config.js +5 -43
  96. package/static/build/services/cron.js +389 -174
  97. package/static/build/services/dependence.js +66 -18
  98. package/static/build/services/env.js +1 -1
  99. package/static/build/services/grpc.js +4 -3
  100. package/static/build/services/health.js +4 -7
  101. package/static/build/services/http.js +9 -3
  102. package/static/build/services/log.js +2 -3
  103. package/static/build/services/metrics.js +46 -14
  104. package/static/build/services/notify.js +73 -5
  105. package/static/build/services/open.js +106 -31
  106. package/static/build/services/retention.js +123 -0
  107. package/static/build/services/schedule.js +77 -43
  108. package/static/build/services/script.js +4 -5
  109. package/static/build/services/scriptHistory.js +30 -0
  110. package/static/build/services/sshKey.js +39 -14
  111. package/static/build/services/subscription.js +161 -87
  112. package/static/build/services/system.js +116 -43
  113. package/static/build/services/user.js +255 -37
  114. package/static/build/shared/auth.js +22 -3
  115. package/static/build/shared/authMutation.js +17 -0
  116. package/static/build/shared/childProcess.js +82 -0
  117. package/static/build/shared/clientIp.js +27 -0
  118. package/static/build/shared/cronCommand.js +17 -0
  119. package/static/build/shared/cronSchedule.js +101 -0
  120. package/static/build/shared/cronScheduler.js +73 -0
  121. package/static/build/shared/errors.js +9 -0
  122. package/static/build/shared/fileAccess.js +60 -0
  123. package/static/build/shared/i18n.js +63 -4
  124. package/static/build/shared/logPath.js +15 -0
  125. package/static/build/shared/logReader.js +85 -0
  126. package/static/build/shared/logStreamManager.js +80 -60
  127. package/static/build/shared/loginThrottle.js +45 -0
  128. package/static/build/shared/pLimit.js +22 -8
  129. package/static/build/shared/password.js +30 -0
  130. package/static/build/shared/retention.js +58 -0
  131. package/static/build/shared/runCron.js +39 -17
  132. package/static/build/shared/schedulerMutationLock.js +44 -0
  133. package/static/build/shared/schedulerReadiness.js +82 -0
  134. package/static/build/shared/schemaMigrations.js +58 -0
  135. package/static/build/shared/scriptHistory.js +445 -0
  136. package/static/build/shared/shellQuote.js +11 -0
  137. package/static/build/shared/startupProcess.js +48 -0
  138. package/static/build/shared/store.js +7 -0
  139. package/static/build/shared/subscriptionMutationLock.js +34 -0
  140. package/static/build/shared/subscriptionPath.js +41 -0
  141. package/static/build/shared/subscriptionStorage.js +98 -0
  142. package/static/build/shared/trustProxy.js +119 -0
  143. package/static/build/shared/utils.js +2 -1
  144. package/static/build/token.js +3 -14
  145. package/static/build/validation/schedule.js +6 -12
  146. package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
  147. package/static/dist/2031.6af40025.async.js +1 -0
  148. package/static/dist/2693.51c2636b.async.js +1 -0
  149. package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
  150. package/static/dist/2901.2ca95295.async.js +1 -0
  151. package/static/dist/292.264757f0.async.js +1 -0
  152. package/static/dist/3512.95e41255.async.js +1 -0
  153. package/static/dist/445.a65ff63b.async.js +1 -0
  154. package/static/dist/4736.1d2b5cb6.async.js +1 -0
  155. package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
  156. package/static/dist/6212.9e6d9913.async.js +1 -0
  157. package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
  158. package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
  159. package/static/dist/7231.f7e5b668.async.js +1 -0
  160. package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
  161. package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
  162. package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
  163. package/static/dist/8844.a0fef08e.async.js +1 -0
  164. package/static/dist/index.html +2 -2
  165. package/static/dist/layouts__index.633d3553.async.js +1 -0
  166. package/static/dist/preload_helper.01fcd534.js +1 -0
  167. package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
  168. package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
  169. package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
  170. package/static/dist/{src__pages__crontab__logModal.0b8cce8c.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
  171. package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
  172. package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
  173. package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
  174. package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
  175. package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
  176. package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
  177. package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
  178. package/static/dist/src__pages__dependence__modal.0fa8b421.async.js +1 -0
  179. package/static/dist/src__pages__diff__index.b94e5dc5.async.js +1 -0
  180. package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
  181. package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
  182. package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
  183. package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
  184. package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
  185. package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
  186. package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
  187. package/static/dist/src__pages__script__editModal.afabf073.async.js +1 -0
  188. package/static/dist/src__pages__script__editNameModal.789ad87b.async.js +1 -0
  189. package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js +1 -0
  190. package/static/dist/src__pages__script__historyDrawer.a449193a.chunk.css +1 -0
  191. package/static/dist/src__pages__script__index.ab360776.chunk.css +1 -0
  192. package/static/dist/src__pages__script__index.fc575945.async.js +1 -0
  193. package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
  194. package/static/dist/src__pages__script__saveModal.8fca1a22.async.js +1 -0
  195. package/static/dist/src__pages__script__saveWithHistory.99ece830.async.js +1 -0
  196. package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
  197. package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
  198. package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +1 -0
  199. package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
  200. package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
  201. package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
  202. package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
  203. package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
  204. package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
  205. package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
  206. package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
  207. package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
  208. package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
  209. package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
  210. package/static/dist/src__pages__subscription__modal.30868ba8.async.js +1 -0
  211. package/static/dist/{umi.ca04a019.js → umi.3a24a9fa.js} +1 -1
  212. package/test/back/advisory-input-security.test.cjs +416 -0
  213. package/test/back/auth-security.test.cjs +74 -0
  214. package/test/back/build-provenance.test.cjs +150 -0
  215. package/test/back/code-scanning-security.test.cjs +189 -0
  216. package/test/back/cron-log-name.test.cjs +110 -0
  217. package/test/back/cron-macros.test.cjs +51 -0
  218. package/test/back/cron-schedule-compatibility.test.cjs +69 -0
  219. package/test/back/cron-scheduler-routing.test.cjs +59 -0
  220. package/test/back/cron-validation.test.cjs +45 -0
  221. package/test/back/dashboard-failures.test.cjs +173 -0
  222. package/test/back/database-bootstrap.test.cjs +193 -0
  223. package/test/back/dependence-cache-status.test.cjs +125 -0
  224. package/test/back/deprecated-file-routes.test.cjs +82 -0
  225. package/test/back/draft-path-security.test.cjs +235 -0
  226. package/test/back/ecosystem.test.cjs +28 -0
  227. package/test/back/env-import-security.test.cjs +91 -0
  228. package/test/back/env-name-parsing.test.cjs +96 -0
  229. package/test/back/execution-lifecycle.test.cjs +236 -0
  230. package/test/back/file-access-scope.test.cjs +180 -0
  231. package/test/back/file-access-security.test.cjs +47 -0
  232. package/test/back/fileTreeListing.test.cjs +57 -0
  233. package/test/back/grpc-cron-response.test.cjs +60 -0
  234. package/test/back/grpc-mtls-security.test.cjs +136 -0
  235. package/test/back/http-exclusive-listen.test.cjs +31 -0
  236. package/test/back/http-security.test.cjs +313 -0
  237. package/test/back/legacy-cron-recovery.test.cjs +76 -0
  238. package/test/back/linux-mirror-result.test.cjs +176 -0
  239. package/test/back/listen-security.test.cjs +68 -0
  240. package/test/back/log-path-security.test.cjs +158 -0
  241. package/test/back/logReader.test.cjs +72 -0
  242. package/test/back/manual-execution.test.cjs +85 -0
  243. package/test/back/manual-stop-claim.test.cjs +220 -0
  244. package/test/back/metrics.test.cjs +34 -0
  245. package/test/back/mirror-status.test.cjs +257 -0
  246. package/test/back/monitoring.test.cjs +73 -0
  247. package/test/back/node-cron-migration.test.cjs +65 -0
  248. package/test/back/node-path-cache.test.cjs +202 -0
  249. package/test/back/node-path-lock.test.cjs +182 -0
  250. package/test/back/npm-publication.test.cjs +70 -0
  251. package/test/back/preload-lazy-notify.test.cjs +168 -0
  252. package/test/back/primary-apm.test.cjs +24 -0
  253. package/test/back/process-exit-state.test.cjs +81 -0
  254. package/test/back/process-stop-signal.test.cjs +77 -0
  255. package/test/back/protected-path-case.test.cjs +58 -0
  256. package/test/back/qlServiceLogCommand.test.cjs +128 -0
  257. package/test/back/queued-cron-invalidation.test.cjs +98 -0
  258. package/test/back/restart-instance-recovery.test.cjs +116 -0
  259. package/test/back/retention.test.cjs +131 -0
  260. package/test/back/role-loading.test.cjs +118 -0
  261. package/test/back/schedule-health.test.cjs +86 -0
  262. package/test/back/scheduler-bulk-recovery.test.cjs +40 -0
  263. package/test/back/scheduler-concurrency.test.cjs +411 -0
  264. package/test/back/scheduler-file-lock.test.cjs +51 -0
  265. package/test/back/scheduler-mutation.test.cjs +312 -0
  266. package/test/back/scheduler-readiness.test.cjs +85 -0
  267. package/test/back/scheduler-reconciliation.test.cjs +206 -0
  268. package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
  269. package/test/back/schema-migrations.test.cjs +127 -0
  270. package/test/back/script-file-access.test.cjs +210 -0
  271. package/test/back/script-history-api.test.cjs +551 -0
  272. package/test/back/script-history.test.cjs +383 -0
  273. package/test/back/shell-api-parsing.test.cjs +184 -0
  274. package/test/back/shell-translation-output.test.cjs +16 -0
  275. package/test/back/shell-upgrade.test.cjs +312 -0
  276. package/test/back/shellApiToken.test.cjs +151 -0
  277. package/test/back/sock-polling.test.cjs +297 -0
  278. package/test/back/sock-security.test.cjs +72 -0
  279. package/test/back/ssh-config-home.test.cjs +113 -0
  280. package/test/back/start-env-preservation.test.cjs +53 -0
  281. package/test/back/static-mirror-trigger.test.cjs +441 -0
  282. package/test/back/static-mirror.test.cjs +179 -0
  283. package/test/back/stop-failure-feedback.test.cjs +158 -0
  284. package/test/back/stop-race.test.cjs +171 -0
  285. package/test/back/subscription-cleanup.test.cjs +53 -0
  286. package/test/back/subscription-mutation-lock.test.cjs +83 -0
  287. package/test/back/subscription-review-regression.test.cjs +607 -0
  288. package/test/back/subscription-stop-state.test.cjs +66 -0
  289. package/test/back/subscription-storage-regression.test.cjs +553 -0
  290. package/test/back/system-dependence-cache.test.cjs +127 -0
  291. package/test/back/system-export-history.test.cjs +119 -0
  292. package/test/back/systemTokenRenewal.test.cjs +497 -0
  293. package/test/back/task-shell-lifecycle.test.cjs +194 -0
  294. package/test/back/task-time.test.cjs +116 -0
  295. package/test/back/unique-constraint-error.test.cjs +72 -0
  296. package/test/back/upgrade-guards.test.cjs +285 -0
  297. package/test/back/upgrade-lifecycle.test.cjs +288 -0
  298. package/test/back/upgrade-transaction.test.cjs +133 -0
  299. package/test/back/user-api.test.cjs +99 -0
  300. package/test/back/user-security.test.cjs +349 -0
  301. package/test/back/worker-apm.test.cjs +84 -0
  302. package/test/back/wpush-grpc.test.cjs +116 -0
  303. package/test/fixtures/legacy-cron.json +1371 -0
  304. package/test/front/cron-log-pagination.test.cjs +214 -0
  305. package/test/front/diff-file-routing.test.cjs +126 -0
  306. package/test/front/http-auth.test.cjs +152 -0
  307. package/test/front/http-error.test.cjs +29 -0
  308. package/test/front/script-history-save.test.cjs +121 -0
  309. package/test/helpers/load-security-module.cjs +42 -0
  310. package/test/helpers/upgrade-fixture.cjs +30 -0
  311. package/version.yaml +14 -34
  312. package/CLAUDE.md +0 -43
  313. package/static/dist/1147.c420132e.async.js +0 -1
  314. package/static/dist/134.54df9e38.async.js +0 -1
  315. package/static/dist/2096.6d98fd12.async.js +0 -1
  316. package/static/dist/2208.f7ba3dfa.async.js +0 -1
  317. package/static/dist/2286.164bb089.async.js +0 -1
  318. package/static/dist/3191.63263871.async.js +0 -1
  319. package/static/dist/4859.6592cebb.async.js +0 -1
  320. package/static/dist/4902.555f92ab.async.js +0 -1
  321. package/static/dist/5520.ff2cfd6b.async.js +0 -1
  322. package/static/dist/6431.c50479be.async.js +0 -1
  323. package/static/dist/6707.801b886b.async.js +0 -1
  324. package/static/dist/8826.2447a104.async.js +0 -1
  325. package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
  326. package/static/dist/preload_helper.0431c0f3.js +0 -1
  327. package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
  328. package/static/dist/src__pages__crontab__index.fed99fd0.async.js +0 -1
  329. package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
  330. package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
  331. package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
  332. package/static/dist/src__pages__dashboard__index.b30f2f47.async.js +0 -1
  333. package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
  334. package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
  335. package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
  336. package/static/dist/src__pages__diff__index.013b7c75.async.js +0 -1
  337. package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
  338. package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
  339. package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
  340. package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
  341. package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
  342. package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
  343. package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
  344. package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
  345. package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
  346. package/static/dist/src__pages__script__index.60b6f827.chunk.css +0 -1
  347. package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
  348. package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
  349. package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
  350. package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
  351. package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
  352. package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
  353. package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
  354. package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
  355. package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
  356. package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
  357. package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
  358. package/static/dist/src__pages__setting__systemLog.67406721.async.js +0 -1
  359. package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
  360. package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
  361. package/static/dist/src__pages__subscription__modal.3562c670.async.js +0 -1
  362. /package/static/dist/{4859.1b962b29.chunk.css → 292.1b962b29.chunk.css} +0 -0
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.updateLinuxMirrorFile = exports.detectOS = exports.isDemoEnv = exports.getUninstallCommand = exports.getInstallCommand = exports.getGetCommand = exports.setSystemTimezone = exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.killAllTasks = exports.getAllPids = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getToken = exports.getLastModifyFilePath = exports.removeAnsi = exports.getFileContentByName = void 0;
32
+ exports.updateLinuxMirrorFile = exports.detectOS = exports.isDemoEnv = exports.getUninstallCommand = exports.getInstallCommand = exports.getGetCommand = exports.setSystemTimezone = exports.rmPath = exports.errStack = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.killAllTasks = exports.getAllPids = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getToken = exports.getLastModifyFilePath = exports.removeAnsi = exports.getFileContentByName = void 0;
33
33
  const fs = __importStar(require("fs/promises"));
34
34
  const path = __importStar(require("path"));
35
35
  const child_process_1 = require("child_process");
@@ -44,6 +44,7 @@ const dependence_1 = require("../data/dependence");
44
44
  const undici_1 = require("undici");
45
45
  const os_1 = __importDefault(require("os"));
46
46
  const container_1 = require("./container");
47
+ const fileAccess_1 = require("../shared/fileAccess");
47
48
  __exportStar(require("./share"), exports);
48
49
  let osType;
49
50
  function getOsTypeSync() {
@@ -172,7 +173,9 @@ async function createFile(file, data = '') {
172
173
  }
173
174
  exports.createFile = createFile;
174
175
  async function handleLogPath(logPath, data = '') {
175
- const absolutePath = path.resolve(index_1.default.logPath, logPath);
176
+ const absolutePath = (0, fileAccess_1.resolveFileAccess)(index_1.default.logPath, [logPath]);
177
+ if (!absolutePath)
178
+ throw new Error('Log path is outside the log directory');
176
179
  const logFileExist = await fileExist(absolutePath);
177
180
  if (!logFileExist) {
178
181
  await createFile(absolutePath, data);
@@ -226,40 +229,66 @@ function dirSort(a, b) {
226
229
  }
227
230
  }
228
231
  exports.dirSort = dirSort;
229
- async function readDirs(dir, baseDir = '', blacklist = [], sort = dirSort) {
232
+ const FILE_SYSTEM_READ_CONCURRENCY = 32;
233
+ function createFileSystemTaskRunner(concurrency) {
234
+ let activeCount = 0;
235
+ const queue = [];
236
+ const runNext = () => {
237
+ var _a;
238
+ while (activeCount < concurrency && queue.length > 0) {
239
+ activeCount += 1;
240
+ (_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
241
+ }
242
+ };
243
+ return (task) => new Promise((resolve, reject) => {
244
+ queue.push(() => {
245
+ task()
246
+ .then(resolve, reject)
247
+ .finally(() => {
248
+ activeCount -= 1;
249
+ runNext();
250
+ });
251
+ });
252
+ runNext();
253
+ });
254
+ }
255
+ async function readDirsWithRunner(dir, baseDir, blacklist, sort, runFileSystemTask) {
230
256
  const relativePath = path.relative(baseDir, dir);
231
- const files = await fs.readdir(dir);
232
- const result = [];
233
- for (const file of files) {
234
- const subPath = path.join(dir, file);
235
- const stats = await fs.lstat(subPath);
236
- const key = path.join(relativePath, file);
237
- if (blacklist.includes(file) || stats.isSymbolicLink()) {
238
- continue;
257
+ const entries = await runFileSystemTask(() => fs.readdir(dir, { withFileTypes: true }));
258
+ const items = await Promise.all(entries.map(async (entry) => {
259
+ if (blacklist.includes(entry.name) || entry.isSymbolicLink()) {
260
+ return undefined;
261
+ }
262
+ const subPath = path.join(dir, entry.name);
263
+ const stats = await runFileSystemTask(() => fs.lstat(subPath));
264
+ if (stats.isSymbolicLink()) {
265
+ return undefined;
239
266
  }
267
+ const key = path.join(relativePath, entry.name);
240
268
  if (stats.isDirectory()) {
241
- const children = await readDirs(subPath, baseDir, blacklist, sort);
242
- result.push({
243
- title: file,
269
+ const children = await readDirsWithRunner(subPath, baseDir, blacklist, sort, runFileSystemTask);
270
+ return {
271
+ title: entry.name,
244
272
  key,
245
273
  type: 'directory',
246
274
  parent: relativePath,
247
275
  createTime: stats.birthtime.getTime(),
248
- children: children.sort(sort),
249
- });
276
+ children,
277
+ };
250
278
  }
251
- else {
252
- result.push({
253
- title: file,
254
- type: 'file',
255
- key,
256
- parent: relativePath,
257
- size: stats.size,
258
- createTime: stats.birthtime.getTime(),
259
- });
260
- }
261
- }
262
- return result.sort(sort);
279
+ return {
280
+ title: entry.name,
281
+ type: 'file',
282
+ key,
283
+ parent: relativePath,
284
+ size: stats.size,
285
+ createTime: stats.birthtime.getTime(),
286
+ };
287
+ }));
288
+ return items.filter((item) => Boolean(item)).sort(sort);
289
+ }
290
+ async function readDirs(dir, baseDir = '', blacklist = [], sort = dirSort) {
291
+ return readDirsWithRunner(dir, baseDir, blacklist, sort, createFileSystemTaskRunner(FILE_SYSTEM_READ_CONCURRENCY));
263
292
  }
264
293
  exports.readDirs = readDirs;
265
294
  async function readDir(dir, baseDir = '', blacklist = []) {
@@ -407,19 +436,83 @@ function psTree(pid) {
407
436
  });
408
437
  }
409
438
  exports.psTree = psTree;
410
- async function killTask(pid) {
411
- const pids = await psTree(pid);
412
- if (pids.length) {
439
+ async function killTask(pid, waitForExit = false) {
440
+ const descendants = await psTree(pid);
441
+ const signal = (target, sig) => {
413
442
  try {
414
- [pid, ...pids].reverse().forEach((x) => {
415
- process.kill(x, 15);
416
- });
443
+ process.kill(target, sig);
417
444
  }
418
- catch (error) { }
419
- }
420
- else {
421
- process.kill(pid, 2);
445
+ catch (error) {
446
+ if (error.code !== 'ESRCH')
447
+ throw error;
448
+ }
449
+ };
450
+ if (!waitForExit) {
451
+ if (descendants.length) {
452
+ // A child may exit after psTree; keep signalling the remaining tree.
453
+ for (const target of [pid, ...descendants].reverse()) {
454
+ signal(target, 'SIGTERM');
455
+ }
456
+ }
457
+ else
458
+ signal(pid, 'SIGINT');
459
+ return;
422
460
  }
461
+ const pids = [...descendants.reverse(), pid];
462
+ for (const target of pids)
463
+ signal(target, 'SIGTERM');
464
+ const alive = async (target) => {
465
+ try {
466
+ process.kill(target, 0);
467
+ }
468
+ catch (error) {
469
+ if (error.code === 'ESRCH')
470
+ return false;
471
+ throw error;
472
+ }
473
+ if (process.platform === 'linux') {
474
+ try {
475
+ const stat = await fs.readFile(`/proc/${target}/stat`, 'utf8');
476
+ // The command field may contain spaces and parentheses. Zombies have
477
+ // exited even while their parent has not reaped the PID yet.
478
+ const state = stat.slice(stat.lastIndexOf(')') + 2).split(' ')[0];
479
+ if (['Z', 'X', 'x'].includes(state))
480
+ return false;
481
+ }
482
+ catch (_a) {
483
+ // /proc may be unavailable, or the process may have just exited.
484
+ // Retain the portable signal probe rather than assuming it is dead.
485
+ try {
486
+ process.kill(target, 0);
487
+ }
488
+ catch (error) {
489
+ if (error.code === 'ESRCH')
490
+ return false;
491
+ throw error;
492
+ }
493
+ }
494
+ }
495
+ return true;
496
+ };
497
+ const wait = async () => {
498
+ const deadline = Date.now() + 1000;
499
+ let remaining = pids;
500
+ while (true) {
501
+ const states = await Promise.all(remaining.map(alive));
502
+ remaining = remaining.filter((_, index) => states[index]);
503
+ if (!remaining.length || Date.now() >= deadline)
504
+ return remaining;
505
+ await new Promise((resolve) => setTimeout(resolve, 20));
506
+ }
507
+ };
508
+ let remaining = await wait();
509
+ if (!remaining.length)
510
+ return;
511
+ for (const target of remaining)
512
+ signal(target, 'SIGKILL');
513
+ remaining = await wait();
514
+ if (remaining.length)
515
+ throw new Error(`Task processes did not exit: ${remaining.join(', ')}`);
423
516
  }
424
517
  exports.killTask = killTask;
425
518
  async function getPid(cmd) {
@@ -498,11 +591,13 @@ function safeJSONParse(value) {
498
591
  return JSON.parse(value);
499
592
  }
500
593
  catch (error) {
501
- logger_1.default.error('[safeJSONParse失败]', error);
594
+ logger_1.default.error('[safeJSONParse error]', error);
502
595
  return {};
503
596
  }
504
597
  }
505
598
  exports.safeJSONParse = safeJSONParse;
599
+ var errors_1 = require("../shared/errors");
600
+ Object.defineProperty(exports, "errStack", { enumerable: true, get: function () { return errors_1.errStack; } });
506
601
  async function rmPath(path) {
507
602
  try {
508
603
  const _exsit = await fileExist(path);
@@ -511,7 +606,7 @@ async function rmPath(path) {
511
606
  }
512
607
  }
513
608
  catch (error) {
514
- logger_1.default.error('[rmPath失败]', error);
609
+ logger_1.default.error('[rmPath error]', error);
515
610
  }
516
611
  }
517
612
  exports.rmPath = rmPath;
@@ -525,7 +620,7 @@ async function setSystemTimezone(timezone) {
525
620
  return true;
526
621
  }
527
622
  catch (error) {
528
- logger_1.default.error('[setSystemTimezone失败]', error);
623
+ logger_1.default.error('[setSystemTimezone error]', error);
529
624
  return false;
530
625
  }
531
626
  }
@@ -666,25 +761,27 @@ async function replaceDomainInFile(filePath, oldDomainWithScheme, newDomainWithS
666
761
  }
667
762
  async function _updateLinuxMirror(osType, mirrorDomainWithScheme) {
668
763
  const S = (0, container_1.isInContainer)() ? 'sudo ' : '';
764
+ // APT otherwise returns zero when index downloads fail with transient errors.
765
+ const aptUpdate = `${S}apt-get update --error-on=any`;
669
766
  let filePath, currentDomainWithScheme;
670
767
  switch (osType) {
671
768
  case 'Debian':
672
769
  filePath = '/etc/apt/sources.list.d/debian.sources';
673
770
  currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
674
771
  if (currentDomainWithScheme) {
675
- return `${S}sed -i 's|${currentDomainWithScheme}|${mirrorDomainWithScheme || 'http://deb.debian.org'}|g' ${filePath} || (${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://deb.debian.org'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates\\nComponents: main\\nSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg" | ${S}tee ${filePath}) && ${S}apt-get update`;
772
+ return `${S}sed -i 's|${currentDomainWithScheme}|${mirrorDomainWithScheme || 'http://deb.debian.org'}|g' ${filePath} || (${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://deb.debian.org'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates\\nComponents: main\\nSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg" | ${S}tee ${filePath}) && ${aptUpdate}`;
676
773
  }
677
774
  else {
678
- return `${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://deb.debian.org'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates\\nComponents: main\\nSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg" | ${S}tee ${filePath} && ${S}apt-get update`;
775
+ return `${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://deb.debian.org'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates\\nComponents: main\\nSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg" | ${S}tee ${filePath} && ${aptUpdate}`;
679
776
  }
680
777
  case 'Ubuntu':
681
778
  filePath = '/etc/apt/sources.list.d/ubuntu.sources';
682
779
  currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
683
780
  if (currentDomainWithScheme) {
684
- return `${S}sed -i 's|${currentDomainWithScheme}|${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}|g' ${filePath} || (${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-backports\\nComponents: main restricted universe multiverse\\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" | ${S}tee ${filePath}) && ${S}apt-get update`;
781
+ return `${S}sed -i 's|${currentDomainWithScheme}|${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}|g' ${filePath} || (${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-backports\\nComponents: main restricted universe multiverse\\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" | ${S}tee ${filePath}) && ${aptUpdate}`;
685
782
  }
686
783
  else {
687
- return `${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-backports\\nComponents: main restricted universe multiverse\\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" | ${S}tee ${filePath} && ${S}apt-get update`;
784
+ return `${S}mkdir -p /etc/apt/sources.list.d && echo -e "Types: deb\\nURIs: ${mirrorDomainWithScheme || 'http://archive.ubuntu.com'}\\nSuites: \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-updates \\$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-backports\\nComponents: main restricted universe multiverse\\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" | ${S}tee ${filePath} && ${aptUpdate}`;
688
785
  }
689
786
  case 'Alpine':
690
787
  filePath = '/etc/apk/repositories';
@@ -61,6 +61,7 @@ exports.CrontabModel = _1.sequelize.define('Crontab', {
61
61
  isDisabled: sequelize_1.DataTypes.NUMBER,
62
62
  isPinned: sequelize_1.DataTypes.NUMBER,
63
63
  log_path: sequelize_1.DataTypes.STRING,
64
+ queued_token: sequelize_1.DataTypes.STRING,
64
65
  labels: sequelize_1.DataTypes.JSON,
65
66
  last_running_time: sequelize_1.DataTypes.NUMBER,
66
67
  last_execution_time: sequelize_1.DataTypes.NUMBER,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpeniLinkNotification = exports.WxPusherBotNotification = exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.synologyChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
3
+ exports.WpushNotification = exports.OpeniLinkNotification = exports.WxPusherSptNotification = exports.WxPusherBotNotification = exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.synologyChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
4
4
  var NotificationMode;
5
5
  (function (NotificationMode) {
6
6
  NotificationMode["gotify"] = "gotify";
@@ -25,6 +25,7 @@ var NotificationMode;
25
25
  NotificationMode["ntfy"] = "ntfy";
26
26
  NotificationMode["wxPusherBot"] = "wxPusherBot";
27
27
  NotificationMode["openiLink"] = "openiLink";
28
+ NotificationMode["wpush"] = "wpush";
28
29
  })(NotificationMode || (exports.NotificationMode = NotificationMode = {}));
29
30
  class NotificationBaseInfo {
30
31
  }
@@ -223,6 +224,13 @@ class WxPusherBotNotification extends NotificationBaseInfo {
223
224
  }
224
225
  }
225
226
  exports.WxPusherBotNotification = WxPusherBotNotification;
227
+ class WxPusherSptNotification extends NotificationBaseInfo {
228
+ constructor() {
229
+ super(...arguments);
230
+ this.wxPusherSptList = '';
231
+ }
232
+ }
233
+ exports.WxPusherSptNotification = WxPusherSptNotification;
226
234
  class OpeniLinkNotification extends NotificationBaseInfo {
227
235
  constructor() {
228
236
  super(...arguments);
@@ -232,4 +240,13 @@ class OpeniLinkNotification extends NotificationBaseInfo {
232
240
  }
233
241
  }
234
242
  exports.OpeniLinkNotification = OpeniLinkNotification;
243
+ class WpushNotification extends NotificationBaseInfo {
244
+ constructor() {
245
+ super(...arguments);
246
+ this.wpushApiKey = '';
247
+ this.wpushChannel = '';
248
+ this.wpushTopicCode = '';
249
+ }
250
+ }
251
+ exports.WpushNotification = WpushNotification;
235
252
  //# sourceMappingURL=notify.js.map
@@ -6,6 +6,7 @@ class SockMessage {
6
6
  this.type = options.type;
7
7
  this.message = options.message;
8
8
  this.references = options.references;
9
+ this.status = options.status;
9
10
  }
10
11
  }
11
12
  exports.SockMessage = SockMessage;
@@ -10,18 +10,20 @@ const initData_1 = __importDefault(require("./initData"));
10
10
  const deps_1 = __importDefault(require("./deps"));
11
11
  const initTask_1 = __importDefault(require("./initTask"));
12
12
  const initFile_1 = __importDefault(require("./initFile"));
13
+ const trustProxy_1 = require("../shared/trustProxy");
13
14
  exports.default = async ({ app }) => {
14
15
  (0, depInjector_1.default)();
15
- logger_1.default.info('✌️ Dependency loaded');
16
+ logger_1.default.info('[boot] Dependency loaded');
16
17
  await (0, deps_1.default)();
17
- logger_1.default.info('✌️ Link deps loaded');
18
+ logger_1.default.info('[boot] Link deps loaded');
18
19
  await (0, initFile_1.default)();
19
- logger_1.default.info('✌️ Init file loaded');
20
+ logger_1.default.info('[boot] Init file loaded');
20
21
  await (0, initData_1.default)();
21
- logger_1.default.info('✌️ Init data loaded');
22
+ logger_1.default.info('[boot] Init data loaded');
22
23
  (0, initTask_1.default)();
23
- logger_1.default.info('✌️ Init task loaded');
24
+ logger_1.default.info('[boot] Init task loaded');
24
25
  (0, express_1.default)({ app });
25
- logger_1.default.info('✌️ Express loaded');
26
+ await (0, trustProxy_1.initializeTrustProxy)(app);
27
+ logger_1.default.info('[boot] Express loaded');
26
28
  };
27
29
  //# sourceMappingURL=app.js.map
@@ -14,6 +14,7 @@ const cronView_1 = require("../data/cronView");
14
14
  const cronStats_1 = require("../data/cronStats");
15
15
  const runningInstance_1 = require("../data/runningInstance");
16
16
  const data_1 = require("../data");
17
+ const schemaMigrations_1 = require("../shared/schemaMigrations");
17
18
  exports.default = async () => {
18
19
  try {
19
20
  await cron_1.CrontabModel.sync();
@@ -25,43 +26,12 @@ exports.default = async () => {
25
26
  await cronView_1.CrontabViewModel.sync();
26
27
  await cronStats_1.CrontabStatModel.sync();
27
28
  await runningInstance_1.RunningInstanceModel.sync();
28
- // 初始化新增字段
29
- const migrations = [
30
- {
31
- table: 'CrontabViews',
32
- column: 'filterRelation',
33
- type: 'VARCHAR(255)',
34
- },
35
- { table: 'Subscriptions', column: 'proxy', type: 'VARCHAR(255)' },
36
- { table: 'CrontabViews', column: 'type', type: 'NUMBER' },
37
- { table: 'Subscriptions', column: 'autoAddCron', type: 'NUMBER' },
38
- { table: 'Subscriptions', column: 'autoDelCron', type: 'NUMBER' },
39
- { table: 'Crontabs', column: 'sub_id', type: 'NUMBER' },
40
- { table: 'Crontabs', column: 'extra_schedules', type: 'JSON' },
41
- { table: 'Crontabs', column: 'task_before', type: 'TEXT' },
42
- { table: 'Crontabs', column: 'task_after', type: 'TEXT' },
43
- { table: 'Crontabs', column: 'log_name', type: 'VARCHAR(255)' },
44
- {
45
- table: 'Crontabs',
46
- column: 'allow_multiple_instances',
47
- type: 'NUMBER',
48
- },
49
- { table: 'Crontabs', column: 'work_dir', type: 'VARCHAR(255)' },
50
- { table: 'Envs', column: 'isPinned', type: 'NUMBER' },
51
- { table: 'Envs', column: 'labels', type: 'JSON' },
52
- ];
53
- for (const migration of migrations) {
54
- try {
55
- await data_1.sequelize.query(`alter table ${migration.table} add column ${migration.column} ${migration.type}`);
56
- }
57
- catch (error) {
58
- // Column already exists or other error, continue
59
- }
60
- }
61
- logger_1.default.info('✌️ DB loaded');
29
+ await (0, schemaMigrations_1.migrateSchema)(data_1.sequelize);
30
+ logger_1.default.info('[boot] DB loaded');
62
31
  }
63
32
  catch (error) {
64
- logger_1.default.error('✌️ DB load failed', error);
33
+ logger_1.default.error('[boot] DB load failed', error);
34
+ throw error;
65
35
  }
66
36
  };
67
37
  //# sourceMappingURL=db.js.map
@@ -6,20 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const promises_1 = __importDefault(require("fs/promises"));
8
8
  const os_1 = __importDefault(require("os"));
9
- const chokidar_1 = __importDefault(require("chokidar"));
10
9
  const index_1 = __importDefault(require("../config/index"));
11
10
  const logger_1 = __importDefault(require("./logger"));
12
- async function linkToNodeModule(src, dst) {
13
- const target = path_1.default.join(index_1.default.rootPath, 'node_modules', dst || src);
14
- const source = path_1.default.join(index_1.default.rootPath, src);
15
- try {
16
- const stats = await promises_1.default.lstat(target);
17
- if (!stats) {
18
- await promises_1.default.symlink(source, target, 'dir');
19
- }
20
- }
21
- catch (error) { }
22
- }
23
11
  async function linkCommand() {
24
12
  const homeDir = os_1.default.homedir();
25
13
  let userBinDir = path_1.default.join(homeDir, 'bin');
@@ -32,6 +20,35 @@ async function linkCommand() {
32
20
  }
33
21
  }
34
22
  async function linkCommandToDir(commandDir) {
23
+ var _a, _b;
24
+ const cliRoot = process.env.QL_CLI_ROOT;
25
+ if (cliRoot) {
26
+ if (!path_1.default.isAbsolute(cliRoot)) {
27
+ throw new Error('QL_CLI_ROOT must be an absolute CLI installation path');
28
+ }
29
+ const { installCliEntrypoints } = require(path_1.default.join(cliRoot, 'dist/local/entrypoints.js'));
30
+ await installCliEntrypoints(commandDir, cliRoot);
31
+ const { installCronEntrypoint } = require(path_1.default.join(cliRoot, 'dist/local/cronEntrypoint.js'));
32
+ await installCronEntrypoint(commandDir, cliRoot, index_1.default.crontabFile, Object.assign(Object.assign({}, process.env), { QL_DIR: index_1.default.rootPath, QL_DATA_DIR: index_1.default.dataPath }));
33
+ // Container-wide legacy links may precede ~/bin. Ensure panel children use
34
+ // the explicitly selected entries without changing system-wide links.
35
+ process.env.PATH = [
36
+ commandDir,
37
+ ...((_b = (_a = process.env.PATH) === null || _a === void 0 ? void 0 : _a.split(path_1.default.delimiter)) !== null && _b !== void 0 ? _b : []).filter((entry) => entry !== commandDir),
38
+ ].join(path_1.default.delimiter);
39
+ return;
40
+ }
41
+ const cronBridge = path_1.default.join(commandDir, 'crontab');
42
+ try {
43
+ if ((await promises_1.default.lstat(cronBridge)).isFile() &&
44
+ (await promises_1.default.readFile(cronBridge, 'utf8')).includes('// QingLong CLI crontab bridge')) {
45
+ await promises_1.default.unlink(cronBridge);
46
+ }
47
+ }
48
+ catch (error) {
49
+ if (error.code !== 'ENOENT')
50
+ throw error;
51
+ }
35
52
  const linkShell = [
36
53
  {
37
54
  src: 'update.sh',
@@ -59,16 +76,7 @@ async function linkCommandToDir(commandDir) {
59
76
  await promises_1.default.rename(tmpTarget, target);
60
77
  }
61
78
  }
62
- exports.default = async (src = 'deps') => {
79
+ exports.default = async () => {
63
80
  await linkCommand();
64
- await linkToNodeModule(src);
65
- const source = path_1.default.join(index_1.default.rootPath, src);
66
- const watcher = chokidar_1.default.watch(source, {
67
- ignored: /(^|[\/\\])\../,
68
- persistent: true,
69
- });
70
- watcher
71
- .on('add', () => linkToNodeModule(src))
72
- .on('change', () => linkToNodeModule(src));
73
81
  };
74
82
  //# sourceMappingURL=deps.js.map
@@ -17,33 +17,44 @@ const store_1 = require("../shared/store");
17
17
  const auth_1 = require("../shared/auth");
18
18
  const path_1 = __importDefault(require("path"));
19
19
  const i18n_1 = require("../shared/i18n");
20
+ const uniqueConstraintError_1 = __importDefault(require("../middlewares/uniqueConstraintError"));
21
+ const protectedPathCase_1 = __importDefault(require("../middlewares/protectedPathCase"));
22
+ function resolveTrustProxy(value = process.env.QL_TRUST_PROXY) {
23
+ const setting = value === null || value === void 0 ? void 0 : value.trim();
24
+ if (!setting) {
25
+ return 'loopback';
26
+ }
27
+ if (setting === 'true' || setting === 'false') {
28
+ return setting === 'true';
29
+ }
30
+ if (/^\d+$/.test(setting)) {
31
+ return Number(setting);
32
+ }
33
+ return setting;
34
+ }
20
35
  exports.default = ({ app }) => {
21
36
  // Security: Enable strict routing to prevent case-insensitive path bypass
22
37
  app.set('case sensitive routing', true);
23
38
  app.set('strict routing', true);
24
- app.set('trust proxy', 'loopback');
39
+ app.set('trust proxy', resolveTrustProxy());
25
40
  app.use((0, cors_1.default)());
26
- // Security: Path normalization middleware to prevent case variation attacks
27
- app.use((req, res, next) => {
28
- const originalPath = req.path;
29
- const normalizedPath = originalPath.toLowerCase();
30
- // Block requests with case variations on protected paths
31
- if (originalPath !== normalizedPath &&
32
- (normalizedPath.startsWith('/api/') || normalizedPath.startsWith('/open/'))) {
33
- return res.status(400).json({
34
- code: 400,
35
- message: 'Invalid path format'
36
- });
37
- }
38
- next();
39
- });
41
+ // Security: Reject case variations under protected API namespaces before
42
+ // authentication checks can interpret the request differently from routing.
43
+ app.use(protectedPathCase_1.default);
40
44
  // Rewrite URLs to strip baseUrl prefix if configured
41
45
  // This allows the rest of the app to work without baseUrl awareness
42
46
  if (config_1.default.baseUrl) {
43
47
  app.use((0, express_urlrewrite_1.default)(`${config_1.default.baseUrl}/*`, '/$1'));
44
48
  }
45
49
  app.get(`${config_1.default.api.prefix}/env.js`, serverEnv_1.serveEnv);
46
- app.use(`${config_1.default.api.prefix}/static`, express_1.default.static(config_1.default.uploadPath));
50
+ app.use(`${config_1.default.api.prefix}/static`, express_1.default.static(config_1.default.uploadPath, {
51
+ setHeaders: (res) => {
52
+ res.setHeader('X-Content-Type-Options', 'nosniff');
53
+ res.setHeader('Content-Security-Policy', "sandbox; default-src 'none'");
54
+ },
55
+ }));
56
+ const credentialPaths = ['/api', '/open'].flatMap((prefix) => ['/user/login', '/user/init', '/user/two-factor/login'].map((route) => `${prefix}${route}`));
57
+ app.use(credentialPaths, body_parser_1.default.json({ limit: '16kb' }), body_parser_1.default.urlencoded({ limit: '16kb', extended: false }));
47
58
  app.use(body_parser_1.default.json({ limit: '50mb' }));
48
59
  app.use(body_parser_1.default.urlencoded({ limit: '50mb', extended: true }));
49
60
  const frontendPath = path_1.default.join(config_1.default.rootPath, 'static/dist');
@@ -78,27 +89,34 @@ exports.default = ({ app }) => {
78
89
  const currentToken = doc.tokens.find((x) => x.value === headerToken);
79
90
  const keyMatch = pathLower.match(/\/open\/([a-z]+)\/*/);
80
91
  const key = keyMatch && keyMatch[1];
81
- if (doc.scopes.includes(key) &&
82
- currentToken &&
83
- currentToken.expiration >= Math.round(Date.now() / 1000)) {
84
- return next();
92
+ if (!doc.scopes.includes(key)) {
93
+ const err = new express_jwt_1.UnauthorizedError('credentials_bad_scheme', {
94
+ message: (0, i18n_1.t)('暂无权限'),
95
+ });
96
+ return next(err);
85
97
  }
98
+ if (!currentToken ||
99
+ currentToken.expiration < Math.round(Date.now() / 1000)) {
100
+ const err = new express_jwt_1.UnauthorizedError('invalid_token', {
101
+ message: (0, i18n_1.t)('Token 已失效'),
102
+ });
103
+ return next(err);
104
+ }
105
+ return next();
86
106
  }
87
107
  }
88
- const originPath = `${req.baseUrl}${req.path === '/' ? '' : req.path}`;
108
+ const originPath = `${req.baseUrl}${pathLower === '/' ? '' : pathLower}`;
89
109
  if (!headerToken &&
90
110
  originPath &&
91
111
  config_1.default.apiWhiteList.includes(originPath)) {
92
112
  return next();
93
113
  }
94
114
  const authInfo = await store_1.shareStore.getAuthInfo();
95
- if ((0, auth_1.isValidToken)(authInfo, headerToken, req.platform)) {
115
+ if ((0, auth_1.isValidToken)(authInfo, headerToken, req.platform, config_1.default.jwt.secret)) {
96
116
  return next();
97
117
  }
98
118
  const errorCode = headerToken ? 'invalid_token' : 'credentials_required';
99
- const errorMessage = headerToken
100
- ? 'jwt malformed'
101
- : 'No authorization token was found';
119
+ const errorMessage = headerToken ? (0, i18n_1.t)('Token 已失效') : (0, i18n_1.t)('请先登录');
102
120
  const err = new express_jwt_1.UnauthorizedError(errorCode, { message: errorMessage });
103
121
  next(err);
104
122
  });
@@ -109,16 +127,11 @@ exports.default = ({ app }) => {
109
127
  '/api/user/notification/init',
110
128
  '/open/user/init',
111
129
  '/open/user/notification/init',
112
- ].includes(req.path)) {
130
+ ].includes(pathLower)) {
113
131
  return next();
114
132
  }
115
133
  const authInfo = (await store_1.shareStore.getAuthInfo()) || {};
116
- let isInitialized = true;
117
- if (Object.keys(authInfo).length === 2 &&
118
- authInfo.username === 'admin' &&
119
- authInfo.password === 'admin') {
120
- isInitialized = false;
121
- }
134
+ let isInitialized = !(0, auth_1.isDefaultAuthInfo)(authInfo);
122
135
  if (isInitialized) {
123
136
  return res.send({ code: 450, message: (0, i18n_1.t)('未知错误') });
124
137
  }
@@ -139,6 +152,7 @@ exports.default = ({ app }) => {
139
152
  });
140
153
  });
141
154
  app.use((0, celebrate_1.errors)());
155
+ app.use(uniqueConstraintError_1.default);
142
156
  app.use((err, req, res, next) => {
143
157
  if (err.name === 'UnauthorizedError') {
144
158
  return res