Skip to content

Commit a6dd656

Browse files
committed
fea: add tls connection options and setup steps for syslog integrations
Signed-off-by: Manuel Abascal <[email protected]>
1 parent 0572f0b commit a6dd656

File tree

6 files changed

+136
-33
lines changed

6 files changed

+136
-33
lines changed

frontend/src/app/app-module/guides/shared/components/install-log-collector.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
ModalConfirmationComponent
55
} from '../../../../shared/components/utm/util/modal-confirmation/modal-confirmation.component';
66
import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
7-
import {generate} from "rxjs";
7+
import {generate} from 'rxjs';
88

99
@Component({
1010
selector: 'app-install-log-collector',

frontend/src/app/app-module/guides/shared/components/log-collector.component.ts

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ModalService} from '../../../../core/modal/modal.service';
33
import {
44
ModalConfirmationComponent
55
} from '../../../../shared/components/utm/util/modal-confirmation/modal-confirmation.component';
6+
import {replaceCommandTokens} from "../../../../shared/util/replace-command-tokens.util";
67
import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
78

89
@Component({
@@ -31,7 +32,7 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
3132
</div>
3233
<ng-container *ngIf="selectedProtocol && selectedPlatform && selectedAction">
3334
<span class="font-weight-semibold mb-2">{{selectedPlatform.shell}}</span>
34-
<app-utm-code-view class="" [code]=command></app-utm-code-view>
35+
<app-utm-code-view class="" [code]=commands></app-utm-code-view>
3536
</ng-container>
3637
`,
3738
styles: [`
@@ -49,56 +50,52 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
4950

5051
export class LogCollectorComponent {
5152

53+
@Input() agent: string;
54+
@Input() platforms: any[];
55+
@Input() hideActions = false;
56+
@Input() hideProtocols = false;
5257
@Input() protocols = [
5358
{id: 1, name: 'TCP'},
54-
{id: 2, name: 'UDP'}
59+
{id: 2, name: 'TCP/TLS'},
60+
{id: 3, name: 'UDP'}
5561
];
5662

5763
actions = [
5864
{id: 1, name: 'ENABLE', action: 'enable-integration'},
5965
{id: 2, name: 'DISABLE', action: 'disable-integration'}
6066
];
6167

62-
platforms = [
63-
{
64-
id: 1, name: 'WINDOWS (ARM64)',
65-
command: 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\', \'AGENTNAME\', \'PORT\' -NoNewWindow -Wait\n',
66-
shell: 'Windows Powershell terminal as “ADMINISTRATOR”'
67-
},
68-
{
69-
id: 2, name: 'WINDOWS (AMD64)',
70-
command: 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\', \'AGENTNAME\', \'PORT\' -NoNewWindow -Wait\n',
71-
shell: 'Windows Powershell terminal as “ADMINISTRATOR”'
72-
},
73-
{
74-
id: 3,
75-
name: 'LINUX', command: 'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENTNAME PORT"',
76-
shell: 'Linux bash terminal'
77-
}
78-
];
79-
80-
@Input() agent: string;
81-
8268
_selectedProtocol: any;
8369
_selectedPlatform: any;
8470
_selectedAction: any;
8571
module = UtmModulesEnum;
8672

87-
constructor(private modalService: ModalService) {
88-
}
73+
constructor(private modalService: ModalService) {}
8974

90-
get command() {
91-
return this.replaceAll(this.selectedPlatform.command, {
92-
PORT: this.selectedProtocol.name.toLowerCase(),
93-
AGENTNAME: this.agentName(),
94-
ACTION: this.selectedAction.action
95-
});
75+
get commands() {
76+
77+
const protocol = this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' ? 'tcp' : this.selectedProtocol.name.toLowerCase();
78+
79+
const command = replaceCommandTokens(this.selectedPlatform.command, {
80+
PROTOCOL: protocol,
81+
AGENT_NAME: this.agent,
82+
ACTION: this.selectedAction && this.selectedAction.action || '',
83+
TLS: this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS' ? ' --tls' : ''
84+
});
85+
86+
if (this.selectedProtocol && this.selectedProtocol.name === 'TCP/TLS') {
87+
const extras = this.selectedPlatform.extraCommands ? this.selectedPlatform.extraCommands : [];
88+
return [...extras, command];
89+
}
90+
91+
return [command];
9692
}
9793

9894
get selectedPlatform() {
9995
return this._selectedPlatform;
10096
}
10197

98+
@Input()
10299
set selectedPlatform(platform) {
103100
this._selectedPlatform = platform;
104101
}

frontend/src/app/app-module/guides/shared/components/step.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class StepDirective {
2222
`
2323
})
2424

25-
export class StepComponent{
25+
export class StepComponent {
2626

2727
@Input() step: Step;
2828
constructor() {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
export interface Platform {
2+
id: number;
3+
name: string;
4+
command: string;
5+
shell: string;
6+
path: string;
7+
restart: string;
8+
}
9+
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+
];
42+
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+
}
65+
];
66+
67+
68+
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"'
74+
);
75+
76+
77+
export const FILEBEAT_PLATFORMS = createFileBeatsPlatforms(
78+
'cd "C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\"; Start-Process "filebeat.exe" -ArgumentList "modules", "enable", \"AGENT_NAME\"',
79+
'cd /opt/utmstack-linux-agent/beats/filebeat/ && ./filebeat modules enable AGENT_NAME',
80+
'C:\\Program Files\\UTMStack\\UTMStack Agent\\beats\\filebeat\\modules.d\\',
81+
'Stop-Service -Name UTMStackModulesLogsCollector; Start-Sleep -Seconds 5; Start-Service -Name UTMStackModulesLogsCollector',
82+
'/opt/utmstack-linux-agent/beats/filebeat/modules.d/',
83+
'sudo systemctl restart UTMStackModulesLogsCollector'
84+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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);
4+
}*/
5+
6+
export function replaceCommandTokens(command: string, wordsToReplace: { [key: string]: string }) {
7+
let cmd = command;
8+
9+
Object.entries(wordsToReplace).forEach(([key, value]) => {
10+
if (!value) {
11+
const regex = new RegExp(`\\s*${key}\\b`, 'g');
12+
cmd = cmd.replace(regex, '');
13+
} else {
14+
const regex = new RegExp(`${key}\\b`, 'g');
15+
cmd = cmd.replace(regex, value);
16+
}
17+
});
18+
19+
cmd = cmd.replace(/\s+/g, ' ').trim();
20+
21+
return cmd;
22+
}

version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 10.9.1
1+
version: 10.9.2

0 commit comments

Comments
 (0)