Skip to content

Commit dfddac4

Browse files
authored
Merge pull request #191 from canonical/revert-186-cve-status-update
Revert "Update cve status options and apply updates across test fixtures"
2 parents 4db192c + 14bf46e commit dfddac4

File tree

12 files changed

+19
-94
lines changed

12 files changed

+19
-94
lines changed
Binary file not shown.

migrations/versions/654254322cd3_update_cve_statuses.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

scripts/generate-sample-security-data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
patches={},
5050
tags={},
5151
bugs={},
52-
status="in-progress",
52+
status="active",
5353
)
5454
db.session.add(cve)
5555
cves.append(cve)

scripts/payloads/cves.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"https://www.mozilla.org/en-US/security/advisories/mfsa2020-08/#CVE-2019-20503",
8181
"https://usn.ubuntu.com/usn/usn-4299-1"
8282
],
83-
"status": "in-progress",
83+
"status": "active",
8484
"tags": {},
8585
"ubuntu_description": ""
8686
}

tests/fixtures/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def make_cve(
3030
patches={},
3131
tags={},
3232
bugs={},
33-
status="in-progress",
33+
status="active",
3434
):
3535
cve = CVE(
3636
id=id,

tests/fixtures/payloads.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
},
4949
"priority": "critical",
5050
"published": "2020-08-01 12:42:54",
51-
"status": "not-in-ubuntu",
5251
}
5352

5453
cve2 = {
@@ -75,7 +74,7 @@
7574
],
7675
"published": "2020-11-01 12:42:54",
7776
"priority": "high",
78-
"status": "in-progress",
77+
"status": "active",
7978
}
8079

8180
cve3 = {
@@ -102,7 +101,7 @@
102101
],
103102
"priority": "medium",
104103
"published": "2019-12-01 12:42:54",
105-
"status": "in-progress",
104+
"status": "active",
106105
}
107106

108107
cve4 = {
@@ -128,7 +127,7 @@
128127
],
129128
"priority": "medium",
130129
"published": "2022-12-01 12:42:54",
131-
"status": "in-progress",
130+
"status": "active",
132131
}
133132

134133
cve5 = {
@@ -153,7 +152,7 @@
153152
],
154153
"published": "2020-12-01 12:42:54",
155154
"priority": "low",
156-
"status": "in-progress",
155+
"status": "active",
157156
}
158157

159158
cve6 = {
@@ -178,7 +177,7 @@
178177
],
179178
"published": "2020-12-01 12:42:54",
180179
"priority": "negligible",
181-
"status": "in-progress",
180+
"status": "active",
182181
}
183182

184183
cve7 = {
@@ -203,7 +202,7 @@
203202
],
204203
"published": "2020-12-01 12:42:54",
205204
"priority": "negligible",
206-
"status": "in-progress",
205+
"status": "active",
207206
}
208207

209208
cve8 = {
@@ -228,7 +227,7 @@
228227
],
229228
"published": "2020-12-01 12:42:54",
230229
"priority": "negligible",
231-
"status": "in-progress",
230+
"status": "active",
232231
}
233232

234233
notice = {

tests/test_routes.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ def test_cves_query_no_500(self):
4848

4949
assert response.status_code == 200
5050

51-
def test_cves_default_status(self):
52-
# Add new CVE without status
53-
cve_payload = payloads.cve1.copy()
54-
55-
add_cve_response = self.client.put(
56-
"/security/updates/cves.json",
57-
json=[cve_payload],
58-
)
59-
60-
assert add_cve_response.status_code == 200
61-
response = self.client.get("/security/cves.json")
62-
63-
assert response.status_code == 200
64-
# Only the CVE with the default "in-progress" status should be returned
65-
assert len(response.json["cves"]) == 1
66-
assert response.json["cves"][0]["status"] == "in-progress"
67-
6851
def test_cves_returns_200_for_non_existing_package_name(self):
6952
response = self.client.get("/security/cves.json?package=no-exist")
7053

@@ -706,7 +689,7 @@ def test_cve_group_by_functionality(self):
706689
Tests that CVEs are correctly grouped by priority
707690
and ordered by publish date.
708691
"""
709-
# Check that there is one CVE in the db with an "in-progress" status
692+
# Check that there is one CVE in the db with an active status
710693
# and a critical priority
711694
initial_cves = self.client.get("/security/cves.json")
712695

webapp/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from webapp.api_spec import WebappFlaskApiSpec
99
from webapp.commands import register_commands
10-
from webapp.database import db, init_db # noqa: F401
10+
from webapp.database import init_db
1111
from webapp.views import (
1212
bulk_upsert_cve,
1313
create_notice,

webapp/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Boolean,
77
Column,
88
DateTime,
9+
Enum,
910
Float,
1011
ForeignKey,
1112
JSON,
@@ -23,7 +24,6 @@
2324
COMPONENT_OPTIONS,
2425
POCKET_OPTIONS,
2526
PRIORITY_OPTIONS,
26-
CVE_STATUSES,
2727
)
2828

2929

@@ -63,7 +63,9 @@ class CVE(db.Model):
6363
patches = Column(JSON)
6464
tags = Column(JSON)
6565
bugs = Column(JSON)
66-
status = Column(CVE_STATUSES)
66+
status = Column(
67+
Enum("not-in-ubuntu", "active", "rejected", name="cve_statuses")
68+
)
6769
statuses = relationship("Status", cascade="all, delete-orphan")
6870
notices = relationship(
6971
"Notice", secondary=notice_cves, back_populates="cves"

webapp/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class CVEsAPISchema(Schema):
529529
),
530530
"cve_status": String(
531531
description="CVE status",
532-
enum=["not-in-ubuntu", "in-progress", "rejected"],
532+
enum=["not-in-ubuntu", "active", "rejected"],
533533
allow_none=True,
534534
),
535535
"status": List(

webapp/types.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,3 @@
4949
"critical",
5050
name="priorities",
5151
)
52-
53-
CVE_STATUSES = Enum(
54-
"not-in-ubuntu",
55-
"in-progress",
56-
"rejected",
57-
name="cve_statuses",
58-
)

webapp/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ def get_cves(**kwargs):
104104
sort_by = kwargs.get("sort_by")
105105
show_hidden = kwargs.get("show_hidden", False)
106106

107-
# query cves by filters. Default filter by "in-progress" CVEs
107+
# query cves by filters. Default filter by active CVEs
108108
if cve_status:
109109
cves_query: Query = db.session.query(CVE).filter(
110110
CVE.status == cve_status
111111
)
112112
else:
113113
cves_query: Query = db.session.query(CVE).filter(
114-
CVE.status == "in-progress"
114+
CVE.status == "active"
115115
)
116116

117117
# order by priority

0 commit comments

Comments
 (0)