From 9aeef9aafa009762e128046bfb2f3cec3252e181 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Feb 2021 16:14:12 +0100 Subject: Check video UUID in args scripts --- scripts/create-import-video-file-job.ts | 6 ++++++ scripts/create-transcoding-job.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts index f5271c7a3..5d38af066 100644 --- a/scripts/create-import-video-file-job.ts +++ b/scripts/create-import-video-file-job.ts @@ -6,6 +6,7 @@ import { resolve } from 'path' import { VideoModel } from '../server/models/video/video' import { initDatabaseModels } from '../server/initializers/database' import { JobQueue } from '../server/lib/job-queue' +import { isUUIDValid } from '@server/helpers/custom-validators/misc' program .option('-v, --video [videoUUID]', 'Video UUID') @@ -30,6 +31,11 @@ run() async function run () { await initDatabaseModels(true) + if (isUUIDValid(options.video) === false) { + console.error('%s is not a valid video UUID.', options.video) + return + } + const video = await VideoModel.loadByUUID(options.video) if (!video) throw new Error('Video not found.') if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 9f1d8b956..56a5f4938 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts @@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue' import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' import { VideoTranscodingPayload } from '@shared/models' import { CONFIG } from '@server/initializers/config' +import { isUUIDValid } from '@server/helpers/custom-validators/misc' program .option('-v, --video [videoUUID]', 'Video UUID') @@ -37,6 +38,11 @@ run() async function run () { await initDatabaseModels(true) + if (isUUIDValid(options.video) === false) { + console.error('%s is not a valid video UUID.', options.video) + return + } + const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video) if (!video) throw new Error('Video not found.') -- cgit v1.2.3