project-nomad/admin/app/validators/system.ts
Claude 6058fd31a0
fix: add input validation constraints for service names, file paths, uploads, and settings keys
- system.ts: Add maxLength(100) and alphanumeric/hyphen/underscore regex to service_name fields
- system.ts: Add maxLength(50) and semver/Docker tag regex to target_version field
- rag.ts: Add maxLength(500) to filePath field
- rag_controller.ts: Add 50MB file upload size limit and validation error handling
- settings_controller.ts: Validate getSetting() key parameter against KV_STORE_SCHEMA at runtime

https://claude.ai/code/session_01JFvpTYgm8GiE4vJ4cJKsFx
2026-03-24 09:30:03 +00:00

34 lines
965 B
TypeScript

import vine from '@vinejs/vine'
export const installServiceValidator = vine.compile(
vine.object({
service_name: vine.string().trim().maxLength(100).regex(/^[a-zA-Z0-9_-]+$/),
})
)
export const affectServiceValidator = vine.compile(
vine.object({
service_name: vine.string().trim().maxLength(100).regex(/^[a-zA-Z0-9_-]+$/),
action: vine.enum(['start', 'stop', 'restart']),
})
)
export const subscribeToReleaseNotesValidator = vine.compile(
vine.object({
email: vine.string().email().trim(),
})
)
export const checkLatestVersionValidator = vine.compile(
vine.object({
force: vine.boolean().optional(), // Optional flag to force bypassing cache and checking for updates immediately
})
)
export const updateServiceValidator = vine.compile(
vine.object({
service_name: vine.string().trim().maxLength(100).regex(/^[a-zA-Z0-9_-]+$/),
target_version: vine.string().trim().maxLength(50).regex(/^[a-zA-Z0-9._-]+$/),
})
)