diff --git a/Jenkinsfile b/Jenkinsfile index 4361987c36a..7e7e31da477 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,15 @@ node { - properties([disableConcurrentBuilds(abortPrevious: true), buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), gitLabConnection('gitlab.eclipse.org'), [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], [$class: 'JobLocalConfiguration', changeReasonComment: '']]) + properties([ + disableConcurrentBuilds(abortPrevious: true), + buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), + gitLabConnection('gitlab.eclipse.org'), + [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], + [$class: 'JobLocalConfiguration', changeReasonComment: ''] + ]) deleteDir() - stage('Preparation') { + stage('Preparation') { dir("kura") { checkout scm } @@ -14,7 +20,7 @@ node { dir("kura") { withMaven(jdk: 'adoptopenjdk-hotspot-jdk8-latest', maven: 'apache-maven-3.6.3') { sh "touch /tmp/isJenkins.txt" - sh "mvn -f target-platform/pom.xml clean install -Pno-mirror -Pcheck-exists-plugin" + sh "mvn -f target-platform/pom.xml clean install -Pno-mirror -Pcheck-exists-plugin" sh "mvn -f kura/pom.xml clean install -Pcheck-exists-plugin" sh "mvn -f kura/distrib/pom.xml clean install -DbuildAll" sh "mvn -f kura/examples/pom.xml clean install -Pcheck-exists-plugin" @@ -41,17 +47,20 @@ node { withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.6.3') { withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) { withSonarQubeEnv { - sh '''mvn -f kura/pom.xml sonar:sonar \ - -Dmaven.test.failure.ignore=true \ - -Dsonar.organization=eclipse \ - -Dsonar.host.url=${SONAR_HOST_URL} \ - -Dsonar.login=${SONARCLOUD_TOKEN} \ - -Dsonar.branch.name=${BRANCH_NAME} \ - -Dsonar.branch.target=${CHANGE_TARGET} \ - -Dsonar.java.binaries='target/' \ - -Dsonar.core.codeCoveragePlugin=jacoco \ - -Dsonar.projectKey=org.eclipse.kura:kura \ - -Dsonar.exclusions=test/**/*.java,test-util/**/*.java,org.eclipse.kura.web2/**/*.java,org.eclipse.kura.nm/src/main/java/org/freedesktop/**/*,org.eclipse.kura.nm/src/main/java/fi/w1/**/*''' + sh ''' + mvn -f kura/pom.xml sonar:sonar \ + -Dmaven.test.failure.ignore=true \ + -Dsonar.organization=eclipse \ + -Dsonar.host.url=${SONAR_HOST_URL} \ + -Dsonar.login=${SONARCLOUD_TOKEN} \ + -Dsonar.branch.name=${BRANCH_NAME} \ + -Dsonar.branch.target=${CHANGE_TARGET} \ + -Dsonar.java.source=8 \ + -Dsonar.java.binaries='target/' \ + -Dsonar.core.codeCoveragePlugin=jacoco \ + -Dsonar.projectKey=org.eclipse.kura:kura \ + -Dsonar.exclusions=test/**/*.java,test-util/**/*.java,org.eclipse.kura.web2/**/*.java,org.eclipse.kura.nm/src/main/java/org/freedesktop/**/*,org.eclipse.kura.nm/src/main/java/fi/w1/**/* + ''' } } } diff --git a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml index 0908a0cee2b..580361383f4 100644 --- a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.dbus.test/pom.xml @@ -28,6 +28,7 @@ ${project.basedir}/../../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml diff --git a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml index b08c05ce32a..dda673a6f6f 100644 --- a/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.ble.tisensortag.test/pom.xml @@ -28,6 +28,7 @@ ${project.basedir}/../../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml diff --git a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml index 5d0d16e9ef0..2af604726e8 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml @@ -24,6 +24,7 @@ ${project.basedir}/../../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml index 3805e00d88b..5a8f89bdaa9 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml @@ -28,6 +28,7 @@ ${project.basedir}/../../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml index 681c82f2c9b..52819964da0 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml @@ -28,6 +28,7 @@ ${project.basedir}/../../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml diff --git a/kura/examples/test/pom.xml b/kura/examples/test/pom.xml index 50ee93e7609..8c8cc69d97c 100644 --- a/kura/examples/test/pom.xml +++ b/kura/examples/test/pom.xml @@ -273,9 +273,6 @@ ${project.basedir}/../.. ${jacocoArgs} -Dlog4j.configurationFile=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/log4j.xml - target/jacoco/ - - ${project.basedir}/../../test/*/target/site/jacoco-aggregate/jacoco.xml diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java index e0c3317cef2..3e300ac1dad 100644 --- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java +++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceImpl.java @@ -712,9 +712,7 @@ private boolean isValidMessage(KuraApplicationTopic kuraTopic, KuraPayload kuraP public void onMessagePublished(int messageId, String topic) { synchronized (this.messageId) { if (this.messageId.get() != -1 && this.messageId.get() == messageId) { - if (CloudServiceOptions.getLifeCycleMessageQos() == 0) { - this.messageId.set(-1); - } + this.messageId.set(-1); this.messageId.notifyAll(); return; } @@ -885,7 +883,7 @@ private void publishLifeCycleMessage(LifecycleMessage message) throws KuraExcept payload.setTimestamp(new Date()); byte[] encodedPayload = encodePayload(payload); int id = this.dataService.publish(message.getTopic(), encodedPayload, - CloudServiceOptions.getLifeCycleMessageQos(), CloudServiceOptions.getLifeCycleMessageRetain(), + message.getQos(), CloudServiceOptions.getLifeCycleMessageRetain(), CloudServiceOptions.getLifeCycleMessagePriority()); this.messageId.set(id); try { diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java index 95f9626e4e9..9bc4716f8b3 100644 --- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java +++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/CloudServiceOptions.java @@ -42,7 +42,6 @@ public class CloudServiceOptions { private static final String ENABLE_DFLT_SUBSCRIPTIONS = "enable.default.subscriptions"; private static final String PAYLOAD_ENCODING = "payload.encoding"; - private static final int LIFECYCLE_QOS = 0; private static final int LIFECYCLE_PRIORITY = 0; private static final boolean LIFECYCLE_RETAIN = false; @@ -217,10 +216,6 @@ public static String getTopicWildCard() { return TOPIC_WILD_CARD; } - public static int getLifeCycleMessageQos() { - return LIFECYCLE_QOS; - } - public static int getLifeCycleMessagePriority() { return LIFECYCLE_PRIORITY; } diff --git a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java index 40e9d04f3e6..7a97df4ea9f 100644 --- a/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java +++ b/kura/org.eclipse.kura.core.cloud/src/main/java/org/eclipse/kura/core/cloud/LifecycleMessage.java @@ -21,6 +21,7 @@ public class LifecycleMessage { private KuraPayload payload; private boolean isAppCertificateMessage = false; private boolean isBirthCertificateMessage = false; + private int qos = 0; public LifecycleMessage(CloudServiceOptions options, CloudServiceImpl cloudServiceImpl) { this.topicBuilder = new StringBuilder(options.getTopicControlPrefix()); @@ -37,6 +38,7 @@ public LifecycleMessage asBirthCertificateMessage() { this.topicBuilder.append(CloudServiceOptions.getTopicBirthSuffix()); this.payload = this.payloadBuilder.buildBirthPayload(); this.isBirthCertificateMessage = true; + this.qos = 1; return this; } @@ -44,6 +46,7 @@ public LifecycleMessage asAppCertificateMessage() { this.topicBuilder.append(CloudServiceOptions.getTopicAppsSuffix()); this.payload = this.payloadBuilder.buildBirthPayload(); this.isAppCertificateMessage = true; + this.qos = 1; return this; } @@ -68,5 +71,9 @@ public boolean isAppCertificateMessage() { public boolean isBirthCertificateMessage() { return this.isBirthCertificateMessage; } + + public int getQos() { + return this.qos; + } } diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java index f1b254a6f7d..043d264f108 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java @@ -342,7 +342,7 @@ private void findAndDecodeCertificatesForInterface(String interfaceName, Map keyCertStrings = Arrays.asList(clientCertString, caCertString, privateKeyString); @@ -367,7 +367,7 @@ private void findAndDecodeCertificatesForInterface(String interfaceName, Map getProperties() { return this.properties; } + public ComponentConfigurationDTO replacePasswordsWithPlaceholder() { + + if (properties == null) { + return this; + } + + final Map result = new HashMap<>(this.properties); + + for (final Entry e : result.entrySet()) { + e.setValue(replacePasswordsWithPlaceholder(e.getValue())); + } + + return new ComponentConfigurationDTO(pid, definition, result); + } + + public PropertyDTO replacePasswordsWithPlaceholder(final PropertyDTO property) { + + if (property == null || property.getType() != Scalar.PASSWORD) { + return property; + } + + if (property.getValue() instanceof String[]) { + final String[] asStringArray = (String[]) property.getValue(); + final String[] result = new String[asStringArray.length]; + + for (int i = 0; i < asStringArray.length; i++) { + if (asStringArray[i] != null) { + result[i] = "placeholder"; + } + } + + return new PropertyDTO(result, Scalar.PASSWORD); + } else { + return new PropertyDTO("placeholder", Scalar.PASSWORD); + } + } + @Override public void validate() { FailureHandler.requireParameter(this.pid, "pid"); diff --git a/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java b/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java index bc92aed3e39..c20b40f715f 100644 --- a/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java +++ b/kura/org.eclipse.kura.rest.configuration.provider/src/main/java/org/eclipse/kura/rest/configuration/api/ComponentConfigurationList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others + * Copyright (c) 2021, 2023 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -13,6 +13,7 @@ package org.eclipse.kura.rest.configuration.api; import java.util.List; +import java.util.stream.Collectors; public class ComponentConfigurationList implements Validable { @@ -30,4 +31,14 @@ public List getConfigs() { public void validate() { FailureHandler.requireParameter(this.configs, "configs"); } + + public ComponentConfigurationList replacePasswordsWithPlaceholder() { + if (configs == null) { + return this; + } + + return new ComponentConfigurationList( + configs.stream().map(ComponentConfigurationDTO::replacePasswordsWithPlaceholder) + .collect(Collectors.toList())); + } } diff --git a/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF index 9828d8607b5..1c459eacd09 100644 --- a/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.rest.wire.provider/META-INF/MANIFEST.MF @@ -24,7 +24,7 @@ Import-Package: com.google.gson;version="2.7.0", org.eclipse.kura.internal.wire.asset;version="[1.0,2.0)", org.eclipse.kura.marshalling;version="[1.0,2.0)", org.eclipse.kura.request.handler.jaxrs;version="[1.0,2.0)", - org.eclipse.kura.rest.configuration.api;version="[1.0,2.0)", + org.eclipse.kura.rest.configuration.api;version="[1.1,2.0)", org.eclipse.kura.util.service;version="[1.0,2.0)", org.eclipse.kura.wire;version="[2.0,3.0)", org.eclipse.kura.wire.graph;version="[1.0,2.0)", diff --git a/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java b/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java index bcb127ad286..674d883a00e 100644 --- a/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java +++ b/kura/org.eclipse.kura.rest.wire.provider/src/main/java/org/eclipse/kura/internal/rest/wire/WireRestService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Eurotech and/or its affiliates and others + * Copyright (c) 2023 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -362,7 +362,7 @@ public ComponentConfigurationList getWireConfigsByPid(final PidSet pidSet) { } } - return DTOUtil.toComponentConfigurationList(result, cryptoService, true); + return DTOUtil.toComponentConfigurationList(result, cryptoService, false).replacePasswordsWithPlaceholder(); } catch (final Exception e) { throw DefaultExceptionHandler.toWebApplicationException(e); diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java index b7ca7a9f8e3..e175415585d 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java @@ -145,12 +145,16 @@ interface AssetConfigurationUiBinder extends UiBinder