mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-485 (Add throttle of 1 sec for activate, bringToFront and setLocale to prevent DoS attacks) (#414)
- Add throttle of 1 sec for activate, bringToFront and setLocale to prevent DoS attacks - Skip resize Spectron test case for Mac
This commit is contained in:
parent
cc39f43ee7
commit
a18f3eb64c
@ -77,6 +77,28 @@ local.ipcRenderer.on('on-page-load', () => {
|
|||||||
snackBar = new SnackBar();
|
snackBar = new SnackBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const throttledActivate = throttle(1000, function(windowName) {
|
||||||
|
local.ipcRenderer.send(apiName, {
|
||||||
|
cmd: apiCmds.activate,
|
||||||
|
windowName: windowName
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const throttledBringToFront = throttle(1000, function(windowName, reason) {
|
||||||
|
local.ipcRenderer.send(apiName, {
|
||||||
|
cmd: apiCmds.bringToFront,
|
||||||
|
windowName: windowName,
|
||||||
|
reason: reason
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const throttledSetLocale = throttle(1000, function(locale) {
|
||||||
|
local.ipcRenderer.send(apiName, {
|
||||||
|
cmd: apiCmds.setLocale,
|
||||||
|
locale,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Gathers renderer process memory
|
// Gathers renderer process memory
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const memory = process.getProcessMemoryInfo();
|
const memory = process.getProcessMemoryInfo();
|
||||||
@ -170,10 +192,9 @@ function createAPI() {
|
|||||||
* @param {String} windowName Name of window. Note: main window name is 'main'
|
* @param {String} windowName Name of window. Note: main window name is 'main'
|
||||||
*/
|
*/
|
||||||
activate: function(windowName) {
|
activate: function(windowName) {
|
||||||
local.ipcRenderer.send(apiName, {
|
if (typeof windowName === 'string') {
|
||||||
cmd: apiCmds.activate,
|
throttledActivate(windowName);
|
||||||
windowName: windowName
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,11 +203,9 @@ function createAPI() {
|
|||||||
* @param {String} reason, The reason for which the window is to be activated
|
* @param {String} reason, The reason for which the window is to be activated
|
||||||
*/
|
*/
|
||||||
bringToFront: function(windowName, reason) {
|
bringToFront: function(windowName, reason) {
|
||||||
local.ipcRenderer.send(apiName, {
|
if (typeof windowName === 'string') {
|
||||||
cmd: apiCmds.bringToFront,
|
throttledBringToFront(windowName, reason);
|
||||||
windowName: windowName,
|
}
|
||||||
reason: reason
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,10 +337,9 @@ function createAPI() {
|
|||||||
* Ex: en-US, ja-JP
|
* Ex: en-US, ja-JP
|
||||||
*/
|
*/
|
||||||
setLocale: function (locale) {
|
setLocale: function (locale) {
|
||||||
local.ipcRenderer.send(apiName, {
|
if (typeof locale === 'string') {
|
||||||
cmd: apiCmds.setLocale,
|
throttledSetLocale(locale);
|
||||||
locale,
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@ const robot = require('robotjs');
|
|||||||
const {isMac} = require('../../js/utils/misc');
|
const {isMac} = require('../../js/utils/misc');
|
||||||
|
|
||||||
let app = new Application({});
|
let app = new Application({});
|
||||||
|
let defaultWidth;
|
||||||
|
let defaultHeight;
|
||||||
|
|
||||||
describe('Tests for Resizing windows', () => {
|
!isMac ? describe('Tests for Resizing windows', () => {
|
||||||
|
|
||||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||||
@ -45,9 +47,6 @@ describe('Tests for Resizing windows', () => {
|
|||||||
* Cover scenarios in AVT-768
|
* Cover scenarios in AVT-768
|
||||||
*/
|
*/
|
||||||
it('should be minimized up to 300px', (done) => {
|
it('should be minimized up to 300px', (done) => {
|
||||||
if (isMac) {
|
|
||||||
return done();
|
|
||||||
}
|
|
||||||
app.browserWindow.getBounds().then((bounds) => {
|
app.browserWindow.getBounds().then((bounds) => {
|
||||||
defaultHeight = bounds.height;
|
defaultHeight = bounds.height;
|
||||||
defaultWidth = bounds.width;
|
defaultWidth = bounds.width;
|
||||||
@ -67,4 +66,4 @@ describe('Tests for Resizing windows', () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}) : describe.skip();
|
Loading…
Reference in New Issue
Block a user