Skip to content

Commit 6c66da6

Browse files
committed
Allow access to CVE API for Canonical publishers
1 parent 90f2091 commit 6c66da6

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

webapp/publisher/cve/cve_views.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ def get_cves(snap_name, revision):
5959
# Pagination params
6060
page = flask.request.args.get("page", default=1, type=int)
6161
page_size = flask.request.args.get("page_size", default=10, type=int)
62-
63-
snap_details = dashboard.get_snap_info(flask.session, snap_name)
64-
account_info = dashboard.get_account(flask.session)
6562
is_user_canonical = flask.session["publisher"].get("is_canonical", False)
66-
can_view_cves = CveHelper.can_user_access_cve_data(
67-
snap_name=snap_name,
68-
snap_details=snap_details,
69-
account_info=account_info,
70-
is_user_canonical=is_user_canonical,
71-
)
72-
if not can_view_cves:
63+
64+
# TODO: in future with brand store support we will need more specific
65+
# checks, such as those implemented in CveHelper.can_user_access_cve_data
66+
# For now, we only check if user is Canonical member and has
67+
# publisher access to the snap.
68+
if not is_user_canonical:
7369
return (
7470
flask.jsonify(
7571
{
@@ -80,6 +76,18 @@ def get_cves(snap_name, revision):
8076
403,
8177
)
8278

79+
snap_details = dashboard.get_snap_info(flask.session, snap_name)
80+
if not snap_details:
81+
return (
82+
flask.jsonify(
83+
{
84+
"success": False,
85+
"error": f"Snap '{snap_name}' not found.",
86+
}
87+
),
88+
404,
89+
)
90+
8391
cves = CveHelper.get_cve_with_revision(snap_name, revision)
8492
cves = CveHelper.filter_cve_data(
8593
cves,

0 commit comments

Comments
 (0)