cloudcms-server 3.2.325 → 3.2.326

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/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "3.2.325",
9
+ "version": "3.2.326",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
package/server/index.js CHANGED
@@ -889,14 +889,20 @@ var startServer = function(config, startServerFinishedFn)
889
889
  next();
890
890
  });
891
891
  */
892
-
892
+
893
893
  // increment and assign request id
894
894
  app.use(function increment_and_assign_id(req, res, next) {
895
895
  requestCounter++;
896
896
  req.id = requestCounter;
897
897
  next();
898
898
  });
899
-
899
+
900
+ // DEBUG
901
+ app.use(function requestHit1(req, res, next) {
902
+ console.log("[REQ: " + req.id + "] DEBUG 1");
903
+ next();
904
+ });
905
+
900
906
  // APPLY CUSTOM INIT FUNCTIONS
901
907
  runFunctions(config.initFunctions, [app], function (err) {
902
908
 
@@ -989,7 +995,13 @@ var startServer = function(config, startServerFinishedFn)
989
995
 
990
996
  // common interceptors and config
991
997
  main.common1(app);
992
-
998
+
999
+ // DEBUG
1000
+ app.use(function requestHit2(req, res, next) {
1001
+ console.log("[REQ: " + req.id + "] DEBUG 2");
1002
+ next();
1003
+ });
1004
+
993
1005
  // general logging of requests
994
1006
  // gather statistics on response time
995
1007
  app.use(responseTime(function (req, res, time) {
@@ -1038,7 +1050,13 @@ var startServer = function(config, startServerFinishedFn)
1038
1050
 
1039
1051
  // common interceptors and config
1040
1052
  main.common2(app);
1041
-
1053
+
1054
+ // DEBUG
1055
+ app.use(function requestHit3(req, res, next) {
1056
+ console.log("[REQ: " + req.id + "] DEBUG 3");
1057
+ next();
1058
+ });
1059
+
1042
1060
  // APPLY CUSTOM DRIVER FUNCTIONS
1043
1061
  runFunctions(config.driverFunctions, [app], function(err) {
1044
1062
 
@@ -1050,7 +1068,13 @@ var startServer = function(config, startServerFinishedFn)
1050
1068
 
1051
1069
  // cloudcms things need to run here
1052
1070
  main.common4(app, true);
1053
-
1071
+
1072
+ // DEBUG
1073
+ app.use(function requestHit4(req, res, next) {
1074
+ console.log("[REQ: " + req.id + "] DEBUG 4");
1075
+ next();
1076
+ });
1077
+
1054
1078
  // APPLY CUSTOM FILTER FUNCTIONS
1055
1079
  runFunctions(config.filterFunctions, [app], function (err) {
1056
1080
 
@@ -1065,7 +1089,13 @@ var startServer = function(config, startServerFinishedFn)
1065
1089
 
1066
1090
  // DEVELOPMENT BASED PERFORMANCE CACHING
1067
1091
  main.perf3(app);
1068
-
1092
+
1093
+ // DEBUG
1094
+ app.use(function requestHit5(req, res, next) {
1095
+ console.log("[REQ: " + req.id + "] DEBUG 5");
1096
+ next();
1097
+ });
1098
+
1069
1099
  // standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
1070
1100
  // that might be JSON (regardless of content type)
1071
1101
  app.use(function (req, res, next) {
@@ -1087,7 +1117,13 @@ var startServer = function(config, startServerFinishedFn)
1087
1117
  app.use(initializedSession);
1088
1118
  app.use(flash());
1089
1119
  }
1090
-
1120
+
1121
+ // DEBUG
1122
+ app.use(function requestHit6(req, res, next) {
1123
+ console.log("[REQ: " + req.id + "] DEBUG 6");
1124
+ next();
1125
+ });
1126
+
1091
1127
  // this is the same as calling
1092
1128
  // app.use(passport.initialize());
1093
1129
  // except we create a new passport each time and store on request to support multitenancy
@@ -1126,7 +1162,13 @@ var startServer = function(config, startServerFinishedFn)
1126
1162
  req.passport.session()(req, res, next);
1127
1163
  });
1128
1164
  }
1129
-
1165
+
1166
+ // DEBUG
1167
+ app.use(function requestHit7(req, res, next) {
1168
+ console.log("[REQ: " + req.id + "] DEBUG 7");
1169
+ next();
1170
+ });
1171
+
1130
1172
  // welcome files
1131
1173
  main.welcome(app);
1132
1174
 
@@ -1137,13 +1179,31 @@ var startServer = function(config, startServerFinishedFn)
1137
1179
 
1138
1180
  // healthcheck middleware
1139
1181
  main.healthcheck(app);
1140
-
1182
+
1183
+ // DEBUG
1184
+ app.use(function requestHit8(req, res, next) {
1185
+ console.log("[REQ: " + req.id + "] DEBUG 8");
1186
+ next();
1187
+ });
1188
+
1141
1189
  // APPLY CUSTOM ROUTES
1142
1190
  runFunctions(config.routeFunctions, [app], function (err) {
1143
-
1191
+
1192
+ // DEBUG
1193
+ app.use(function requestHit9(req, res, next) {
1194
+ console.log("[REQ: " + req.id + "] DEBUG 9");
1195
+ next();
1196
+ });
1197
+
1144
1198
  // configure cloudcms app server handlers
1145
1199
  main.handlers(app, true);
1146
-
1200
+
1201
+ // DEBUG
1202
+ app.use(function requestHit10(req, res, next) {
1203
+ console.log("[REQ: " + req.id + "] DEBUG 10");
1204
+ next();
1205
+ });
1206
+
1147
1207
  // register error functions
1148
1208
  runFunctions(config.errorFunctions, [app], function (err) {
1149
1209
 
@@ -1161,7 +1221,7 @@ var startServer = function(config, startServerFinishedFn)
1161
1221
  }
1162
1222
  }
1163
1223
  runFunctions(allConfigureFunctions, [app], function (err) {
1164
-
1224
+
1165
1225
  // create the server (either HTTP or HTTPS)
1166
1226
  createHttpServer(app, function(err, httpServer) {
1167
1227
 
package/util/auth.js CHANGED
@@ -5,16 +5,18 @@ var LRUCache = require("lru-cache");
5
5
 
6
6
  var request = require("./request");
7
7
 
8
+ const IsolatedVM = require("isolated-vm");
9
+
8
10
  // trusted profile cache size 100
9
11
  var TRUSTED_PROFILE_CACHE = new LRUCache({
10
12
  max:100,
11
- maxAge: 1000 * 60 * 15 // 15 minutes
13
+ ttl: 1000 * 60 * 15 // 15 minutes
12
14
  });
13
15
 
14
16
  // user entry cache size 100
15
17
  var USER_ENTRY_CACHE = new LRUCache({
16
18
  max: 100,
17
- maxAge: 1000 * 60 * 15 // 15 minutes
19
+ ttl: 1000 * 60 * 15 // 15 minutes
18
20
  });
19
21
 
20
22
  var Gitana = require("gitana");
@@ -652,28 +654,28 @@ var executeRule = function(req, rule, gitanaUser, callback)
652
654
  });
653
655
  };
654
656
 
655
- const {VM} = require("vm2");
656
- var vm = new VM({
657
- timeout: 5000,
658
- sandbox: {
659
- "addToProject": function(projectId, teamIdentifiers) {
660
- return addToProject(projectId, teamIdentifiers, function() {
661
- console.log("Added user: " + gitanaUser._doc + " to project: " + projectId + ", teams: " + JSON.stringify(teamIdentifiers));
662
- });
663
- },
664
- "addToPlatformTeam": function(teamIdentifier) {
665
- return addToPlatformTeams([teamIdentifier], function() {
666
- console.log("Added user: " + gitanaUser._doc + " to platform team: " + teamIdentifier);
667
- });
668
- },
669
- "addToPlatformTeams": function(teamIdentifiers) {
670
- return addToPlatformTeams(teamIdentifiers, function() {
671
- console.log("Added user: " + gitanaUser._doc + " to platform teams: " + JSON.stringify(teamIdentifiers));
672
- });
673
- }
674
- }
657
+ const isolate = new IsolatedVM.Isolate({ memoryLimit: 32 });
658
+ const context = isolate.createContextSync();
659
+ const jail = context.global;
660
+
661
+ // functions
662
+ jail.setSync('addToProject', function(projectId, teamIdentifiers) {
663
+ return addToProject(projectId, teamIdentifiers, function() {
664
+ console.log("Added user: " + gitanaUser._doc + " to project: " + projectId + ", teams: " + JSON.stringify(teamIdentifiers));
665
+ });
666
+ });
667
+ jail.setSync("addToPlatformTeam", function(teamIdentifier) {
668
+ return addToPlatformTeams([teamIdentifier], function() {
669
+ console.log("Added user: " + gitanaUser._doc + " to platform team: " + teamIdentifier);
670
+ });
675
671
  });
676
- vm.run(rule);
672
+ jail.setSync("addToPlatformTeams", function(teamIdentifiers) {
673
+ return addToPlatformTeams(teamIdentifiers, function() {
674
+ console.log("Added user: " + gitanaUser._doc + " to platform teams: " + JSON.stringify(teamIdentifiers));
675
+ });
676
+ });
677
+
678
+ context.evalSync(rule);
677
679
 
678
680
  setTimeout(function() {
679
681
  callback();