mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Updated security changes for exec command with the exec garden.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>4.5.0alpha-2</version>
|
<version>4.5.0alpha-3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -983,6 +983,9 @@ public class HueMulator {
|
|||||||
else
|
else
|
||||||
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
|
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
|
||||||
responseString = homeManager.findHome(callItems[i].getType().trim()).deviceHandler(callItems[i], aMultiUtil, lightId, state.getBri(), targetBri, targetBriInc, device, body);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import com.bwssystems.HABridge.hue.TimeDecode;
|
|||||||
|
|
||||||
public class CommandHome implements Home {
|
public class CommandHome implements Home {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommandHome.class);
|
private static final Logger log = LoggerFactory.getLogger(CommandHome.class);
|
||||||
private String execGarden;;
|
private BridgeSettings theSettings;
|
||||||
|
|
||||||
public CommandHome(BridgeSettings bridgeSettings) {
|
public CommandHome(BridgeSettings bridgeSettings) {
|
||||||
super();
|
super();
|
||||||
@@ -25,7 +25,7 @@ public class CommandHome implements Home {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int itensity, Integer targetBri, Integer targetBriInc, DeviceDescriptor device, String body) {
|
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 responseString = null;
|
||||||
String intermediate;
|
String intermediate;
|
||||||
if (anItem.getItem().getAsString().contains("exec://"))
|
if (anItem.getItem().getAsString().contains("exec://"))
|
||||||
@@ -35,8 +35,10 @@ public class CommandHome implements Home {
|
|||||||
intermediate = BrightnessDecode.calculateReplaceIntensityValue(intermediate, itensity, targetBri, targetBriInc, false);
|
intermediate = BrightnessDecode.calculateReplaceIntensityValue(intermediate, itensity, targetBri, targetBriInc, false);
|
||||||
intermediate = DeviceDataDecode.replaceDeviceData(intermediate, device);
|
intermediate = DeviceDataDecode.replaceDeviceData(intermediate, device);
|
||||||
intermediate = TimeDecode.replaceTimeValue(intermediate);
|
intermediate = TimeDecode.replaceTimeValue(intermediate);
|
||||||
if(execGarden != null) {
|
String execGarden = theSettings.getBridgeSecurity().getExecGarden();
|
||||||
if(System.getProperty("os.name").toLowerCase().indexOf("win") > 0)
|
execGarden = execGarden.trim();
|
||||||
|
if(execGarden != null && !execGarden.isEmpty()) {
|
||||||
|
if(System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)
|
||||||
intermediate = execGarden + "\\" + intermediate;
|
intermediate = execGarden + "\\" + intermediate;
|
||||||
else
|
else
|
||||||
intermediate = execGarden + "/" + intermediate;
|
intermediate = execGarden + "/" + intermediate;
|
||||||
@@ -57,7 +59,7 @@ public class CommandHome implements Home {
|
|||||||
Process p = Runtime.getRuntime().exec(anItem);
|
Process p = Runtime.getRuntime().exec(anItem);
|
||||||
log.debug("Process running: " + p.isAlive());
|
log.debug("Process running: " + p.isAlive());
|
||||||
} catch (IOException e) {
|
} 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
|
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
|
||||||
+ "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId
|
+ "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId
|
||||||
+ "state\"}}]";
|
+ "state\"}}]";
|
||||||
@@ -75,7 +77,7 @@ public class CommandHome implements Home {
|
|||||||
@Override
|
@Override
|
||||||
public Home createHome(BridgeSettings bridgeSettings) {
|
public Home createHome(BridgeSettings bridgeSettings) {
|
||||||
log.info("Command Home for system program execution created.");
|
log.info("Command Home for system program execution created.");
|
||||||
this.execGarden = bridgeSettings.getBridgeSecurity().getExecGarden();
|
this.theSettings = bridgeSettings;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
|
|||||||
bridgeService.getTestUser();
|
bridgeService.getTestUser();
|
||||||
bridgeService.getSecurityInfo();
|
bridgeService.getSecurityInfo();
|
||||||
bridgeService.viewMapTypes();
|
bridgeService.viewMapTypes();
|
||||||
bridgeService.viewConfigs();
|
|
||||||
$location.path("/");
|
$location.path("/");
|
||||||
} else {
|
} else {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -97,11 +96,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
|
|||||||
|
|
||||||
$rootScope.$on('securityReview', function(event, data) {
|
$rootScope.$on('securityReview', function(event, data) {
|
||||||
if(Auth.isLoggedIn()) {
|
if(Auth.isLoggedIn()) {
|
||||||
bridgeService.loadBridgeSettings();
|
|
||||||
bridgeService.getTestUser();
|
|
||||||
bridgeService.getSecurityInfo();
|
|
||||||
bridgeService.viewMapTypes();
|
|
||||||
bridgeService.viewConfigs();
|
|
||||||
$location.path("/");
|
$location.path("/");
|
||||||
} else {
|
} else {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -116,13 +110,6 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('$routeChangeStart', function (event, next) {
|
$rootScope.$on('$routeChangeStart', function (event, next) {
|
||||||
if(Auth.isLoggedIn()) {
|
|
||||||
bridgeService.loadBridgeSettings();
|
|
||||||
bridgeService.getTestUser();
|
|
||||||
bridgeService.getSecurityInfo();
|
|
||||||
bridgeService.viewMapTypes();
|
|
||||||
bridgeService.viewConfigs();
|
|
||||||
}
|
|
||||||
if (!Auth.checkPermissionForView(next)){
|
if (!Auth.checkPermissionForView(next)){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$location.path("/login");
|
$location.path("/login");
|
||||||
@@ -2926,7 +2913,6 @@ app.controller('SomfyController', function ($scope, $location, bridgeService, ng
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.controller('EditController', function ($scope, $location, bridgeService) {
|
app.controller('EditController', function ($scope, $location, bridgeService) {
|
||||||
bridgeService.viewMapTypes();
|
|
||||||
$scope.bridge = bridgeService.state;
|
$scope.bridge = bridgeService.state;
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
$scope.onDevices = null;
|
$scope.onDevices = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user