Skip to content

Commit

Permalink
Merge pull request #1969 from reportportal/hotfix/5.11.1
Browse files Browse the repository at this point in the history
Hotfix 5.11.1
  • Loading branch information
IvanKustau authored Apr 18, 2024
2 parents 0c426d5 + 9d71a7f commit b39dadd
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
GH_USER_NAME: github.actor
RELEASE_VERSION: 5.11.0
RELEASE_VERSION: 5.11.1
REPOSITORY_URL: 'https://maven.pkg.github.com/'

jobs:
Expand Down
27 changes: 19 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ext['spring-boot.version'] = '2.5.15'

dependencyManagement {
imports {
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.11.6' : 'com.epam.reportportal:commons-bom:5.11.6')
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.11.7' : 'com.epam.reportportal:commons-bom:5.11.7')
mavenBom('io.zonky.test.postgres:embedded-postgres-binaries-bom:12.9.0')
}
}
Expand All @@ -71,15 +71,15 @@ dependencies {
implementation 'com.epam.reportportal:commons-model'
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:commons-fonts'
implementation 'com.epam.reportportal:plugin-api'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
} else {
implementation 'com.epam.reportportal:commons-events'
implementation 'com.epam.reportportal:commons-dao'
implementation 'com.epam.reportportal:commons-rules'
implementation 'com.epam.reportportal:commons-model'
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:commons-fonts'
implementation 'com.epam.reportportal:plugin-api'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
}

implementation 'org.springframework.boot:spring-boot-starter-aop'
Expand All @@ -90,13 +90,19 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-batch'

//Fix CVE-2023-34050
implementation 'org.springframework.amqp:spring-amqp:2.4.17'

//Fix CVE-2023-40827, CVE-2023-40828, CVE-2023-40826
implementation 'org.springframework:spring-webmvc:5.3.33'
implementation 'org.springframework:spring-web:5.3.33'

implementation 'com.opencsv:opencsv:5.8'

// Fix CVE-2021-41079, CVE-2022-23181, CVE-2021-33037, CVE-2021-30640, CVE-2022-42252
implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.82'
implementation 'org.apache.tomcat.embed:tomcat-embed-el:9.0.82'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.82'
// Fix CVE-2023-46589, CVE-2024-24549
implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.86'
implementation 'org.apache.tomcat.embed:tomcat-embed-el:9.0.86'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.86'
//

//https://nvd.nist.gov/vuln/detail/CVE-2020-5411
Expand Down Expand Up @@ -139,10 +145,15 @@ dependencies {
implementation 'org.codehaus.jettison:jettison:1.5.4'
// Fix CVE-2020-15522
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'org.apache.commons:commons-compress:1.25.0'
// Fix CVE-2024-25710, CVE-2024-26308
implementation 'org.apache.commons:commons-compress:1.26.0'
implementation 'org.yaml:snakeyaml:1.33'
implementation 'org.hibernate:hibernate-core:5.6.15.Final'

//Fix CVE-2023-6378, CVE-2023-6481, CVE-2023-6378, CVE-2023-6481
implementation 'ch.qos.logback:logback-classic:1.2.13'
implementation 'ch.qos.logback:logback-core:1.2.13'

// Metrics
implementation 'io.micrometer:micrometer-registry-prometheus:1.8.13'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.11.0
version=5.11.1
description=EPAM Report portal. Main API Service
dockerPrepareEnvironment=
dockerJavaOpts=-Xmx1g -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=70 -Djava.security.egd=file:/dev/./urandom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.pf4j.PluginException;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;

/**
Expand All @@ -35,9 +35,9 @@ public interface PluginLoader {
*
* @param pluginPath Plugin's path
* @return {@link PluginInfo} with {@link PluginInfo#getId()} and {@link PluginInfo#getVersion()}
* @throws PluginException if there is an issue in loading the plugin or the plugin is not found in the specified path
* @throws PluginRuntimeException if there is an issue in loading the plugin or the plugin is not found in the specified path
*/
PluginInfo extractPluginInfo(Path pluginPath) throws PluginException;
PluginInfo extractPluginInfo(Path pluginPath) throws PluginRuntimeException;

/**
* Creates the {@link IntegrationTypeDetails} object based on the params of the plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.apache.commons.lang3.StringUtils;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginDescriptorFinder;
import org.pf4j.PluginException;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -87,7 +87,7 @@ public PluginLoaderImpl(DataStore dataStore, IntegrationTypeRepository integrati

@Override
@NotNull
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginException {
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginRuntimeException {
PluginDescriptor pluginDescriptor = pluginDescriptorFinder.find(pluginPath);
return new PluginInfo(pluginDescriptor.getPluginId(), pluginDescriptor.getVersion());
}
Expand All @@ -99,8 +99,7 @@ public IntegrationTypeDetails resolvePluginDetails(PluginInfo pluginInfo) {
.flatMap(it -> ofNullable(it.getDetails())).flatMap(
typeDetails -> IntegrationTypeProperties.VERSION.getValue(typeDetails.getDetails())
.map(String::valueOf)).ifPresent(
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase(
pluginInfo.getVersion()))
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase(pluginInfo.getVersion()))
.verify(
ErrorType.PLUGIN_UPLOAD_ERROR, Suppliers.formattedSupplier(
"Plugin with ID = '{}' of the same VERSION = '{}' "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.epam.ta.reportportal.entity.enums.StatusEnum.FAILED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.INFO;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.PASSED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.SKIPPED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.WARN;
import static com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE;
import static java.util.Optional.ofNullable;
Expand Down Expand Up @@ -93,6 +94,7 @@ private boolean isParentStatusUpdateRequired(TestItem parent) {
return parent.getItemResults().getStatus() != StatusEnum.IN_PROGRESS
&& parent.getItemResults().getStatus() != PASSED
&& parent.getItemResults().getStatus() != FAILED
&& parent.getItemResults().getStatus() != SKIPPED
&& !testItemRepository.hasItemsInStatusByParent(parent.getItemId(), parent.getPath(),
StatusEnum.IN_PROGRESS.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.epam.ta.reportportal.commons.querygen.Queryable;
import com.epam.ta.reportportal.entity.jasper.ReportFormat;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.ws.model.project.ProjectResource;
import com.epam.ta.reportportal.ws.model.user.SearchUserResource;
import com.epam.ta.reportportal.ws.model.user.UserResource;
Expand Down Expand Up @@ -87,7 +88,7 @@ public interface GetProjectHandler {
* @param pageable {@link Pageable} Page Details
* @return List of found user resources
*/
Iterable<SearchUserResource> getUserNames(String value,
Iterable<SearchUserResource> getUserNames(String value, UserRole userRole,
ReportPortalUser.ProjectDetails projectDetails, Pageable pageable);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.project.ProjectInfo;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler;
import com.epam.ta.reportportal.ws.converter.converters.ProjectConverter;
Expand All @@ -43,6 +44,7 @@
import org.jooq.Operator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -77,15 +79,18 @@ public class GetProjectHandlerImpl implements GetProjectHandler {

private final ProjectConverter projectConverter;

@Autowired
public GetProjectHandlerImpl(ProjectRepository projectRepository, UserRepository userRepository,
@Qualifier("projectJasperReportHandler") GetJasperReportHandler<ProjectInfo> jasperReportHandler,
ProjectConverter projectConverter) {
this.projectRepository = projectRepository;
this.userRepository = userRepository;
this.jasperReportHandler = jasperReportHandler;
this.projectConverter = projectConverter;
}
@Value("${rp.environment.variable.user.suggestions:true}")
boolean isUserSuggestions;

@Autowired
public GetProjectHandlerImpl(ProjectRepository projectRepository, UserRepository userRepository,
@Qualifier("projectJasperReportHandler") GetJasperReportHandler<ProjectInfo> jasperReportHandler,
ProjectConverter projectConverter) {
this.projectRepository = projectRepository;
this.userRepository = userRepository;
this.jasperReportHandler = jasperReportHandler;
this.projectConverter = projectConverter;
}

@Override
public Iterable<UserResource> getProjectUsers(String projectName, Filter filter, Pageable pageable) {
Expand Down Expand Up @@ -147,10 +152,13 @@ private void checkBusinessRuleLessThan1Symbol(String value) {
}

@Override
public Iterable<SearchUserResource> getUserNames(String value, ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) {
public Iterable<SearchUserResource> getUserNames(String value, UserRole userRole,
ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) {
checkBusinessRuleLessThan1Symbol(value);

final CompositeFilterCondition userCondition = getUserSearchCondition(value);
final CompositeFilterCondition userCondition =
(userRole.equals(UserRole.ADMINISTRATOR) || isUserSuggestions)
? getUserSearchSuggestCondition(value) : getUserSearchCondition(value);

final Filter filter = Filter.builder()
.withTarget(User.class)
Expand All @@ -162,13 +170,19 @@ public Iterable<SearchUserResource> getUserNames(String value, ReportPortalUser.
.apply(userRepository.findByFilterExcludingProjects(filter, pageable));
}

private CompositeFilterCondition getUserSearchCondition(String value) {
private CompositeFilterCondition getUserSearchSuggestCondition(String value) {
return new CompositeFilterCondition(List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_USER),
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_FULL_NAME),
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_EMAIL)
), Operator.AND);
}

private CompositeFilterCondition getUserSearchCondition(String value) {
return new CompositeFilterCondition(List.of(
new FilterCondition(Operator.OR, Condition.EQUALS, false, value, CRITERIA_EMAIL)
), Operator.AND);
}

@Override
public List<String> getAllProjectNames() {
return projectRepository.findAllProjectNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.digester.plugins.PluginException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.pf4j.PluginException;
import org.pf4j.PluginManager;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginState;
import org.pf4j.PluginWrapper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -385,7 +386,7 @@ private PluginInfo resolvePluginInfo(final String fileName, InputStream fileStre
BusinessRule.expect(validatePluginMetaInfo(newPluginInfo), equalTo(Boolean.TRUE))
.verify(ErrorType.PLUGIN_UPLOAD_ERROR, "Plugin version should be specified.");
return newPluginInfo;
} catch (PluginException e) {
} catch (PluginRuntimeException e) {
removeUploadingPlugin(fileName);
throw new ReportPortalException(ErrorType.PLUGIN_UPLOAD_ERROR, e.getMessage());
}
Expand Down Expand Up @@ -746,7 +747,7 @@ private PluginState loadPreviousPlugin(PluginWrapper previousPlugin,
previousPlugin.getPluginId())
.get()
)));
} catch (PluginException e) {
} catch (PluginRuntimeException e) {
throw new ReportPortalException(ErrorType.PLUGIN_UPLOAD_ERROR,
Suppliers.formattedSupplier("Unable to reload previousPlugin with id = '{}': '{}'",
previousPlugin.getPluginId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ public ReportPortalExtensionFactory(String resourcesDir, PluginManager pluginMan
}

@Override
public Object create(Class<?> extensionClass) {
public <T> T create(Class<T> extensionClass) {
PluginWrapper pluginWrapper = pluginManager.whichPlugin(extensionClass);
if (beanFactory.containsSingleton(pluginWrapper.getPluginId())) {
return beanFactory.getSingleton(pluginWrapper.getPluginId());
return extensionClass.cast(beanFactory.getSingleton(pluginWrapper.getPluginId()));
} else {
return createExtension(extensionClass, pluginWrapper);
return extensionClass.cast(createExtension(extensionClass, pluginWrapper));
}
}

private Object createExtension(Class<?> extensionClass, PluginWrapper pluginWrapper) {
private <T> T createExtension(Class<T> extensionClass, PluginWrapper pluginWrapper) {
Map<String, Object> initParams = getInitParams(pluginWrapper);
Object plugin = createPlugin(extensionClass, initParams);
T plugin = createPlugin(extensionClass, initParams);
beanFactory.autowireBean(plugin);
beanFactory.initializeBean(plugin, pluginWrapper.getDescriptor().getPluginId());
beanFactory.registerSingleton(pluginWrapper.getDescriptor().getPluginId(), plugin);
Expand All @@ -66,7 +66,7 @@ private Object createExtension(Class<?> extensionClass, PluginWrapper pluginWrap
return plugin;
}

private Object createPlugin(Class<?> extensionClass, Map<String, Object> initParams) {
private <T> T createPlugin(Class<T> extensionClass, Map<String, Object> initParams) {
try {
return extensionClass.getDeclaredConstructor(Map.class).newInstance(initParams);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public List<String> getProjectUsers(@PathVariable String projectName,
public Iterable<SearchUserResource> searchForUser(@PathVariable String projectName,
@RequestParam(value = "term") String term,
Pageable pageable, @AuthenticationPrincipal ReportPortalUser user) {
return getProjectHandler.getUserNames(term,
return getProjectHandler.getUserNames(term, user.getUserRole(),
projectExtractor.extractProjectDetails(user, projectName), pageable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,17 @@ private void createItemLog(SaveLogRQ request, TestItem item, BinaryDataMetaInfo
Launch effectiveLaunch = testItemService.getEffectiveLaunch(item);
logService.saveLogMessage(logFull, effectiveLaunch.getId());

if (Objects.nonNull(request.getFile())) {saveAttachment(request.getFile().getName(), metaInfo,
logFull.getId(),
projectId,
effectiveLaunch.getId(),
item.getItemId(),
effectiveLaunch.getUuid(),
logFull.getUuid()
);
}}
if (Objects.nonNull(request.getFile())) {
saveAttachment(request.getFile().getName(), metaInfo,
logFull.getId(),
projectId,
effectiveLaunch.getId(),
item.getItemId(),
effectiveLaunch.getUuid(),
logFull.getUuid()
);
}
}

private void createLaunchLog(SaveLogRQ request, Launch launch, BinaryDataMetaInfo metaInfo,
Long projectId) {
Expand All @@ -331,9 +333,12 @@ private void createLaunchLog(SaveLogRQ request, Launch launch, BinaryDataMetaInf
logFull.setId(log.getId());
logService.saveLogMessage(logFull, launch.getId());

saveAttachment(request.getFile().getName(), metaInfo, logFull.getId(), projectId, launch.getId(),
null, launch.getUuid(),
logFull.getUuid());
if (Objects.nonNull(request.getFile())) {
saveAttachment(request.getFile().getName(), metaInfo, logFull.getId(), projectId,
launch.getId(),
null, launch.getUuid(),
logFull.getUuid());
}
}

private void saveAttachment(String fileName, BinaryDataMetaInfo metaInfo, Long logId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.junit.jupiter.api.Test;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginDescriptorFinder;
import org.pf4j.PluginException;
import org.pf4j.PluginManager;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ class PluginLoaderTest {
);

@Test
void shouldExtractPluginIdWhenExists() throws PluginException {
void shouldExtractPluginIdWhenExists() throws PluginRuntimeException {

Path path = Paths.get("dir", FILE_NAME);

Expand Down
Loading

0 comments on commit b39dadd

Please sign in to comment.