Browse Source

Закрыта дыра безопасности

Book Pauk 5 years ago
parent
commit
1bcd902817

+ 2 - 1
client/api/misc.js

@@ -14,7 +14,8 @@ class Misc {
 
 
         try {
         try {
             await wsc.open();
             await wsc.open();
-            return await wsc.message(wsc.send(Object.assign({action: 'get-config'}, query)));
+            const config = await wsc.message(wsc.send(Object.assign({action: 'get-config'}, query)));
+            return config;
         } catch (e) {
         } catch (e) {
             console.error(e);
             console.error(e);
         }
         }

+ 2 - 1
server/config/base.js

@@ -21,7 +21,8 @@ module.exports = {
     maxTempPublicDirSize: 512*1024*1024,//512Мб
     maxTempPublicDirSize: 512*1024*1024,//512Мб
     maxUploadPublicDirSize: 200*1024*1024,//100Мб
     maxUploadPublicDirSize: 200*1024*1024,//100Мб
 
 
-    useExternalBookConverter: false,    
+    useExternalBookConverter: false,
+    webConfigParams: ['name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter', 'branch'],
 
 
     db: [
     db: [
         {
         {

+ 5 - 2
server/controllers/MiscController.js

@@ -3,8 +3,11 @@ const _ = require('lodash');
 
 
 class MiscController extends BaseController {
 class MiscController extends BaseController {
     async getConfig(req, res) {
     async getConfig(req, res) {
-        if (Array.isArray(req.body.params))
-            return _.pick(this.config, req.body.params);
+        if (Array.isArray(req.body.params)) {
+            const paramsSet = new Set(req.body.params);
+
+            return _.pick(this.config, this.config.webConfigParams.filter(x => paramsSet.has(x)));
+        }
         //bad request
         //bad request
         res.status(400).send({error: 'params is not an array'});
         res.status(400).send({error: 'params is not an array'});
         return false;
         return false;

+ 3 - 1
server/controllers/WebSocketController.js

@@ -98,7 +98,9 @@ class WebSocketController {
 
 
     async getConfig(req, ws) {
     async getConfig(req, ws) {
         if (Array.isArray(req.params)) {
         if (Array.isArray(req.params)) {
-            this.send(_.pick(this.config, req.params), req, ws);
+            const paramsSet = new Set(req.params);
+
+            this.send(_.pick(this.config, this.config.webConfigParams.filter(x => paramsSet.has(x))), req, ws);
         } else {
         } else {
             throw new Error('params is not an array');
             throw new Error('params is not an array');
         }
         }