Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
- Fixed the IP location component to accurately determine whether an IP address is public or private.
- Fixed communication from/to agents using secure connections.
- Fixed negative operator evaluation matching on wrong input value due to insufficient checking in correlation engine.
- Reorganized GeoIP database and threat intelligence loading into more modular functions for improved maintainability and code readability. Simplified caching, removed unused database function, and restructured rule-handling logic. Addressed minor variable renames and logging adjustments for consistency.
- Removed unused docker volume configuration for GeoIp.
- Fixed Kernel modules wheren't loaded because incorrect function call

## New Features
- Introduced new standards, sections, dashboards, and visualizations to compliance reports.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,29 @@ public AuthResponseDTO updateAgentAttributes(AgentRequestVM agentRequestVM) thro
final String ctx = CLASSNAME + ".updateAgentAttributes";
try {
AgentRequest req = agentRequestVM.getAgentRequest();
Metadata customHeaders = new Metadata();
customHeaders.put(Metadata.Key.of("key", Metadata.ASCII_STRING_MARSHALLER), agentRequestVM.getAgentKey());
customHeaders.put(Metadata.Key.of("id", Metadata.ASCII_STRING_MARSHALLER), String.valueOf(agentRequestVM.getId()));

// Validating the existence of the agent.
String currentUser = SecurityUtils.getCurrentUserLogin().orElseThrow(() -> new RuntimeException("No current user login"));
Agent agent = null;
String hostname = agentRequestVM.getHostname();

try {
agent = blockingStub.getAgentByHostname(Hostname.newBuilder().setHostname(hostname).build());
if (agent == null) {
String msg = String.format("%1$s: Agent %2$s could not be updated because no information was obtained from the agent", ctx, hostname);
log.error(msg);
throw new Exception(msg);
}
} catch (StatusRuntimeException e) {
if (e.getStatus().getCode() == Status.Code.NOT_FOUND) {
String msg = String.format("%1$s: Agent %2$s could not be updated because was not found", ctx, hostname);
log.error(msg);
throw new Exception(msg);
}
}

assert agent != null;
Metadata customHeaders = getCustomHeaders(agent);

Channel intercept = ClientInterceptors.intercept(grpcManagedChannel, MetadataUtils.newAttachHeadersInterceptor(customHeaders));
AgentServiceGrpc.AgentServiceBlockingStub newStub = AgentServiceGrpc.newBlockingStub(intercept);
Expand Down Expand Up @@ -163,9 +183,8 @@ public void deleteAgent(String hostname) {

AgentDelete request = AgentDelete.newBuilder().setDeletedBy(currentUser).build();

Metadata customHeaders = new Metadata();
customHeaders.put(Metadata.Key.of("key", Metadata.ASCII_STRING_MARSHALLER), agent.getAgentKey());
customHeaders.put(Metadata.Key.of("id", Metadata.ASCII_STRING_MARSHALLER), String.valueOf(agent.getId()));
assert agent != null;
Metadata customHeaders = getCustomHeaders(agent);

Channel intercept = ClientInterceptors.intercept(grpcManagedChannel, MetadataUtils.newAttachHeadersInterceptor(customHeaders));
AgentServiceGrpc.AgentServiceBlockingStub newStub = AgentServiceGrpc.newBlockingStub(intercept);
Expand All @@ -177,4 +196,11 @@ public void deleteAgent(String hostname) {
throw new RuntimeException(msg);
}
}

private Metadata getCustomHeaders (Agent agent) {
Metadata customHeaders = new Metadata();
customHeaders.put(Metadata.Key.of("key", Metadata.ASCII_STRING_MARSHALLER), agent.getAgentKey());
customHeaders.put(Metadata.Key.of("id", Metadata.ASCII_STRING_MARSHALLER), String.valueOf(agent.getId()));
return customHeaders;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
package com.park.utmstack.web.rest.vm;

import com.park.utmstack.service.grpc.AgentRequest;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/*
* Use this class when you need to update agent's attributes.
* To add new attributes to update, add it to the class. Actually only ip is permitted.
* */
public class AgentRequestVM {
@NotEmpty
private String ip;
@NotEmpty
private String hostname;
private String os;
private String platform;
private String version;
@NotEmpty
private String mac;
private String osMajorVersion;
private String osMinorVersion;
private String aliases;
private String addresses;
@NotEmpty
private String agentKey;
@Min(1)
private int id;


public AgentRequestVM() {}
Expand All @@ -32,14 +20,6 @@ public AgentRequest getAgentRequest() {
return AgentRequest.newBuilder()
.setIp(this.ip)
.setHostname(this.hostname)
.setOs(this.os)
.setPlatform(this.platform)
.setVersion(this.version)
.setMac(this.mac)
.setOsMajorVersion(this.osMajorVersion)
.setOsMinorVersion(this.osMinorVersion)
.setAliases(this.aliases)
.setAddresses(this.addresses)
.build();
}

Expand All @@ -58,84 +38,4 @@ public String getHostname() {
public void setHostname(String hostname) {
this.hostname = hostname;
}

public String getOs() {
return os;
}

public void setOs(String os) {
this.os = os;
}

public String getPlatform() {
return platform;
}

public void setPlatform(String platform) {
this.platform = platform;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getMac() {
return mac;
}

public void setMac(String mac) {
this.mac = mac;
}

public String getOsMajorVersion() {
return osMajorVersion;
}

public void setOsMajorVersion(String osMajorVersion) {
this.osMajorVersion = osMajorVersion;
}

public String getOsMinorVersion() {
return osMinorVersion;
}

public void setOsMinorVersion(String osMinorVersion) {
this.osMinorVersion = osMinorVersion;
}

public String getAliases() {
return aliases;
}

public void setAliases(String aliases) {
this.aliases = aliases;
}

public String getAddresses() {
return addresses;
}

public void setAddresses(String addresses) {
this.addresses = addresses;
}

public String getAgentKey() {
return agentKey;
}

public void setAgentKey(String agentKey) {
this.agentKey = agentKey;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ export class UtmAgentDetailComponent implements OnInit {
changeIp(event: string) {
this.loading = true;
const agent = {
id: this.agent.id,
hostname: this.agent.hostname,
ip: this.agentIp,
mac: this.macs.length > 0 ? this.macs[0] : '',
agentKey: this.agent.agentKey
};

this.agentManagerService.updateAgent(agent)
Expand Down