Skip to content

Commit 7c992fd

Browse files
committed
Merge branch 'release/v11.2.1' of https://github.com/utmstack/UTMStack into release/v11.2.1
2 parents 8e361ac + 36096cf commit 7c992fd

File tree

16 files changed

+540
-174
lines changed

16 files changed

+540
-174
lines changed

backend/src/main/java/com/park/utmstack/service/app_info/AppInfoService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class AppInfoService {
1616

1717
private static final String CLASSNAME = "AppInfoService";
1818

19-
public AppInfoDto loadVersionInfo() throws Exception {
19+
public AppInfoDto loadVersionInfo() {
2020
final String ctx = "loadVersionInfo";
2121
try {
2222
ObjectMapper mapper = new ObjectMapper();

backend/src/main/java/com/park/utmstack/service/impl/UtmAlertServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void checkForNewAlerts() {
8181

8282
List<FilterType> filters = new ArrayList<>();
8383
filters.add(new FilterType(Constants.alertStatus, OperatorType.IS, AlertStatus.OPEN.getCode()));
84+
filters.add(new FilterType(Constants.alertTags, OperatorType.DOES_NOT_CONTAIN, Constants.FALSE_POSITIVE_TAG));
8485
filters.add(new FilterType(Constants.timestamp, OperatorType.IS_GREATER_THAN, initialDate.getLastAlertTimestamp().toString()));
8586

8687
SearchRequest.Builder srb = new SearchRequest.Builder();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.park.utmstack.service.validators.tw_config;
2+
3+
import com.park.utmstack.domain.UtmConfigurationParameter;
4+
import com.park.utmstack.service.app_info.AppInfoService;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.validation.Errors;
8+
import org.springframework.validation.Validator;
9+
10+
@Service
11+
@RequiredArgsConstructor
12+
public class TwConfigValidatorService implements Validator {
13+
14+
private final AppInfoService infoService;
15+
16+
@Override
17+
public boolean supports(Class<?> clazz) {
18+
return UtmConfigurationParameter.class.equals(clazz);
19+
}
20+
21+
@Override
22+
public void validate(Object target, Errors errors) {
23+
UtmConfigurationParameter parameter = (UtmConfigurationParameter) target;
24+
25+
String value = parameter.getConfParamValue();
26+
if (value == null) {
27+
errors.rejectValue("confParamValue", "null", "Value cannot be null");
28+
return;
29+
}
30+
31+
String edition;
32+
try {
33+
edition = infoService.loadVersionInfo().getEdition();
34+
} catch (Exception e) {
35+
errors.reject("appInfo.error", "Could not determine application edition");
36+
return;
37+
}
38+
39+
if (!Boolean.parseBoolean(value) && "community".equals(edition)) {
40+
errors.rejectValue("confParamValue", "forbidden", "Forbidden to disable in COMMUNITY edition");
41+
}
42+
}
43+
}

backend/src/main/java/com/park/utmstack/web/rest/UtmConfigurationParameterResource.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
import com.park.utmstack.service.dto.UtmConfigurationParameterCriteria;
1010
import com.park.utmstack.service.mail_config.MailConfigService;
1111
import com.park.utmstack.service.validators.email.EmailValidatorService;
12+
import com.park.utmstack.service.validators.tw_config.TwConfigValidatorService;
1213
import com.park.utmstack.util.ResponseUtil;
1314
import com.park.utmstack.util.exceptions.UtmMailException;
1415
import com.park.utmstack.web.rest.util.PaginationUtil;
16+
import lombok.RequiredArgsConstructor;
1517
import org.slf4j.Logger;
1618
import org.slf4j.LoggerFactory;
1719
import org.springdoc.api.annotations.ParameterObject;
@@ -35,6 +37,7 @@
3537
* REST controller for managing UtmConfigurationParameter.
3638
*/
3739
@RestController
40+
@RequiredArgsConstructor
3841
@RequestMapping("/api")
3942
public class UtmConfigurationParameterResource {
4043

@@ -48,19 +51,7 @@ public class UtmConfigurationParameterResource {
4851
private final EmailValidatorService emailValidatorService;
4952
private final MailConfigService mailConfigService;
5053
private final UtmStackService utmStackService;
51-
public UtmConfigurationParameterResource(UtmConfigurationParameterService utmConfigurationParameterService,
52-
UtmConfigurationParameterQueryService utmConfigurationParameterQueryService,
53-
ApplicationEventService applicationEventService,
54-
EmailValidatorService emailValidatorService,
55-
MailConfigService mailConfigService,
56-
UtmStackService utmStackService) {
57-
this.utmConfigurationParameterService = utmConfigurationParameterService;
58-
this.utmConfigurationParameterQueryService = utmConfigurationParameterQueryService;
59-
this.applicationEventService = applicationEventService;
60-
this.emailValidatorService = emailValidatorService;
61-
this.mailConfigService = mailConfigService;
62-
this.utmStackService = utmStackService;
63-
}
54+
private final TwConfigValidatorService twConfigValidatorService;
6455

6556
/**
6657
* PUT /utm-configuration-parameters : Updates an existing utmConfigurationParameter.
@@ -76,16 +67,21 @@ public ResponseEntity<Void> updateConfigurationParameters(@Valid @RequestBody Li
7667
try {
7768
Assert.notEmpty(parameters, "There isn't any parameter to update");
7869
for (UtmConfigurationParameter parameter : parameters) {
70+
Errors errors = new BeanPropertyBindingResult(parameter, "utmConfigurationParameter");
71+
72+
if(parameter.getConfParamShort().equals("utmstack.tw.enable")){
73+
twConfigValidatorService.validate(parameter, errors);
74+
}
75+
7976
if(StringUtils.hasText(parameter.getConfParamRegexp())){
80-
Errors errors = new BeanPropertyBindingResult(parameter, "utmConfigurationParameter");
8177
emailValidatorService.validate(parameter, errors);
78+
}
8279

83-
if (errors.hasErrors()) {
84-
String msg = String.format("Validation failed for field %s.", parameter.getConfParamShort());
85-
log.error(msg);
86-
applicationEventService.createEvent(msg, ApplicationEventType.ERROR);
87-
return ResponseUtil.buildPreconditionFailedResponse(msg);
88-
}
80+
if (errors.hasErrors()) {
81+
String msg = String.format("Validation failed for field %s.", parameter.getConfParamShort());
82+
log.error(msg);
83+
applicationEventService.createEvent(msg, ApplicationEventType.ERROR);
84+
return ResponseUtil.buildPreconditionFailedResponse(msg);
8985
}
9086
}
9187
utmConfigurationParameterService.saveAll(parameters);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
6+
7+
<changeSet id="20260113001" author="manuel">
8+
9+
<update tableName="utm_module">
10+
<column name="module_category" value="Agents &amp; Syslog"/>
11+
<where>module_name = 'MACOS'</where>
12+
</update>
13+
14+
</changeSet>
15+
</databaseChangeLog>

backend/src/main/resources/config/liquibase/master.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,7 @@
301301

302302
<include file="config/liquibase/changelog/20260112001_add_threatwinds_credentials_section.xml" relativeToChangelogFile="false"/>
303303

304+
<include file="config/liquibase/changelog/20260113001_update_macos_integration_category.xml" relativeToChangelogFile="false"/>
305+
304306

305307
</databaseChangeLog>

0 commit comments

Comments
 (0)