Skip to content

Commit f38062c

Browse files
committed
feat: set ip address to agent
1 parent ccac933 commit f38062c

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# UTMStack 10.5.21 Release Notes
1+
# UTMStack 10.5.20 Release Notes
22
## Bug Fixes
3+
- Fixed the IP location component to accurately determine whether an IP address is public or private.
34

45
## New Features
5-
- Introduced new standards, sections, dashboards, and visualizations to compliance reports.
6+
- Introduced new standards, sections, dashboards, and visualizations to compliance reports.
7+
- Update ip address to agent

frontend/src/app/shared/components/utm/util/utm-agent-detail/utm-agent-detail.component.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
<div class="agent-details w-100 d-flex justify-content-start mb-2"
33
*ngIf="agent.ip">
44
<span class="text-blue-800 font-weight-light has-minimum-width">IP:</span>&nbsp;
5-
{{agent.ip}}
5+
<ng-select (change)="changeIp($event)"
6+
[(ngModel)]="agentIp"
7+
[loading]="loading"
8+
[clearable]="true"
9+
[items]="ips"
10+
[searchable]="false"
11+
class="has-minimum-width mr-3"
12+
placeholder="Agent ip"
13+
style="width: 40%"
14+
></ng-select>
615
</div>
716
<div class="agent-details w-100 d-flex justify-content-start mb-2" *ngIf="agent.hostname">
817
<span class="text-blue-800 font-weight-light has-minimum-width">Name:</span>&nbsp;

frontend/src/app/shared/components/utm/util/utm-agent-detail/utm-agent-detail.component.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {Component, Input, OnInit} from '@angular/core';
2+
import {EMPTY, of} from 'rxjs';
3+
import {catchError, map, tap} from 'rxjs/operators';
24
import {NetScanType} from '../../../../../assets-discover/shared/types/net-scan.type';
5+
import {UtmToastService} from '../../../../alert/utm-toast.service';
6+
import {UtmAgentManagerService} from '../../../../services/agent/utm-agent-manager.service';
37
import {AgentStatusEnum, AgentType} from '../../../../types/agent/agent.type';
48

59
@Component({
@@ -11,11 +15,19 @@ export class UtmAgentDetailComponent implements OnInit {
1115
@Input() agent: AgentType;
1216
@Input() asset: NetScanType;
1317
agentStatusEnum = AgentStatusEnum;
18+
ips: string[];
19+
macs: string[];
20+
agentIp: string;
21+
loading = false;
1422

15-
constructor() {
23+
constructor(private agentManagerService: UtmAgentManagerService,
24+
private utmToastService: UtmToastService) {
1625
}
1726

1827
ngOnInit() {
28+
this.agentIp = this.agent.ip;
29+
this.ips = this.agent.addresses !== '' ? this.agent.addresses.split(',') : [];
30+
this.macs = this.agent.mac !== '' ? this.agent.mac.split(',') : [];
1931
}
2032

2133
public getAgentIcon(): string {
@@ -36,4 +48,27 @@ export class UtmAgentDetailComponent implements OnInit {
3648
getAssets() {
3749

3850
}
51+
52+
changeIp(event: string) {
53+
this.loading = true;
54+
const agent = {
55+
id: this.agent.id,
56+
ip: this.agentIp,
57+
mac: this.macs.length > 0 ? this.macs[0] : '',
58+
agentKey: this.agent.agentKey
59+
};
60+
61+
this.agentManagerService.updateAgent(agent)
62+
.pipe(
63+
map(response => response.body),
64+
tap(response => this.loading = false),
65+
catchError(error => {
66+
this.utmToastService.showError('Error',
67+
'An error occurred while updating the agent ip. Please try again later.');
68+
this.loading = false;
69+
this.agentIp = this.agent.ip;
70+
return EMPTY;
71+
}))
72+
.subscribe(() => this.agent.ip = this.agentIp);
73+
}
3974
}

frontend/src/app/shared/services/agent/utm-agent-manager.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ export class UtmAgentManagerService {
4444
return this.http.get<AgentCommandType[]>(this.resourceUrl + '/agent-commands', {params: options, observe: 'response'});
4545
}
4646

47+
updateAgent(agent: Partial<AgentType>): Observable<HttpResponse<any>> {
48+
return this.http.post(this.resourceUrl + '/update-agent-attrs', agent, {observe: 'response'});
49+
}
4750

4851
}

version.yml

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

0 commit comments

Comments
 (0)