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.
- package/README.md +1820 -147
- package/dist/constants.d.ts +10 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +18 -8
- package/dist/constants.js.map +1 -1
- package/dist/events/emitter.d.ts +63 -0
- package/dist/events/emitter.d.ts.map +1 -0
- package/dist/events/emitter.js +112 -0
- package/dist/events/emitter.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +51 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +3 -0
- package/dist/events/types.js.map +1 -0
- package/dist/formatters/compose.d.ts +185 -0
- package/dist/formatters/compose.d.ts.map +1 -0
- package/dist/formatters/compose.js +397 -0
- package/dist/formatters/compose.js.map +1 -0
- package/dist/formatters/container.d.ts +84 -0
- package/dist/formatters/container.d.ts.map +1 -0
- package/dist/formatters/container.js +323 -0
- package/dist/formatters/container.js.map +1 -0
- package/dist/formatters/diagnostics.d.ts +20 -0
- package/dist/formatters/diagnostics.d.ts.map +1 -0
- package/dist/formatters/diagnostics.js +73 -0
- package/dist/formatters/diagnostics.js.map +1 -0
- package/dist/formatters/docker.d.ts +139 -0
- package/dist/formatters/docker.d.ts.map +1 -0
- package/dist/formatters/docker.js +216 -0
- package/dist/formatters/docker.js.map +1 -0
- package/dist/formatters/host.d.ts +137 -0
- package/dist/formatters/host.d.ts.map +1 -0
- package/dist/formatters/host.js +198 -0
- package/dist/formatters/host.js.map +1 -0
- package/dist/formatters/index.d.ts +17 -270
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +21 -456
- package/dist/formatters/index.js.map +1 -1
- package/dist/formatters/scout.d.ts +424 -0
- package/dist/formatters/scout.d.ts.map +1 -0
- package/dist/formatters/scout.js +687 -0
- package/dist/formatters/scout.js.map +1 -0
- package/dist/formatters/strategy.d.ts +105 -0
- package/dist/formatters/strategy.d.ts.map +1 -0
- package/dist/formatters/strategy.js +120 -0
- package/dist/formatters/strategy.js.map +1 -0
- package/dist/formatters/utils.d.ts +84 -0
- package/dist/formatters/utils.d.ts.map +1 -0
- package/dist/formatters/utils.js +129 -0
- package/dist/formatters/utils.js.map +1 -0
- package/dist/health-rate-limiter.d.ts +59 -0
- package/dist/health-rate-limiter.d.ts.map +1 -0
- package/dist/health-rate-limiter.js +159 -0
- package/dist/health-rate-limiter.js.map +1 -0
- package/dist/index.js +61 -100
- package/dist/index.js.map +1 -1
- package/dist/middleware/async-handler.d.ts +62 -0
- package/dist/middleware/async-handler.d.ts.map +1 -0
- package/dist/middleware/async-handler.js +58 -0
- package/dist/middleware/async-handler.js.map +1 -0
- package/dist/middleware/auth.d.ts +32 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +63 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/csrf-protection.d.ts +58 -0
- package/dist/middleware/csrf-protection.d.ts.map +1 -0
- package/dist/middleware/csrf-protection.js +123 -0
- package/dist/middleware/csrf-protection.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +49 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +90 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/error-mapper.d.ts +44 -0
- package/dist/middleware/error-mapper.d.ts.map +1 -0
- package/dist/middleware/error-mapper.js +127 -0
- package/dist/middleware/error-mapper.js.map +1 -0
- package/dist/middleware/index.d.ts +13 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +13 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/request-id.d.ts +22 -0
- package/dist/middleware/request-id.d.ts.map +1 -0
- package/dist/middleware/request-id.js +31 -0
- package/dist/middleware/request-id.js.map +1 -0
- package/dist/middleware/types.d.ts +33 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +2 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/schemas/common.d.ts +205 -8
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/common.js +290 -17
- package/dist/schemas/common.js.map +1 -1
- package/dist/schemas/flux/compose.d.ts +307 -44
- package/dist/schemas/flux/compose.d.ts.map +1 -1
- package/dist/schemas/flux/compose.js +74 -48
- package/dist/schemas/flux/compose.js.map +1 -1
- package/dist/schemas/flux/container.d.ts +423 -56
- package/dist/schemas/flux/container.d.ts.map +1 -1
- package/dist/schemas/flux/container.js +83 -61
- package/dist/schemas/flux/container.js.map +1 -1
- package/dist/schemas/flux/docker.d.ts +254 -37
- package/dist/schemas/flux/docker.d.ts.map +1 -1
- package/dist/schemas/flux/docker.js +69 -39
- package/dist/schemas/flux/docker.js.map +1 -1
- package/dist/schemas/flux/host.d.ts +312 -29
- package/dist/schemas/flux/host.d.ts.map +1 -1
- package/dist/schemas/flux/host.js +74 -31
- package/dist/schemas/flux/host.js.map +1 -1
- package/dist/schemas/flux/index.d.ts +503 -11
- package/dist/schemas/flux/index.d.ts.map +1 -1
- package/dist/schemas/flux/index.js +34 -70
- package/dist/schemas/flux/index.js.map +1 -1
- package/dist/schemas/host-config.d.ts +76 -0
- package/dist/schemas/host-config.d.ts.map +1 -0
- package/dist/schemas/host-config.js +105 -0
- package/dist/schemas/host-config.js.map +1 -0
- package/dist/schemas/scout/index.d.ts +80 -23
- package/dist/schemas/scout/index.d.ts.map +1 -1
- package/dist/schemas/scout/index.js +26 -11
- package/dist/schemas/scout/index.js.map +1 -1
- package/dist/schemas/scout/logs.d.ts +17 -5
- package/dist/schemas/scout/logs.d.ts.map +1 -1
- package/dist/schemas/scout/logs.js +41 -31
- package/dist/schemas/scout/logs.js.map +1 -1
- package/dist/schemas/scout/simple.d.ts +126 -11
- package/dist/schemas/scout/simple.d.ts.map +1 -1
- package/dist/schemas/scout/simple.js +112 -57
- package/dist/schemas/scout/simple.js.map +1 -1
- package/dist/schemas/scout/zfs.d.ts +17 -5
- package/dist/schemas/scout/zfs.d.ts.map +1 -1
- package/dist/schemas/scout/zfs.js +34 -25
- package/dist/schemas/scout/zfs.js.map +1 -1
- package/dist/services/cache-layer.d.ts +160 -0
- package/dist/services/cache-layer.d.ts.map +1 -0
- package/dist/services/cache-layer.js +138 -0
- package/dist/services/cache-layer.js.map +1 -0
- package/dist/services/compose-cache.d.ts +75 -0
- package/dist/services/compose-cache.d.ts.map +1 -0
- package/dist/services/compose-cache.js +178 -0
- package/dist/services/compose-cache.js.map +1 -0
- package/dist/services/compose-discovery.d.ts +46 -0
- package/dist/services/compose-discovery.d.ts.map +1 -0
- package/dist/services/compose-discovery.js +219 -0
- package/dist/services/compose-discovery.js.map +1 -0
- package/dist/services/compose-project-lister.d.ts +27 -0
- package/dist/services/compose-project-lister.d.ts.map +1 -0
- package/dist/services/compose-project-lister.js +71 -0
- package/dist/services/compose-project-lister.js.map +1 -0
- package/dist/services/compose-scanner.d.ts +63 -0
- package/dist/services/compose-scanner.d.ts.map +1 -0
- package/dist/services/compose-scanner.js +253 -0
- package/dist/services/compose-scanner.js.map +1 -0
- package/dist/services/compose.d.ts +64 -28
- package/dist/services/compose.d.ts.map +1 -1
- package/dist/services/compose.js +220 -98
- package/dist/services/compose.js.map +1 -1
- package/dist/services/config-loader.d.ts +23 -0
- package/dist/services/config-loader.d.ts.map +1 -0
- package/dist/services/config-loader.js +124 -0
- package/dist/services/config-loader.js.map +1 -0
- package/dist/services/config-service.d.ts +38 -0
- package/dist/services/config-service.d.ts.map +1 -0
- package/dist/services/config-service.js +225 -0
- package/dist/services/config-service.js.map +1 -0
- package/dist/services/container-host-map-cache.d.ts +121 -0
- package/dist/services/container-host-map-cache.d.ts.map +1 -0
- package/dist/services/container-host-map-cache.js +188 -0
- package/dist/services/container-host-map-cache.js.map +1 -0
- package/dist/services/container.d.ts +194 -6
- package/dist/services/container.d.ts.map +1 -1
- package/dist/services/container.js +386 -11
- package/dist/services/container.js.map +1 -1
- package/dist/services/diagnostics.d.ts +57 -0
- package/dist/services/diagnostics.d.ts.map +1 -0
- package/dist/services/diagnostics.js +271 -0
- package/dist/services/diagnostics.js.map +1 -0
- package/dist/services/docker/container-service.d.ts +123 -0
- package/dist/services/docker/container-service.d.ts.map +1 -0
- package/dist/services/docker/container-service.js +347 -0
- package/dist/services/docker/container-service.js.map +1 -0
- package/dist/services/docker/image-service.d.ts +82 -0
- package/dist/services/docker/image-service.d.ts.map +1 -0
- package/dist/services/docker/image-service.js +193 -0
- package/dist/services/docker/image-service.js.map +1 -0
- package/dist/services/docker/index.d.ts +80 -0
- package/dist/services/docker/index.d.ts.map +1 -0
- package/dist/services/docker/index.js +103 -0
- package/dist/services/docker/index.js.map +1 -0
- package/dist/services/docker/network-service.d.ts +22 -0
- package/dist/services/docker/network-service.d.ts.map +1 -0
- package/dist/services/docker/network-service.js +43 -0
- package/dist/services/docker/network-service.js.map +1 -0
- package/dist/services/docker/system-service.d.ts +49 -0
- package/dist/services/docker/system-service.d.ts.map +1 -0
- package/dist/services/docker/system-service.js +215 -0
- package/dist/services/docker/system-service.js.map +1 -0
- package/dist/services/docker/utils/client-factory.d.ts +56 -0
- package/dist/services/docker/utils/client-factory.d.ts.map +1 -0
- package/dist/services/docker/utils/client-factory.js +139 -0
- package/dist/services/docker/utils/client-factory.js.map +1 -0
- package/dist/services/docker/utils/client-manager.d.ts +88 -0
- package/dist/services/docker/utils/client-manager.d.ts.map +1 -0
- package/dist/services/docker/utils/client-manager.js +124 -0
- package/dist/services/docker/utils/client-manager.js.map +1 -0
- package/dist/services/docker/utils/exec-handler.d.ts +94 -0
- package/dist/services/docker/utils/exec-handler.d.ts.map +1 -0
- package/dist/services/docker/utils/exec-handler.js +197 -0
- package/dist/services/docker/utils/exec-handler.js.map +1 -0
- package/dist/services/docker/utils/formatters.d.ts +13 -0
- package/dist/services/docker/utils/formatters.d.ts.map +1 -0
- package/dist/services/docker/utils/formatters.js +33 -0
- package/dist/services/docker/utils/formatters.js.map +1 -0
- package/dist/services/docker/utils/log-parser.d.ts +10 -0
- package/dist/services/docker/utils/log-parser.d.ts.map +1 -0
- package/dist/services/docker/utils/log-parser.js +48 -0
- package/dist/services/docker/utils/log-parser.js.map +1 -0
- package/dist/services/docker/utils/stats-calculator.d.ts +68 -0
- package/dist/services/docker/utils/stats-calculator.d.ts.map +1 -0
- package/dist/services/docker/utils/stats-calculator.js +61 -0
- package/dist/services/docker/utils/stats-calculator.js.map +1 -0
- package/dist/services/docker/volume-service.d.ts +22 -0
- package/dist/services/docker/volume-service.d.ts.map +1 -0
- package/dist/services/docker/volume-service.js +48 -0
- package/dist/services/docker/volume-service.js.map +1 -0
- package/dist/services/docker-interfaces.d.ts +283 -0
- package/dist/services/docker-interfaces.d.ts.map +1 -0
- package/dist/services/docker-interfaces.js +13 -0
- package/dist/services/docker-interfaces.js.map +1 -0
- package/dist/services/docker.d.ts +42 -5
- package/dist/services/docker.d.ts.map +1 -1
- package/dist/services/docker.js +335 -127
- package/dist/services/docker.js.map +1 -1
- package/dist/services/file-service.d.ts +6 -2
- package/dist/services/file-service.d.ts.map +1 -1
- package/dist/services/file-service.js +156 -52
- package/dist/services/file-service.js.map +1 -1
- package/dist/services/host-config-repository.d.ts +133 -0
- package/dist/services/host-config-repository.d.ts.map +1 -0
- package/dist/services/host-config-repository.js +323 -0
- package/dist/services/host-config-repository.js.map +1 -0
- package/dist/services/host-resolver.d.ts +49 -0
- package/dist/services/host-resolver.d.ts.map +1 -0
- package/dist/services/host-resolver.js +176 -0
- package/dist/services/host-resolver.js.map +1 -0
- package/dist/services/interfaces.d.ts +61 -194
- package/dist/services/interfaces.d.ts.map +1 -1
- package/dist/services/local-executor.d.ts +31 -0
- package/dist/services/local-executor.d.ts.map +1 -0
- package/dist/services/local-executor.js +71 -0
- package/dist/services/local-executor.js.map +1 -0
- package/dist/services/ssh-config-loader.d.ts +35 -0
- package/dist/services/ssh-config-loader.d.ts.map +1 -0
- package/dist/services/ssh-config-loader.js +218 -0
- package/dist/services/ssh-config-loader.js.map +1 -0
- package/dist/services/ssh-pool.d.ts +26 -1
- package/dist/services/ssh-pool.d.ts.map +1 -1
- package/dist/services/ssh-pool.js +166 -25
- package/dist/services/ssh-pool.js.map +1 -1
- package/dist/services/ssh-service.d.ts +3 -0
- package/dist/services/ssh-service.d.ts.map +1 -1
- package/dist/services/ssh-service.js +53 -31
- package/dist/services/ssh-service.js.map +1 -1
- package/dist/services/ssh.d.ts +2 -6
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +9 -40
- package/dist/services/ssh.js.map +1 -1
- package/dist/tools/definitions/flux.d.ts +13 -0
- package/dist/tools/definitions/flux.d.ts.map +1 -0
- package/dist/tools/definitions/flux.js +101 -0
- package/dist/tools/definitions/flux.js.map +1 -0
- package/dist/tools/definitions/index.d.ts +8 -0
- package/dist/tools/definitions/index.d.ts.map +1 -0
- package/dist/tools/definitions/index.js +8 -0
- package/dist/tools/definitions/index.js.map +1 -0
- package/dist/tools/definitions/scout.d.ts +13 -0
- package/dist/tools/definitions/scout.d.ts.map +1 -0
- package/dist/tools/definitions/scout.js +78 -0
- package/dist/tools/definitions/scout.js.map +1 -0
- package/dist/tools/flux.d.ts +16 -8
- package/dist/tools/flux.d.ts.map +1 -1
- package/dist/tools/flux.js +27 -66
- package/dist/tools/flux.js.map +1 -1
- package/dist/tools/handlers/base-handler.d.ts +172 -0
- package/dist/tools/handlers/base-handler.d.ts.map +1 -0
- package/dist/tools/handlers/base-handler.js +234 -0
- package/dist/tools/handlers/base-handler.js.map +1 -0
- package/dist/tools/handlers/compose-handlers.d.ts +108 -0
- package/dist/tools/handlers/compose-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/compose-handlers.js +293 -0
- package/dist/tools/handlers/compose-handlers.js.map +1 -0
- package/dist/tools/handlers/compose-utils.d.ts +35 -0
- package/dist/tools/handlers/compose-utils.d.ts.map +1 -0
- package/dist/tools/handlers/compose-utils.js +76 -0
- package/dist/tools/handlers/compose-utils.js.map +1 -0
- package/dist/tools/handlers/compose.d.ts +23 -0
- package/dist/tools/handlers/compose.d.ts.map +1 -0
- package/dist/tools/handlers/compose.js +125 -0
- package/dist/tools/handlers/compose.js.map +1 -0
- package/dist/tools/handlers/container.d.ts +23 -0
- package/dist/tools/handlers/container.d.ts.map +1 -0
- package/dist/tools/handlers/container.js +333 -0
- package/dist/tools/handlers/container.js.map +1 -0
- package/dist/tools/handlers/docker.d.ts +24 -0
- package/dist/tools/handlers/docker.d.ts.map +1 -0
- package/dist/tools/handlers/docker.js +155 -0
- package/dist/tools/handlers/docker.js.map +1 -0
- package/dist/tools/handlers/host.d.ts +23 -0
- package/dist/tools/handlers/host.d.ts.map +1 -0
- package/dist/tools/handlers/host.js +196 -0
- package/dist/tools/handlers/host.js.map +1 -0
- package/dist/tools/handlers/scout-logs.d.ts +24 -0
- package/dist/tools/handlers/scout-logs.d.ts.map +1 -0
- package/dist/tools/handlers/scout-logs.js +119 -0
- package/dist/tools/handlers/scout-logs.js.map +1 -0
- package/dist/tools/handlers/scout-simple.d.ts +23 -0
- package/dist/tools/handlers/scout-simple.d.ts.map +1 -0
- package/dist/tools/handlers/scout-simple.js +286 -0
- package/dist/tools/handlers/scout-simple.js.map +1 -0
- package/dist/tools/handlers/scout-zfs.d.ts +23 -0
- package/dist/tools/handlers/scout-zfs.d.ts.map +1 -0
- package/dist/tools/handlers/scout-zfs.js +82 -0
- package/dist/tools/handlers/scout-zfs.js.map +1 -0
- package/dist/tools/index.d.ts +32 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +41 -35
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/registry.d.ts +135 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +151 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/scout.d.ts +16 -8
- package/dist/tools/scout.d.ts.map +1 -1
- package/dist/tools/scout.js +36 -78
- package/dist/tools/scout.js.map +1 -1
- package/dist/types.d.ts +629 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/command-security.d.ts +82 -0
- package/dist/utils/command-security.d.ts.map +1 -0
- package/dist/utils/command-security.js +122 -0
- package/dist/utils/command-security.js.map +1 -0
- package/dist/utils/error-sanitization.d.ts +77 -0
- package/dist/utils/error-sanitization.d.ts.map +1 -0
- package/dist/utils/error-sanitization.js +107 -0
- package/dist/utils/error-sanitization.js.map +1 -0
- package/dist/utils/errors.d.ts +30 -6
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +91 -12
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/help-handler.d.ts +23 -0
- package/dist/utils/help-handler.d.ts.map +1 -0
- package/dist/utils/help-handler.js +21 -0
- package/dist/utils/help-handler.js.map +1 -0
- package/dist/utils/help.d.ts +1 -1
- package/dist/utils/help.d.ts.map +1 -1
- package/dist/utils/help.js +57 -16
- package/dist/utils/help.js.map +1 -1
- package/dist/utils/host-utils.d.ts +31 -0
- package/dist/utils/host-utils.d.ts.map +1 -0
- package/dist/utils/host-utils.js +80 -0
- package/dist/utils/host-utils.js.map +1 -0
- package/dist/utils/index.d.ts +8 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/init-detection.d.ts +36 -0
- package/dist/utils/init-detection.d.ts.map +1 -0
- package/dist/utils/init-detection.js +79 -0
- package/dist/utils/init-detection.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +32 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/pagination.d.ts +20 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +29 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/path-security.d.ts +132 -18
- package/dist/utils/path-security.d.ts.map +1 -1
- package/dist/utils/path-security.js +164 -35
- package/dist/utils/path-security.js.map +1 -1
- package/dist/utils/sorting.d.ts +33 -0
- package/dist/utils/sorting.d.ts.map +1 -0
- package/dist/utils/sorting.js +57 -0
- package/dist/utils/sorting.js.map +1 -0
- package/dist/utils/text-filters.d.ts +13 -0
- package/dist/utils/text-filters.d.ts.map +1 -0
- package/dist/utils/text-filters.js +18 -0
- package/dist/utils/text-filters.js.map +1 -0
- package/dist/utils/time.d.ts +11 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +13 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/validation.d.ts +25 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +56 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +45 -19
- package/dist/schemas/discriminator.d.ts +0 -20
- package/dist/schemas/discriminator.d.ts.map +0 -1
- package/dist/schemas/discriminator.js +0 -25
- package/dist/schemas/discriminator.js.map +0 -1
- package/dist/schemas/unified.d.ts +0 -674
- package/dist/schemas/unified.d.ts.map +0 -1
- package/dist/schemas/unified.js +0 -453
- package/dist/schemas/unified.js.map +0 -1
- package/dist/tools/unified.d.ts +0 -7
- package/dist/tools/unified.d.ts.map +0 -1
- package/dist/tools/unified.js +0 -827
- package/dist/tools/unified.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/middleware/types.ts"],"names":[],"mappings":""}
|
package/dist/schemas/common.d.ts
CHANGED
|
@@ -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<
|
|
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
|
-
*
|
|
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
|
-
*
|
|
42
|
-
*
|
|
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
|
-
*
|
|
45
|
-
*
|
|
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
|
|
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;
|
|
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"}
|
package/dist/schemas/common.js
CHANGED
|
@@ -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
|
-
.
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
-
*
|
|
57
|
-
*
|
|
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
|
-
*
|
|
60
|
-
*
|
|
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
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
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;A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