Skip to content

Commit a441574

Browse files
committed
Merge branch 'release/v11' of ssh://github.com/utmstack/UTMStack into release/v11
2 parents 97c8434 + 5e2ffc5 commit a441574

9 files changed

Lines changed: 47 additions & 52 deletions

File tree

agent/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ func main() {
168168
fmt.Println("[OK]")
169169

170170
fmt.Println("TLS certificates loaded successfully!")
171-
fmt.Println("NOTE: You may need to restart integrations with TLS enabled for changes to take effect.")
172171
time.Sleep(5 * time.Second)
173172

174173
case "check-tls-certs":

agent/modules/syslog.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ func (m *SyslogModule) enableUDP() {
258258
func (m *SyslogModule) disableTCP() {
259259
if m.TCPListener.IsEnabled && m.TCPListener.Port != "" {
260260
utils.Logger.Info("Server %s closed in port: %s protocol: TCP", m.DataType, m.TCPListener.Port)
261+
262+
if m.TCPListener.Listener != nil {
263+
if err := m.TCPListener.Listener.Close(); err != nil {
264+
utils.Logger.ErrorF("error closing TCP listener: %v", err)
265+
}
266+
}
267+
261268
m.TCPListener.Cancel()
262269
m.TCPListener.IsEnabled = false
263270
}
@@ -266,6 +273,13 @@ func (m *SyslogModule) disableTCP() {
266273
func (m *SyslogModule) disableUDP() {
267274
if m.UDPListener.IsEnabled && m.UDPListener.Port != "" {
268275
utils.Logger.Info("Server %s closed in port: %s protocol: UDP", m.DataType, m.UDPListener.Port)
276+
277+
if m.UDPListener.Listener != nil {
278+
if err := m.UDPListener.Listener.Close(); err != nil {
279+
utils.Logger.ErrorF("error closing UDP listener: %v", err)
280+
}
281+
}
282+
269283
m.UDPListener.Cancel()
270284
m.UDPListener.IsEnabled = false
271285
}

backend/src/main/java/com/park/utmstack/config/Constants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ public final class Constants {
151151
public static final String ENV_TFA_ENABLE = "APP_TFA_ENABLED";
152152
public static final String TFA_EXEMPTION_HEADER = "X-Bypass-TFA";
153153

154+
// Configuration data types for moduleGroupConfiguration
155+
156+
public static final String CONF_TYPE_PASSWORD = "password";
157+
public static final String CONF_TYPE_FILE = "file";
158+
154159
private Constants() {
155160
}
156161
}

backend/src/main/java/com/park/utmstack/domain/UtmDataInputStatus.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ public class UtmDataInputStatus implements Serializable {
3535
@Column(name = "source", length = 256, nullable = false)
3636
private String source;
3737

38-
@ManyToOne(fetch = FetchType.LAZY)
39-
@JoinColumn(name = "source", referencedColumnName = "asset_name", insertable = false, updatable = false, nullable = false)
40-
@JsonIgnore
41-
private UtmNetworkScan assetName;
42-
43-
@ManyToOne(fetch = FetchType.LAZY)
44-
@JoinColumn(name = "source", referencedColumnName = "asset_ip", insertable = false, updatable = false, nullable = false)
45-
@JsonIgnore
46-
private UtmNetworkScan assetIp;
47-
4838
@NotNull
4939
@Size(max = 50)
5040
@Column(name = "data_type", length = 50, nullable = false)

backend/src/main/java/com/park/utmstack/domain/application_modules/validators/UtmModuleConfigValidator.java

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,40 @@ public class UtmModuleConfigValidator {
2121
private final UtmModuleGroupConfigurationRepository moduleGroupConfigurationRepository;
2222
private final UtmStackConnectionService utmStackConnectionService;
2323

24-
/**
25-
* Validates if the given configuration allows a successful connection to UTMStack.
26-
*
27-
* @param keys A list of configuration keys that should include at least `ipAddress` and `connectionKey`.
28-
* @return true if login and ping are successful; false otherwise.
29-
* @throws Exception If required fields are missing or the connection fails.
30-
*/
3124
public boolean validate(UtmModule module, List<UtmModuleGroupConfiguration> keys) throws Exception {
3225
if (keys.isEmpty()) return false;
3326

34-
List<UtmModuleGroupConfiguration> configurations = moduleGroupConfigurationRepository
35-
.findAllByGroupId(keys.get(0).getGroupId())
36-
.stream()
37-
.map(c -> {
38-
if (this.containsConfigInKeys(keys, c.getConfKey()) != null) {
39-
return this.containsConfigInKeys(keys, c.getConfKey());
40-
} else {
41-
if ("password".equals(c.getConfDataType())) {
42-
c.setConfValue(CipherUtil.decrypt(
43-
c.getConfValue(),
44-
System.getenv(Constants.ENV_ENCRYPTION_KEY)
45-
));
46-
}
47-
return c;
48-
}
49-
})
50-
.collect(Collectors.toList());
27+
List<UtmModuleGroupConfiguration> dbConfigs = moduleGroupConfigurationRepository
28+
.findAllByGroupId(keys.get(0).getGroupId());
29+
30+
List<UtmModuleGroupConfDTO> configDTOs = dbConfigs.stream()
31+
.map(dbConf -> {
32+
UtmModuleGroupConfiguration override = findInKeys(keys, dbConf.getConfKey());
33+
UtmModuleGroupConfiguration source = override != null ? override : dbConf;
5134

52-
List<UtmModuleGroupConfDTO> configDTOs = configurations.stream()
53-
.map(entity -> new UtmModuleGroupConfDTO(entity.getConfKey(), entity.getConfValue()))
54-
.collect(Collectors.toList());
35+
return new UtmModuleGroupConfDTO(
36+
source.getConfKey(),
37+
decryptIfNeeded(source.getConfDataType(), source.getConfValue())
38+
);
39+
})
40+
.toList();
5541

5642
UtmModuleGroupConfWrapperDTO body = new UtmModuleGroupConfWrapperDTO(configDTOs);
5743

58-
return utmStackConnectionService.testConnection(module.getModuleName().name(),body);
44+
return utmStackConnectionService.testConnection(module.getModuleName().name(), body);
5945
}
6046

61-
private UtmModuleGroupConfiguration containsConfigInKeys(List<UtmModuleGroupConfiguration> keys, String confKey) {
47+
private UtmModuleGroupConfiguration findInKeys(List<UtmModuleGroupConfiguration> keys, String confKey) {
6248
return keys.stream()
63-
.filter(key -> key.getConfKey().equals(confKey))
49+
.filter(k -> k.getConfKey().equals(confKey))
6450
.findFirst()
6551
.orElse(null);
6652
}
53+
54+
private String decryptIfNeeded(String dataType, String value) {
55+
if (Constants.CONF_TYPE_PASSWORD.equals(dataType) || Constants.CONF_TYPE_FILE.equals(dataType)) {
56+
return CipherUtil.decrypt(value, System.getenv(Constants.ENV_ENCRYPTION_KEY));
57+
}
58+
return value;
59+
}
6760
}

backend/src/main/java/com/park/utmstack/domain/network_scan/UtmNetworkScan.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ public class UtmNetworkScan implements Serializable {
140140
@OneToMany(mappedBy = "asset", fetch = FetchType.LAZY)
141141
private List<UtmAssetMetrics> metrics;
142142

143-
/*@OneToMany(mappedBy = "assetName", fetch = FetchType.LAZY)
144-
private List<UtmDataInputStatus> dataInputSourceList;
145-
146-
@OneToMany(mappedBy = "assetIp", fetch = FetchType.LAZY)
147-
private List<UtmDataInputStatus> dataInputIpList;*/
148-
149143
@OneToOne
150144
@JoinColumn(name = "group_id", referencedColumnName = "id", insertable = false, updatable = false)
151145
private UtmAssetGroup assetGroup;

backend/src/main/java/com/park/utmstack/event_processor/EventProcessorManagerService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void decryptModuleConfig (UtmModule module){
6262
Set<UtmModuleGroup> groups = module.getModuleGroups();
6363
groups.forEach((gp) -> {
6464
gp.getModuleGroupConfigurations().forEach((gpc) -> {
65-
if ((gpc.getConfDataType().equals("password") && StringUtils.hasText(gpc.getConfValue()))
66-
|| (gpc.getConfDataType().equals("file") && StringUtils.hasText(gpc.getConfValue())) && typeFileNeedsDecryptList.contains(module.getModuleName())) {
65+
if ((gpc.getConfDataType().equals(Constants.CONF_TYPE_PASSWORD) && StringUtils.hasText(gpc.getConfValue()))
66+
|| (gpc.getConfDataType().equals(Constants.CONF_TYPE_FILE) && StringUtils.hasText(gpc.getConfValue())) && typeFileNeedsDecryptList.contains(module.getModuleName())) {
6767
gpc.setConfValue(CipherUtil.decrypt(gpc.getConfValue(), System.getenv(Constants.ENV_ENCRYPTION_KEY)));
6868
}
6969
});

backend/src/main/java/com/park/utmstack/repository/network_scan/UtmNetworkScanRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public interface UtmNetworkScanRepository extends JpaRepository<UtmNetworkScan,
5656
"AND ((cast(:initDate as timestamp) is null) or (cast(:endDate as timestamp) is null) or (ns.discoveredAt BETWEEN :initDate AND :endDate)) " +
5757
"AND (:dataTypes IS NULL OR EXISTS (\n" +
5858
" SELECT 1 FROM UtmDataInputStatus ip\n" +
59-
" WHERE ip.assetIp = ns.assetIp AND ip.dataType IN :dataTypes\n" +
59+
" WHERE ip.source = ns.assetIp AND ip.dataType IN :dataTypes\n" +
6060
" ) \n" +
6161
" OR EXISTS (\n" +
6262
" SELECT 1 FROM UtmDataInputStatus src\n" +
63-
" WHERE src.assetName = ns.assetName AND src.dataType IN :dataTypes\n" +
63+
" WHERE src.source = ns.assetName AND src.dataType IN :dataTypes\n" +
6464
" ))" +
6565
"AND (:ports IS NULL OR ns.id IN (" +
6666
" SELECT p.scanId FROM UtmPorts p WHERE p.port IN :ports))")

frontend/src/app/shared/components/auth/login/login.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class LoginComponent implements OnInit {
151151
this.startLogin = false;
152152
this.authenticationError = true;
153153
const utmStackError = err.headers.get('X-UtmStack-error');
154-
if (utmStackError.includes('UserJWTController.authorize: blocked')) {
154+
if (utmStackError && utmStackError.includes('UserJWTController.authorize: blocked')) {
155155
this.utmToast.showError('Login blocked', 'Your ip was blocked due multiple login failures, please try again in 10 minutes');
156156
} else {
157157
this.utmToast.showError('Login fail', 'Authentication error, ' +

0 commit comments

Comments
 (0)