aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/plugins.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/plugins.ts')
-rw-r--r--server/middlewares/validators/plugins.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 78c030333..64bef2648 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -4,7 +4,12 @@ import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { PluginType } from '../../../shared/models/plugins/plugin.type' 4import { PluginType } from '../../../shared/models/plugins/plugin.type'
5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' 5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' 6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
7import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 7import {
8 isNpmPluginNameValid,
9 isPluginNameValid,
10 isPluginStableOrUnstableVersionValid,
11 isPluginTypeValid
12} from '../../helpers/custom-validators/plugins'
8import { CONFIG } from '../../initializers/config' 13import { CONFIG } from '../../initializers/config'
9import { PluginManager } from '../../lib/plugins/plugin-manager' 14import { PluginManager } from '../../lib/plugins/plugin-manager'
10import { PluginModel } from '../../models/server/plugin' 15import { PluginModel } from '../../models/server/plugin'
@@ -19,7 +24,7 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
19 if (withVersion) { 24 if (withVersion) {
20 validators.push( 25 validators.push(
21 param('pluginVersion') 26 param('pluginVersion')
22 .custom(isPluginVersionValid) 27 .custom(isPluginStableOrUnstableVersionValid)
23 ) 28 )
24 } 29 }
25 30
@@ -113,7 +118,7 @@ const installOrUpdatePluginValidator = [
113 .custom(isNpmPluginNameValid), 118 .custom(isNpmPluginNameValid),
114 body('pluginVersion') 119 body('pluginVersion')
115 .optional() 120 .optional()
116 .custom(isPluginVersionValid), 121 .custom(isPluginStableOrUnstableVersionValid),
117 body('path') 122 body('path')
118 .optional() 123 .optional()
119 .custom(isSafePath), 124 .custom(isSafePath),
@@ -185,7 +190,7 @@ const listAvailablePluginsValidator = [
185 .custom(isPluginTypeValid), 190 .custom(isPluginTypeValid),
186 query('currentPeerTubeEngine') 191 query('currentPeerTubeEngine')
187 .optional() 192 .optional()
188 .custom(isPluginVersionValid), 193 .custom(isPluginStableOrUnstableVersionValid),
189 194
190 (req: express.Request, res: express.Response, next: express.NextFunction) => { 195 (req: express.Request, res: express.Response, next: express.NextFunction) => {
191 if (areValidationErrors(req, res)) return 196 if (areValidationErrors(req, res)) return