Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Spring Boot to 2.3.7.RELEASE #1018

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
28b65a2
Update Spring Boot to 2.3.2
AmmarBikic Jan 30, 2020
a6404fd
Update Spring Boot to 2.3.3
AmmarBikic Aug 27, 2020
8e90ffd
Adaptations due to Vaadin 8 merge
AmmarBikic Aug 31, 2020
c17ba89
Use best practise annotation for SAM interfaces in Java 8
AmmarBikic Sep 1, 2020
2d3de50
Remove aspectj-weaver again as not needed
AmmarBikic Sep 16, 2020
16675e0
Update supported versions in README.md
AmmarBikic Sep 17, 2020
26964ce
Update Spring Boot to 2.3.4
AmmarBikic Sep 22, 2020
6faaad8
Add license header to MgmtContentTypeTest
AmmarBikic Sep 28, 2020
ddabbc5
Replace MediaTypes and make use of proper Identifiable.class
AmmarBikic Oct 5, 2020
edb9d91
Remove aspectj-weaver.arg
AmmarBikic Oct 5, 2020
bd382c3
Adaptations due to PR comments
AmmarBikic Oct 15, 2020
2e0122d
Adaptations due to PR comments
AmmarBikic Oct 15, 2020
2e224b0
Merge remote-tracking branch 'origin/master' into fix_migration_to_ne…
AmmarBikic Oct 23, 2020
165f6e0
Change to proper versioning
AmmarBikic Nov 3, 2020
68e4cd9
Merge remote-tracking branch 'origin/master' into fix_migration_to_ne…
AmmarBikic Nov 9, 2020
75d9062
Fix host header attack
AmmarBikic Nov 30, 2020
e23f4da
Improve firewall logging
AmmarBikic Dec 3, 2020
98f7a5b
Host header attack implementation improvements and tests
AmmarBikic Dec 4, 2020
458bc8c
Merge remote-tracking branch 'origin/master' into fix_migration_to_ne…
AmmarBikic Dec 4, 2020
918304f
SonarQube adaptations
AmmarBikic Dec 4, 2020
5cf008c
Update Spring Boot to 2.3.7.RELEASE
floruschbaschan Dec 11, 2020
3ee7d81
Overwriting VaadinAuthenticationSuccessHandler of default VaadinShare…
AmmarBikic Dec 8, 2020
7434293
Changes requested within pull request review.
AmmarBikic Jan 8, 2021
adeabbd
Changes requested within pull request review.
AmmarBikic Jan 8, 2021
0356039
Insert spring-webmvc dependency with test scope to make tests running
AmmarBikic Jan 15, 2021
ac8c174
Merge remote-tracking branch 'origin/master' into fix_migration_to_ne…
AmmarBikic Jan 15, 2021
0a31b51
Merge remote-tracking branch 'origin/master' into fix_migration_to_ne…
AmmarBikic Jan 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ There are clients outside of the Eclipse IoT eco system as well, e.g.:

## SQL database

| Database | H2 | MySQL/MariaDB | MS SQL Server | PostgreSQL | IBM DB2 |
| --------------------------------- | :------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------: | :----------------------------------------------------------------: | :----------------: |
| DDLs maintained by project | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Test dependencies defined | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
| Versions tested | 1.4 | MySQL 5.6/5.7, AWS Aurora | MS SQL Server 2017/2019 | PostgreSQL 12/13 | DB2 Server v11.1 |
| Docker image with driver provided | :white_check_mark: | :white_check_mark: (Tag: "-mysql") | :white_check_mark: | :white_check_mark: | |
| JDBC driver | [H2 1.4](https://github.com/h2database/h2database) | [MariaDB Connector/J 2.0](https://github.com/MariaDB/mariadb-connector-j) | [MSSQL-JDBC 6.4](https://github.com/Microsoft/mssql-jdbc) | [PostgreSQL JDBC Driver 42.2.10](https://github.com/pgjdbc/pgjdbc) | |
| Status | Test, Dev | Production grade | Production grade | Test, Dev | Test, Dev |
| Database | H2 | MySQL/MariaDB | MS SQL Server | PostgreSQL | IBM DB2 |
| --------------------------------- | :----------------------------------------------------: | :-------------------------------------------------------------------------: | :--------------------------------------------------------------: | :----------------------------------------------------------------: | :----------------: |
| DDLs maintained by project | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Test dependencies defined | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
| Versions tested | 1.4 | MySQL 5.6/5.7, AWS Aurora | MS SQL Server 2017/2019 | PostgreSQL 12/13 | DB2 Server v11.1 |
| Docker image with driver provided | :white_check_mark: | :white_check_mark: (Tag: "-mysql") | :white_check_mark: | :white_check_mark: | |
| JDBC driver | [H2 1.4.200](https://github.com/h2database/h2database) | [MariaDB Connector/J 2.6.2](https://github.com/MariaDB/mariadb-connector-j) | [MSSQL-JDBC 7.4.1.jre8](https://github.com/Microsoft/mssql-jdbc) | [PostgreSQL JDBC Driver 42.2.14](https://github.com/pgjdbc/pgjdbc) | |
| Status | Test, Dev | Production grade | Production grade | Test, Dev | Test, Dev |

## (Optional) RabbitMQ: 3.6,3.7,3.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.eclipse.hawkbit.cache.DownloadIdCache;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
Expand Down Expand Up @@ -56,6 +58,7 @@
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
Expand Down Expand Up @@ -91,9 +94,13 @@
import org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter;
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.firewall.FirewalledRequest;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;
import org.springframework.security.web.session.HttpSessionEventPublisher;
import org.springframework.security.web.session.SessionManagementFilter;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
Expand Down Expand Up @@ -183,7 +190,7 @@ static class ControllerSecurityConfigurationAdapter extends WebSecurityConfigure
/**
* Filter to protect the hawkBit server DDI interface against to many
* requests.
*
*
* @param securityProperties
* for filter configuration
*
Expand Down Expand Up @@ -299,7 +306,7 @@ static class ControllerDownloadSecurityConfigurationAdapter extends WebSecurityC
/**
* Filter to protect the hawkBit server DDI download interface against
* to many requests.
*
*
* @param securityProperties
* for filter configuration
*
Expand Down Expand Up @@ -389,7 +396,7 @@ protected void configure(final AuthenticationManagerBuilder auth) throws Excepti
/**
* Filter to protect the hawkBit server system management interface against
* to many requests.
*
*
* @param securityProperties
* for filter configuration
*
Expand Down Expand Up @@ -490,7 +497,7 @@ public static class RestSecurityConfigurationAdapter extends WebSecurityConfigur
/**
* Filter to protect the hawkBit server Management interface against to
* many requests.
*
*
* @param securityProperties
* for filter configuration
*
Expand Down Expand Up @@ -523,9 +530,8 @@ protected void configure(final HttpSecurity http) throws Exception {
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
}

httpSec.authorizeRequests().anyRequest().authenticated()
.antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN);
httpSec.authorizeRequests().antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).anyRequest().authenticated();

if (oidcBearerTokenAuthenticationFilter != null) {

Expand Down Expand Up @@ -619,7 +625,7 @@ public static class UISecurityConfigurationAdapter extends WebSecurityConfigurer

/**
* Filter to protect the hawkBit management UI against to many requests.
*
*
* @param securityProperties
* for filter configuration
*
Expand Down Expand Up @@ -647,8 +653,10 @@ public AuthenticationManager authenticationManagerBean() throws Exception {
}

/**
* Overwriting VaadinAuthenticationSuccessHandler of default VaadinSharedSecurityConfiguration
* @return the vaadin success authentication handler
*/
@Primary
@Bean(name = VaadinSharedSecurityConfiguration.VAADIN_AUTHENTICATION_SUCCESS_HANDLER_BEAN)
public VaadinAuthenticationSuccessHandler redirectSaveHandler(final HttpService httpService,
final VaadinRedirectStrategy redirectStrategy) {
Expand Down Expand Up @@ -719,6 +727,49 @@ protected void configure(final HttpSecurity http) throws Exception {
.logoutSuccessHandler(logoutSuccessHandler);
}

/**
* HttpFirewall which enables to define a list of allowed host names.
*
* @return the http firewall.
*/
@Bean
public HttpFirewall httpFirewall() {
AmmarBikic marked this conversation as resolved.
Show resolved Hide resolved
final List<String> allowedHostNames = hawkbitSecurityProperties.getAllowedHostNames();
final IgnorePathsStrictHttpFirewall firewall = new IgnorePathsStrictHttpFirewall(
hawkbitSecurityProperties.getHttpFirewallIgnoredPaths());

if (!CollectionUtils.isEmpty(allowedHostNames)) {
firewall.setAllowedHostnames(hostName -> {
LOG.debug("Firewall check host: {}, allowed: {}", hostName, allowedHostNames.contains(hostName));
return allowedHostNames.contains(hostName);
});
}
return firewall;
}

private static class IgnorePathsStrictHttpFirewall extends StrictHttpFirewall {

private final Collection<String> pathsToIgnore;

public IgnorePathsStrictHttpFirewall(final Collection<String> pathsToIgnore) {
super();
this.pathsToIgnore = pathsToIgnore;
}

@Override
public FirewalledRequest getFirewalledRequest(final HttpServletRequest request) {
if (pathsToIgnore != null && pathsToIgnore.contains(request.getRequestURI())) {
return new FirewalledRequest(request) {
@Override
public void reset() {
//nothing to do
}
};
}
return super.getFirewalledRequest(request);
}
}

@Override
public void configure(final WebSecurity webSecurity) throws Exception {
// No security for static content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;

import io.qameta.allure.Description;
import io.qameta.allure.Feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
Expand Down
1 change: 0 additions & 1 deletion hawkbit-dmf/hawkbit-dmf-amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<name>hawkBit :: DMF :: AMQP 0.9 Implementation</name>

<dependencies>

<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;

/**
* Set matcher for {@link SoftwareModule} and a list of
Expand Down Expand Up @@ -44,7 +43,6 @@ public final class SoftwareModuleJsonMatcher {
* @param expectedModules
* the json sofware modules.
*/
@Factory
public static SoftwareModulesMatcher containsExactly(final List<DmfSoftwareModule> expectedModules) {
return new SoftwareModulesMatcher(expectedModules);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
Expand Down
4 changes: 4 additions & 0 deletions hawkbit-repository/hawkbit-repository-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<artifactId>hawkbit-security-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Identifiable;
import org.springframework.security.access.prepost.PreAuthorize;

/**
Expand Down Expand Up @@ -70,7 +69,7 @@ public interface ArtifactManagement {

/**
* Garbage collects artifact binaries if only referenced by given
* {@link SoftwareModule#getId()} or {@link SoftwareModules} that are marged
* {@link SoftwareModule#getId()} or {@link SoftwareModule}'s that are marked
* as deleted.
*
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository;

import java.io.Serializable;

/**
* @param <T> the parameter of the class
*/
@FunctionalInterface
public interface Identifiable<T extends Serializable> {
AmmarBikic marked this conversation as resolved.
Show resolved Hide resolved

T getId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
package org.eclipse.hawkbit.repository.event.remote;

import org.eclipse.hawkbit.repository.Identifiable;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Target;
import org.springframework.hateoas.Identifiable;

import java.util.ArrayList;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
*/
package org.eclipse.hawkbit.repository.model;

import org.eclipse.hawkbit.repository.Identifiable;

import java.io.Serializable;

import org.springframework.hateoas.Identifiable;

/**
* Use to display software modules for the selected distribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/
package org.eclipse.hawkbit.repository.model;

import org.eclipse.hawkbit.repository.Identifiable;

import java.io.Serializable;
import java.util.concurrent.TimeUnit;

import org.springframework.hateoas.Identifiable;

/**
* Core information of all entities.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/
package org.eclipse.hawkbit.repository.model;

import org.eclipse.hawkbit.repository.Identifiable;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.springframework.hateoas.Identifiable;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void validateDurationInvalid() {
final String duration = "10";
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration))
.isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid")
.extracting("durationErrorIndex").containsExactly(2);
.extracting("durationErrorIndex").isEqualTo(2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
package org.eclipse.hawkbit.repository.builder;

import org.springframework.hateoas.Identifiable;
import org.eclipse.hawkbit.repository.Identifiable;

public abstract class AbstractBaseEntityBuilder implements Identifiable<Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public List<String> getActionHistoryMessages(final long actionId, final int mess
? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT
: messageCount;

final PageRequest pageable = PageRequest.of(0, limit, new Sort(Direction.DESC, "occurredAt"));
final PageRequest pageable = PageRequest.of(0, limit, Sort.by(Direction.DESC, "occurredAt"));
final Page<String> messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId,
RepositoryConstants.SERVER_MESSAGE_PREFIX + "%");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private void handleCreateRollout(final JpaRollout rollout) {
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());

final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(
PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")),
PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), Sort.by(Direction.ASC, "id")),
rollout.getId()).getContent();

int readyGroups = 0;
Expand Down
Loading