-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
backend/backend/settings/dev.py
Outdated
@@ -22,6 +22,7 @@ | |||
'django_extensions' | |||
] | |||
|
|||
IS_DEV = True | |||
IS_MTLS_API=IS_API=IS_DASH=IS_DEV = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8
@@ -39,6 +40,18 @@ def from_db_value(self, value, expression, connection, context): | |||
return value | |||
|
|||
|
|||
class DebPackage(models.Model): | |||
class Distro(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want the field value to be converted to Enum class, this way we can have some type checking later when we work with deb packages in a separate worker which will scan them for CVEs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give me some example of such type checking that requires enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of your approach?
can you give me some example of such type checking that requires enum?
This is self-documented, has less code and will fail quickly (before even getting to the db backend) if we do package.distro = SomeOtherEnum.Other
instead of package.distro = DebPackage.Distro.Raspbian
.
@a-martynovich I recommend to re-create migrations for the task at the very end of working on it in order to reduce their number. I can help with this if you need |
It's easy, I'll do this myself together with the improvements you've requested. |
backend/device_registry/models.py
Outdated
return self.deb_packages.filter(name__in=self.INSECURE_SERVICES) | ||
|
||
def set_deb_packages(self, packages): | ||
packages_set = set((p['name'], p['version']) for p in packages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO there's no need to transmit {'name': 'xxx', 'version': 'yyy'}
. ('xxx', 'yyy')
is much better for bandwith
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only reduce the size of this message by 2. But then we will lose flexibility. If we decide to change this message in any way (and we will eventually), i.e. add, remove or change fields, we will break compatibility with older message.
Also the size of this message is no more than 100Kbytes. I don't think we should worry about bandwidth here.
Fix test_ping_writes_packages.
Implement deb_packages as an m2m field.
Remove unused import in test_api. Don't allow missing fields in deb_packages inside ping message. Add unique constraint to DebPackage model.
Merge migrations.
fc39ad4
to
c76eece
Compare
WoTTsecurity/agent#22
#23
Closes #391