Fixed content-disposition headers.
Ylian Saint-Hilaire committed
Apr 30, 2019 at 15:40 UTC
8790e4e284b5c7be996451824e7917f3cbaf8f5d
3 files changed
+17
-17
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.3.3-k",
3
+ "version": "0.3.3-m",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
redirserver.js
+1
-1
@@ -58,7 +58,7 @@ module.exports.CreateRedirServer = function (parent, db, args, func) {
58
obj.app.get("/MeshServerRootCert.cer", function (req, res) {
59
// The redirection server starts before certificates are loaded, make sure to handle the case where no certificate is loaded now.
60
if (obj.certificates != null) {
61
- res.set({ "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0", "Content-Type": "application/octet-stream", "Content-Disposition": "attachment; filename=" + obj.certificates.RootName + ".cer" });
61
+ res.set({ "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0", "Content-Type": "application/octet-stream", "Content-Disposition": "attachment; filename=\"" + obj.certificates.RootName + ".cer\"" });
62
var rootcert = obj.certificates.root.cert;
63
var i = rootcert.indexOf("-----BEGIN CERTIFICATE-----\r\n");
64
if (i >= 0) { rootcert = rootcert.substring(i + 29); }
webserver.js
+15
-15
@@ -1475,7 +1475,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1475
// Returns the mesh server root certificate
1476
function handleRootCertRequest(req, res) {
1477
if ((obj.userAllowedIp != null) && (checkIpAddressEx(req, res, obj.userAllowedIp, false) === false)) { return; } // Check server-wide IP filter only.
1478
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=' + certificates.RootName + '.cer' });
1478
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="' + certificates.RootName + '.cer"' });
1479
res.send(Buffer.from(getRootCertBase64(), 'base64'));
1480
}
1481
@@ -1554,14 +1554,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1554
if (req.query.type == 1) {
1555
obj.getCiraConfigurationScript(req.query.meshid, function (script) {
1556
if (script == null) { res.sendStatus(404); } else {
1557
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=cira_setup.mescript' });
1557
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="cira_setup.mescript"' });
1558
res.send(script);
1559
}
1560
});
1561
} else if (req.query.type == 2) {
1562
obj.getCiraCleanupScript(function (script) {
1563
if (script == null) { res.sendStatus(404); } else {
1564
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=cira_cleanup.mescript' });
1564
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="cira_cleanup.mescript"' });
1565
res.send(script);
1566
}
1567
});
@@ -2238,7 +2238,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2238
var argentInfo = obj.parent.meshAgentBinaries[req.query.id];
2239
if (argentInfo == null) { res.sendStatus(404); return; }
2240
if ((req.query.meshid == null) || (argentInfo.platform != 'win32')) {
2241
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=' + argentInfo.rname });
2241
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="' + argentInfo.rname + '"' });
2242
res.sendFile(argentInfo.path);
2243
} else {
2244
// We are going to embed the .msh file into the Windows executable (signed or not).
@@ -2269,14 +2269,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2269
if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + "\r\n"; } }
2270
if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + "\r\n"; } }
2271
2272
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=' + argentInfo.rname });
2272
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="' + argentInfo.rname + '"' });
2273
obj.parent.exeHandler.streamExeWithMeshPolicy({ platform: 'win32', sourceFileName: obj.parent.meshAgentBinaries[req.query.id].path, destinationStream: res, msh: meshsettings, peinfo: obj.parent.meshAgentBinaries[req.query.id].pe });
2274
}
2275
} else if (req.query.script != null) {
2276
// Send a specific mesh install script back
2277
var scriptInfo = obj.parent.meshAgentInstallScripts[req.query.script];
2278
if (scriptInfo == null) { res.sendStatus(404); return; }
2279
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename=' + scriptInfo.rname });
2279
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename="' + scriptInfo.rname + '"' });
2280
res.send(scriptInfo.data.split('{{{noproxy}}}').join((domain.agentnoproxy === true)?'--no-proxy ':''));
2281
} else if (req.query.meshcmd != null) {
2282
// Send meshcmd for a specific platform back
@@ -2285,17 +2285,17 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2285
if ((agentid == 3)) { // Signed Windows MeshCmd.exe x86
2286
var stats = null, meshCmdPath = obj.path.join(__dirname, 'agents', 'MeshCmd-signed.exe');
2287
try { stats = obj.fs.statSync(meshCmdPath); } catch (e) { }
2288
- if ((stats != null)) { res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshcmd' + ((req.query.meshcmd <= 3) ? '.exe' : '') }); res.sendFile(meshCmdPath); return; }
2288
+ if ((stats != null)) { res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="meshcmd' + ((req.query.meshcmd <= 3) ? '.exe' : '') + '"' }); res.sendFile(meshCmdPath); return; }
2289
} else if ((agentid == 4)) { // Signed Windows MeshCmd64.exe x64
2290
var stats = null, meshCmd64Path = obj.path.join(__dirname, 'agents', 'MeshCmd64-signed.exe');
2291
try { stats = obj.fs.statSync(meshCmd64Path); } catch (e) { }
2292
- if ((stats != null)) { res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshcmd' + ((req.query.meshcmd <= 4) ? '.exe' : '') }); res.sendFile(meshCmd64Path); return; }
2292
+ if ((stats != null)) { res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="meshcmd' + ((req.query.meshcmd <= 4) ? '.exe' : '') + '"' }); res.sendFile(meshCmd64Path); return; }
2293
}
2294
// No signed agents, we are going to merge a new MeshCmd.
2295
if ((agentid < 10000) && (obj.parent.meshAgentBinaries[agentid + 10000] != null)) { agentid += 10000; } // Avoid merging javascript to a signed mesh agent.
2296
var argentInfo = obj.parent.meshAgentBinaries[agentid];
2297
if ((argentInfo == null) || (obj.parent.defaultMeshCmd == null)) { res.sendStatus(404); return; }
2298
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshcmd' + ((req.query.meshcmd <= 4) ? '.exe' : '') });
2298
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="meshcmd' + ((req.query.meshcmd <= 4) ? '.exe' : '') + '"' });
2299
res.statusCode = 200;
2300
if (argentInfo.signedMeshCmdPath != null) {
2301
// If we hav a pre-signed MeshCmd, send that.
@@ -2329,7 +2329,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2329
if (user != null) { meshaction.username = user.name; }
2330
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
2331
if (obj.args.lanonly != true) { meshaction.serverUrl = ((obj.args.notls == true) ? 'ws://' : 'wss://') + obj.getWebServerName(domain) + ':' + httpsPort + '/' + ((domain.id == '') ? '' : ('/' + domain.id)) + 'meshrelay.ashx'; }
2332
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename=meshaction.txt' });
2332
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename="meshaction.txt"' });
2333
res.send(JSON.stringify(meshaction, null, ' '));
2334
});
2335
}
@@ -2344,12 +2344,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2344
if (user != null) { meshaction.username = user.name; }
2345
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
2346
if (obj.args.lanonly != true) { meshaction.serverUrl = ((obj.args.notls == true) ? 'ws://' : 'wss://') + obj.getWebServerName(domain) + ':' + httpsPort + '/' + ((domain.id == '') ? '' : ('/' + domain.id)) + 'meshrelay.ashx'; }
2347
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename=meshaction.txt' });
2347
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename="meshaction.txt"' });
2348
res.send(JSON.stringify(meshaction, null, ' '));
2349
} else if (req.query.meshaction == 'winrouter') {
2350
var p = obj.path.join(__dirname, 'agents', 'MeshCentralRouter.exe');
2351
if (obj.fs.existsSync(p)) {
2352
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename=MeshCentralRouter.exe' });
2352
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename="MeshCentralRouter.exe"' });
2353
try { res.sendFile(p); } catch (e) { res.sendStatus(404); }
2354
} else { res.sendStatus(404); }
2355
} else {
@@ -2420,7 +2420,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2420
// Setup the response output
2421
var archive = require('archiver')('zip', { level: 5 }); // Sets the compression method.
2422
archive.on('error', function (err) { throw err; });
2423
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename=MeshAgent-' + mesh.name + '.zip' });
2423
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename="MeshAgent-' + mesh.name + '.zip"' });
2424
archive.pipe(res);
2425
2426
// Opens the "MeshAgentOSXPackager.zip"
@@ -2501,7 +2501,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2501
if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + "\r\n"; } }
2502
if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + "\r\n"; } }
2503
2504
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshagent.msh' });
2504
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="meshagent.msh"' });
2505
res.send(meshsettings);
2506
};
2507
@@ -2526,7 +2526,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2526
if (rights == 0) { res.sendStatus(401); return; }
2527
2528
// Get the list of power events and send them
2529
- res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename=powerevents.csv' });
2529
+ res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename="powerevents.csv"' });
2530
obj.db.getPowerTimeline(node._id, function (err, docs) {
2531
var xevents = [ 'Time, State, Previous State' ], prevState = 0;
2532
for (var i in docs) {