From 52335b6e31b0b1455a2a5b05c95d539f94d3062d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 22 Nov 2019 11:01:41 +0100 Subject: [PATCH] Added computername to actortoken db --- actor/src/UDSActorConfig.py | 1 + actor/src/udsactor/rest.py | 4 +++- server/src/uds/REST/methods/actor_v2.py | 4 +++- server/src/uds/migrations/0034_actortoken.py | 3 ++- server/src/uds/models/actor_token.py | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/actor/src/UDSActorConfig.py b/actor/src/UDSActorConfig.py index 56fb6ccb..f639baba 100644 --- a/actor/src/UDSActorConfig.py +++ b/actor/src/UDSActorConfig.py @@ -115,6 +115,7 @@ class UDSConfigDialog(QDialog): self.ui.authenticators.currentData().auth, self.ui.username.text(), self.ui.password.text(), + udsactor.operations.getComputerName(), data.ip or '', # IP data.mac or '', # MAC self.ui.preCommand.text(), diff --git a/actor/src/udsactor/rest.py b/actor/src/udsactor/rest.py index 89314978..91111d78 100644 --- a/actor/src/udsactor/rest.py +++ b/actor/src/udsactor/rest.py @@ -137,11 +137,12 @@ class REST: pass - def register( #pylint: disable=too-many-arguments + def register( #pylint: disable=too-many-arguments, too-many-locals self, auth: str, username: str, password: str, + hostname: str, ip: str, mac: str, preCommand: str, @@ -154,6 +155,7 @@ class REST: """ data = { 'username': username, + 'hostname': hostname, 'ip': ip, 'mac': mac, 'pre_command': preCommand, diff --git a/server/src/uds/REST/methods/actor_v2.py b/server/src/uds/REST/methods/actor_v2.py index 4cb24d5f..7b54f63a 100644 --- a/server/src/uds/REST/methods/actor_v2.py +++ b/server/src/uds/REST/methods/actor_v2.py @@ -37,7 +37,7 @@ import typing from uds.models import getSqlDatetimeAsUnix, getSqlDatetime, ActorToken from uds.core import VERSION -from ..handlers import Handler, NotFound +from ..handlers import Handler logger = logging.getLogger(__name__) @@ -87,6 +87,7 @@ class ActorV2Register(ActorV2Action): # Update parameters actorToken.ip_from = self._request.ip actorToken.ip = self._params['ip'] + actorToken.hostname = self._params['hostname'] actorToken.pre_command = self._params['pre_command'] actorToken.post_command = self._params['post_command'] actorToken.runonce_command = self._params['run_once_command'] @@ -98,6 +99,7 @@ class ActorV2Register(ActorV2Action): username=self._params['username'], ip_from=self._request.ip, ip=self._params['ip'], + hostname=self._params['hostname'], mac=self._params['mac'], pre_command=self._params['pre_command'], post_command=self._params['post_command'], diff --git a/server/src/uds/migrations/0034_actortoken.py b/server/src/uds/migrations/0034_actortoken.py index 79acbe2a..3fb2e899 100644 --- a/server/src/uds/migrations/0034_actortoken.py +++ b/server/src/uds/migrations/0034_actortoken.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.7 on 2019-11-21 12:22 +# Generated by Django 2.2.7 on 2019-11-22 10:54 from django.db import migrations, models @@ -17,6 +17,7 @@ class Migration(migrations.Migration): ('username', models.CharField(max_length=128)), ('ip_from', models.CharField(max_length=128)), ('ip', models.CharField(max_length=128)), + ('hostname', models.CharField(max_length=128)), ('mac', models.CharField(db_index=True, max_length=128, unique=True)), ('pre_command', models.CharField(blank=True, default='', max_length=255)), ('post_command', models.CharField(blank=True, default='', max_length=255)), diff --git a/server/src/uds/models/actor_token.py b/server/src/uds/models/actor_token.py index 1ba70f10..8f1c6c69 100644 --- a/server/src/uds/models/actor_token.py +++ b/server/src/uds/models/actor_token.py @@ -37,6 +37,7 @@ class ActorToken(models.Model): username = models.CharField(max_length=128) ip_from = models.CharField(max_length=128) ip = models.CharField(max_length=128) + hostname = models.CharField(max_length=128) mac = models.CharField(max_length=128, db_index=True, unique=True) pre_command = models.CharField(max_length=255, blank=True, default='') post_command = models.CharField(max_length=255, blank=True, default='')