Skip to content

Commit 630e852

Browse files
peuterkaikreuzer
authored andcommitted
[cometvisu] Security fixes & cleanup for cometvisu backend (#2671)
add required authentication for some rest endpoints, add some sanity checks to improve security. Remove code that has been marked as deprecated. --------- Signed-off-by: Tobias Bräutigam <[email protected]>
1 parent 091d0ed commit 630e852

24 files changed

+104
-1318
lines changed

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/ManagerSettings.java

+11-9
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,18 @@ private void refreshMounts() {
109109
for (final String target : Config.mountPoints.keySet()) {
110110
if (!target.contains("..") && !"demo".equalsIgnoreCase(target)) {
111111
String value = (String) Config.mountPoints.get(target);
112-
String[] parts = value.split(":");
113-
String source = parts[0];
114-
if (!source.contains("..") || (allowLookup && lookupMount.matcher(source).find())) {
115-
boolean writeable = parts.length > 1 && parts[1].contains("w");
116-
boolean showSubDirs = parts.length > 1 && parts[1].contains("s");
117-
if (source.startsWith(File.separator)) {
118-
source = source.substring(1);
112+
if (value != null) {
113+
String[] parts = value.split(":");
114+
String source = parts[0];
115+
if (!source.contains("..") || (allowLookup && lookupMount.matcher(source).find())) {
116+
boolean writeable = parts.length > 1 && parts[1].contains("w");
117+
boolean showSubDirs = parts.length > 1 && parts[1].contains("s");
118+
if (source.startsWith(File.separator)) {
119+
source = source.substring(1);
120+
}
121+
MountPoint mount = new MountPoint(Paths.get(target), Paths.get(source), showSubDirs, writeable);
122+
mounts.add(mount);
119123
}
120-
MountPoint mount = new MountPoint(Paths.get(target), Paths.get(source), showSubDirs, writeable);
121-
mounts.add(mount);
122124
}
123125
}
124126
}

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/StateBeanMessageBodyWriter.java

-89
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/ConfigBean.java

-27
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/LoginBean.java

-26
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/ResourcesBean.java

-27
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/StateBean.java

-25
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/SuccessBean.java

-24
This file was deleted.

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/model/rest/RestBackendEnvironmentState.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package org.openhab.ui.cometvisu.internal.backend.model.rest;
1414

15+
import org.eclipse.jdt.annotation.NonNullByDefault;
1516
import org.openhab.core.OpenHAB;
1617

1718
/**
@@ -21,16 +22,18 @@
2122
* @author Tobias Bräutigam - Initial contribution
2223
*
2324
*/
25+
@NonNullByDefault
2426
public class RestBackendEnvironmentState {
2527
// as we are just simulating we use a fixed version here to tell that we are compatible
2628
public int PHP_VERSION_ID = 80100;
2729
public String phpversion = "8.1.0";
2830

29-
public String SERVER_SIGNATURE;
30-
public String SERVER_SOFTWARE;
31+
public String SERVER_SIGNATURE = "";
32+
public String SERVER_SOFTWARE = "";
3133
public String required_php_version = ">=7.4";
3234

3335
// openHAB specific values
3436
public boolean isOpenHab = true;
37+
public boolean requiresAuth = true;
3538
public String server_release = "openHAB " + OpenHAB.getVersion();
3639
}

0 commit comments

Comments
 (0)