33
33
34
34
class Vulnerability (models .Model ):
35
35
"""
36
- A software vulnerability with minimal information.
37
- Identifiers other than CVE ID are stored as VulnerabilityReference.
36
+ A software vulnerability with minimal information. Identifiers other than CVE ID are stored as
37
+ VulnerabilityReference.
38
38
"""
39
39
cve_id = models .CharField (max_length = 50 , help_text = 'CVE ID' , unique = True , null = True )
40
40
summary = models .TextField (help_text = 'Summary of the vulnerability' , blank = True )
@@ -49,8 +49,7 @@ class Meta:
49
49
50
50
class VulnerabilityReference (models .Model ):
51
51
"""
52
- A reference to a vulnerability such as a security advisory from
53
- a Linux distribution or language package manager.
52
+ A reference to a vulnerability such as a security advisory from a Linux distribution or language package manager.
54
53
"""
55
54
vulnerability = models .ForeignKey (
56
55
Vulnerability , on_delete = models .CASCADE )
@@ -70,13 +69,12 @@ def __str__(self):
70
69
71
70
class Package (PackageURLMixin ):
72
71
"""
73
- A software package with minimal identifying information.
74
- Other identifiers are stored as PackageReference.
72
+ A software package with links to relevant vulnerabilities.
75
73
"""
76
74
vulnerabilities = models .ManyToManyField (to = 'Vulnerability' , through = 'ImpactedPackage' )
77
75
78
76
def __str__ (self ):
79
- return self .name
77
+ return self .package_url
80
78
81
79
82
80
class ImpactedPackage (models .Model ):
@@ -92,56 +90,23 @@ class Meta:
92
90
93
91
class ResolvedPackage (models .Model ):
94
92
"""
95
- Relates a vulnerability to package(s) that contain
96
- a fix or resolution of this vulnerability.
93
+ Relates a vulnerability to package(s) that contain a fix or resolution of this vulnerability.
97
94
"""
98
95
vulnerability = models .ForeignKey (Vulnerability , on_delete = models .CASCADE )
99
96
package = models .ForeignKey (Package , on_delete = models .CASCADE )
100
97
101
98
102
- class PackageReference (models .Model ):
103
- """
104
- One or more identifiers and references for a software package
105
- in a package repository, such as a Debian, Maven or NPM repository.
106
- """
107
- package = models .ForeignKey (Package , on_delete = models .CASCADE )
108
- repository = models .CharField (
109
- max_length = 100 ,
110
- help_text = 'Repository URL eg:http://central.maven.org' ,
111
- blank = True ,
112
- )
113
- platform = models .CharField (
114
- max_length = 50 ,
115
- help_text = 'Platform eg:maven' ,
116
- blank = True ,
117
- )
118
- name = models .CharField (
119
- max_length = 50 ,
120
- help_text = 'Package reference name eg:org.apache.commons.io' ,
121
- blank = True ,
122
- )
123
- version = models .CharField (
124
- max_length = 50 ,
125
- help_text = 'Reference version' ,
126
- blank = True ,
127
- )
128
-
129
- def __str__ (self ):
130
- return self .platform
131
-
132
-
133
99
class Importer (models .Model ):
134
100
"""
135
- Metadata and pointer to the implementation for a source
136
- of vulnerability data (aka security advisories)
101
+ Metadata and pointer to the implementation for a source of vulnerability data (aka security advisories)
137
102
"""
138
103
name = models .CharField (max_length = 100 , unique = True , help_text = 'Name of the importer' )
139
104
license = models .CharField (max_length = 100 , blank = True , help_text = 'License of the vulnerability data' )
140
105
last_run = models .DateTimeField (null = True , help_text = 'UTC Timestamp of the last run' )
141
-
106
+
142
107
data_source = models .CharField (
143
108
max_length = 100 ,
144
- help_text = 'Class name of the data source implementation importable from vulnerabilities.importers' ,
109
+ help_text = 'Class name of the data source implementation importable from vulnerabilities.importers' ,
145
110
)
146
111
data_source_cfg = pgfields .JSONField (
147
112
null = False ,
@@ -151,8 +116,7 @@ class Importer(models.Model):
151
116
152
117
def make_data_source (self , cutoff_date = None , batch_size = None ) -> DataSource :
153
118
"""
154
- Return a configured and ready to use instance of
155
- this importers data source implementation.
119
+ Return a configured and ready to use instance of this importers data source implementation.
156
120
157
121
cutoff_date - timestamp of the oldest data to include in the import (default: self.last_run)
158
122
batch_size - max. number of records to return on each iteration
0 commit comments