100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Removed UPnP protocol due to XXE vulnerability in Cling library
Christian Bauerc81544fc0edf
diff --git a/LICENSE.txt b/LICENSE.txtindex 79beb18df..3b6c68f04 100644--- a/LICENSE.txt+++ b/LICENSE.txt@@ -58,7 +58,6 @@ org.bouncycastle:bcpkix-jdk15on: BOUNCYCASTLE LICENSEorg.bouncycastle:bcprov-jdk15on: BOUNCYCASTLE LICENSEorg.codehaus.btm:btm: GNU LESSER GENERAL PUBLIC LICENSE, VERSION 3org.codehaus.groovy:*: APACHE LICENSE, VERSION 2.0-org.fourthline.cling:cling-core: GNU LESSER GENERAL PUBLIC LICENSE, VERSION 2.1org.hibernate.common:hibernate-commons-annotations: GNU LESSER GENERAL PUBLIC LICENSE, VERSION 2.1org.hibernate.javax.persistence:hibernate-jpa-2.1-api: ECLIPSE DISTRIBUTION LICENSE, VERSION 1.0org.hibernate:hibernate-core: GNU LESSER GENERAL PUBLIC LICENSE, VERSION 2.1diff --git a/agent/build.gradle b/agent/build.gradleindex 92104fd16..eda82de28 100644--- a/agent/build.gradle+++ b/agent/build.gradle@@ -24,8 +24,6 @@ dependencies {exclude group: "org.slf4j"}- compile "org.fourthline.cling:cling-core:$clingVersion"-compile "net.sf.saxon:Saxon-HE:$saxonHEVersion"}diff --git a/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.javadeleted file mode 100644index 7e30f7ddc..000000000--- a/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java+++ /dev/null@@ -1,236 +0,0 @@-package org.openremote.agent.protocol.upnp;--import org.fourthline.cling.UpnpService;-import org.fourthline.cling.UpnpServiceImpl;-import org.fourthline.cling.model.message.header.STAllHeader;-import org.fourthline.cling.model.meta.Device;-import org.fourthline.cling.registry.DefaultRegistryListener;-import org.fourthline.cling.registry.Registry;-import org.fourthline.cling.registry.RegistryListener;-import org.openremote.agent.protocol.AbstractProtocol;-import org.openremote.container.util.UniqueIdentifierGenerator;-import org.openremote.model.AbstractValueHolder;-import org.openremote.model.asset.Asset;-import org.openremote.model.asset.AssetAttribute;-import org.openremote.model.asset.AssetType;-import org.openremote.model.asset.agent.ConnectionStatus;-import org.openremote.model.attribute.AttributeEvent;-import org.openremote.model.attribute.AttributeRef;-import org.openremote.model.attribute.MetaItem;-import org.openremote.model.attribute.MetaItemDescriptor;-import org.openremote.model.value.Values;--import java.util.*;-import java.util.logging.Logger;--import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;-import static org.openremote.model.asset.AssetMeta.LABEL;-import static org.openremote.model.attribute.AttributeValueType.STRING;--// TODO Experimental--public class UpnpProtocol extends AbstractProtocol {-- private static final Logger LOG = Logger.getLogger(UpnpProtocol.class.getName());-- public static final String PROTOCOL_NAME = PROTOCOL_NAMESPACE + ":upnp";- public static final String PROTOCOL_DISPLAY_NAME = "UPnP";-- /**- * The asset under which all discovered devices are merged.- */- public static final String GROUP_ASSET_ID = PROTOCOL_NAME + ":groupAssetId";-- protected static final String VERSION = "1.0";-- protected Map<AttributeRef, String> protocolConfigsGroupAssetId = new HashMap<>();-- static protected UpnpService INSTANCE = null;-- final protected RegistryListener registryListener = new DefaultRegistryListener() {- @Override- public void deviceAdded(Registry registry, Device device) {- LOG.fine("UPnP device discovered: " + device.getDisplayString());- linkedProtocolConfigurations.values().forEach(linkedProtocolInfo -> {- storeAssets(linkedProtocolInfo.getProtocolConfiguration(), device);- });- }-- @Override- public void deviceRemoved(Registry registry, Device device) {- LOG.fine("UPnP device gone: " + device.getDisplayString());- if (!assetService.deleteAsset(getAssetId(device))) {- LOG.warning("UPnP device gone but can't delete discovered asset: " + device);- }- }-- };-- @Override- public String getProtocolName() {- return PROTOCOL_NAME;- }-- @Override- public String getProtocolDisplayName() {- return PROTOCOL_DISPLAY_NAME;- }-- @Override- public String getVersion() {- return VERSION;- }-- @Override- protected List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors() {- return Collections.emptyList();- }-- @Override- protected List<MetaItemDescriptor> getLinkedAttributeMetaItemDescriptors() {- return super.getLinkedAttributeMetaItemDescriptors();- }-- @Override- protected void doLinkProtocolConfiguration(AssetAttribute protocolConfiguration) {- boolean isEnabled = protocolConfiguration.isEnabled();- if (!isEnabled) {- updateStatus(protocolConfiguration.getReferenceOrThrow(), ConnectionStatus.DISABLED);- return;- }-- protocolConfiguration.getAssetId().ifPresent(agentId -> {-- // The parent is either the configured asset to group all discovered devices or the agent- protocolConfigsGroupAssetId.put(- protocolConfiguration.getReferenceOrThrow(),- protocolConfiguration.getMetaItem(GROUP_ASSET_ID).flatMap(AbstractValueHolder::getValueAsString).orElse(agentId)- );-- Collection<Device> devices = getService().getRegistry().getDevices();- updateStatus(protocolConfiguration.getReferenceOrThrow(), ConnectionStatus.CONNECTED);-- if (devices.size() > 0) {- for (Device device : getService().getRegistry().getDevices()) {- storeAssets(protocolConfiguration, device);- }- }- });- }-- @Override- protected void doUnlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {- protocolConfigsGroupAssetId.remove(protocolConfiguration.getReferenceOrThrow());-- updateStatus(protocolConfiguration.getReferenceOrThrow(), ConnectionStatus.DISABLED);-- if (linkedProtocolConfigurations.size() == 1) {- closeService();- }- }-- @Override- protected void doLinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {--- }-- @Override- protected void doUnlinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {-- }-- @Override- protected void processLinkedAttributeWrite(AttributeEvent event, AssetAttribute protocolConfiguration) {-- }-- protected UpnpService getService() {- if (INSTANCE == null) {- INSTANCE = new UpnpServiceImpl(registryListener);- INSTANCE.getControlPoint().search(new STAllHeader());- }- return INSTANCE;- }-- protected void closeService() {- if (INSTANCE != null) {- INSTANCE.shutdown();- INSTANCE = null;- }- }-- protected void storeAssets(AssetAttribute protocolConfiguration, Device device) {- String parentId = protocolConfigsGroupAssetId.get(protocolConfiguration.getReferenceOrThrow());- LOG.fine("Storing UPnP device as child assets of " + parentId + ": " + device);- Asset asset = createAsset(parentId, device);- asset = assetService.mergeAsset(asset);- }-- protected Asset createAsset(String parentId, Device device) {- Asset asset = new Asset(- device.getDisplayString(),- AssetType.THING- );- asset.setParentId(parentId);- asset.setId(getAssetId(device));-- long currentTime = timerService.getCurrentTimeMillis();- Optional.ofNullable(device.getType().getDisplayString()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("type", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Device Type")))- )- );-- Optional.ofNullable(device.getDetails().getManufacturerDetails().getManufacturer()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("manufacturer", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Manufacturer")))- )- );-- Optional.ofNullable(device.getDetails().getFriendlyName()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("friendlyName", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Friendly Name")))- )- );-- Optional.ofNullable(device.getDetails().getModelDetails().getModelNumber()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("modelNumber", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Model Number")))- )- );-- Optional.ofNullable(device.getDetails().getModelDetails().getModelName()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("modelName", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Model Name")))- )- );-- Optional.ofNullable(device.getDetails().getModelDetails().getModelDescription()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("modelDescription", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Model Description")))- )- );-- Optional.ofNullable(device.getDetails().getSerialNumber()).ifPresent(v ->- asset.addAttributes(- new AssetAttribute("serialNumber", STRING, Values.create(v), currentTime)- .addMeta(new MetaItem(LABEL, Values.create("Serial Number")))- )- );-- return asset;- }-- protected String getAssetId(Device device) {- return UniqueIdentifierGenerator.generateId(- device.getIdentity().getUdn().getIdentifierString()- );- }-}diff --git a/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocolindex da7bf465c..265497bf3 100644--- a/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol+++ b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol@@ -2,7 +2,6 @@ org.openremote.agent.protocol.simulator.SimulatorProtocolorg.openremote.agent.protocol.macro.MacroProtocolorg.openremote.agent.protocol.timer.TimerProtocolorg.openremote.agent.protocol.knx.KNXProtocol-org.openremote.agent.protocol.upnp.UpnpProtocolorg.openremote.agent.protocol.velbus.VelbusSocketProtocolorg.openremote.agent.protocol.velbus.VelbusSerialProtocolorg.openremote.agent.protocol.http.HttpClientProtocol\ No newline at end of filediff --git a/console/android/build.gradle b/console/android/build.gradleindex bd4ebe77f..865f6144f 100644--- a/console/android/build.gradle+++ b/console/android/build.gradle@@ -22,9 +22,6 @@ repositories {maven {url "http://m2repo.openremote.com/content/groups/public/"}- maven {- url "http://4thline.org/m2"- }}apply plugin: "com.android.library"diff --git a/gradle.properties b/gradle.propertiesindex 0dc48126c..e727cd6d4 100644--- a/gradle.properties+++ b/gradle.properties@@ -34,7 +34,6 @@ sunriseSunsetCalculatorVersion = 1.2easyRulesVersion = 3.1.0quartzVersion= 2.2.3calimeroVersion = 2.4-SNAPSHOT-clingVersion = 2.1.1uuidGeneratorVersion = 3.1.3nrjavaserialVersion = 3.13.0saxonHEVersion = 9.8.0-3diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.javaindex 39f070da5..6fe9ed3cc 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java@@ -20,7 +20,6 @@package org.openremote.manager.setup.builtin;import org.openremote.agent.protocol.knx.KNXProtocol;-import org.openremote.agent.protocol.upnp.UpnpProtocol;import org.openremote.agent.protocol.velbus.VelbusSerialProtocol;import org.openremote.container.Container;import org.openremote.manager.setup.AbstractManagerSetup;@@ -49,8 +48,6 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS = "SETUP_IMPORT_DEMO_AGENT_VELBUS";public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT = "SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT";- public static final String SETUP_IMPORT_DEMO_AGENT_UPNP = "SETUP_IMPORT_DEMO_AGENT_UPNP";-public String masterRealmId;final protected boolean knx;@@ -60,8 +57,6 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {final protected boolean velbus;final protected String velbusComPort;- final protected boolean upnp;-public ManagerDemoAgentSetup(Container container) {super(container);@@ -71,8 +66,6 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {this.velbus = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS, false);this.velbusComPort = getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT, "COM3");-- this.upnp = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_UPNP, false);}@Override@@ -111,19 +104,6 @@ public class ManagerDemoAgentSetup extends AbstractManagerSetup {velbusDevices = assetStorageService.merge(velbusDevices);}- if (upnp) {- LOG.info("Enable UPnP demo protocol configuration");- Asset upnpDevices = new Asset("UPnP Devices", THING, agent, masterRealmId);- upnpDevices = assetStorageService.merge(upnpDevices);- agent.addAttributes(- initProtocolConfiguration(new AssetAttribute("upnpConfig"), UpnpProtocol.PROTOCOL_NAME)- .addMeta(- // TODO Protocols should create these grouping assets automatically and import assets underneath for each protocol configuration- new MetaItem(UpnpProtocol.GROUP_ASSET_ID, Values.create(upnpDevices.getId()))- )- );- }-agent = assetStorageService.merge(agent);}}\ No newline at end of filediff --git a/profile/deploy.yml b/profile/deploy.ymlindex 0b4740139..177f96193 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -121,7 +121,6 @@ services:## - KNX IP gateway# - Velbus IP gateway or serial bridge- # - UPnP (asset discovery only)#SETUP_IMPORT_DEMO_AGENT: 'true'SETUP_IMPORT_DEMO_AGENT_KNX: 'false'@@ -129,7 +128,6 @@ services:# SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP: '10.0.0.12'SETUP_IMPORT_DEMO_AGENT_VELBUS: 'false'# SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT: 'COM3'- SETUP_IMPORT_DEMO_AGENT_UPNP: 'false'# TODO: Additional docker settings are necessary to use com ports and multicast from within containers# The public host name of this OpenRemote installation. This name is used in bearer tokensdiff --git a/project.gradle b/project.gradleindex ec55a312a..17980be1d 100644--- a/project.gradle+++ b/project.gradle@@ -28,9 +28,6 @@ repositories {maven {url "http://m2repo.openremote.com/content/groups/public/"}- maven {- url "http://4thline.org/m2"- }}// Eclipse needs help