Browse Source

Merge branch 'lts-4.4' into fix/coap-integration-certificate-reload

pull/16258/head
Viacheslav Klimov 2 months ago
committed by GitHub
parent
commit
8f287d8dee
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      application/src/main/java/org/thingsboard/server/config/ThingsboardSecurityConfiguration.java
  2. 29
      application/src/main/java/org/thingsboard/server/controller/EdgeController.java
  3. 20
      application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java
  4. 35
      application/src/main/java/org/thingsboard/server/service/edge/DefaultEdgeLicenseService.java
  5. 4
      application/src/main/java/org/thingsboard/server/service/edge/EdgeLicenseService.java
  6. 19
      application/src/main/java/org/thingsboard/server/service/report/LocalReportDataService.java
  7. 5
      application/src/main/java/org/thingsboard/server/service/security/AccessValidator.java
  8. 10
      application/src/main/java/org/thingsboard/server/service/telemetry/DefaultTbTelemetryService.java
  9. 76
      application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java
  10. 6
      application/src/test/java/org/thingsboard/server/client/TbResourceApiClientTest.java
  11. 42
      application/src/test/java/org/thingsboard/server/controller/TelemetryControllerTest.java
  12. 42
      application/src/test/java/org/thingsboard/server/controller/TwoFactorAuthTest.java
  13. 12
      application/src/test/java/org/thingsboard/server/controller/WebSocketApiTest.java
  14. 4
      common/dao-api/pom.xml
  15. 4
      common/data/pom.xml
  16. 8
      common/report/src/main/java/org/thingsboard/server/report/datasource/RemoteReportDataService.java
  17. 4
      common/version-control/pom.xml
  18. 4
      dao/pom.xml
  19. 12
      pom.xml
  20. 4
      rule-engine/rule-engine-components/pom.xml
  21. 18
      tools/src/main/python/license-headers/curations.json
  22. 40
      ui-ngx/src/app/shared/models/converter.models.ts
  23. 37
      ui-ngx/src/assets/converters/js-chirpstack-encoder.raw
  24. 7
      ui-ngx/src/assets/converters/js-loriot-decoder.raw
  25. 37
      ui-ngx/src/assets/converters/js-loriot-encoder.raw
  26. 20
      ui-ngx/src/assets/converters/js-mqtt-encoder.raw
  27. 49
      ui-ngx/src/assets/converters/js-ttn-tti-encoder.raw
  28. 37
      ui-ngx/src/assets/converters/tbel-chirpstack-encoder.raw
  29. 7
      ui-ngx/src/assets/converters/tbel-loriot-decoder.raw
  30. 37
      ui-ngx/src/assets/converters/tbel-loriot-encoder.raw
  31. 20
      ui-ngx/src/assets/converters/tbel-mqtt-encoder.raw
  32. 49
      ui-ngx/src/assets/converters/tbel-ttn-tti-encoder.raw

2
application/src/main/java/org/thingsboard/server/config/ThingsboardSecurityConfiguration.java

@ -134,7 +134,7 @@ public class ThingsboardSecurityConfiguration {
/** Session bootstrap, exempt for GET only: {@code POST} on the same path creates a custom menu. */
public static final String CUSTOM_MENU_ENTRY_POINT = "/api/customMenu";
public static final String ALLOWED_PERMISSIONS_ENTRY_POINT = "/api/permissions/allowedPermissions";
protected static final String[] NON_TOKEN_BASED_AUTH_ENTRY_POINTS = new String[]{"/index.html", "/assets/**", "/static/**", "/api/noauth/**", "/webjars/**", "/api/license/**", "/api/images/public/**", "/api/v2/report/public/**", "/.well-known/**"};
protected static final String[] NON_TOKEN_BASED_AUTH_ENTRY_POINTS = new String[]{"/index.html", "/assets/**", "/static/**", "/api/noauth/**", "/webjars/**", "/api/license/**", "/api/v2/license/**", "/api/images/public/**", "/api/v2/report/public/**", "/.well-known/**"};
/**
* API entry points that stay reachable while the setup is incomplete, or while a provisioned instance is
* locked again at runtime. Only {@link #SETUP_PROTECTED_ENTRY_POINTS} is locked, so the Angular

29
application/src/main/java/org/thingsboard/server/controller/EdgeController.java

@ -671,6 +671,35 @@ public class EdgeController extends BaseController {
}
}
@ApiOperation(value = "Check edge license (checkInstance)",
notes = "Checks license request (V1/V2) from edge service by forwarding request to license portal.")
@PostMapping(value = "/v2/license/checkInstance")
public ResponseEntity<JsonNode> checkInstanceV2(@RequestBody JsonNode request) throws ThingsboardException {
log.debug("Checking instance [{}]", request);
try {
return edgeLicenseService.checkInstanceV2(request);
} catch (Exception e) {
log.error("Error occurred: [{}]", e.getMessage(), e);
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
}
}
@ApiOperation(value = "Activate edge instance (activateInstance)",
notes = "Activates edge license (V1/V2) on license portal.")
@PostMapping(value = "/v2/license/activateInstance", params = {"licenseSecret", "releaseDate", "clusterId"})
public ResponseEntity<JsonNode> activateInstanceV2(@RequestParam String licenseSecret,
@RequestParam String releaseDate,
@RequestParam String clusterId,
@RequestParam(required = false) String protocolVersion) throws ThingsboardException {
log.debug("Activating instance [{}], [{}], [{}], [{}]", licenseSecret, releaseDate, clusterId, protocolVersion);
try {
return edgeLicenseService.activateInstanceV2(licenseSecret, releaseDate, clusterId, protocolVersion);
} catch (Exception e) {
log.error("Error occurred: [{}]", e.getMessage(), e);
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
}
}
private void cleanUpLicenseKey(Edge edge) {
edge.setEdgeLicenseKey(null);
}

20
application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
package org.thingsboard.server.controller.plugin;
import com.github.benmanes.caffeine.cache.Cache;
@ -19,6 +20,7 @@ import org.springframework.beans.factory.BeanCreationNotAllowedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.PongMessage;
@ -34,6 +36,7 @@ import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.limit.LimitedApi;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
import org.thingsboard.server.config.WebSocketConfiguration;
import org.thingsboard.server.dao.tenant.TbTenantProfileCache;
@ -56,6 +59,7 @@ import org.thingsboard.server.service.ws.telemetry.cmd.TelemetryCmdsWrapper;
import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
@ -77,6 +81,8 @@ import static org.thingsboard.server.service.ws.DefaultWebSocketService.NUMBER_O
@RequiredArgsConstructor
public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocketMsgEndpoint {
private static final Set<Authority> USER_AUTHORITIES = EnumSet.of(Authority.SYS_ADMIN, Authority.TENANT_ADMIN, Authority.CUSTOMER_USER);
private final ConcurrentMap<String, SessionMetaData> internalSessionMap = new ConcurrentHashMap<>();
private final ConcurrentMap<String, String> externalSessionMap = new ConcurrentHashMap<>();
@ -187,7 +193,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
if (StringUtils.isNotEmpty(authCmd.getApiKey())) {
securityCtx = apiKeyAuthenticationProvider.authenticate(authCmd.getApiKey());
} else {
securityCtx = authenticationProvider.authenticate(authCmd.getToken());
securityCtx = authenticate(authCmd.getToken());
}
} catch (Exception e) {
close(sessionRef, CloseStatus.BAD_DATA.withReason(e.getMessage()));
@ -326,7 +332,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
if (query != null) {
String token = extractQueryParam(query, "token");
if (StringUtils.isNotEmpty(token)) {
securityCtx = authenticationProvider.authenticate(token);
securityCtx = authenticate(token);
}
}
return WebSocketSessionRef.builder()
@ -347,6 +353,14 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
return null;
}
private SecurityUser authenticate(String token) {
SecurityUser securityUser = authenticationProvider.authenticate(token);
if (!USER_AUTHORITIES.contains(securityUser.getAuthority())) {
throw new BadCredentialsException("Token is invalid");
}
return securityUser;
}
private SessionMetaData getSessionMd(String internalSessionId) {
SessionMetaData sessionMd = internalSessionMap.get(internalSessionId);
if (sessionMd == null) {

35
application/src/main/java/org/thingsboard/server/service/edge/DefaultEdgeLicenseService.java

@ -66,7 +66,7 @@ public class DefaultEdgeLicenseService implements EdgeLicenseService {
new HttpEntity<>(request, headers), JsonNode.class);
log.trace("checkInstance response: {}", response);
// removing headers from response of the license server, because it might be a conflict with the proxy from we are accepting incoming connections
return new ResponseEntity<JsonNode>(response.getBody(), response.getStatusCode());
return new ResponseEntity<>(response.getBody(), response.getStatusCode());
}
@Override
@ -80,7 +80,38 @@ public class DefaultEdgeLicenseService implements EdgeLicenseService {
null, JsonNode.class, params);
log.trace("activateInstance response: {}", response);
// removing headers from response of the license server, because it might be a conflict with the proxy from we are accepting incoming connections
return new ResponseEntity<JsonNode>(response.getBody(), response.getStatusCode());
return new ResponseEntity<>(response.getBody(), response.getStatusCode());
}
@Override
public ResponseEntity<JsonNode> checkInstanceV2(JsonNode request) {
log.trace("checkInstance V2 [{}]", request);
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
ResponseEntity<JsonNode> response = this.restTemplate.postForEntity(
EDGE_LICENSE_SERVER_ENDPOINT + "/api/v2/license/checkInstance",
new HttpEntity<>(request, headers), JsonNode.class);
log.trace("checkInstance V2 response: {}", response);
// removing headers from response of the license server, because it might be a conflict with the proxy from we are accepting incoming connections
return new ResponseEntity<>(response.getBody(), response.getStatusCode());
}
@Override
public ResponseEntity<JsonNode> activateInstanceV2(String edgeLicenseSecret, String releaseDate, String clusterId, String protocolVersion) {
log.trace("activateInstance V2 [{}][{}][{}]", releaseDate, clusterId, protocolVersion);
Map<String, String> params = new HashMap<>();
params.put("licenseSecret", edgeLicenseSecret);
params.put("releaseDate", releaseDate);
params.put("clusterId", clusterId);
String url = EDGE_LICENSE_SERVER_ENDPOINT + "/api/v2/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}&clusterId={clusterId}";
if (protocolVersion != null) {
params.put("protocolVersion", protocolVersion);
url += "&protocolVersion={protocolVersion}";
}
ResponseEntity<JsonNode> response = this.restTemplate.postForEntity(url, null, JsonNode.class, params);
log.trace("activateInstance V2 response: {}", response);
// removing headers from response of the license server, because it might be a conflict with the proxy from we are accepting incoming connections
return new ResponseEntity<>(response.getBody(), response.getStatusCode());
}
private RestTemplate initRestTemplate() {

4
application/src/main/java/org/thingsboard/server/service/edge/EdgeLicenseService.java

@ -10,4 +10,8 @@ public interface EdgeLicenseService {
ResponseEntity<JsonNode> checkInstance(JsonNode request);
ResponseEntity<JsonNode> activateInstance(String licenseSecret, String releaseDate);
ResponseEntity<JsonNode> checkInstanceV2(JsonNode request);
ResponseEntity<JsonNode> activateInstanceV2(String licenseSecret, String releaseDate, String clusterId, String protocolVersion);
}

19
application/src/main/java/org/thingsboard/server/service/report/LocalReportDataService.java

@ -2,6 +2,7 @@
// SPDX-License-Identifier: BUSL-1.1
package org.thingsboard.server.service.report;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
@ -32,6 +33,7 @@ import org.thingsboard.server.dao.alarm.AlarmService;
import org.thingsboard.server.dao.report.ReportService;
import org.thingsboard.server.dao.report.ReportTemplateService;
import org.thingsboard.server.dao.resource.ImageService;
import org.thingsboard.server.exception.AccessDeniedException;
import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.report.context.TbReportCtx;
import org.thingsboard.server.report.datasource.ReportDataService;
@ -41,7 +43,9 @@ import org.thingsboard.server.service.security.permission.AccessControlService;
import org.thingsboard.server.service.telemetry.TbTelemetryService;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import static org.thingsboard.server.common.data.report.configuration.timewindow.TimeIntervalCalculator.getIntervalTs;
import static org.thingsboard.server.common.data.report.configuration.timewindow.TimeIntervalCalculator.getIntervalType;
@ -112,13 +116,13 @@ public class LocalReportDataService implements ReportDataService {
@Override
public List<TsKvEntry> getTimeseries(EntityId entityId, List<String> keys, Long startTs, Long endTs, Interval interval, String timeZone, Aggregation agg, SortOrder.Direction sortOrder,
Integer limit, boolean useStrictDataTypes, TbReportCtx ctx) {
return tbTelemetryService.getTimeseries(entityId, keys, startTs, endTs, getIntervalType(interval), getIntervalTs(interval), timeZone, limit, agg, sortOrder.name(), useStrictDataTypes, getSecurityUser(ctx)).get(); // .get() will be interrupted on task processing timeout
return getOrEmptyIfAccessDenied(tbTelemetryService.getTimeseries(entityId, keys, startTs, endTs, getIntervalType(interval), getIntervalTs(interval), timeZone, limit, agg, sortOrder.name(), useStrictDataTypes, getSecurityUser(ctx))); // .get() will be interrupted on task processing timeout
}
@SneakyThrows
@Override
public List<ReadTsKvQueryResult> findTimeseriesByQueries(EntityId entityId, List<BaseReadTsKvQuery> queries, TbReportCtx ctx) {
return tbTelemetryService.getTimeseriesByReadQueries(entityId, queries, getSecurityUser(ctx)).get();
return getOrEmptyIfAccessDenied(tbTelemetryService.getTimeseriesByReadQueries(entityId, queries, getSecurityUser(ctx)));
}
@Override
@ -127,6 +131,17 @@ public class LocalReportDataService implements ReportDataService {
return reportService.createReport(report, data);
}
private <T> List<T> getOrEmptyIfAccessDenied(ListenableFuture<List<T>> future) throws InterruptedException, ExecutionException {
try {
return future.get();
} catch (ExecutionException e) {
if (e.getCause() instanceof AccessDeniedException) {
return Collections.emptyList();
}
throw e;
}
}
private SecurityUser getSecurityUser(TbReportCtx ctx) {
return ((LocalTbReportCtxProvider.LocalTbReportCtx) ctx).getSecurityUser();
}

5
application/src/main/java/org/thingsboard/server/service/security/AccessValidator.java

@ -358,6 +358,7 @@ public class AccessValidator {
accessControlService.checkPermission(currentUser, Resource.DEVICE_PROFILE, operation, entityId, deviceProfile);
} catch (ThingsboardException e) {
callback.onSuccess(ValidationResult.accessDenied(e.getMessage()));
return;
}
callback.onSuccess(ValidationResult.ok(deviceProfile));
}
@ -376,6 +377,7 @@ public class AccessValidator {
accessControlService.checkPermission(currentUser, Resource.ASSET_PROFILE, operation, entityId, assetProfile);
} catch (ThingsboardException e) {
callback.onSuccess(ValidationResult.accessDenied(e.getMessage()));
return;
}
callback.onSuccess(ValidationResult.ok(assetProfile));
}
@ -388,6 +390,7 @@ public class AccessValidator {
} else {
if (!operation.equals(Operation.READ_TELEMETRY)) {
callback.onSuccess(ValidationResult.accessDenied("Allowed only READ_TELEMETRY operation!"));
return;
}
ApiUsageState apiUsageState = apiUsageStateService.findApiUsageStateById(currentUser.getTenantId(), new ApiUsageStateId(entityId.getId()));
if (apiUsageState == null) {
@ -397,6 +400,7 @@ public class AccessValidator {
accessControlService.checkPermission(currentUser, Resource.API_USAGE_STATE, operation, entityId, apiUsageState);
} catch (ThingsboardException e) {
callback.onSuccess(ValidationResult.accessDenied(e.getMessage()));
return;
}
callback.onSuccess(ValidationResult.ok(apiUsageState));
}
@ -415,6 +419,7 @@ public class AccessValidator {
accessControlService.checkPermission(currentUser, Resource.OTA_PACKAGE, operation, entityId, otaPackage);
} catch (ThingsboardException e) {
callback.onSuccess(ValidationResult.accessDenied(e.getMessage()));
return;
}
callback.onSuccess(ValidationResult.ok(otaPackage));
}

10
application/src/main/java/org/thingsboard/server/service/telemetry/DefaultTbTelemetryService.java

@ -22,7 +22,9 @@ import org.thingsboard.server.common.data.kv.TsKvEntry;
import org.thingsboard.server.common.data.permission.Operation;
import org.thingsboard.server.dao.timeseries.TimeseriesService;
import org.thingsboard.server.service.security.AccessValidator;
import org.thingsboard.server.service.security.ValidationCallback;
import org.thingsboard.server.service.security.ValidationResult;
import org.thingsboard.server.service.security.ValidationResultCode;
import org.thingsboard.server.service.security.model.SecurityUser;
import java.util.ArrayList;
@ -45,6 +47,10 @@ public class DefaultTbTelemetryService implements TbTelemetryService {
accessValidator.validate(currentUser, Operation.READ_TELEMETRY, entityId, new FutureCallback<>() {
@Override
public void onSuccess(ValidationResult validationResult) {
if (validationResult.getResultCode() != ValidationResultCode.OK) {
onFailure(ValidationCallback.getException(validationResult));
return;
}
try {
AggregationParams params;
if (Aggregation.NONE.equals(agg)) {
@ -85,6 +91,10 @@ public class DefaultTbTelemetryService implements TbTelemetryService {
accessValidator.validate(currentUser, Operation.READ_TELEMETRY, entityId, new FutureCallback<>() {
@Override
public void onSuccess(ValidationResult validationResult) {
if (validationResult.getResultCode() != ValidationResultCode.OK) {
onFailure(ValidationCallback.getException(validationResult));
return;
}
try {
Futures.addCallback(tsService.findAllByQueries(currentUser.getTenantId(), entityId, new ArrayList<>(queries)), new FutureCallback<>() {
@Override

76
application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java

@ -991,72 +991,36 @@ public class DefaultWebSocketService implements WebSocketService {
}, executor);
}
private <T> FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final List<String> keys, final FutureCallback<List<AttributeKvEntry>> callback) {
return new FutureCallback<ValidationResult>() {
@Override
public void onSuccess(@Nullable ValidationResult result) {
List<ListenableFuture<List<AttributeKvEntry>>> futures = new ArrayList<>();
for (AttributeScope scope : AttributeScope.values()) {
futures.add(attributesService.find(tenantId, entityId, scope, keys));
}
ListenableFuture<List<AttributeKvEntry>> future = mergeAllAttributesFutures(futures);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
private FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final List<String> keys, final FutureCallback<List<AttributeKvEntry>> callback) {
return on(r -> {
List<ListenableFuture<List<AttributeKvEntry>>> futures = new ArrayList<>();
for (AttributeScope scope : AttributeScope.values()) {
futures.add(attributesService.find(tenantId, entityId, scope, keys));
}
@Override
public void onFailure(Throwable t) {
callback.onFailure(t);
}
};
ListenableFuture<List<AttributeKvEntry>> future = mergeAllAttributesFutures(futures);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
}, callback::onFailure);
}
private <T> FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final String scope, final List<String> keys, final FutureCallback<List<AttributeKvEntry>> callback) {
return new FutureCallback<ValidationResult>() {
@Override
public void onSuccess(@Nullable ValidationResult result) {
Futures.addCallback(attributesService.find(tenantId, entityId, AttributeScope.valueOf(scope), keys), callback, MoreExecutors.directExecutor());
}
@Override
public void onFailure(Throwable t) {
callback.onFailure(t);
}
};
private FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final String scope, final List<String> keys, final FutureCallback<List<AttributeKvEntry>> callback) {
return on(r -> Futures.addCallback(attributesService.find(tenantId, entityId, AttributeScope.valueOf(scope), keys), callback, MoreExecutors.directExecutor()), callback::onFailure);
}
private <T> FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final FutureCallback<List<AttributeKvEntry>> callback) {
return new FutureCallback<ValidationResult>() {
@Override
public void onSuccess(@Nullable ValidationResult result) {
List<ListenableFuture<List<AttributeKvEntry>>> futures = new ArrayList<>();
for (AttributeScope scope : AttributeScope.values()) {
futures.add(attributesService.findAll(tenantId, entityId, scope));
}
ListenableFuture<List<AttributeKvEntry>> future = mergeAllAttributesFutures(futures);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
private FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final FutureCallback<List<AttributeKvEntry>> callback) {
return on(r -> {
List<ListenableFuture<List<AttributeKvEntry>>> futures = new ArrayList<>();
for (AttributeScope scope : AttributeScope.values()) {
futures.add(attributesService.findAll(tenantId, entityId, scope));
}
@Override
public void onFailure(Throwable t) {
callback.onFailure(t);
}
};
ListenableFuture<List<AttributeKvEntry>> future = mergeAllAttributesFutures(futures);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
}, callback::onFailure);
}
private <T> FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final String scope, final FutureCallback<List<AttributeKvEntry>> callback) {
return new FutureCallback<ValidationResult>() {
@Override
public void onSuccess(@Nullable ValidationResult result) {
Futures.addCallback(attributesService.findAll(tenantId, entityId, AttributeScope.valueOf(scope)), callback, MoreExecutors.directExecutor());
}
@Override
public void onFailure(Throwable t) {
callback.onFailure(t);
}
};
private FutureCallback<ValidationResult> getAttributesFetchCallback(final TenantId tenantId, final EntityId entityId, final String scope, final FutureCallback<List<AttributeKvEntry>> callback) {
return on(r -> Futures.addCallback(attributesService.findAll(tenantId, entityId, AttributeScope.valueOf(scope)), callback, MoreExecutors.directExecutor()), callback::onFailure);
}
private FutureCallback<ValidationResult> on(Consumer<Void> success, Consumer<Throwable> failure) {

6
application/src/test/java/org/thingsboard/server/client/TbResourceApiClientTest.java

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
package org.thingsboard.server.client;
import org.junit.Test;
@ -21,6 +22,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
@ -79,7 +81,7 @@ public class TbResourceApiClientTest extends AbstractApiClientTest {
PageDataTbResourceInfo jsResources = client.getResources(GetResourcesArgs.builder()
.pageSize(100)
.page(0)
.resourceType(ResourceType.JS_MODULE.getValue())
.resourceType(Set.of(ResourceType.JS_MODULE))
.textSearch(TEST_PREFIX + "Resource_" + timestamp)
.build());
assertEquals(5, jsResources.getData().size());

42
application/src/test/java/org/thingsboard/server/controller/TelemetryControllerTest.java

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
package org.thingsboard.server.controller;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -10,8 +11,11 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.AttributeScope;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.SaveDeviceWithCredentialsRequest;
import org.thingsboard.server.common.data.id.DeviceProfileId;
import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery;
import org.thingsboard.server.common.data.kv.BasicTsKvEntry;
import org.thingsboard.server.common.data.kv.LongDataEntry;
import org.thingsboard.server.common.data.query.AliasEntityId;
@ -22,9 +26,11 @@ import org.thingsboard.server.common.data.security.DeviceCredentialsType;
import org.thingsboard.server.dao.service.DaoSqlTest;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.thingsboard.server.common.data.query.EntityKeyType.TIME_SERIES;
@ -291,6 +297,40 @@ public class TelemetryControllerTest extends AbstractControllerTest {
Assert.assertTrue(tsDataAfterDeletion.get("key3").get(0).get("value").isNull());
}
@Test
public void testCustomerUserCannotReadTimeseriesOfNotAssignedDevice() throws Exception {
loginTenantAdmin();
Device device = createDevice();
tsService.save(tenantId, device.getId(), new BasicTsKvEntry(1000L, new LongDataEntry("t", 1L))).get();
loginCustomerAdminUser();
String url = "/api/plugins/telemetry/DEVICE/{entityId}/values/timeseries?keys=t&startTs=0&endTs={endTs}";
doGetAsync(url, device.getUuidId(), System.currentTimeMillis()).andExpect(status().isForbidden());
doGetAsync(url + "&agg=SUM&interval=86400000", device.getUuidId(), System.currentTimeMillis()).andExpect(status().isForbidden());
doGetAsync(url, UUID.randomUUID(), System.currentTimeMillis()).andExpect(status().isNotFound());
List<BaseReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery("t", 0, System.currentTimeMillis(), 10, "DESC"));
doPostAsync("/api/plugins/telemetry/DEVICE/" + device.getId() + "/values/timeseries", queries, String.class, status().isForbidden());
loginTenantAdmin();
doPost("/api/owner/CUSTOMER/" + customerId.getId() + "/DEVICE/" + device.getId().getId()).andExpect(status().isOk());
loginCustomerAdminUser();
ObjectNode result = doGetAsync(url, ObjectNode.class, device.getUuidId(), System.currentTimeMillis());
Assert.assertEquals(1L, result.get("t").get(0).get("value").asLong());
}
@Test
public void testCustomerUserCannotSaveDeviceProfileAttributes() throws Exception {
loginTenantAdmin();
DeviceProfileId deviceProfileId = createDevice().getDeviceProfileId();
loginCustomerUser();
doPostAsync("/api/plugins/telemetry/DEVICE_PROFILE/" + deviceProfileId + "/SERVER_SCOPE", "{\"attr\": \"value\"}", String.class, status().isForbidden());
await().during(1, TimeUnit.SECONDS).atMost(2, TimeUnit.SECONDS)
.until(() -> attributesService.find(tenantId, deviceProfileId, AttributeScope.SERVER_SCOPE, "attr").get().isEmpty());
}
private Device createDevice() throws Exception {
String testToken = "TEST_TOKEN";

42
application/src/test/java/org/thingsboard/server/controller/TwoFactorAuthTest.java

@ -15,6 +15,8 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.web.util.UriComponentsBuilder;
import org.thingsboard.rule.engine.api.SmsService;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.audit.ActionStatus;
@ -27,6 +29,8 @@ import org.thingsboard.server.common.data.notification.targets.platform.TenantAd
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.page.SortOrder;
import org.thingsboard.server.common.data.page.TimePageLink;
import org.thingsboard.server.common.data.query.EntityData;
import org.thingsboard.server.common.data.query.EntityTypeFilter;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.common.data.security.model.JwtPair;
import org.thingsboard.server.common.data.security.model.mfa.PlatformTwoFaSettings;
@ -43,6 +47,7 @@ import org.thingsboard.server.dao.service.DaoSqlTest;
import org.thingsboard.server.service.security.auth.mfa.TwoFactorAuthService;
import org.thingsboard.server.service.security.auth.mfa.config.TwoFaConfigManager;
import org.thingsboard.server.service.security.auth.rest.LoginRequest;
import org.thingsboard.server.service.ws.telemetry.cmd.v2.EntityDataUpdate;
import java.time.Duration;
import java.util.Arrays;
@ -144,6 +149,43 @@ public class TwoFactorAuthTest extends AbstractControllerTest {
assertThat(currentUser.getId()).isEqualTo(user.getId());
}
@Test
public void testWsAuthCmd_preVerificationTokenRejected() throws Exception {
configureTotpTwoFa();
logInWithMfaToken(username, password, Authority.PRE_VERIFICATION_TOKEN);
wsClient = buildAndConnectWebSocketClient();
await().atMost(TIMEOUT, TimeUnit.SECONDS).until(wsClient::isClosed);
}
@Test
public void testWsQueryToken_preVerificationTokenRejected() throws Exception {
configureTotpTwoFa();
logInWithMfaToken(username, password, Authority.PRE_VERIFICATION_TOKEN);
wsClient = buildAndConnectWebSocketClient("/api/ws?token=" + token);
await().atMost(TIMEOUT, TimeUnit.SECONDS).until(wsClient::isClosed);
}
@Test
public void testWs_accessTokenAcceptedAfterTwoFa() throws Exception {
TotpTwoFaAccountConfig totpTwoFaAccountConfig = configureTotpTwoFa();
logInWithMfaToken(username, password, Authority.PRE_VERIFICATION_TOKEN);
JsonNode tokenPair = readResponse(doPost("/api/auth/2fa/verification/check?providerType=TOTP&verificationCode=" + getCorrectTotp(totpTwoFaAccountConfig))
.andExpect(status().isOk()), JsonNode.class);
validateAndSetJwtToken(tokenPair, username);
Device device = createDevice("2FA device", "2FA device token");
EntityTypeFilter deviceFilter = new EntityTypeFilter();
deviceFilter.setEntityType(EntityType.DEVICE);
EntityDataUpdate update = getWsClient().sendEntityDataQuery(deviceFilter);
assertThat(update.getData().getData()).singleElement()
.extracting(EntityData::getEntityId).isEqualTo(device.getId());
}
@Test
public void testTwoFaPreVerificationTokenLifetime() throws Exception {
configureTotpTwoFa(twoFaSettings -> {

12
application/src/test/java/org/thingsboard/server/controller/WebSocketApiTest.java

@ -988,6 +988,18 @@ public class WebSocketApiTest extends AbstractControllerTest {
assertThat(update.get("data").get("attr").get(0).get(1).asText()).isEqualTo(expectedAttrValue);
}
@Test
public void testAttributesSubscription_customerUserNotAssignedDevice() throws Exception {
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, List.of(
new BaseAttributeKvEntry(System.currentTimeMillis(), new StringDataEntry("attr", "secret"))
));
loginCustomerUser();
JsonNode update = getWsClient().subscribeForAttributes(device.getId(), TbAttributeSubscriptionScope.SERVER_SCOPE.name(), List.of("attr"));
assertThat(update.get("errorCode").asInt()).isNotEqualTo(SubscriptionErrorCode.NO_ERROR.getCode());
assertThat(update.path("data").isEmpty()).isTrue();
}
@Test
public void testEntityCountCmd_filterTypeSingularCompatibilityTest() throws Exception {
ObjectNode oldFormatDeviceTypeFilterSingular = JacksonUtil.newObjectNode();

4
common/dao-api/pom.xml

@ -42,6 +42,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>

4
common/data/pom.xml

@ -82,6 +82,10 @@
<groupId>com.squareup.wire</groupId>
<artifactId>wire-schema-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>org.thingsboard</groupId>
<artifactId>protobuf-dynamic</artifactId>

8
common/report/src/main/java/org/thingsboard/server/report/datasource/RemoteReportDataService.java

@ -4,6 +4,7 @@ package org.thingsboard.server.report.datasource;
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientResponseException;
import org.thingsboard.common.util.JacksonUtil;
@ -32,6 +33,7 @@ import org.thingsboard.server.report.context.TbReportCtx;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.thingsboard.server.common.data.report.configuration.timewindow.TimeIntervalCalculator.getIntervalTs;
@ -125,6 +127,9 @@ public class RemoteReportDataService implements ReportDataService {
try {
return getRestClient(ctx).getTimeseries(entityId, keys, getIntervalTs(interval), getIntervalType(interval), timeZone, agg, sortOrder, startTs, endTs, limit, useStrictDataTypes);
} catch (RestClientResponseException e) {
if (e.getStatusCode().value() == HttpStatus.FORBIDDEN.value()) {
return Collections.emptyList();
}
throw handleRestClientException(e);
}
}
@ -134,6 +139,9 @@ public class RemoteReportDataService implements ReportDataService {
try {
return getRestClient(ctx).getTimeseriesByQueries(entityId, queries);
} catch (RestClientResponseException e) {
if (e.getStatusCode().value() == HttpStatus.FORBIDDEN.value()) {
return Collections.emptyList();
}
throw handleRestClientException(e);
}
}

4
common/version-control/pom.xml

@ -59,6 +59,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>

4
dao/pom.xml

@ -170,6 +170,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>

12
pom.xml

@ -75,12 +75,12 @@
<commons-lang3.version>3.18.0</commons-lang3.version> <!-- to fix CVE-2025-48924. TODO: remove when fixed in spring-boot-dependencies -->
<netty.version>4.1.138.Final</netty.version> <!-- to fix CVE-2026-44891, CVE-2026-55831, CVE-2026-55833, CVE-2026-55851, CVE-2026-56745, CVE-2026-56817, CVE-2026-56819, CVE-2026-56820, CVE-2026-56821, CVE-2026-56822, CVE-2026-59901, CVE-2026-59902, CVE-2026-59903, CVE-2026-59920, CVE-2026-62243, CVE-2026-73507, CVE-2026-75595, CVE-2026-93488, CVE-2026-93491, CVE-2026-93560, CVE-2026-100655, CVE-2026-100656, CVE-2026-100657 (supersedes earlier netty CVE pins; also retains the 4.1.134 MQTT decoder regression fix). TODO: remove when fixed in spring-boot-dependencies -->
<opentelemetry.version>1.62.0</opentelemetry.version> <!-- to fix CVE-2026-45292 (transitive opentelemetry-api). Pinned via the opentelemetry-bom import below. TODO: remove when a TB dependency pulls opentelemetry >= 1.62.0 transitively -->
<tomcat.version>10.1.59</tomcat.version> <!-- to fix CVE-2026-53434, CVE-2026-55955, CVE-2026-65182, CVE-2026-65905 and CVE-2026-68525 (10.1.58 was never released; 10.1.59 is the release carrying the fixes). Pinned via the tomcat-embed overrides below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<tomcat.version>10.1.60</tomcat.version> <!-- to fix CVE-2026-53434, CVE-2026-55955, CVE-2026-65182, CVE-2026-65905, CVE-2026-68525 and CVE-2026-76183. Pinned via the tomcat-embed overrides below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<httpcore5.version>5.4.3</httpcore5.version> <!-- to fix CVE-2026-54399 and CVE-2026-54428 (no fix exists on the 5.3.x line; the httpclient5 5.6.4 pin below requires httpcore5 5.4.3). Pinned via the httpcore5 overrides below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<logback.version>1.5.38</logback.version> <!-- to fix CVE-2026-13006 (1.5.36 as reported by the scanner is still vulnerable; 1.5.37 removed Janino conditional processing entirely, 1.5.38 adds a HardenedObjectInputStream fix). Pinned via the logback overrides below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<jackson-bom.version>2.21.7</jackson-bom.version> <!-- to fix CVE-2026-59889, CVE-2026-68497, CVE-2026-89425 and CVE-2026-91777. Pinned via the jackson-bom import below: spring-boot-dependencies re-imports jackson-bom with its own placeholder, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<postgresql.version>42.7.12</postgresql.version> <!-- to fix CVE-2026-54291. Pinned via the postgresql override below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<lz4-java.version>1.11.1</lz4-java.version> <!-- to fix CVE-2026-59949. Transitive dependency of amazon-kinesis-producer 0.15.12; not managed by any BOM, so the override below is the sole source of the version. TODO: remove once amazon-kinesis-producer pulls lz4-java >= 1.11.1 -->
<postgresql.version>42.7.14</postgresql.version> <!-- to fix CVE-2026-54291 and CVE-2026-107314. Pinned via the postgresql override below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<lz4-java.version>1.11.4</lz4-java.version> <!-- to fix CVE-2026-59949, CVE-2026-106450 and CVE-2026-106451. Transitive dependency of amazon-kinesis-producer 0.15.12 and kafka-clients 3.9.2; not managed by any BOM, so the override below is the sole source of the version. TODO: remove once amazon-kinesis-producer and kafka-clients pull lz4-java >= 1.11.4 -->
<amqp-client.version>5.34.0</amqp-client.version> <!-- to fix CVE-2026-63337, CVE-2026-69219, CVE-2026-69220 and CVE-2026-75516. Pinned via the amqp-client override below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<httpclient5.version>5.6.4</httpclient5.version> <!-- to fix CVE-2026-71290. Pinned via the httpclient5 overrides below: spring-boot-dependencies is imported as a BOM, so this property alone would not win. TODO: remove when fixed in spring-boot-dependencies -->
<zstd-jni.version>1.5.7-14</zstd-jni.version> <!-- to fix CVE-2026-87795, CVE-2026-87823, CVE-2026-87824, CVE-2026-87825, CVE-2026-87877, CVE-2026-90560 and CVE-2026-90852. Transitive dependency of kafka-clients 3.9.2; not managed by any BOM, so the override below is the sole source of the version. TODO: remove once kafka-clients pulls zstd-jni >= 1.5.7-14 -->
@ -92,7 +92,7 @@
<cassandra.version>4.17.0</cassandra.version>
<metrics.version>4.2.25</metrics.version>
<cassandra-all.version>5.0.7</cassandra-all.version> <!-- tools; 5.0.7 fixes CVE-2026-27314 -->
<guava.version>33.1.0-jre</guava.version>
<guava.version>33.7.2-jre</guava.version> <!-- to fix CVE-2026-102554 -->
<commons-io.version>2.16.1</commons-io.version>
<commons-logging.version>1.3.1</commons-logging.version>
<commons-csv.version>1.10.0</commons-csv.version>
@ -125,7 +125,7 @@
<swagger-annotations.version>2.2.30</swagger-annotations.version>
<spatial4j.version>0.8</spatial4j.version>
<jts.version>1.19.0</jts.version>
<bouncycastle.version>1.85</bouncycastle.version> <!-- to fix CVE-2026-8763, CVE-2026-12185, CVE-2026-12802, CVE-2026-12803, CVE-2026-12816, CVE-2026-12860, CVE-2026-13506, CVE-2026-14682, CVE-2026-58059, CVE-2026-58060, CVE-2026-58061, CVE-2026-58062, CVE-2026-59639, CVE-2026-59642, CVE-2026-59645, CVE-2026-59650, CVE-2026-59651 (supersedes the earlier 1.84 pin for CVE-2026-5588, CVE-2026-5598, CVE-2025-14813). Not managed by the Spring Boot BOM — this pin is the sole source of the bouncycastle version. -->
<bouncycastle.version>1.86</bouncycastle.version> <!-- to fix CVE-2026-18036, CVE-2026-71888, CVE-2026-71889, CVE-2026-71891, CVE-2026-8763, CVE-2026-12185, CVE-2026-12802, CVE-2026-12803, CVE-2026-12816, CVE-2026-12860, CVE-2026-13506, CVE-2026-14682, CVE-2026-58059, CVE-2026-58060, CVE-2026-58061, CVE-2026-58062, CVE-2026-59639, CVE-2026-59642, CVE-2026-59645, CVE-2026-59650, CVE-2026-59651 (supersedes the earlier 1.84 pin for CVE-2026-5588, CVE-2026-5598, CVE-2025-14813). Not managed by the Spring Boot BOM — this pin is the sole source of the bouncycastle version. -->
<winsw.version>2.0.1</winsw.version>
<azure-iot-service-client.version>1.13.0</azure-iot-service-client.version>
<proton-j.version>0.35.0</proton-j.version> <!-- to fix CVE-2026-66257, CVE-2026-66273, CVE-2026-66274, CVE-2026-66275, CVE-2026-66276 and CVE-2026-66277. Not managed by the Spring Boot BOM — this pin is the sole source of the proton-j version. TODO: remove only once a TB dependency pulls proton-j >= 0.35.0 transitively -->
@ -204,7 +204,7 @@
<weisj-jsvg.version>1.6.1</weisj-jsvg.version>
<drewnoakes-metadata-extractor.version>2.19.0</drewnoakes-metadata-extractor.version>
<firebase-admin.version>9.2.0</firebase-admin.version>
<snappy.version>1.1.10.5</snappy.version>
<snappy.version>1.1.10.10</snappy.version> <!-- to fix CVE-2026-108106, CVE-2026-90559 and CVE-2026-93452 -->
<rocksdbjni.version>9.10.0</rocksdbjni.version>
<thymeleaf.version>3.1.5.RELEASE</thymeleaf.version> <!-- to fix CVE-2026-40477, CVE-2026-40478, CVE-2026-41901. TODO: remove when fixed in spring-boot-dependencies -->
<flying-saucer.version>9.13.0</flying-saucer.version>

4
rule-engine/rule-engine-components/pom.xml

@ -68,6 +68,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>

18
tools/src/main/python/license-headers/curations.json

@ -439,6 +439,18 @@
"reason": "PE-specific data/configuration type IntegrationLifecycleEventTrigger.java. Reviewed fields, type discriminators and serialization hooks describe PE entities or PE behavior; matching CE types supply only the common DTO/interface pattern. Resolved as PE-authored consistently with the maintainer decision for PE entity wrappers. Reviewed candidate common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/RuleEngineComponentLifecycleEventTrigger.java at 0d3b41e002f958887a317ca8366fdc4efa549058 (blob e4c967c19792ecf5fa6409973459efe5ce73cb8d).",
"contentHash": "sha256:c5da9a11ed196635c09972733cf511bee2bd111242c0d084d115d37e2e7524c5"
},
{
"path": "common/data/src/main/java/org/thingsboard/server/common/data/notification/targets/platform/UserGroupListFilter.java",
"header": "busl",
"reason": "PE user group filter, a new class with its own groupsIds field and USER_GROUP_LIST type. The similarity comes from the shared shape of small filter DTOs, not from CE code. Reviewed candidate common/data/src/main/java/org/thingsboard/server/common/data/notification/targets/platform/UserListFilter.java at 862b224dd7e4e770804ffad3411255166daa4501 (blob 07cd0280ba84ab71b6823242e18c7c7285296b84).",
"contentHash": "sha256:64563fbc6ee416025b555c14cf3c517c5027bfc112a883078cc717ed471c5b52"
},
{
"path": "common/data/src/main/java/org/thingsboard/server/common/data/notification/targets/platform/UserRoleFilter.java",
"header": "busl",
"reason": "PE role filter, a new class with its own rolesIds field and USER_ROLE type. The similarity comes from the shared shape of small filter DTOs, not from CE code. Reviewed candidate common/data/src/main/java/org/thingsboard/server/common/data/notification/targets/platform/UserListFilter.java at 862b224dd7e4e770804ffad3411255166daa4501 (blob 07cd0280ba84ab71b6823242e18c7c7285296b84).",
"contentHash": "sha256:007e94e798f25a9d0ccd1716b8a68eada4fe3ced71e531bd0538c2c56e24ecb7"
},
{
"path": "common/data/src/main/java/org/thingsboard/server/common/data/permission/Operation.java",
"header": "ce-modified",
@ -457,6 +469,12 @@
"reason": "PE-specific data/configuration type EntityGroupNameFilter.java. Reviewed fields, type discriminators and serialization hooks describe PE entities or PE behavior; matching CE types supply only the common DTO/interface pattern. Resolved as PE-authored consistently with the maintainer decision for PE entity wrappers. Reviewed candidate common/data/src/main/java/org/thingsboard/server/common/data/query/EntityNameFilter.java at 0d3b41e002f958887a317ca8366fdc4efa549058 (blob a3889bc7c07de44917eac165a9c4e8578bbbcd62).",
"contentHash": "sha256:46cc0073210fb81fb1a71f44604042da6056f78f62468cf45bdc78cdaf8cdd09"
},
{
"path": "common/data/src/main/java/org/thingsboard/server/common/data/query/StateEntityFilter.java",
"header": "busl",
"reason": "PE dashboard state entity filter, a new class with its own defaultStateEntity field and STATE_ENTITY type. The similarity comes from the shared shape of small filter DTOs, not from CE code. Reviewed candidate common/data/src/main/java/org/thingsboard/server/common/data/query/SingleEntityFilter.java at 862b224dd7e4e770804ffad3411255166daa4501 (blob dacd7de6eae6cd80cfd63047dad8951d76aeb455).",
"contentHash": "sha256:46835b82b0320007209a5d53528f9fdb534af41c2fcb5a528754c316c530394a"
},
{
"path": "common/data/src/main/java/org/thingsboard/server/common/data/query/StateEntityOwnerFilter.java",
"header": "busl",

40
ui-ngx/src/app/shared/models/converter.models.ts

@ -15,7 +15,7 @@ export enum ConverterType {
DOWNLINK = 'DOWNLINK'
}
export const IntegrationTbelDefaultConvertersUrl = new Map<IntegrationType, string>([
export const IntegrationTbelDefaultDecodersUrl = new Map<IntegrationType, string>([
[IntegrationType.CHIRPSTACK, '/assets/converters/tbel-chirpstack-decoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/tbel-loriot-decoder.raw'],
[IntegrationType.TTI,'/assets/converters/tbel-tti-decoder.raw'],
@ -31,7 +31,7 @@ export const IntegrationTbelDefaultConvertersUrl = new Map<IntegrationType, stri
[IntegrationType.MQTT, '/assets/converters/tbel-mqtt-decoder.raw']
]);
export const IntegrationJSDefaultConvertersUrl = new Map<IntegrationType, string>([
export const IntegrationJSDefaultDecodersUrl = new Map<IntegrationType, string>([
[IntegrationType.CHIRPSTACK, '/assets/converters/js-chirpstack-decoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/js-loriot-decoder.raw'],
[IntegrationType.TTI,'/assets/converters/js-tti-decoder.raw'],
@ -42,7 +42,20 @@ export const IntegrationJSDefaultConvertersUrl = new Map<IntegrationType, string
]);
export const IntegrationTbelDefaultEncodersUrl = new Map<IntegrationType, string>([
[IntegrationType.OPC_UA, '/assets/converters/tbel-opc-ua-encoder.raw']
[IntegrationType.OPC_UA, '/assets/converters/tbel-opc-ua-encoder.raw'],
[IntegrationType.TTI, '/assets/converters/tbel-ttn-tti-encoder.raw'],
[IntegrationType.TTN, '/assets/converters/tbel-ttn-tti-encoder.raw'],
[IntegrationType.MQTT, '/assets/converters/tbel-mqtt-encoder.raw'],
[IntegrationType.CHIRPSTACK, '/assets/converters/tbel-chirpstack-encoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/tbel-loriot-encoder.raw']
])
export const IntegrationJSDefaultEncodersUrl = new Map<IntegrationType, string>([
[IntegrationType.TTI, '/assets/converters/js-ttn-tti-encoder.raw'],
[IntegrationType.TTN, '/assets/converters/js-ttn-tti-encoder.raw'],
[IntegrationType.MQTT, '/assets/converters/js-mqtt-encoder.raw'],
[IntegrationType.CHIRPSTACK, '/assets/converters/js-chirpstack-encoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/js-loriot-encoder.raw']
])
export const jsDefaultConvertersUrl = new Map<ConverterType, string>([
@ -262,16 +275,19 @@ export const getTargetField =
export const getTargetTemplateUrl =
(converterType: ConverterType, scriptLang: ScriptLanguage,
integrationType: IntegrationType, converterVersion: ConverterVersion = 1): string => {
if (scriptLang === ScriptLanguage.JS && converterType === ConverterType.UPLINK && IntegrationJSDefaultConvertersUrl.has(integrationType)) {
return IntegrationJSDefaultConvertersUrl.get(integrationType)
} else if (scriptLang === ScriptLanguage.JS) {
return getJsTemplateUrl(converterType, converterVersion);
} else if (converterType === ConverterType.UPLINK && IntegrationTbelDefaultConvertersUrl.has(integrationType)) {
return IntegrationTbelDefaultConvertersUrl.get(integrationType);
} else if (converterType === ConverterType.DOWNLINK && IntegrationTbelDefaultEncodersUrl.has(integrationType)) {
return IntegrationTbelDefaultEncodersUrl.get(integrationType);
const isJs = scriptLang === ScriptLanguage.JS;
const isUplink = converterType === ConverterType.UPLINK;
// Integration-specific template map for this (language, direction); UPLINK -> decoders, DOWNLINK -> encoders.
const integrationUrls = isJs
? (isUplink ? IntegrationJSDefaultDecodersUrl : IntegrationJSDefaultEncodersUrl)
: (isUplink ? IntegrationTbelDefaultDecodersUrl : IntegrationTbelDefaultEncodersUrl);
if (integrationUrls.has(integrationType)) {
return integrationUrls.get(integrationType);
}
return getTbelTemplateUrl(converterType, converterVersion);
// Fall back to the generic template for the script language.
return isJs
? getJsTemplateUrl(converterType, converterVersion)
: getTbelTemplateUrl(converterType, converterVersion);
}
const getTbelConverterFunctionHeldId = (converterType: ConverterType, converterVersion: ConverterVersion): string => {

37
ui-ngx/src/assets/converters/js-chirpstack-encoder.raw

@ -0,0 +1,37 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// ChirpStack reads DevEUI and fPort from the metadata below to enqueue the downlink (POST .../devices/{DevEUI}/queue).
// Both are client-side device attributes that could be populated via an Originator attributes rule node.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — ChirpStack device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// EXAMPLE — replace this: it encodes a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field(s) and encoding your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var base64Payload = (msg.powerState != null)
? btoa(msg.powerState) // if powerState is present, encode it to base64
: btoa('unspecified'); // fall back to 'unspecified' when absent
// Result object with encoded downlink payload
var result = {
// downlink data content type: JSON, TEXT or BINARY (base64 format)
contentType: "TEXT",
// downlink data
data: base64Payload,
// Metadata required by ChirpStack for downlink delivery.
metadata: {
// Target device EUI; ChirpStack rejects the downlink if this is missing.
DevEUI: metadata.cs_eui,
// LoRaWAN frame port (1-223); ChirpStack parses this as an integer.
fPort: metadata.cs_fPort
}
};
return result;

7
ui-ngx/src/assets/converters/js-loriot-decoder.raw

@ -52,6 +52,13 @@ function decodePayload(input) {
// };
}
// Process only LORIOT uplink messages: cmd is 'rx', or 'gw' when gateway info is included.
// Skip downlink confirmations (e.g. cmd == 'txd') and other events so they
// are not stored as telemetry. Returning an empty array yields no uplink data.
if (metadata.cmd != 'rx' && metadata.cmd != 'gw') {
return [];
}
var result = decodePayload(payload);
// Uncomment this code block to overwrite values set in the main configuration window. Useful if you extract device/asset/customer/group names from the payload;
// result.type = 'DEVICE'; // Entity type allows you to choose type of created entity. Can be 'DEVICE' or 'ASSET'.

37
ui-ngx/src/assets/converters/js-loriot-encoder.raw

@ -0,0 +1,37 @@
// Encode downlink data from incoming Rule Engine message.
// msg - JSON message payload (e.g. { "state": "on" })
// msgType - message type, e.g. 'ATTRIBUTES_UPDATED'
// metadata - enriched by the Originator attributes node with device client attributes.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — LORIOT device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
var eui = metadata.cs_eui;
// Default port to 1 when the device fPort attribute is missing or empty.
var port = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
// EXAMPLE — replace this: it sends a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var payload = (msg.powerState != null)
? msg.powerState
: 'unspecified';
var result = {
// Downlink data content type: JSON, TEXT, or BINARY (base64 format).
contentType: "TEXT",
// Downlink data — the command value; LORIOT hex-encodes it before delivery.
data: payload,
// Metadata required by LORIOT for downlink delivery.
metadata: {
"EUI": eui,
"port": port
}
};
return result;

20
ui-ngx/src/assets/converters/js-mqtt-encoder.raw

@ -0,0 +1,20 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Publish the ThingsBoard message as JSON to the device upload topic.
// metadata.topic is read by the integration when Downlink topic pattern is ${topic}.
var result = {
contentType: "JSON",
data: JSON.stringify(msg),
metadata: {
topic: metadata['deviceType'] + '/' + metadata['deviceName'] + '/upload'
}
};
return result;

49
ui-ngx/src/assets/converters/js-ttn-tti-encoder.raw

@ -0,0 +1,49 @@
// Encode downlink data from incoming Rule Engine message
// Shared by the TTN and TTI integrations (The Things Stack).
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Target device identifier used to build the TTN/TTI downlink topic (devId is assumed to be added via Originator fields rule node)
var devId = metadata.devId;
// LoRaWAN frame port the downlink is scheduled on (cs_fPort is assumed to be added via Originator attributes rule node, prefix 'cs_' (client-side) is added by rule node)
// Default port to 1 when the device fPort attribute is missing or empty. parseInt keeps f_port a number, as the TTN/TTI API expects.
var fPort = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
// EXAMPLE — replace this: it encodes a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field(s) and encoding your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var base64Payload = (msg.powerState != null)
? btoa(msg.powerState) // if powerState is present, encode it to base64
: btoa('unspecified'); // fall back to 'unspecified' when absent
// The Things Stack (TTN/TTI) expects a 'downlinks' array; each entry is a single scheduled downlink.
var data = {
downlinks: [{
// Frame port to deliver the payload on (must match the device's expected port).
f_port: fPort,
// false - best-effort downlink; set to true to request an acknowledgement from the device.
confirmed: false,
// Downlink payload, base64-encoded as required by the TTN/TTI API.
frm_payload: base64Payload,
// Scheduling priority for the network server: LOWEST, LOW, BELOW_NORMAL, NORMAL, ABOVE_NORMAL, HIGH, HIGHEST.
priority: "NORMAL"
}]
};
// Result object with encoded downlink payload
var result = {
contentType: "JSON",
data: JSON.stringify(data),
metadata: {
devId: devId
}
};
return result;

37
ui-ngx/src/assets/converters/tbel-chirpstack-encoder.raw

@ -0,0 +1,37 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// ChirpStack reads DevEUI and fPort from the metadata below to enqueue the downlink (POST .../devices/{DevEUI}/queue).
// Both are client-side device attributes that could be populated via an Originator attributes rule node.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — ChirpStack device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// EXAMPLE — replace this: it encodes a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field(s) and encoding your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var base64Payload = (msg.powerState != null)
? btoa(msg.powerState) // if powerState is present, encode it to base64
: btoa('unspecified'); // fall back to 'unspecified' when absent
// Result object with encoded downlink payload
var result = {
// downlink data content type: JSON, TEXT or BINARY (base64 format)
contentType: "TEXT",
// downlink data
data: base64Payload,
// Metadata required by ChirpStack for downlink delivery.
metadata: {
// Target device EUI; ChirpStack rejects the downlink if this is missing.
DevEUI: metadata.cs_eui,
// LoRaWAN frame port (1-223); ChirpStack parses this as an integer.
fPort: metadata.cs_fPort
}
};
return result;

7
ui-ngx/src/assets/converters/tbel-loriot-decoder.raw

@ -52,6 +52,13 @@ function decodePayload(input) {
// };
}
// Process only LORIOT uplink messages: cmd is 'rx', or 'gw' when gateway info is included.
// Skip downlink confirmations (e.g. cmd == 'txd') and other events so they
// are not stored as telemetry. Returning an empty array yields no uplink data.
if (metadata.cmd != 'rx' && metadata.cmd != 'gw') {
return [];
}
var result = decodePayload(payload);
// Uncomment this code block to overwrite values set in the main configuration window. Useful if you extract device/asset/customer/group names from the payload;
// result.type = 'DEVICE'; // Entity type allows you to choose type of created entity. Can be 'DEVICE' or 'ASSET'.

37
ui-ngx/src/assets/converters/tbel-loriot-encoder.raw

@ -0,0 +1,37 @@
// Encode downlink data from incoming Rule Engine message.
// msg - JSON message payload (e.g. { "state": "on" })
// msgType - message type, e.g. 'ATTRIBUTES_UPDATED'
// metadata - enriched by the Originator attributes node with device client attributes.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — LORIOT device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
var eui = metadata.cs_eui;
// Default port to 1 when the device fPort attribute is missing or empty.
var port = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
// EXAMPLE — replace this: it sends a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var payload = (msg.powerState != null)
? msg.powerState
: 'unspecified';
var result = {
// Downlink data content type: JSON, TEXT, or BINARY (base64 format).
contentType: "TEXT",
// Downlink data — the command value; LORIOT hex-encodes it before delivery.
data: payload,
// Metadata required by LORIOT for downlink delivery.
metadata: {
"EUI": eui,
"port": port
}
};
return result;

20
ui-ngx/src/assets/converters/tbel-mqtt-encoder.raw

@ -0,0 +1,20 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Publish the ThingsBoard message as JSON to the device upload topic.
// metadata.topic is read by the integration when Downlink topic pattern is ${topic}.
var result = {
contentType: "JSON",
data: JSON.stringify(msg),
metadata: {
topic: metadata['deviceType'] + '/' + metadata['deviceName'] + '/upload'
}
};
return result;

49
ui-ngx/src/assets/converters/tbel-ttn-tti-encoder.raw

@ -0,0 +1,49 @@
// Encode downlink data from incoming Rule Engine message
// Shared by the TTN and TTI integrations (The Things Stack).
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Target device identifier used to build the TTN/TTI downlink topic (devId is assumed to be added via Originator fields rule node)
var devId = metadata.devId;
// LoRaWAN frame port the downlink is scheduled on (cs_fPort is assumed to be added via Originator attributes rule node, prefix 'cs_' (client-side) is added by rule node)
// Default port to 1 when the device fPort attribute is missing or empty. parseInt keeps f_port a number, as the TTN/TTI API expects.
var fPort = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
// EXAMPLE — replace this: it encodes a single field ('powerState') from the downlink message.
// Swap 'powerState' (and the 'unspecified' fallback) for the field(s) and encoding your device expects;
// as written, any downlink without a 'powerState' field sends the constant value 'unspecified'.
var base64Payload = (msg.powerState != null)
? btoa(msg.powerState) // if powerState is present, encode it to base64
: btoa('unspecified'); // fall back to 'unspecified' when absent
// The Things Stack (TTN/TTI) expects a 'downlinks' array; each entry is a single scheduled downlink.
var data = {
downlinks: [{
// Frame port to deliver the payload on (must match the device's expected port).
f_port: fPort,
// false - best-effort downlink; set to true to request an acknowledgement from the device.
confirmed: false,
// Downlink payload, base64-encoded as required by the TTN/TTI API.
frm_payload: base64Payload,
// Scheduling priority for the network server: LOWEST, LOW, BELOW_NORMAL, NORMAL, ABOVE_NORMAL, HIGH, HIGHEST.
priority: "NORMAL"
}]
};
// Result object with encoded downlink payload
var result = {
contentType: "JSON",
data: JSON.stringify(data),
metadata: {
devId: devId
}
};
return result;
Loading…
Cancel
Save