Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Store the list of deb packages. #401

Merged
merged 17 commits into from Sep 11, 2019

Conversation

a-martynovich
Copy link
Contributor

@@ -22,6 +22,7 @@
'django_extensions'
]

IS_DEV = True
IS_MTLS_API=IS_API=IS_DASH=IS_DEV = True
Copy link
Contributor

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Снимок экрана 2019-09-06 в 14 38 08

Usually in Django they do this ^ way. What's the advantage of your approach?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@rptrchv
Copy link
Contributor

rptrchv commented Sep 6, 2019

@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

@a-martynovich
Copy link
Contributor Author

@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.
Also I forgot that we need to store deb package OS version and arch.

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)
Copy link
Contributor

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

Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn for packages
3 participants