diff --git a/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.html b/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.html index 378165bc3..052af7fae 100644 --- a/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.html +++ b/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.html @@ -32,8 +32,7 @@

+ [platforms]="platforms"> diff --git a/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.ts b/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.ts index bc0d6dc56..42d382e3c 100644 --- a/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.ts +++ b/frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.ts @@ -85,9 +85,7 @@ export class GuideSyslogComponent implements OnInit { } ngOnInit() {} - getImage(): SyslogModuleImages { - return this.moduleImages.filter(value => value.module === this.moduleEnum)[0]; - } + getPorts(): SyslogModulePorts[] { return this.syslogPorts.filter(value => value.module === this.moduleEnum); } diff --git a/frontend/src/app/app-module/guides/shared/components/agent-action-command.component.ts b/frontend/src/app/app-module/guides/shared/components/agent-action-command.component.ts index 7c6b35aa9..b10401c4c 100644 --- a/frontend/src/app/app-module/guides/shared/components/agent-action-command.component.ts +++ b/frontend/src/app/app-module/guides/shared/components/agent-action-command.component.ts @@ -33,9 +33,16 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum'; class="flex-item"> - +
+ After the TLS certificates have been successfully loaded into the system, + it is not necessary to repeat the certificate loading process when enabling + additional integrations that use TLS. The system will automatically apply the + previously configured certificates to ensure secure communication. +
+ {{selectedPlatform.shell}} - + `, styles: [` @@ -59,7 +66,8 @@ export class AgentActionCommandComponent implements OnInit{ @Input() hideProtocols = false; @Input() protocols = [ {id: 1, name: 'TCP'}, - {id: 2, name: 'UDP'} + {id: 2, name: 'TCP/TLS'}, + {id: 3, name: 'UDP'} ]; actions = [ @@ -75,16 +83,27 @@ export class AgentActionCommandComponent implements OnInit{ constructor(private modalService: ModalService) { } - ngOnInit(): void { - console.log(this.selectedPlatform); - } + ngOnInit(): void {} + + get commands() { + + const protocol = this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' ? 'tcp' : this.selectedProtocol.name.toLowerCase(); - get command() { - return replaceCommandTokens(this.selectedPlatform.command, { - PORT: this.selectedProtocol && this.selectedProtocol.name.toLowerCase() || '', - AGENT_NAME: this.agent, - ACTION: this.selectedAction && this.selectedAction.action || '' + const command = replaceCommandTokens(this.selectedPlatform.command, { + ACTION: this.selectedAction && this.selectedAction.action || '', + AGENT_NAME: this.agent || '', + PROTOCOL: protocol, + TLS: this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' && + this.selectedAction.name === 'ENABLE' ? `--tls` : '' }); + + if (this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' && + this.selectedAction.name === 'ENABLE') { + const extras = this.selectedPlatform.extraCommands ? this.selectedPlatform.extraCommands : []; + return [...extras, command]; + } + + return [command]; } get selectedPlatform() { diff --git a/frontend/src/app/app-module/guides/shared/constant.ts b/frontend/src/app/app-module/guides/shared/constant.ts index 5be905914..468dd47fc 100644 --- a/frontend/src/app/app-module/guides/shared/constant.ts +++ b/frontend/src/app/app-module/guides/shared/constant.ts @@ -1,81 +1,109 @@ +const WINDOWS_SHELL = + 'Run the following PowerShell script as “ADMINISTRATOR” on a server with the UTMStack agent installed.'; + +const LINUX_SHELL = + 'Run the following Bash script as “ADMINISTRATOR” on a server with the UTMStack agent installed.'; + export interface Platform { id: number; name: string; command: string; shell: string; - path: string; - restart: string; + path?: string; + restart?: string; + extraCommands?: string[]; } -export const createPlatforms = (windowsCommandAMD64: string, - windowsCommandARM64: string, - linuxCommand: string, - windowsPath?: string, - windowsRestart?: string, - linuxPath?: string, - linuxRestart?: string) => [ - { - id: 1, - name: 'WINDOWS (AMD64)', - command: windowsCommandAMD64, - shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.', - path: windowsPath, - restart: windowsRestart - }, - { - id: 2, - name: 'WINDOWS (ARM64)', - command: windowsCommandARM64, - shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.', - path: windowsPath, - restart: windowsRestart - }, - { - id: 3, - name: 'LINUX', - command: linuxCommand, - shell: 'Run the following bash script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.', - path: linuxPath, - restart: linuxRestart - } -]; +function createPlatform( + id: number, + name: string, + command: string, + shell: string, + path?: string, + restart?: string, + extraCommands?: string[]): Platform { + return { id, name, command, shell, path, restart, extraCommands }; +} -export const createFileBeatsPlatforms = (windowsCommand: string, - linuxCommand: string, - windowsPath?: string, - windowsRestart?: string, - linuxPath?: string, - linuxRestart?: string) => [ - { - id: 1, - name: 'WINDOWS', - command: windowsCommand, - shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.', - path: windowsPath, - restart: windowsRestart - }, - { - id: 3, - name: 'LINUX', - command: linuxCommand, - shell: 'Run the following bash script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.', - path: linuxPath, - restart: linuxRestart - } +export const createPlatforms = ( + windowsCommandAMD64: string, + windowsCommandARM64: string, + linuxCommand: string, + windowsPath?: string, + windowsRestart?: string, + linuxPath?: string, + linuxRestart?: string): Platform[] => [ + createPlatform( + 1, + 'WINDOWS (AMD64)', + windowsCommandAMD64, + WINDOWS_SHELL, + windowsPath, + windowsRestart,[ + 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" ' + + '-ArgumentList \'load-tls-certs\', \'[YOUR_CERT_PATH]\', \'[YOUR_KEY_PATH]\' ' + + '-NoNewWindow -Wait' + ] + ), + createPlatform( + 2, + 'WINDOWS (ARM64)', + windowsCommandARM64, + WINDOWS_SHELL, + windowsPath, + windowsRestart, + [ + 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" ' + + '-ArgumentList \'load-tls-certs\', \'[YOUR_CERT_PATH]\', \'[YOUR_KEY_PATH]\' ' + + '-NoNewWindow -Wait' + ] + ), + createPlatform( + 3, + 'LINUX', + linuxCommand, + LINUX_SHELL, + linuxPath, + linuxRestart, + [ + `sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service load-tls-certs [YOUR_CERT_PATH] [YOUR_KEY_PATH]"` + ] + ) ]; +export const createFileBeatsPlatforms = ( + windowsCommand: string, + linuxCommand: string, + windowsPath?: string, + windowsRestart?: string, + linuxPath?: string, + linuxRestart?: string): Platform[] => [ + createPlatform( + 1, + 'WINDOWS', + windowsCommand, + WINDOWS_SHELL, + windowsPath, + windowsRestart + ), + createPlatform( + 3, + 'LINUX', + linuxCommand, + LINUX_SHELL, + linuxPath, + linuxRestart + ) +]; export const PLATFORMS = createPlatforms( - 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\',' + - ' \'AGENT_NAME\', \'PORT\' -NoNewWindow -Wait\n', - 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\',' + - ' \'AGENT_NAME\', \'PORT\' -NoNewWindow -Wait\n', - 'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENT_NAME PORT"' + 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\', \'AGENT_NAME\', \'PROTOCOL\', \'TLS\' -NoNewWindow -Wait\n', + 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\', \'AGENT_NAME\', \'PROTOCOL\, \'TLS\' -NoNewWindow -Wait\n', + 'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENT_NAME PROTOCOL TLS"' ); - export const FILEBEAT_PLATFORMS = createFileBeatsPlatforms( - 'cd "C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\"; Start-Process "filebeat.exe" -ArgumentList "modules", "enable", \"AGENT_NAME\"', + 'cd "C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\"; Start-Process "filebeat.exe" -ArgumentList "modules", "enable", "AGENT_NAME"', 'cd /opt/utmstack-linux-agent/beats/filebeat/ && ./filebeat modules enable AGENT_NAME', 'C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\modules.d\\', 'Stop-Service -Name UTMStackModulesLogsCollector; Start-Sleep -Seconds 5; Start-Service -Name UTMStackModulesLogsCollector', diff --git a/frontend/src/app/data-management/alert-management/shared/components/alert-entity-display/alert-entity-display.component.ts b/frontend/src/app/data-management/alert-management/shared/components/alert-entity-display/alert-entity-display.component.ts index b98e10556..f4a52ee6d 100644 --- a/frontend/src/app/data-management/alert-management/shared/components/alert-entity-display/alert-entity-display.component.ts +++ b/frontend/src/app/data-management/alert-management/shared/components/alert-entity-display/alert-entity-display.component.ts @@ -59,8 +59,6 @@ export class AlertEntityDisplayComponent implements OnInit, OnChanges { } ngOnInit() { - console.log('type', this.type); - console.log('field', this.field); if (this.alert[this.key]) { this.fields = Object.keys(this.alert[this.key]); if (this.alert[this.key].geolocation) { diff --git a/frontend/src/app/shared/util/replace-command-tokens.util.ts b/frontend/src/app/shared/util/replace-command-tokens.util.ts index 89399eda3..7dbddc16a 100644 --- a/frontend/src/app/shared/util/replace-command-tokens.util.ts +++ b/frontend/src/app/shared/util/replace-command-tokens.util.ts @@ -1,4 +1,33 @@ -export function replaceCommandTokens(command: string, wordsToReplace: { [key: string]: string }) { - return Object.keys(wordsToReplace) - .reduce((f, s) => f.replace(new RegExp(s, 'ig'), wordsToReplace[s]), command); +export function replaceCommandTokens(command: string, wordsToReplace: { [key: string]: string }): string { + let cmd = command; + + if (cmd.includes('-ArgumentList')) { + + const args = Object.values(wordsToReplace) + .filter(v => v && v.trim().length > 0) + .map(v => `'${v.trim()}'`) + .join(', '); + + cmd = cmd.replace( + /-ArgumentList\s+(['"].*?['"])(?=\s+-|$)/, + `-ArgumentList ${args}` + ); + } else { + const match = cmd.match(/"(.*)"/); + if (match) { + const original = match[1]; + const parts = original.split(/\s+/); + const fixedCommand = parts[0]; + const args = Object.entries(wordsToReplace) + .filter(([_, v]) => v && v.trim().length > 0) + .map(([_, v]) => v.trim()) + .join(' '); + + cmd = cmd.replace(/"(.*)"/, `"${fixedCommand} ${args}"`); + } + } + + cmd = cmd.replace(/\s+/g, ' ').trim(); + + return cmd; }