Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions .github/workflows/principal-multi-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
$env:GOARCH = "amd64"
go build -o utmstack_agent_service.exe -v .
signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /f "${{ vars.SIGN_CERT }}" /csp "eToken Base Cryptographic Provider" /k "[{{${{ secrets.SIGN_KEY }}}}]=${{ secrets.SIGN_CONTAINER }}" "utmstack_agent_service.exe"
# $env:GOARCH = "arm64"
# go build -o utmstack_agent_service_arm64.exe -v .
# signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /f "${{ vars.SIGN_CERT }}" /csp "eToken Base Cryptographic Provider" /k "[{{${{ secrets.SIGN_KEY }}}}]=${{ secrets.SIGN_CONTAINER }}" "utmstack_agent_service_arm64.exe"
$env:GOARCH = "arm64"
go build -o utmstack_agent_service_arm64.exe -v .
signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /f "${{ vars.SIGN_CERT }}" /csp "eToken Base Cryptographic Provider" /k "[{{${{ secrets.SIGN_KEY }}}}]=${{ secrets.SIGN_CONTAINER }}" "utmstack_agent_service_arm64.exe"

echo "Agent build completed"

Expand All @@ -74,7 +74,7 @@ jobs:
Copy-Item -Path "${{ github.workspace }}/agent/utmstack_agent_service" -Destination "./dependencies/agent/"
# Copy-Item -Path "${{ github.workspace }}/agent/utmstack_agent_service_arm64" -Destination "./dependencies/agent/"
Copy-Item -Path "${{ github.workspace }}/agent/utmstack_agent_service.exe" -Destination "./dependencies/agent/"
# Copy-Item -Path "${{ github.workspace }}/agent/utmstack_agent_service_arm64.exe" -Destination "./dependencies/agent/"
Copy-Item -Path "${{ github.workspace }}/agent/utmstack_agent_service_arm64.exe" -Destination "./dependencies/agent/"
Copy-Item -Path "${{ github.workspace }}/agent/version.json" -Destination "./dependencies/agent/"

docker build -t ghcr.io/utmstack/utmstack/agent-manager:${{ needs.setup_deployment.outputs.env_version }} .
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# UTMStack 10.6.3 Release Notes
# UTMStack 10.7.0 Release Notes
## New Features and Improvements
- **Agent & Collector Dependencies**: agents and collectors now fetch their dependencies from the **agent-manager**, improving consistency and centralizing dependency management.

Expand All @@ -7,3 +7,9 @@
- **Agent Service Cleanup**: removed unnecessary services to streamline the system and reduce overhead.

- **Error Recovery**: enhanced the agent's ability to recover from certain data streaming errors when interacting with the agent-manager, improving stability and fault tolerance.

- **Debug Mode for Agents**: Added a debug mode for agents, allowing better troubleshooting and logging for debugging purposes.

- **Certificate Verification Improvements**: Improved certificate verification in agents to enhance security and prevent connection issues.

- **Windows ARM64 Agent Support**: Added support for a Windows ARM64 agent, expanding compatibility to more architectures.
18 changes: 15 additions & 3 deletions agent/agent/incident_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func IncidentResponseStream(cnf *config.Config, ctx context.Context) {
if !connErrMsgWritten {
utils.Logger.ErrorF("failed to start AgentStream: %v", err)
connErrMsgWritten = true
} else {
utils.Logger.LogF(100, "failed to start AgentStream: %v", err)
}
time.Sleep(timeToSleep)
continue
Expand All @@ -46,6 +48,7 @@ func IncidentResponseStream(cnf *config.Config, ctx context.Context) {
in, err := stream.Recv()
if err != nil {
if strings.Contains(err.Error(), "EOF") {
utils.Logger.LogF(100, "error receiving command from server: %v", err)
time.Sleep(timeToSleep)
break
}
Expand All @@ -54,13 +57,17 @@ func IncidentResponseStream(cnf *config.Config, ctx context.Context) {
if !errorLogged {
utils.Logger.ErrorF("error receiving command from server: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error receiving command from server: %v", err)
}
time.Sleep(timeToSleep)
break
} else {
if !errorLogged {
utils.Logger.ErrorF("error receiving command from server: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error receiving command from server: %v", err)
}
time.Sleep(timeToSleep)
continue
Expand All @@ -72,6 +79,7 @@ func IncidentResponseStream(cnf *config.Config, ctx context.Context) {
err = commandProcessor(path, stream, cnf, []string{msg.Command.Command, in.GetCommand().CmdId})
if err != nil {
if strings.Contains(err.Error(), "EOF") {
utils.Logger.LogF(100, "error sending result to server: %v", err)
time.Sleep(timeToSleep)
break
}
Expand All @@ -80,13 +88,17 @@ func IncidentResponseStream(cnf *config.Config, ctx context.Context) {
if !errorLogged {
utils.Logger.ErrorF("error sending result to server: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error sending result to server: %v", err)
}
time.Sleep(timeToSleep)
break
} else {
if !errorLogged {
utils.Logger.ErrorF("error sending result to server: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error sending result to server: %v", err)
}
time.Sleep(timeToSleep)
continue
Expand All @@ -102,7 +114,7 @@ func commandProcessor(path string, stream AgentService_AgentStreamClient, cnf *c
var result string
var errB bool

utils.Logger.Info("Received command: %s", commandPair[0])
utils.Logger.LogF(100, "Received command: %s", commandPair[0])

switch runtime.GOOS {
case "windows":
Expand All @@ -116,7 +128,7 @@ func commandProcessor(path string, stream AgentService_AgentStreamClient, cnf *c
if errB {
utils.Logger.ErrorF("error executing command %s: %s", commandPair[0], result)
} else {
utils.Logger.Info("Result when executing the command %s: %s", commandPair[0], result)
utils.Logger.LogF(100, "Result when executing the command %s: %s", commandPair[0], result)
}

if err := stream.Send(&BidirectionalStream{
Expand All @@ -126,7 +138,7 @@ func commandProcessor(path string, stream AgentService_AgentStreamClient, cnf *c
}); err != nil {
return err
} else {
utils.Logger.Info("Result sent to server successfully!!!")
utils.Logger.LogF(100, "Result sent to server successfully!!!")
}
return nil
}
11 changes: 11 additions & 0 deletions agent/agent/ping_imp.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func StartPing(cnf *config.Config, ctx context.Context) {
if !connErrMsgWritten {
utils.Logger.ErrorF("error connecting to Agent Manager: %v", err)
connErrMsgWritten = true
} else {
utils.Logger.LogF(100, "error connecting to Agent Manager: %v", err)
}
time.Sleep(timeToSleep)
continue
Expand All @@ -37,11 +39,14 @@ func StartPing(cnf *config.Config, ctx context.Context) {
if !connErrMsgWritten {
utils.Logger.ErrorF("failed to start Ping Stream: %v", err)
connErrMsgWritten = true
} else {
utils.Logger.LogF(100, "failed to start Ping Stream: %v", err)
}
time.Sleep(timeToSleep)
continue
}

utils.Logger.LogF(100, "Ping Stream started")
connErrMsgWritten = false

ticker := time.NewTicker(pingInterval)
Expand All @@ -50,6 +55,7 @@ func StartPing(cnf *config.Config, ctx context.Context) {
err := stream.Send(&PingRequest{Type: ConnectorType_AGENT})
if err != nil {
if strings.Contains(err.Error(), "EOF") {
utils.Logger.LogF(100, "error sending Ping request: %v", err)
time.Sleep(timeToSleep)
break
}
Expand All @@ -58,20 +64,25 @@ func StartPing(cnf *config.Config, ctx context.Context) {
if !errorLogged {
utils.Logger.ErrorF("error sending Ping request: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error sending Ping request: %v", err)
}
time.Sleep(timeToSleep)
break
} else {
if !errorLogged {
utils.Logger.ErrorF("error sending Ping request: %v", err)
errorLogged = true
} else {
utils.Logger.LogF(100, "error sending Ping request: %v", err)
}
time.Sleep(timeToSleep)
continue
}
}

errorLogged = false
utils.Logger.LogF(100, "Ping request sent")
}

ticker.Stop()
Expand Down
2 changes: 2 additions & 0 deletions agent/agent/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ func RegisterAgent(cnf *config.Config, UTMKey string) error {
cnf.AgentID = uint(response.Id)
cnf.AgentKey = response.Key

utils.Logger.LogF(100, "Agent registered with ID: %v", cnf.AgentID)

return nil
}
10 changes: 7 additions & 3 deletions agent/agent/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ func UpdateAgent(cnf *config.Config, ctx context.Context) error {
}

version := models.Version{}
err = utils.ReadJson(config.VersionPath, &version)
if err != nil {
utils.Logger.Fatal("error reading version file: %v", err)
if utils.CheckIfPathExist(config.VersionPath) {
err = utils.ReadJson(config.VersionPath, &version)
if err != nil {
utils.Logger.Fatal("error reading version file: %v", err)
}
} else {
version.Version = "10.6.0"
}

request := &AgentRequest{
Expand Down
20 changes: 2 additions & 18 deletions agent/collectors/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package collectors

import (
"fmt"
"runtime"

"github.com/utmstack/UTMStack/agent/utils"
)
Expand All @@ -18,21 +17,6 @@ type Collector interface {
Uninstall() error
}

func getCollectorsInstances() []Collector {
var collectors []Collector
switch runtime.GOOS {
case "windows":
collectors = append(collectors, Windows{})
if runtime.GOARCH == "amd64" {
collectors = append(collectors, Filebeat{})
}
case "linux":
collectors = append(collectors, Filebeat{})
}

return collectors
}

func InstallCollectors() error {
collectors := getCollectorsInstances()

Expand All @@ -43,7 +27,7 @@ func InstallCollectors() error {
}
}

utils.Logger.Info("collector installed correctly")
utils.Logger.LogF(100, "collectors installed correctly")

return nil
}
Expand All @@ -65,6 +49,6 @@ func UninstallCollectors() error {
}
}

utils.Logger.Info("collectors uninstalled correctly")
utils.Logger.LogF(100, "collectors uninstalled correctly")
return nil
}
File renamed without changes.
11 changes: 11 additions & 0 deletions agent/collectors/linux_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build linux && amd64
// +build linux,amd64

package collectors

func getCollectorsInstances() []Collector {
var collectors []Collector
collectors = append(collectors, Filebeat{})

return collectors
}
8 changes: 8 additions & 0 deletions agent/collectors/windows_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import (

type Windows struct{}

func getCollectorsInstances() []Collector {
var collectors []Collector
collectors = append(collectors, Windows{})
collectors = append(collectors, Filebeat{})

return collectors
}

func (w Windows) Install() error {
path := utils.GetMyPath()

Expand Down
15 changes: 11 additions & 4 deletions agent/collectors/windows_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
package collectors

import (
"github.com/utmstack/UTMStack/agent/config"
"github.com/utmstack/UTMStack/agent/logservice"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/utmstack/UTMStack/agent/config"
"github.com/utmstack/UTMStack/agent/logservice"

"github.com/threatwinds/validations"
"github.com/utmstack/UTMStack/agent/utils"
)

type Windows struct{}

func getCollectorsInstances() []Collector {
var collectors []Collector
collectors = append(collectors, Windows{})
return collectors
}

const PowerShellScript = `
<#
.SYNOPSIS
Expand Down Expand Up @@ -172,10 +179,10 @@ func (w Windows) SendSystemLogs() {

validatedLogs := make([]string, 0, len(logLines))

for logLine := range logLines {
for _, logLine := range logLines {
validatedLog, _, err := validations.ValidateString(logLine, false)
if err != nil {
_ = utils.Logger.ErrorF("error validating log: %s: %v", logLine, err)
utils.Logger.LogF(100, "error validating log: %s: %v", logLine, err)
continue
}

Expand Down
Loading
Loading