synapse-mcp 1.0.0 → 1.0.2

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 (413) hide show
  1. package/README.md +1820 -147
  2. package/dist/constants.d.ts +10 -4
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +18 -8
  5. package/dist/constants.js.map +1 -1
  6. package/dist/events/emitter.d.ts +63 -0
  7. package/dist/events/emitter.d.ts.map +1 -0
  8. package/dist/events/emitter.js +112 -0
  9. package/dist/events/emitter.js.map +1 -0
  10. package/dist/events/index.d.ts +3 -0
  11. package/dist/events/index.d.ts.map +1 -0
  12. package/dist/events/index.js +3 -0
  13. package/dist/events/index.js.map +1 -0
  14. package/dist/events/types.d.ts +51 -0
  15. package/dist/events/types.d.ts.map +1 -0
  16. package/dist/events/types.js +3 -0
  17. package/dist/events/types.js.map +1 -0
  18. package/dist/formatters/compose.d.ts +185 -0
  19. package/dist/formatters/compose.d.ts.map +1 -0
  20. package/dist/formatters/compose.js +397 -0
  21. package/dist/formatters/compose.js.map +1 -0
  22. package/dist/formatters/container.d.ts +84 -0
  23. package/dist/formatters/container.d.ts.map +1 -0
  24. package/dist/formatters/container.js +323 -0
  25. package/dist/formatters/container.js.map +1 -0
  26. package/dist/formatters/diagnostics.d.ts +20 -0
  27. package/dist/formatters/diagnostics.d.ts.map +1 -0
  28. package/dist/formatters/diagnostics.js +73 -0
  29. package/dist/formatters/diagnostics.js.map +1 -0
  30. package/dist/formatters/docker.d.ts +139 -0
  31. package/dist/formatters/docker.d.ts.map +1 -0
  32. package/dist/formatters/docker.js +216 -0
  33. package/dist/formatters/docker.js.map +1 -0
  34. package/dist/formatters/host.d.ts +137 -0
  35. package/dist/formatters/host.d.ts.map +1 -0
  36. package/dist/formatters/host.js +198 -0
  37. package/dist/formatters/host.js.map +1 -0
  38. package/dist/formatters/index.d.ts +17 -270
  39. package/dist/formatters/index.d.ts.map +1 -1
  40. package/dist/formatters/index.js +21 -456
  41. package/dist/formatters/index.js.map +1 -1
  42. package/dist/formatters/scout.d.ts +424 -0
  43. package/dist/formatters/scout.d.ts.map +1 -0
  44. package/dist/formatters/scout.js +687 -0
  45. package/dist/formatters/scout.js.map +1 -0
  46. package/dist/formatters/strategy.d.ts +105 -0
  47. package/dist/formatters/strategy.d.ts.map +1 -0
  48. package/dist/formatters/strategy.js +120 -0
  49. package/dist/formatters/strategy.js.map +1 -0
  50. package/dist/formatters/utils.d.ts +84 -0
  51. package/dist/formatters/utils.d.ts.map +1 -0
  52. package/dist/formatters/utils.js +129 -0
  53. package/dist/formatters/utils.js.map +1 -0
  54. package/dist/health-rate-limiter.d.ts +59 -0
  55. package/dist/health-rate-limiter.d.ts.map +1 -0
  56. package/dist/health-rate-limiter.js +159 -0
  57. package/dist/health-rate-limiter.js.map +1 -0
  58. package/dist/index.js +61 -100
  59. package/dist/index.js.map +1 -1
  60. package/dist/middleware/async-handler.d.ts +62 -0
  61. package/dist/middleware/async-handler.d.ts.map +1 -0
  62. package/dist/middleware/async-handler.js +58 -0
  63. package/dist/middleware/async-handler.js.map +1 -0
  64. package/dist/middleware/auth.d.ts +32 -0
  65. package/dist/middleware/auth.d.ts.map +1 -0
  66. package/dist/middleware/auth.js +63 -0
  67. package/dist/middleware/auth.js.map +1 -0
  68. package/dist/middleware/csrf-protection.d.ts +58 -0
  69. package/dist/middleware/csrf-protection.d.ts.map +1 -0
  70. package/dist/middleware/csrf-protection.js +123 -0
  71. package/dist/middleware/csrf-protection.js.map +1 -0
  72. package/dist/middleware/error-handler.d.ts +49 -0
  73. package/dist/middleware/error-handler.d.ts.map +1 -0
  74. package/dist/middleware/error-handler.js +90 -0
  75. package/dist/middleware/error-handler.js.map +1 -0
  76. package/dist/middleware/error-mapper.d.ts +44 -0
  77. package/dist/middleware/error-mapper.d.ts.map +1 -0
  78. package/dist/middleware/error-mapper.js +127 -0
  79. package/dist/middleware/error-mapper.js.map +1 -0
  80. package/dist/middleware/index.d.ts +13 -0
  81. package/dist/middleware/index.d.ts.map +1 -0
  82. package/dist/middleware/index.js +13 -0
  83. package/dist/middleware/index.js.map +1 -0
  84. package/dist/middleware/request-id.d.ts +22 -0
  85. package/dist/middleware/request-id.d.ts.map +1 -0
  86. package/dist/middleware/request-id.js +31 -0
  87. package/dist/middleware/request-id.js.map +1 -0
  88. package/dist/middleware/types.d.ts +33 -0
  89. package/dist/middleware/types.d.ts.map +1 -0
  90. package/dist/middleware/types.js +2 -0
  91. package/dist/middleware/types.js.map +1 -0
  92. package/dist/schemas/common.d.ts +205 -8
  93. package/dist/schemas/common.d.ts.map +1 -1
  94. package/dist/schemas/common.js +290 -17
  95. package/dist/schemas/common.js.map +1 -1
  96. package/dist/schemas/flux/compose.d.ts +307 -44
  97. package/dist/schemas/flux/compose.d.ts.map +1 -1
  98. package/dist/schemas/flux/compose.js +74 -48
  99. package/dist/schemas/flux/compose.js.map +1 -1
  100. package/dist/schemas/flux/container.d.ts +423 -56
  101. package/dist/schemas/flux/container.d.ts.map +1 -1
  102. package/dist/schemas/flux/container.js +83 -61
  103. package/dist/schemas/flux/container.js.map +1 -1
  104. package/dist/schemas/flux/docker.d.ts +254 -37
  105. package/dist/schemas/flux/docker.d.ts.map +1 -1
  106. package/dist/schemas/flux/docker.js +69 -39
  107. package/dist/schemas/flux/docker.js.map +1 -1
  108. package/dist/schemas/flux/host.d.ts +312 -29
  109. package/dist/schemas/flux/host.d.ts.map +1 -1
  110. package/dist/schemas/flux/host.js +74 -31
  111. package/dist/schemas/flux/host.js.map +1 -1
  112. package/dist/schemas/flux/index.d.ts +503 -11
  113. package/dist/schemas/flux/index.d.ts.map +1 -1
  114. package/dist/schemas/flux/index.js +34 -70
  115. package/dist/schemas/flux/index.js.map +1 -1
  116. package/dist/schemas/host-config.d.ts +76 -0
  117. package/dist/schemas/host-config.d.ts.map +1 -0
  118. package/dist/schemas/host-config.js +105 -0
  119. package/dist/schemas/host-config.js.map +1 -0
  120. package/dist/schemas/scout/index.d.ts +80 -23
  121. package/dist/schemas/scout/index.d.ts.map +1 -1
  122. package/dist/schemas/scout/index.js +26 -11
  123. package/dist/schemas/scout/index.js.map +1 -1
  124. package/dist/schemas/scout/logs.d.ts +17 -5
  125. package/dist/schemas/scout/logs.d.ts.map +1 -1
  126. package/dist/schemas/scout/logs.js +41 -31
  127. package/dist/schemas/scout/logs.js.map +1 -1
  128. package/dist/schemas/scout/simple.d.ts +126 -11
  129. package/dist/schemas/scout/simple.d.ts.map +1 -1
  130. package/dist/schemas/scout/simple.js +112 -57
  131. package/dist/schemas/scout/simple.js.map +1 -1
  132. package/dist/schemas/scout/zfs.d.ts +17 -5
  133. package/dist/schemas/scout/zfs.d.ts.map +1 -1
  134. package/dist/schemas/scout/zfs.js +34 -25
  135. package/dist/schemas/scout/zfs.js.map +1 -1
  136. package/dist/services/cache-layer.d.ts +160 -0
  137. package/dist/services/cache-layer.d.ts.map +1 -0
  138. package/dist/services/cache-layer.js +138 -0
  139. package/dist/services/cache-layer.js.map +1 -0
  140. package/dist/services/compose-cache.d.ts +75 -0
  141. package/dist/services/compose-cache.d.ts.map +1 -0
  142. package/dist/services/compose-cache.js +178 -0
  143. package/dist/services/compose-cache.js.map +1 -0
  144. package/dist/services/compose-discovery.d.ts +46 -0
  145. package/dist/services/compose-discovery.d.ts.map +1 -0
  146. package/dist/services/compose-discovery.js +219 -0
  147. package/dist/services/compose-discovery.js.map +1 -0
  148. package/dist/services/compose-project-lister.d.ts +27 -0
  149. package/dist/services/compose-project-lister.d.ts.map +1 -0
  150. package/dist/services/compose-project-lister.js +71 -0
  151. package/dist/services/compose-project-lister.js.map +1 -0
  152. package/dist/services/compose-scanner.d.ts +63 -0
  153. package/dist/services/compose-scanner.d.ts.map +1 -0
  154. package/dist/services/compose-scanner.js +253 -0
  155. package/dist/services/compose-scanner.js.map +1 -0
  156. package/dist/services/compose.d.ts +64 -28
  157. package/dist/services/compose.d.ts.map +1 -1
  158. package/dist/services/compose.js +220 -98
  159. package/dist/services/compose.js.map +1 -1
  160. package/dist/services/config-loader.d.ts +23 -0
  161. package/dist/services/config-loader.d.ts.map +1 -0
  162. package/dist/services/config-loader.js +124 -0
  163. package/dist/services/config-loader.js.map +1 -0
  164. package/dist/services/config-service.d.ts +38 -0
  165. package/dist/services/config-service.d.ts.map +1 -0
  166. package/dist/services/config-service.js +225 -0
  167. package/dist/services/config-service.js.map +1 -0
  168. package/dist/services/container-host-map-cache.d.ts +121 -0
  169. package/dist/services/container-host-map-cache.d.ts.map +1 -0
  170. package/dist/services/container-host-map-cache.js +188 -0
  171. package/dist/services/container-host-map-cache.js.map +1 -0
  172. package/dist/services/container.d.ts +194 -6
  173. package/dist/services/container.d.ts.map +1 -1
  174. package/dist/services/container.js +386 -11
  175. package/dist/services/container.js.map +1 -1
  176. package/dist/services/diagnostics.d.ts +57 -0
  177. package/dist/services/diagnostics.d.ts.map +1 -0
  178. package/dist/services/diagnostics.js +271 -0
  179. package/dist/services/diagnostics.js.map +1 -0
  180. package/dist/services/docker/container-service.d.ts +123 -0
  181. package/dist/services/docker/container-service.d.ts.map +1 -0
  182. package/dist/services/docker/container-service.js +347 -0
  183. package/dist/services/docker/container-service.js.map +1 -0
  184. package/dist/services/docker/image-service.d.ts +82 -0
  185. package/dist/services/docker/image-service.d.ts.map +1 -0
  186. package/dist/services/docker/image-service.js +193 -0
  187. package/dist/services/docker/image-service.js.map +1 -0
  188. package/dist/services/docker/index.d.ts +80 -0
  189. package/dist/services/docker/index.d.ts.map +1 -0
  190. package/dist/services/docker/index.js +103 -0
  191. package/dist/services/docker/index.js.map +1 -0
  192. package/dist/services/docker/network-service.d.ts +22 -0
  193. package/dist/services/docker/network-service.d.ts.map +1 -0
  194. package/dist/services/docker/network-service.js +43 -0
  195. package/dist/services/docker/network-service.js.map +1 -0
  196. package/dist/services/docker/system-service.d.ts +49 -0
  197. package/dist/services/docker/system-service.d.ts.map +1 -0
  198. package/dist/services/docker/system-service.js +215 -0
  199. package/dist/services/docker/system-service.js.map +1 -0
  200. package/dist/services/docker/utils/client-factory.d.ts +56 -0
  201. package/dist/services/docker/utils/client-factory.d.ts.map +1 -0
  202. package/dist/services/docker/utils/client-factory.js +139 -0
  203. package/dist/services/docker/utils/client-factory.js.map +1 -0
  204. package/dist/services/docker/utils/client-manager.d.ts +88 -0
  205. package/dist/services/docker/utils/client-manager.d.ts.map +1 -0
  206. package/dist/services/docker/utils/client-manager.js +124 -0
  207. package/dist/services/docker/utils/client-manager.js.map +1 -0
  208. package/dist/services/docker/utils/exec-handler.d.ts +94 -0
  209. package/dist/services/docker/utils/exec-handler.d.ts.map +1 -0
  210. package/dist/services/docker/utils/exec-handler.js +197 -0
  211. package/dist/services/docker/utils/exec-handler.js.map +1 -0
  212. package/dist/services/docker/utils/formatters.d.ts +13 -0
  213. package/dist/services/docker/utils/formatters.d.ts.map +1 -0
  214. package/dist/services/docker/utils/formatters.js +33 -0
  215. package/dist/services/docker/utils/formatters.js.map +1 -0
  216. package/dist/services/docker/utils/log-parser.d.ts +10 -0
  217. package/dist/services/docker/utils/log-parser.d.ts.map +1 -0
  218. package/dist/services/docker/utils/log-parser.js +48 -0
  219. package/dist/services/docker/utils/log-parser.js.map +1 -0
  220. package/dist/services/docker/utils/stats-calculator.d.ts +68 -0
  221. package/dist/services/docker/utils/stats-calculator.d.ts.map +1 -0
  222. package/dist/services/docker/utils/stats-calculator.js +61 -0
  223. package/dist/services/docker/utils/stats-calculator.js.map +1 -0
  224. package/dist/services/docker/volume-service.d.ts +22 -0
  225. package/dist/services/docker/volume-service.d.ts.map +1 -0
  226. package/dist/services/docker/volume-service.js +48 -0
  227. package/dist/services/docker/volume-service.js.map +1 -0
  228. package/dist/services/docker-interfaces.d.ts +283 -0
  229. package/dist/services/docker-interfaces.d.ts.map +1 -0
  230. package/dist/services/docker-interfaces.js +13 -0
  231. package/dist/services/docker-interfaces.js.map +1 -0
  232. package/dist/services/docker.d.ts +42 -5
  233. package/dist/services/docker.d.ts.map +1 -1
  234. package/dist/services/docker.js +335 -127
  235. package/dist/services/docker.js.map +1 -1
  236. package/dist/services/file-service.d.ts +6 -2
  237. package/dist/services/file-service.d.ts.map +1 -1
  238. package/dist/services/file-service.js +156 -52
  239. package/dist/services/file-service.js.map +1 -1
  240. package/dist/services/host-config-repository.d.ts +133 -0
  241. package/dist/services/host-config-repository.d.ts.map +1 -0
  242. package/dist/services/host-config-repository.js +323 -0
  243. package/dist/services/host-config-repository.js.map +1 -0
  244. package/dist/services/host-resolver.d.ts +49 -0
  245. package/dist/services/host-resolver.d.ts.map +1 -0
  246. package/dist/services/host-resolver.js +176 -0
  247. package/dist/services/host-resolver.js.map +1 -0
  248. package/dist/services/interfaces.d.ts +61 -194
  249. package/dist/services/interfaces.d.ts.map +1 -1
  250. package/dist/services/local-executor.d.ts +31 -0
  251. package/dist/services/local-executor.d.ts.map +1 -0
  252. package/dist/services/local-executor.js +71 -0
  253. package/dist/services/local-executor.js.map +1 -0
  254. package/dist/services/ssh-config-loader.d.ts +35 -0
  255. package/dist/services/ssh-config-loader.d.ts.map +1 -0
  256. package/dist/services/ssh-config-loader.js +218 -0
  257. package/dist/services/ssh-config-loader.js.map +1 -0
  258. package/dist/services/ssh-pool.d.ts +26 -1
  259. package/dist/services/ssh-pool.d.ts.map +1 -1
  260. package/dist/services/ssh-pool.js +166 -25
  261. package/dist/services/ssh-pool.js.map +1 -1
  262. package/dist/services/ssh-service.d.ts +3 -0
  263. package/dist/services/ssh-service.d.ts.map +1 -1
  264. package/dist/services/ssh-service.js +53 -31
  265. package/dist/services/ssh-service.js.map +1 -1
  266. package/dist/services/ssh.d.ts +2 -6
  267. package/dist/services/ssh.d.ts.map +1 -1
  268. package/dist/services/ssh.js +9 -40
  269. package/dist/services/ssh.js.map +1 -1
  270. package/dist/tools/definitions/flux.d.ts +13 -0
  271. package/dist/tools/definitions/flux.d.ts.map +1 -0
  272. package/dist/tools/definitions/flux.js +101 -0
  273. package/dist/tools/definitions/flux.js.map +1 -0
  274. package/dist/tools/definitions/index.d.ts +8 -0
  275. package/dist/tools/definitions/index.d.ts.map +1 -0
  276. package/dist/tools/definitions/index.js +8 -0
  277. package/dist/tools/definitions/index.js.map +1 -0
  278. package/dist/tools/definitions/scout.d.ts +13 -0
  279. package/dist/tools/definitions/scout.d.ts.map +1 -0
  280. package/dist/tools/definitions/scout.js +78 -0
  281. package/dist/tools/definitions/scout.js.map +1 -0
  282. package/dist/tools/flux.d.ts +16 -8
  283. package/dist/tools/flux.d.ts.map +1 -1
  284. package/dist/tools/flux.js +27 -66
  285. package/dist/tools/flux.js.map +1 -1
  286. package/dist/tools/handlers/base-handler.d.ts +172 -0
  287. package/dist/tools/handlers/base-handler.d.ts.map +1 -0
  288. package/dist/tools/handlers/base-handler.js +234 -0
  289. package/dist/tools/handlers/base-handler.js.map +1 -0
  290. package/dist/tools/handlers/compose-handlers.d.ts +108 -0
  291. package/dist/tools/handlers/compose-handlers.d.ts.map +1 -0
  292. package/dist/tools/handlers/compose-handlers.js +293 -0
  293. package/dist/tools/handlers/compose-handlers.js.map +1 -0
  294. package/dist/tools/handlers/compose-utils.d.ts +35 -0
  295. package/dist/tools/handlers/compose-utils.d.ts.map +1 -0
  296. package/dist/tools/handlers/compose-utils.js +76 -0
  297. package/dist/tools/handlers/compose-utils.js.map +1 -0
  298. package/dist/tools/handlers/compose.d.ts +23 -0
  299. package/dist/tools/handlers/compose.d.ts.map +1 -0
  300. package/dist/tools/handlers/compose.js +125 -0
  301. package/dist/tools/handlers/compose.js.map +1 -0
  302. package/dist/tools/handlers/container.d.ts +23 -0
  303. package/dist/tools/handlers/container.d.ts.map +1 -0
  304. package/dist/tools/handlers/container.js +333 -0
  305. package/dist/tools/handlers/container.js.map +1 -0
  306. package/dist/tools/handlers/docker.d.ts +24 -0
  307. package/dist/tools/handlers/docker.d.ts.map +1 -0
  308. package/dist/tools/handlers/docker.js +155 -0
  309. package/dist/tools/handlers/docker.js.map +1 -0
  310. package/dist/tools/handlers/host.d.ts +23 -0
  311. package/dist/tools/handlers/host.d.ts.map +1 -0
  312. package/dist/tools/handlers/host.js +196 -0
  313. package/dist/tools/handlers/host.js.map +1 -0
  314. package/dist/tools/handlers/scout-logs.d.ts +24 -0
  315. package/dist/tools/handlers/scout-logs.d.ts.map +1 -0
  316. package/dist/tools/handlers/scout-logs.js +119 -0
  317. package/dist/tools/handlers/scout-logs.js.map +1 -0
  318. package/dist/tools/handlers/scout-simple.d.ts +23 -0
  319. package/dist/tools/handlers/scout-simple.d.ts.map +1 -0
  320. package/dist/tools/handlers/scout-simple.js +286 -0
  321. package/dist/tools/handlers/scout-simple.js.map +1 -0
  322. package/dist/tools/handlers/scout-zfs.d.ts +23 -0
  323. package/dist/tools/handlers/scout-zfs.d.ts.map +1 -0
  324. package/dist/tools/handlers/scout-zfs.js +82 -0
  325. package/dist/tools/handlers/scout-zfs.js.map +1 -0
  326. package/dist/tools/index.d.ts +32 -2
  327. package/dist/tools/index.d.ts.map +1 -1
  328. package/dist/tools/index.js +41 -35
  329. package/dist/tools/index.js.map +1 -1
  330. package/dist/tools/registry.d.ts +135 -0
  331. package/dist/tools/registry.d.ts.map +1 -0
  332. package/dist/tools/registry.js +151 -0
  333. package/dist/tools/registry.js.map +1 -0
  334. package/dist/tools/scout.d.ts +16 -8
  335. package/dist/tools/scout.d.ts.map +1 -1
  336. package/dist/tools/scout.js +36 -78
  337. package/dist/tools/scout.js.map +1 -1
  338. package/dist/types.d.ts +629 -1
  339. package/dist/types.d.ts.map +1 -1
  340. package/dist/types.js.map +1 -1
  341. package/dist/utils/command-security.d.ts +82 -0
  342. package/dist/utils/command-security.d.ts.map +1 -0
  343. package/dist/utils/command-security.js +122 -0
  344. package/dist/utils/command-security.js.map +1 -0
  345. package/dist/utils/error-sanitization.d.ts +77 -0
  346. package/dist/utils/error-sanitization.d.ts.map +1 -0
  347. package/dist/utils/error-sanitization.js +107 -0
  348. package/dist/utils/error-sanitization.js.map +1 -0
  349. package/dist/utils/errors.d.ts +30 -6
  350. package/dist/utils/errors.d.ts.map +1 -1
  351. package/dist/utils/errors.js +91 -12
  352. package/dist/utils/errors.js.map +1 -1
  353. package/dist/utils/help-handler.d.ts +23 -0
  354. package/dist/utils/help-handler.d.ts.map +1 -0
  355. package/dist/utils/help-handler.js +21 -0
  356. package/dist/utils/help-handler.js.map +1 -0
  357. package/dist/utils/help.d.ts +1 -1
  358. package/dist/utils/help.d.ts.map +1 -1
  359. package/dist/utils/help.js +57 -16
  360. package/dist/utils/help.js.map +1 -1
  361. package/dist/utils/host-utils.d.ts +31 -0
  362. package/dist/utils/host-utils.d.ts.map +1 -0
  363. package/dist/utils/host-utils.js +80 -0
  364. package/dist/utils/host-utils.js.map +1 -0
  365. package/dist/utils/index.d.ts +8 -2
  366. package/dist/utils/index.d.ts.map +1 -1
  367. package/dist/utils/index.js +8 -2
  368. package/dist/utils/index.js.map +1 -1
  369. package/dist/utils/init-detection.d.ts +36 -0
  370. package/dist/utils/init-detection.d.ts.map +1 -0
  371. package/dist/utils/init-detection.js +79 -0
  372. package/dist/utils/init-detection.js.map +1 -0
  373. package/dist/utils/logger.d.ts +11 -0
  374. package/dist/utils/logger.d.ts.map +1 -0
  375. package/dist/utils/logger.js +32 -0
  376. package/dist/utils/logger.js.map +1 -0
  377. package/dist/utils/pagination.d.ts +20 -0
  378. package/dist/utils/pagination.d.ts.map +1 -0
  379. package/dist/utils/pagination.js +29 -0
  380. package/dist/utils/pagination.js.map +1 -0
  381. package/dist/utils/path-security.d.ts +132 -18
  382. package/dist/utils/path-security.d.ts.map +1 -1
  383. package/dist/utils/path-security.js +164 -35
  384. package/dist/utils/path-security.js.map +1 -1
  385. package/dist/utils/sorting.d.ts +33 -0
  386. package/dist/utils/sorting.d.ts.map +1 -0
  387. package/dist/utils/sorting.js +57 -0
  388. package/dist/utils/sorting.js.map +1 -0
  389. package/dist/utils/text-filters.d.ts +13 -0
  390. package/dist/utils/text-filters.d.ts.map +1 -0
  391. package/dist/utils/text-filters.js +18 -0
  392. package/dist/utils/text-filters.js.map +1 -0
  393. package/dist/utils/time.d.ts +11 -0
  394. package/dist/utils/time.d.ts.map +1 -0
  395. package/dist/utils/time.js +13 -0
  396. package/dist/utils/time.js.map +1 -0
  397. package/dist/utils/validation.d.ts +25 -0
  398. package/dist/utils/validation.d.ts.map +1 -0
  399. package/dist/utils/validation.js +56 -0
  400. package/dist/utils/validation.js.map +1 -0
  401. package/package.json +45 -19
  402. package/dist/schemas/discriminator.d.ts +0 -20
  403. package/dist/schemas/discriminator.d.ts.map +0 -1
  404. package/dist/schemas/discriminator.js +0 -25
  405. package/dist/schemas/discriminator.js.map +0 -1
  406. package/dist/schemas/unified.d.ts +0 -674
  407. package/dist/schemas/unified.d.ts.map +0 -1
  408. package/dist/schemas/unified.js +0 -453
  409. package/dist/schemas/unified.js.map +0 -1
  410. package/dist/tools/unified.d.ts +0 -7
  411. package/dist/tools/unified.d.ts.map +0 -1
  412. package/dist/tools/unified.js +0 -827
  413. package/dist/tools/unified.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/middleware/types.ts"],"names":[],"mappings":""}
@@ -10,7 +10,10 @@ import { ResponseFormat } from "../types.js";
10
10
  * Response format schema for output formatting
11
11
  * Defaults to markdown for human-readable output
12
12
  */
13
- export declare const responseFormatSchema: z.ZodDefault<z.ZodEnum<typeof ResponseFormat>>;
13
+ export declare const responseFormatSchema: z.ZodDefault<z.ZodEnum<{
14
+ json: ResponseFormat.JSON;
15
+ markdown: ResponseFormat.MARKDOWN;
16
+ }>>;
14
17
  /**
15
18
  * Pagination schema for list operations
16
19
  * Used to control result set size and implement pagination
@@ -25,8 +28,55 @@ export declare const paginationSchema: z.ZodObject<{
25
28
  */
26
29
  export declare const hostSchema: z.ZodString;
27
30
  /**
28
- * Container ID or name schema
29
- * Validates non-empty string for container identification
31
+ * Container ID or name schema with comprehensive validation
32
+ *
33
+ * SECURITY: Prevents command injection (CWE-78) by validating Docker container identifiers.
34
+ * Docker API accepts three formats for container identification:
35
+ *
36
+ * 1. **Container Name**: User-defined name assigned with `--name` flag
37
+ * - Must start with alphanumeric character (prevents option injection like `-evil`)
38
+ * - Allowed characters: alphanumeric, underscore, hyphen, dot
39
+ * - Examples: `nginx`, `my-web-app`, `app_service_1`, `plex.v2`
40
+ * - Max length: 256 characters (practical limit for Docker names)
41
+ *
42
+ * 2. **Short ID**: First 12 characters of the full container ID
43
+ * - Exactly 12 lowercase hexadecimal characters
44
+ * - Examples: `abc123def456`, `0123456789ab`
45
+ *
46
+ * 3. **Full ID**: Complete 64-character SHA256 hash
47
+ * - Exactly 64 lowercase hexadecimal characters
48
+ * - Examples: `abc123def456...` (64 chars total)
49
+ *
50
+ * @note Docker IDs are always lowercase. Uppercase hex is rejected to prevent
51
+ * ambiguity with container names and ensure consistent identification.
52
+ *
53
+ * @note This schema is used with Docker's `getContainer()` API which accepts
54
+ * any of these three formats. The API handles the lookup internally.
55
+ *
56
+ * @example Valid container names
57
+ * ```typescript
58
+ * containerIdSchema.parse("nginx"); // Simple name
59
+ * containerIdSchema.parse("my-web-app"); // Name with hyphens
60
+ * containerIdSchema.parse("app_service_1"); // Compose generated name
61
+ * containerIdSchema.parse("plex.v2"); // Name with dots
62
+ * ```
63
+ *
64
+ * @example Valid Docker IDs
65
+ * ```typescript
66
+ * containerIdSchema.parse("abc123def456"); // Short ID (12 hex)
67
+ * containerIdSchema.parse("a".repeat(64)); // Full ID (64 hex)
68
+ * ```
69
+ *
70
+ * @example Invalid formats (throw ZodError)
71
+ * ```typescript
72
+ * containerIdSchema.parse("-evil"); // Starts with hyphen
73
+ * containerIdSchema.parse("app; rm -rf /"); // Shell metacharacters
74
+ * containerIdSchema.parse("ABC123DEF456"); // Uppercase hex rejected
75
+ * containerIdSchema.parse("abc123def45"); // 11 chars (invalid ID length)
76
+ * containerIdSchema.parse("xyz123456789"); // VALID as container name (not a hex ID)
77
+ * ```
78
+ *
79
+ * @see {@link https://docs.docker.com/engine/api/v1.43/#tag/Container}
30
80
  */
31
81
  export declare const containerIdSchema: z.ZodString;
32
82
  /**
@@ -38,11 +88,158 @@ export declare const projectSchema: z.ZodString;
38
88
  */
39
89
  export declare const imageSchema: z.ZodString;
40
90
  /**
41
- * Preprocessor to inject composite discriminator key
42
- * Used by Flux tool to create action_subaction from action + subaction
91
+ * Schema for grep patterns passed to shell commands.
92
+ *
93
+ * @description Strict validation that blocks shell metacharacters to prevent
94
+ * command injection (CWE-78). Use this ONLY for patterns passed to shell
95
+ * commands like `grep`, `awk`, or other CLI tools via SSH or exec.
96
+ *
97
+ * This schema intentionally rejects common log message characters like
98
+ * brackets `[]`, quotes `'"`, and parentheses `()` because these have
99
+ * special meaning in shell contexts and could enable injection attacks.
100
+ *
101
+ * @example
102
+ * // CORRECT - For shell grep commands (scout-logs)
103
+ * const scoutLogsSchema = z.object({
104
+ * host: hostSchema,
105
+ * grep: shellGrepSchema.optional() // Passed to: grep -E "${pattern}"
106
+ * });
107
+ *
108
+ * @example
109
+ * // Valid patterns for shell grep
110
+ * shellGrepSchema.parse("error"); // Simple word
111
+ * shellGrepSchema.parse("connection reset"); // Words with spaces
112
+ * shellGrepSchema.parse("nginx.*failed"); // Basic regex
113
+ * shellGrepSchema.parse("status: 5.."); // Numbers and punctuation
114
+ *
115
+ * @example
116
+ * // INVALID - These throw ZodError
117
+ * shellGrepSchema.parse("[ERROR]"); // Brackets are shell metacharacters
118
+ * shellGrepSchema.parse("'admin'"); // Quotes are shell metacharacters
119
+ * shellGrepSchema.parse("$(whoami)"); // Command substitution attempt
120
+ * shellGrepSchema.parse("foo; rm -rf"); // Command chaining attempt
121
+ *
122
+ * @example
123
+ * // INCORRECT - Don't use for JavaScript filtering
124
+ * // For client-side String.includes() matching, use jsFilterSchema instead
125
+ * // which allows brackets, quotes, and other common log characters
126
+ *
127
+ * @see {@link jsFilterSchema} for JavaScript-side filtering with String.includes()
128
+ */
129
+ export declare const shellGrepSchema: z.ZodString;
130
+ /**
131
+ * Backwards-compatible alias for existing schema imports.
132
+ */
133
+ export declare const safeGrepSchema: z.ZodString;
134
+ /**
135
+ * Schema for filter patterns used in JavaScript String.includes() matching.
136
+ *
137
+ * @description Relaxed validation for patterns that are ONLY used client-side
138
+ * in JavaScript with `String.includes()`. These patterns are never passed to
139
+ * shell commands, so shell metacharacters are safe to allow.
140
+ *
141
+ * This schema allows characters commonly found in log messages that would be
142
+ * rejected by shellGrepSchema:
143
+ * - Brackets: `[ERROR]`, `[INFO]`, `[2024-01-15]`
144
+ * - Quotes: `User 'admin'`, `key="value"`
145
+ * - Parentheses: `(deprecated)`, `method(arg)`
146
+ * - Special chars: `$PATH`, `a|b`, `foo;bar`
147
+ *
148
+ * Only control characters (0x00-0x1F) are rejected to prevent log injection
149
+ * and display corruption.
150
+ *
151
+ * @example
152
+ * // CORRECT - For JavaScript String.includes() filtering
153
+ * const containerLogsSchema = z.object({
154
+ * container: containerIdSchema,
155
+ * filter: jsFilterSchema.optional() // Used with: line.includes(filter)
156
+ * });
157
+ *
158
+ * @example
159
+ * // Valid patterns for JS filtering (allows log message syntax)
160
+ * jsFilterSchema.parse("[ERROR]"); // Brackets allowed
161
+ * jsFilterSchema.parse("User 'admin'"); // Quotes allowed
162
+ * jsFilterSchema.parse("status=(failed)"); // Parentheses allowed
163
+ * jsFilterSchema.parse("key=\"value\""); // Escaped quotes allowed
164
+ * jsFilterSchema.parse("path: /var/log"); // Forward slashes allowed
165
+ *
166
+ * @example
167
+ * // INVALID - These throw ZodError
168
+ * jsFilterSchema.parse("line\ninjection"); // Newlines are control chars
169
+ * jsFilterSchema.parse("has\ttab"); // Tabs are control chars
170
+ * jsFilterSchema.parse("null\x00byte"); // Null bytes rejected
171
+ *
172
+ * @example
173
+ * // INCORRECT - Don't use for shell commands
174
+ * // For patterns passed to grep/awk via SSH, use shellGrepSchema instead
175
+ * // which blocks shell metacharacters for security
176
+ *
177
+ * @see {@link shellGrepSchema} for shell-safe grep patterns
178
+ */
179
+ export declare const jsFilterSchema: z.ZodString;
180
+ /**
181
+ * ZFS pool name schema with security validation
182
+ * SECURITY: Prevents command injection (CWE-78) by rejecting shell metacharacters
183
+ * Valid characters: alphanumeric, underscore, hyphen, period
184
+ * Must start with a letter (per ZFS naming requirements)
185
+ * Does NOT allow forward slash (pools are top-level only)
186
+ */
187
+ export declare const zfsPoolSchema: z.ZodString;
188
+ /**
189
+ * ZFS dataset name schema with security validation
190
+ * SECURITY: Prevents command injection (CWE-78) by rejecting shell metacharacters
191
+ * Valid characters: alphanumeric, underscore, hyphen, period, forward slash, @, #
192
+ * Must start with a letter (per ZFS naming requirements)
193
+ * Allows hierarchical paths like tank/data/backup
194
+ * Allows snapshot notation like tank/data@snap
195
+ * Allows bookmark notation like tank/data#bookmark
196
+ *
197
+ * Note: Colon (:) is intentionally excluded. While ZFS allows it for user properties
198
+ * (e.g., com.example:property), this schema is for dataset/snapshot/bookmark paths only.
199
+ * If user property support is needed, create a separate zfsPropertySchema.
200
+ */
201
+ export declare const zfsDatasetSchema: z.ZodString;
202
+ /**
203
+ * Exec user schema with security validation
204
+ * SECURITY: Prevents command injection by validating Docker exec user format
205
+ * Valid formats:
206
+ * - Simple username: root, www-data, app_user
207
+ * - Numeric UID: 1000
208
+ * - UID:GID: 1000:1000
209
+ * - username:groupname: www-data:www-data
210
+ * Must start with alphanumeric or underscore (not hyphen to prevent option injection)
211
+ */
212
+ export declare const execUserSchema: z.ZodString;
213
+ /**
214
+ * Exec workdir schema with security validation
215
+ * SECURITY: Prevents path traversal and command injection
216
+ * Requirements:
217
+ * - Must be an absolute path (starts with /)
218
+ * - Only allows safe characters: alphanumeric, underscore, hyphen, period, forward slash
219
+ * - Does NOT allow: shell metacharacters, directory traversal (..), variable expansion ($)
220
+ *
221
+ * @note The root path `/` is intentionally allowed. Some Docker containers
222
+ * (especially minimal/distroless or scratch-based images) have very minimal
223
+ * filesystems where `/` may be the only valid working directory. Additionally,
224
+ * many official images use `/` as the default WORKDIR. Restricting this would
225
+ * break legitimate use cases.
226
+ *
227
+ * @example Valid paths
228
+ * ```typescript
229
+ * execWorkdirSchema.parse("/") // Root path (allowed for minimal containers)
230
+ * execWorkdirSchema.parse("/app") // Simple absolute path
231
+ * execWorkdirSchema.parse("/var/lib/data") // Nested path
232
+ * execWorkdirSchema.parse("/app-v1.0") // Path with dashes and dots
233
+ * ```
43
234
  *
44
- * Transforms: { action: "container", subaction: "list" }
45
- * To: { action: "container", subaction: "list", action_subaction: "container:list" }
235
+ * @example Invalid paths
236
+ * ```typescript
237
+ * execWorkdirSchema.parse("app") // Relative path (no leading /)
238
+ * execWorkdirSchema.parse("/app/../etc") // Directory traversal
239
+ * execWorkdirSchema.parse("/app; rm -rf /") // Shell metacharacters
240
+ * execWorkdirSchema.parse("/app/$HOME") // Variable expansion
241
+ * execWorkdirSchema.parse("/path with spaces") // Spaces not allowed
242
+ * ```
46
243
  */
47
- export declare function preprocessWithDiscriminator(data: unknown): unknown;
244
+ export declare const execWorkdirSchema: z.ZodString;
48
245
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,gDAGiB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;iBAS3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,UAAU,aAIU,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAAqD,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,aAAa,aAA4D,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,WAAW,aAA6D,CAAC;AAEtF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAMlE"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;GAGiB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;iBAS3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,UAAU,aAIU,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,iBAAiB,aA8CK,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,aAAa,aAIgB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,WAAW,aAA6D,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,eAAe,aAK6C,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,cAAc,aAAkB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,cAAc,aAc4C,CAAC;AAExE;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,aAQE,CAAC;AAE7B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,aAQkE,CAAC;AAEhG;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,aAQwC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,iBAAiB,aAWoB,CAAC"}
@@ -6,14 +6,14 @@
6
6
  * All schemas here are designed to be composable and reusable.
7
7
  */
8
8
  import { z } from "zod";
9
- import { ResponseFormat } from "../types.js";
10
9
  import { DEFAULT_LIMIT, MAX_LIMIT } from "../constants.js";
10
+ import { ResponseFormat } from "../types.js";
11
11
  /**
12
12
  * Response format schema for output formatting
13
13
  * Defaults to markdown for human-readable output
14
14
  */
15
15
  export const responseFormatSchema = z
16
- .nativeEnum(ResponseFormat)
16
+ .enum(Object.values(ResponseFormat))
17
17
  .default(ResponseFormat.MARKDOWN)
18
18
  .describe("Output format: 'markdown' or 'json'");
19
19
  /**
@@ -28,7 +28,7 @@ export const paginationSchema = z.object({
28
28
  .max(MAX_LIMIT)
29
29
  .default(DEFAULT_LIMIT)
30
30
  .describe("Maximum results to return"),
31
- offset: z.number().int().min(0).default(0).describe("Number of results to skip for pagination")
31
+ offset: z.number().int().min(0).default(0).describe("Number of results to skip for pagination"),
32
32
  });
33
33
  /**
34
34
  * Host name schema with validation
@@ -40,30 +40,303 @@ export const hostSchema = z
40
40
  .regex(/^[a-zA-Z0-9_-]+$/, "Host must be alphanumeric with dashes/underscores")
41
41
  .describe("Target Docker host");
42
42
  /**
43
- * Container ID or name schema
44
- * Validates non-empty string for container identification
43
+ * Container ID or name schema with comprehensive validation
44
+ *
45
+ * SECURITY: Prevents command injection (CWE-78) by validating Docker container identifiers.
46
+ * Docker API accepts three formats for container identification:
47
+ *
48
+ * 1. **Container Name**: User-defined name assigned with `--name` flag
49
+ * - Must start with alphanumeric character (prevents option injection like `-evil`)
50
+ * - Allowed characters: alphanumeric, underscore, hyphen, dot
51
+ * - Examples: `nginx`, `my-web-app`, `app_service_1`, `plex.v2`
52
+ * - Max length: 256 characters (practical limit for Docker names)
53
+ *
54
+ * 2. **Short ID**: First 12 characters of the full container ID
55
+ * - Exactly 12 lowercase hexadecimal characters
56
+ * - Examples: `abc123def456`, `0123456789ab`
57
+ *
58
+ * 3. **Full ID**: Complete 64-character SHA256 hash
59
+ * - Exactly 64 lowercase hexadecimal characters
60
+ * - Examples: `abc123def456...` (64 chars total)
61
+ *
62
+ * @note Docker IDs are always lowercase. Uppercase hex is rejected to prevent
63
+ * ambiguity with container names and ensure consistent identification.
64
+ *
65
+ * @note This schema is used with Docker's `getContainer()` API which accepts
66
+ * any of these three formats. The API handles the lookup internally.
67
+ *
68
+ * @example Valid container names
69
+ * ```typescript
70
+ * containerIdSchema.parse("nginx"); // Simple name
71
+ * containerIdSchema.parse("my-web-app"); // Name with hyphens
72
+ * containerIdSchema.parse("app_service_1"); // Compose generated name
73
+ * containerIdSchema.parse("plex.v2"); // Name with dots
74
+ * ```
75
+ *
76
+ * @example Valid Docker IDs
77
+ * ```typescript
78
+ * containerIdSchema.parse("abc123def456"); // Short ID (12 hex)
79
+ * containerIdSchema.parse("a".repeat(64)); // Full ID (64 hex)
80
+ * ```
81
+ *
82
+ * @example Invalid formats (throw ZodError)
83
+ * ```typescript
84
+ * containerIdSchema.parse("-evil"); // Starts with hyphen
85
+ * containerIdSchema.parse("app; rm -rf /"); // Shell metacharacters
86
+ * containerIdSchema.parse("ABC123DEF456"); // Uppercase hex rejected
87
+ * containerIdSchema.parse("abc123def45"); // 11 chars (invalid ID length)
88
+ * containerIdSchema.parse("xyz123456789"); // VALID as container name (not a hex ID)
89
+ * ```
90
+ *
91
+ * @see {@link https://docs.docker.com/engine/api/v1.43/#tag/Container}
45
92
  */
46
- export const containerIdSchema = z.string().min(1).describe("Container name or ID");
93
+ export const containerIdSchema = z
94
+ .string()
95
+ .trim()
96
+ .min(1, "Container ID or name cannot be empty")
97
+ .max(256, "Container name too long (max 256 characters)")
98
+ .refine((val) => {
99
+ // Pattern 1: Short ID (exactly 12 lowercase hex chars)
100
+ const shortIdPattern = /^[a-f0-9]{12}$/;
101
+ if (shortIdPattern.test(val))
102
+ return true;
103
+ // Pattern 2: Full ID (exactly 64 lowercase hex chars)
104
+ const fullIdPattern = /^[a-f0-9]{64}$/;
105
+ if (fullIdPattern.test(val))
106
+ return true;
107
+ // Pattern 3: Container Name
108
+ // Must start with alphanumeric, then alphanumeric/underscore/hyphen/dot
109
+ const namePattern = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
110
+ if (!namePattern.test(val))
111
+ return false;
112
+ // Additional validation: reject strings that look like malformed IDs
113
+ // If string is ONLY hex chars (no separators) and looks like a malformed ID, reject it
114
+ const onlyHexPattern = /^[a-fA-F0-9]+$/;
115
+ if (onlyHexPattern.test(val)) {
116
+ // Reject if it's close to valid ID lengths (potential typo/malformed ID)
117
+ const len = val.length;
118
+ if ((len >= 11 && len <= 13) || (len >= 63 && len <= 65)) {
119
+ return false; // Likely a malformed ID
120
+ }
121
+ // Reject uppercase hex (Docker IDs are always lowercase)
122
+ if (/[A-F]/.test(val) && len >= 11) {
123
+ return false; // Uppercase hex that looks like an ID
124
+ }
125
+ }
126
+ // Valid container name
127
+ return true;
128
+ }, {
129
+ message: "Container identifier must be either:\n" +
130
+ " • Container name (alphanumeric with _-. allowed, must start with alphanumeric)\n" +
131
+ " • Short ID (exactly 12 lowercase hex characters)\n" +
132
+ " • Full ID (exactly 64 lowercase hex characters)",
133
+ })
134
+ .describe("Container name or ID");
47
135
  /**
48
136
  * Project name schema for Docker Compose
49
137
  */
50
- export const projectSchema = z.string().min(1).describe("Docker Compose project name");
138
+ export const projectSchema = z
139
+ .string()
140
+ .min(1)
141
+ .regex(/^[a-zA-Z0-9_-]+$/, "Project name must be alphanumeric with dashes/underscores")
142
+ .describe("Docker Compose project name");
51
143
  /**
52
144
  * Image name schema with optional tag
53
145
  */
54
146
  export const imageSchema = z.string().min(1).describe("Image name with optional tag");
55
147
  /**
56
- * Preprocessor to inject composite discriminator key
57
- * Used by Flux tool to create action_subaction from action + subaction
148
+ * Schema for grep patterns passed to shell commands.
149
+ *
150
+ * @description Strict validation that blocks shell metacharacters to prevent
151
+ * command injection (CWE-78). Use this ONLY for patterns passed to shell
152
+ * commands like `grep`, `awk`, or other CLI tools via SSH or exec.
153
+ *
154
+ * This schema intentionally rejects common log message characters like
155
+ * brackets `[]`, quotes `'"`, and parentheses `()` because these have
156
+ * special meaning in shell contexts and could enable injection attacks.
157
+ *
158
+ * @example
159
+ * // CORRECT - For shell grep commands (scout-logs)
160
+ * const scoutLogsSchema = z.object({
161
+ * host: hostSchema,
162
+ * grep: shellGrepSchema.optional() // Passed to: grep -E "${pattern}"
163
+ * });
164
+ *
165
+ * @example
166
+ * // Valid patterns for shell grep
167
+ * shellGrepSchema.parse("error"); // Simple word
168
+ * shellGrepSchema.parse("connection reset"); // Words with spaces
169
+ * shellGrepSchema.parse("nginx.*failed"); // Basic regex
170
+ * shellGrepSchema.parse("status: 5.."); // Numbers and punctuation
171
+ *
172
+ * @example
173
+ * // INVALID - These throw ZodError
174
+ * shellGrepSchema.parse("[ERROR]"); // Brackets are shell metacharacters
175
+ * shellGrepSchema.parse("'admin'"); // Quotes are shell metacharacters
176
+ * shellGrepSchema.parse("$(whoami)"); // Command substitution attempt
177
+ * shellGrepSchema.parse("foo; rm -rf"); // Command chaining attempt
178
+ *
179
+ * @example
180
+ * // INCORRECT - Don't use for JavaScript filtering
181
+ * // For client-side String.includes() matching, use jsFilterSchema instead
182
+ * // which allows brackets, quotes, and other common log characters
183
+ *
184
+ * @see {@link jsFilterSchema} for JavaScript-side filtering with String.includes()
185
+ */
186
+ export const shellGrepSchema = z
187
+ .string()
188
+ .min(1)
189
+ .max(200)
190
+ .regex(/^[^;&|`$()<>{}[\]\\"\n\r\t']+$/, "Grep pattern contains shell metacharacters")
191
+ .describe("Shell-safe grep pattern (shell metacharacters not allowed)");
192
+ /**
193
+ * Backwards-compatible alias for existing schema imports.
194
+ */
195
+ export const safeGrepSchema = shellGrepSchema;
196
+ /**
197
+ * Schema for filter patterns used in JavaScript String.includes() matching.
58
198
  *
59
- * Transforms: { action: "container", subaction: "list" }
60
- * To: { action: "container", subaction: "list", action_subaction: "container:list" }
199
+ * @description Relaxed validation for patterns that are ONLY used client-side
200
+ * in JavaScript with `String.includes()`. These patterns are never passed to
201
+ * shell commands, so shell metacharacters are safe to allow.
202
+ *
203
+ * This schema allows characters commonly found in log messages that would be
204
+ * rejected by shellGrepSchema:
205
+ * - Brackets: `[ERROR]`, `[INFO]`, `[2024-01-15]`
206
+ * - Quotes: `User 'admin'`, `key="value"`
207
+ * - Parentheses: `(deprecated)`, `method(arg)`
208
+ * - Special chars: `$PATH`, `a|b`, `foo;bar`
209
+ *
210
+ * Only control characters (0x00-0x1F) are rejected to prevent log injection
211
+ * and display corruption.
212
+ *
213
+ * @example
214
+ * // CORRECT - For JavaScript String.includes() filtering
215
+ * const containerLogsSchema = z.object({
216
+ * container: containerIdSchema,
217
+ * filter: jsFilterSchema.optional() // Used with: line.includes(filter)
218
+ * });
219
+ *
220
+ * @example
221
+ * // Valid patterns for JS filtering (allows log message syntax)
222
+ * jsFilterSchema.parse("[ERROR]"); // Brackets allowed
223
+ * jsFilterSchema.parse("User 'admin'"); // Quotes allowed
224
+ * jsFilterSchema.parse("status=(failed)"); // Parentheses allowed
225
+ * jsFilterSchema.parse("key=\"value\""); // Escaped quotes allowed
226
+ * jsFilterSchema.parse("path: /var/log"); // Forward slashes allowed
227
+ *
228
+ * @example
229
+ * // INVALID - These throw ZodError
230
+ * jsFilterSchema.parse("line\ninjection"); // Newlines are control chars
231
+ * jsFilterSchema.parse("has\ttab"); // Tabs are control chars
232
+ * jsFilterSchema.parse("null\x00byte"); // Null bytes rejected
233
+ *
234
+ * @example
235
+ * // INCORRECT - Don't use for shell commands
236
+ * // For patterns passed to grep/awk via SSH, use shellGrepSchema instead
237
+ * // which blocks shell metacharacters for security
238
+ *
239
+ * @see {@link shellGrepSchema} for shell-safe grep patterns
61
240
  */
62
- export function preprocessWithDiscriminator(data) {
63
- if (data && typeof data === "object" && "action" in data && "subaction" in data) {
64
- const obj = data;
65
- return { ...obj, action_subaction: `${obj.action}:${obj.subaction}` };
241
+ export const jsFilterSchema = z
242
+ .string()
243
+ .min(1)
244
+ .max(500)
245
+ .refine((s) => {
246
+ for (let i = 0; i < s.length; i++) {
247
+ const code = s.charCodeAt(i);
248
+ if (code >= 0 && code <= 31)
249
+ return false;
66
250
  }
67
- return data;
68
- }
251
+ return true;
252
+ }, { message: "Filter pattern contains control characters" })
253
+ .describe("Filter pattern for JavaScript String.includes() matching");
254
+ /**
255
+ * ZFS pool name schema with security validation
256
+ * SECURITY: Prevents command injection (CWE-78) by rejecting shell metacharacters
257
+ * Valid characters: alphanumeric, underscore, hyphen, period
258
+ * Must start with a letter (per ZFS naming requirements)
259
+ * Does NOT allow forward slash (pools are top-level only)
260
+ */
261
+ export const zfsPoolSchema = z
262
+ .string()
263
+ .min(1)
264
+ .max(255)
265
+ .regex(/^[a-zA-Z][a-zA-Z0-9_\-.]*$/, "Pool name must start with a letter and contain only alphanumeric, dashes, underscores, or periods")
266
+ .describe("ZFS pool name");
267
+ /**
268
+ * ZFS dataset name schema with security validation
269
+ * SECURITY: Prevents command injection (CWE-78) by rejecting shell metacharacters
270
+ * Valid characters: alphanumeric, underscore, hyphen, period, forward slash, @, #
271
+ * Must start with a letter (per ZFS naming requirements)
272
+ * Allows hierarchical paths like tank/data/backup
273
+ * Allows snapshot notation like tank/data@snap
274
+ * Allows bookmark notation like tank/data#bookmark
275
+ *
276
+ * Note: Colon (:) is intentionally excluded. While ZFS allows it for user properties
277
+ * (e.g., com.example:property), this schema is for dataset/snapshot/bookmark paths only.
278
+ * If user property support is needed, create a separate zfsPropertySchema.
279
+ */
280
+ export const zfsDatasetSchema = z
281
+ .string()
282
+ .min(1)
283
+ .max(255)
284
+ .regex(/^[a-zA-Z][a-zA-Z0-9_\-./@#]*$/, "Dataset name must start with a letter and contain only alphanumeric, dashes, underscores, periods, slashes, @, or #")
285
+ .describe("ZFS dataset name (can include path like pool/dataset, snapshot @, or bookmark #)");
286
+ /**
287
+ * Exec user schema with security validation
288
+ * SECURITY: Prevents command injection by validating Docker exec user format
289
+ * Valid formats:
290
+ * - Simple username: root, www-data, app_user
291
+ * - Numeric UID: 1000
292
+ * - UID:GID: 1000:1000
293
+ * - username:groupname: www-data:www-data
294
+ * Must start with alphanumeric or underscore (not hyphen to prevent option injection)
295
+ */
296
+ export const execUserSchema = z
297
+ .string()
298
+ .min(1)
299
+ .max(64)
300
+ .regex(/^[a-zA-Z0-9_][a-zA-Z0-9_-]*(?::[a-zA-Z0-9_][a-zA-Z0-9_-]*)?$|^\d+(?::\d+)?$/, "User must be a valid username, uid, username:groupname, or uid:gid format")
301
+ .describe("User to run command as (e.g., root, 1000, 1000:1000)");
302
+ /**
303
+ * Exec workdir schema with security validation
304
+ * SECURITY: Prevents path traversal and command injection
305
+ * Requirements:
306
+ * - Must be an absolute path (starts with /)
307
+ * - Only allows safe characters: alphanumeric, underscore, hyphen, period, forward slash
308
+ * - Does NOT allow: shell metacharacters, directory traversal (..), variable expansion ($)
309
+ *
310
+ * @note The root path `/` is intentionally allowed. Some Docker containers
311
+ * (especially minimal/distroless or scratch-based images) have very minimal
312
+ * filesystems where `/` may be the only valid working directory. Additionally,
313
+ * many official images use `/` as the default WORKDIR. Restricting this would
314
+ * break legitimate use cases.
315
+ *
316
+ * @example Valid paths
317
+ * ```typescript
318
+ * execWorkdirSchema.parse("/") // Root path (allowed for minimal containers)
319
+ * execWorkdirSchema.parse("/app") // Simple absolute path
320
+ * execWorkdirSchema.parse("/var/lib/data") // Nested path
321
+ * execWorkdirSchema.parse("/app-v1.0") // Path with dashes and dots
322
+ * ```
323
+ *
324
+ * @example Invalid paths
325
+ * ```typescript
326
+ * execWorkdirSchema.parse("app") // Relative path (no leading /)
327
+ * execWorkdirSchema.parse("/app/../etc") // Directory traversal
328
+ * execWorkdirSchema.parse("/app; rm -rf /") // Shell metacharacters
329
+ * execWorkdirSchema.parse("/app/$HOME") // Variable expansion
330
+ * execWorkdirSchema.parse("/path with spaces") // Spaces not allowed
331
+ * ```
332
+ */
333
+ export const execWorkdirSchema = z
334
+ .string()
335
+ .min(1)
336
+ .max(4096)
337
+ .regex(/^\/[a-zA-Z0-9_\-./]*$/, "Working directory must be an absolute path with safe characters only")
338
+ .refine((path) => !path.includes(".."), {
339
+ message: "Working directory cannot contain directory traversal (..)",
340
+ })
341
+ .describe("Absolute path for working directory");
69
342
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,UAAU,CAAC,cAAc,CAAC;KAC1B,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC;KAChC,QAAQ,CAAC,qCAAqC,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,SAAS,CAAC;SACd,OAAO,CAAC,aAAa,CAAC;SACtB,QAAQ,CAAC,2BAA2B,CAAC;IACxC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,0CAA0C,CAAC;CAChG,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,KAAK,CAAC,kBAAkB,EAAE,mDAAmD,CAAC;KAC9E,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CA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