Skip to content

Commit c19bc0f

Browse files
authored
Merge pull request #1404 from utmstack/backlog/add-tls-connection-option-and-setup-steps-for-syslog-integrations
Backlog/add tls connection option and setup steps for syslog integrations
2 parents 2da208d + d538fa3 commit c19bc0f

File tree

6 files changed

+155
-84
lines changed

6 files changed

+155
-84
lines changed

frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ <h4 class="card-title mb-0 text-primary">
3232

3333
<ng-template [ngIf]="step.content.id === 'stepContent2'">
3434
<app-agent-action-command [agent] = "getDataType()"
35-
[platforms]="platforms"
36-
[protocols]="getProtocols()">
35+
[platforms]="platforms">
3736
</app-agent-action-command>
3837
</ng-template>
3938

frontend/src/app/app-module/guides/guide-syslog/guide-syslog.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ export class GuideSyslogComponent implements OnInit {
8585
}
8686

8787
ngOnInit() {}
88-
getImage(): SyslogModuleImages {
89-
return this.moduleImages.filter(value => value.module === this.moduleEnum)[0];
90-
}
88+
9189
getPorts(): SyslogModulePorts[] {
9290
return this.syslogPorts.filter(value => value.module === this.moduleEnum);
9391
}

frontend/src/app/app-module/guides/shared/components/agent-action-command.component.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
3333
class="flex-item">
3434
</ng-select>
3535
</div>
36-
<ng-container *ngIf="(selectedProtocol && selectedPlatform && selectedAction || (hideActions && hideProtocols && selectedPlatform))">
36+
<div *ngIf="this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' && selectedAction"
37+
class="alert alert-info alert-styled-right mt-2">
38+
After the TLS certificates have been successfully loaded into the system,
39+
it is not necessary to repeat the certificate loading process when enabling
40+
additional integrations that use TLS. The system will automatically apply the
41+
previously configured certificates to ensure secure communication.
42+
</div>
43+
<ng-container *ngIf="selectedProtocol && selectedPlatform && selectedAction">
3744
<span class="font-weight-semibold mb-2">{{selectedPlatform.shell}}</span>
38-
<app-utm-code-view class="" [code]=command></app-utm-code-view>
45+
<app-utm-code-view *ngFor="let command of commands" class="" [code]=command></app-utm-code-view>
3946
</ng-container>
4047
`,
4148
styles: [`
@@ -59,7 +66,8 @@ export class AgentActionCommandComponent implements OnInit{
5966
@Input() hideProtocols = false;
6067
@Input() protocols = [
6168
{id: 1, name: 'TCP'},
62-
{id: 2, name: 'UDP'}
69+
{id: 2, name: 'TCP/TLS'},
70+
{id: 3, name: 'UDP'}
6371
];
6472

6573
actions = [
@@ -75,16 +83,27 @@ export class AgentActionCommandComponent implements OnInit{
7583
constructor(private modalService: ModalService) {
7684
}
7785

78-
ngOnInit(): void {
79-
console.log(this.selectedPlatform);
80-
}
86+
ngOnInit(): void {}
87+
88+
get commands() {
89+
90+
const protocol = this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' ? 'tcp' : this.selectedProtocol.name.toLowerCase();
8191

82-
get command() {
83-
return replaceCommandTokens(this.selectedPlatform.command, {
84-
PORT: this.selectedProtocol && this.selectedProtocol.name.toLowerCase() || '',
85-
AGENT_NAME: this.agent,
86-
ACTION: this.selectedAction && this.selectedAction.action || ''
92+
const command = replaceCommandTokens(this.selectedPlatform.command, {
93+
ACTION: this.selectedAction && this.selectedAction.action || '',
94+
AGENT_NAME: this.agent || '',
95+
PROTOCOL: protocol,
96+
TLS: this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' &&
97+
this.selectedAction.name === 'ENABLE' ? `--tls` : ''
8798
});
99+
100+
if (this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' &&
101+
this.selectedAction.name === 'ENABLE') {
102+
const extras = this.selectedPlatform.extraCommands ? this.selectedPlatform.extraCommands : [];
103+
return [...extras, command];
104+
}
105+
106+
return [command];
88107
}
89108

90109
get selectedPlatform() {

frontend/src/app/app-module/guides/shared/constant.ts

Lines changed: 91 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,109 @@
1+
const WINDOWS_SHELL =
2+
'Run the following PowerShell script as “ADMINISTRATOR” on a server with the UTMStack agent installed.';
3+
4+
const LINUX_SHELL =
5+
'Run the following Bash script as “ADMINISTRATOR” on a server with the UTMStack agent installed.';
6+
17
export interface Platform {
28
id: number;
39
name: string;
410
command: string;
511
shell: string;
6-
path: string;
7-
restart: string;
12+
path?: string;
13+
restart?: string;
14+
extraCommands?: string[];
815
}
916

10-
export const createPlatforms = (windowsCommandAMD64: string,
11-
windowsCommandARM64: string,
12-
linuxCommand: string,
13-
windowsPath?: string,
14-
windowsRestart?: string,
15-
linuxPath?: string,
16-
linuxRestart?: string) => [
17-
{
18-
id: 1,
19-
name: 'WINDOWS (AMD64)',
20-
command: windowsCommandAMD64,
21-
shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.',
22-
path: windowsPath,
23-
restart: windowsRestart
24-
},
25-
{
26-
id: 2,
27-
name: 'WINDOWS (ARM64)',
28-
command: windowsCommandARM64,
29-
shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.',
30-
path: windowsPath,
31-
restart: windowsRestart
32-
},
33-
{
34-
id: 3,
35-
name: 'LINUX',
36-
command: linuxCommand,
37-
shell: 'Run the following bash script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.',
38-
path: linuxPath,
39-
restart: linuxRestart
40-
}
41-
];
17+
function createPlatform(
18+
id: number,
19+
name: string,
20+
command: string,
21+
shell: string,
22+
path?: string,
23+
restart?: string,
24+
extraCommands?: string[]): Platform {
25+
return { id, name, command, shell, path, restart, extraCommands };
26+
}
4227

43-
export const createFileBeatsPlatforms = (windowsCommand: string,
44-
linuxCommand: string,
45-
windowsPath?: string,
46-
windowsRestart?: string,
47-
linuxPath?: string,
48-
linuxRestart?: string) => [
49-
{
50-
id: 1,
51-
name: 'WINDOWS',
52-
command: windowsCommand,
53-
shell: 'Run the following powershell script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.',
54-
path: windowsPath,
55-
restart: windowsRestart
56-
},
57-
{
58-
id: 3,
59-
name: 'LINUX',
60-
command: linuxCommand,
61-
shell: 'Run the following bash script as “ADMINISTRATOR” in a Server with the UTMStack agent Installed.',
62-
path: linuxPath,
63-
restart: linuxRestart
64-
}
28+
export const createPlatforms = (
29+
windowsCommandAMD64: string,
30+
windowsCommandARM64: string,
31+
linuxCommand: string,
32+
windowsPath?: string,
33+
windowsRestart?: string,
34+
linuxPath?: string,
35+
linuxRestart?: string): Platform[] => [
36+
createPlatform(
37+
1,
38+
'WINDOWS (AMD64)',
39+
windowsCommandAMD64,
40+
WINDOWS_SHELL,
41+
windowsPath,
42+
windowsRestart,[
43+
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" ' +
44+
'-ArgumentList \'load-tls-certs\', \'[YOUR_CERT_PATH]\', \'[YOUR_KEY_PATH]\' ' +
45+
'-NoNewWindow -Wait'
46+
]
47+
),
48+
createPlatform(
49+
2,
50+
'WINDOWS (ARM64)',
51+
windowsCommandARM64,
52+
WINDOWS_SHELL,
53+
windowsPath,
54+
windowsRestart,
55+
[
56+
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" ' +
57+
'-ArgumentList \'load-tls-certs\', \'[YOUR_CERT_PATH]\', \'[YOUR_KEY_PATH]\' ' +
58+
'-NoNewWindow -Wait'
59+
]
60+
),
61+
createPlatform(
62+
3,
63+
'LINUX',
64+
linuxCommand,
65+
LINUX_SHELL,
66+
linuxPath,
67+
linuxRestart,
68+
[
69+
`sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service load-tls-certs [YOUR_CERT_PATH] [YOUR_KEY_PATH]"`
70+
]
71+
)
6572
];
6673

74+
export const createFileBeatsPlatforms = (
75+
windowsCommand: string,
76+
linuxCommand: string,
77+
windowsPath?: string,
78+
windowsRestart?: string,
79+
linuxPath?: string,
80+
linuxRestart?: string): Platform[] => [
81+
createPlatform(
82+
1,
83+
'WINDOWS',
84+
windowsCommand,
85+
WINDOWS_SHELL,
86+
windowsPath,
87+
windowsRestart
88+
),
89+
createPlatform(
90+
3,
91+
'LINUX',
92+
linuxCommand,
93+
LINUX_SHELL,
94+
linuxPath,
95+
linuxRestart
96+
)
97+
];
6798

6899
export const PLATFORMS = createPlatforms(
69-
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\',' +
70-
' \'AGENT_NAME\', \'PORT\' -NoNewWindow -Wait\n',
71-
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\',' +
72-
' \'AGENT_NAME\', \'PORT\' -NoNewWindow -Wait\n',
73-
'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENT_NAME PORT"'
100+
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\', \'AGENT_NAME\', \'PROTOCOL\', \'TLS\' -NoNewWindow -Wait\n',
101+
'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\', \'AGENT_NAME\', \'PROTOCOL\, \'TLS\' -NoNewWindow -Wait\n',
102+
'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENT_NAME PROTOCOL TLS"'
74103
);
75104

76-
77105
export const FILEBEAT_PLATFORMS = createFileBeatsPlatforms(
78-
'cd "C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\"; Start-Process "filebeat.exe" -ArgumentList "modules", "enable", \"AGENT_NAME\"',
106+
'cd "C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\"; Start-Process "filebeat.exe" -ArgumentList "modules", "enable", "AGENT_NAME"',
79107
'cd /opt/utmstack-linux-agent/beats/filebeat/ && ./filebeat modules enable AGENT_NAME',
80108
'C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\modules.d\\',
81109
'Stop-Service -Name UTMStackModulesLogsCollector; Start-Sleep -Seconds 5; Start-Service -Name UTMStackModulesLogsCollector',

frontend/src/app/data-management/alert-management/shared/components/alert-entity-display/alert-entity-display.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ export class AlertEntityDisplayComponent implements OnInit, OnChanges {
5959
}
6060

6161
ngOnInit() {
62-
console.log('type', this.type);
63-
console.log('field', this.field);
6462
if (this.alert[this.key]) {
6563
this.fields = Object.keys(this.alert[this.key]);
6664
if (this.alert[this.key].geolocation) {
Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
export function replaceCommandTokens(command: string, wordsToReplace: { [key: string]: string }) {
2-
return Object.keys(wordsToReplace)
3-
.reduce((f, s) => f.replace(new RegExp(s, 'ig'), wordsToReplace[s]), command);
1+
export function replaceCommandTokens(command: string, wordsToReplace: { [key: string]: string }): string {
2+
let cmd = command;
3+
4+
if (cmd.includes('-ArgumentList')) {
5+
6+
const args = Object.values(wordsToReplace)
7+
.filter(v => v && v.trim().length > 0)
8+
.map(v => `'${v.trim()}'`)
9+
.join(', ');
10+
11+
cmd = cmd.replace(
12+
/-ArgumentList\s+(['"].*?['"])(?=\s+-|$)/,
13+
`-ArgumentList ${args}`
14+
);
15+
} else {
16+
const match = cmd.match(/"(.*)"/);
17+
if (match) {
18+
const original = match[1];
19+
const parts = original.split(/\s+/);
20+
const fixedCommand = parts[0];
21+
const args = Object.entries(wordsToReplace)
22+
.filter(([_, v]) => v && v.trim().length > 0)
23+
.map(([_, v]) => v.trim())
24+
.join(' ');
25+
26+
cmd = cmd.replace(/"(.*)"/, `"${fixedCommand} ${args}"`);
27+
}
28+
}
29+
30+
cmd = cmd.replace(/\s+/g, ' ').trim();
31+
32+
return cmd;
433
}

0 commit comments

Comments
 (0)