Updated security changes for exec command with the exec garden.

This commit is contained in:
Admin
2017-04-04 11:47:04 -05:00
parent a7e516925c
commit 0737c54a0e
4 changed files with 12 additions and 21 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>4.5.0alpha-2</version>
<version>4.5.0alpha-3</version>
<packaging>jar</packaging>
<name>HA Bridge</name>

View File

@@ -983,6 +983,9 @@ public class HueMulator {
else
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
responseString = homeManager.findHome(callItems[i].getType().trim()).deviceHandler(callItems[i], aMultiUtil, lightId, state.getBri(), targetBri, targetBriInc, device, body);
if(responseString != null && responseString.contains("{\"error\":")) {
x = aMultiUtil.getSetCount();
}
}
}
}

View File

@@ -16,7 +16,7 @@ import com.bwssystems.HABridge.hue.TimeDecode;
public class CommandHome implements Home {
private static final Logger log = LoggerFactory.getLogger(CommandHome.class);
private String execGarden;;
private BridgeSettings theSettings;
public CommandHome(BridgeSettings bridgeSettings) {
super();
@@ -25,7 +25,7 @@ public class CommandHome implements Home {
@Override
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int itensity, Integer targetBri, Integer targetBriInc, DeviceDescriptor device, String body) {
log.debug("Exec Request called with url: " + anItem.getItem().getAsString());
log.debug("Exec Request called with url: " + anItem.getItem().getAsString() + " and exec Garden: " + (theSettings.getBridgeSecurity().getExecGarden() == null ? "not given" : theSettings.getBridgeSecurity().getExecGarden()));
String responseString = null;
String intermediate;
if (anItem.getItem().getAsString().contains("exec://"))
@@ -35,8 +35,10 @@ public class CommandHome implements Home {
intermediate = BrightnessDecode.calculateReplaceIntensityValue(intermediate, itensity, targetBri, targetBriInc, false);
intermediate = DeviceDataDecode.replaceDeviceData(intermediate, device);
intermediate = TimeDecode.replaceTimeValue(intermediate);
if(execGarden != null) {
if(System.getProperty("os.name").toLowerCase().indexOf("win") > 0)
String execGarden = theSettings.getBridgeSecurity().getExecGarden();
execGarden = execGarden.trim();
if(execGarden != null && !execGarden.isEmpty()) {
if(System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)
intermediate = execGarden + "\\" + intermediate;
else
intermediate = execGarden + "/" + intermediate;
@@ -57,7 +59,7 @@ public class CommandHome implements Home {
Process p = Runtime.getRuntime().exec(anItem);
log.debug("Process running: " + p.isAlive());
} catch (IOException e) {
log.warn("Could not execute request: " + anItem, e);
log.warn("Could not execute request: " + anItem + " with message: " + e.getMessage());
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId
+ "state\"}}]";
@@ -75,7 +77,7 @@ public class CommandHome implements Home {
@Override
public Home createHome(BridgeSettings bridgeSettings) {
log.info("Command Home for system program execution created.");
this.execGarden = bridgeSettings.getBridgeSecurity().getExecGarden();
this.theSettings = bridgeSettings;
return this;
}

View File

@@ -87,7 +87,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
bridgeService.getTestUser();
bridgeService.getSecurityInfo();
bridgeService.viewMapTypes();
bridgeService.viewConfigs();
$location.path("/");
} else {
event.preventDefault();
@@ -97,11 +96,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
$rootScope.$on('securityReview', function(event, data) {
if(Auth.isLoggedIn()) {
bridgeService.loadBridgeSettings();
bridgeService.getTestUser();
bridgeService.getSecurityInfo();
bridgeService.viewMapTypes();
bridgeService.viewConfigs();
$location.path("/");
} else {
event.preventDefault();
@@ -116,13 +110,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
});
$rootScope.$on('$routeChangeStart', function (event, next) {
if(Auth.isLoggedIn()) {
bridgeService.loadBridgeSettings();
bridgeService.getTestUser();
bridgeService.getSecurityInfo();
bridgeService.viewMapTypes();
bridgeService.viewConfigs();
}
if (!Auth.checkPermissionForView(next)){
event.preventDefault();
$location.path("/login");
@@ -2926,7 +2913,6 @@ app.controller('SomfyController', function ($scope, $location, bridgeService, ng
});
app.controller('EditController', function ($scope, $location, bridgeService) {
bridgeService.viewMapTypes();
$scope.bridge = bridgeService.state;
$scope.device = bridgeService.state.device;
$scope.onDevices = null;