Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2f7a07

Browse files
AlexanderYeremeyevAlexanderYeremeyev
authored andcommitted
SOAPUIOS-497 add-option-to-disable-project-save-and-load-scrypts
1 parent b72009f commit a2f7a07

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

RELEASENOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
* SoapUI 5.5.0 will not run project or suites - Toolkit not initialized error
2222

23+
* Add setting to enable/disable load script/save script execution.
24+
2325
-------------------------------------------------------------------------------
2426

2527
# SoapUI Open Source 5.5.0

soapui/src/main/java/com/eviware/soapui/DefaultSoapUICore.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
* SoapUI, Copyright (C) 2004-2019 SmartBear Software
33
*
4-
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
5-
* versions of the EUPL (the "Licence");
6-
* You may not use this work except in compliance with the Licence.
7-
* You may obtain a copy of the Licence at:
8-
*
9-
* http://ec.europa.eu/idabc/eupl
10-
*
11-
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
12-
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13-
* express or implied. See the Licence for the specific language governing permissions and limitations
14-
* under the Licence.
4+
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
5+
* versions of the EUPL (the "Licence");
6+
* You may not use this work except in compliance with the Licence.
7+
* You may obtain a copy of the Licence at:
8+
*
9+
* http://ec.europa.eu/idabc/eupl
10+
*
11+
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
12+
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
* express or implied. See the Licence for the specific language governing permissions and limitations
14+
* under the Licence.
1515
*/
1616

1717
package com.eviware.soapui;
@@ -279,7 +279,7 @@ protected Settings initSettings(String fileName) {
279279
} catch (Exception e) {
280280
log.warn("Wrong password.");
281281
JOptionPane.showMessageDialog(null, "Wrong password, creating backup settings file [ "
282-
+ settingsFile.getAbsolutePath() + ".bak.xml. ]\nSwitch to default settings.",
282+
+ settingsFile.getAbsolutePath() + ".bak.xml. ]\nSwitch to default settings.",
283283
"Error - Wrong Password", JOptionPane.ERROR_MESSAGE);
284284
settingsDocument.save(new File(settingsFile.getAbsolutePath() + ".bak.xml"));
285285
throw e;
@@ -355,6 +355,7 @@ protected Settings initSettings(String fileName) {
355355
settings.setBoolean(ProxySettings.AUTO_PROXY, true);
356356
settings.setBoolean(ProxySettings.ENABLE_PROXY, true);
357357
}
358+
setIfNotSet(SecuritySettings.DISABLE_PROJECT_LOAD_SAVE_SCRIPTS, true);
358359

359360
boolean setWsiDir = false;
360361
String wsiLocationString = settings.getString(WSISettings.WSI_LOCATION, null);

soapui/src/main/java/com/eviware/soapui/impl/wsdl/WsdlProject.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import com.eviware.soapui.model.testsuite.TestSuite;
7777
import com.eviware.soapui.model.testsuite.TestSuite.TestSuiteRunType;
7878
import com.eviware.soapui.settings.ProjectSettings;
79+
import com.eviware.soapui.settings.SecuritySettings;
7980
import com.eviware.soapui.settings.UISettings;
8081
import com.eviware.soapui.settings.WsdlSettings;
8182
import com.eviware.soapui.support.SoapUIException;
@@ -131,6 +132,11 @@
131132

132133
public class WsdlProject extends AbstractTestPropertyHolderWsdlModelItem<ProjectConfig> implements Project,
133134
PropertyExpansionContainer, PropertyChangeListener, TestRunnable {
135+
/*???*/ // %s - the project name
136+
private final static String LOAD_SCRYPT_EXECUTION_WARNING_MESSAGE = "In project '%s' we have detected Load script that may contain malicious code, if you do not want to receive this message please change the setting in preferences.";
137+
/*???*/ // %s - the project name
138+
private final static String SAVE_SCRYPT_EXECUTION_WARNING_MESSAGE = "In project '%s' we have detected Save script that may contain malicious code, if you do not want to receive this message please change the setting in preferences.";
139+
134140
public final static String AFTER_LOAD_SCRIPT_PROPERTY = WsdlProject.class.getName() + "@setupScript";
135141
public final static String BEFORE_SAVE_SCRIPT_PROPERTY = WsdlProject.class.getName() + "@tearDownScript";
136142
public final static String RESOURCE_ROOT_PROPERTY = WsdlProject.class.getName() + "@resourceRoot";
@@ -1503,6 +1509,11 @@ public Object runAfterLoadScript() throws Exception {
15031509
return null;
15041510
}
15051511

1512+
if (isLoadSaveScriptsDisabled()) {
1513+
log.warn(String.format(LOAD_SCRYPT_EXECUTION_WARNING_MESSAGE, getName()));
1514+
return null;
1515+
}
1516+
15061517
if (afterLoadScriptEngine == null) {
15071518
afterLoadScriptEngine = SoapUIScriptEngineRegistry.create(this);
15081519
afterLoadScriptEngine.setScript(script);
@@ -1520,6 +1531,11 @@ public Object runBeforeSaveScript() throws Exception {
15201531
return null;
15211532
}
15221533

1534+
if (isLoadSaveScriptsDisabled()) {
1535+
log.warn(String.format(SAVE_SCRYPT_EXECUTION_WARNING_MESSAGE, getName()));
1536+
return null;
1537+
}
1538+
15231539
if (beforeSaveScriptEngine == null) {
15241540
beforeSaveScriptEngine = SoapUIScriptEngineRegistry.create(this);
15251541
beforeSaveScriptEngine.setScript(script);
@@ -2037,4 +2053,8 @@ public boolean isFromReadyApi() {
20372053
}
20382054
return false;
20392055
}
2056+
2057+
private boolean isLoadSaveScriptsDisabled() {
2058+
return SoapUI.getSoapUICore().getSettings().getBoolean(SecuritySettings.DISABLE_PROJECT_LOAD_SAVE_SCRIPTS);
2059+
}
20402060
}

soapui/src/main/java/com/eviware/soapui/settings/SecuritySettings.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
public interface SecuritySettings {
2222

2323
@Setting(name = "Password", description = "password for shadowing proxy password in settings file", type = SettingType.PASSWORD)
24-
public final static String SHADOW_PASSWORD = SecuritySettings.class.getSimpleName() + "@" + "shadowProxyPassword";
24+
String SHADOW_PASSWORD = SecuritySettings.class.getSimpleName() + "@" + "shadowProxyPassword";
25+
26+
@Setting(name = "Disable the Load and Save scripts", description = "Do not run the Load and Save scripts on opening and saving projects", type = SettingType.BOOLEAN)
27+
String DISABLE_PROJECT_LOAD_SAVE_SCRIPTS = SecuritySettings.class.getSimpleName() + "@disable_project_load_save_scripts";
2528
}

0 commit comments

Comments
 (0)