Skip to content

Commit

Permalink
fix: [website] Make the GET List (with filters) for Bundles in the AP…
Browse files Browse the repository at this point in the history
…I case insensitive.
  • Loading branch information
cedricbonhomme committed Oct 1, 2024
1 parent c123281 commit 32c9bb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion website/web/api/v1/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from flask_restx import Namespace
from flask_restx import reqparse
from flask_restx import Resource
from sqlalchemy import String, cast, func

from vulnerabilitylookup.default import get_config
from website.lib.utils import find_cve_ids
Expand Down Expand Up @@ -161,7 +162,12 @@ def get(self) -> Tuple[ResultType, int]:
if author is not None:
query = query.filter(Bundle.author.has(login=author))
if vuln_id is not None:
query = query.filter(Bundle.related_vulnerabilities.contains([vuln_id]))
# query = query.filter(Bundle.related_vulnerabilities.contains([vuln_id]))
query = query.filter(
func.lower(cast(Bundle.related_vulnerabilities, String)).contains(
vuln_id.lower()
)
)
if meta_query is not None:
query = query.filter(Bundle.meta.contains(meta_query))

Expand Down
6 changes: 5 additions & 1 deletion website/web/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Response,
)
from flask_paginate import get_page_args # type: ignore[import-untyped]
from sqlalchemy import String, cast, func

from werkzeug import Response as WerkzeugResponse

Expand Down Expand Up @@ -188,8 +189,11 @@ def vulnerability_view(vulnerability_id: str) -> str:
Comment.vulnerability.ilike(vulnerability_id)
).count()
nb_bundles = Bundle.query.filter(
Bundle.related_vulnerabilities.contains([vulnerability_id])
func.lower(cast(Bundle.related_vulnerabilities, String)).contains(
vulnerability_id.lower()
)
).count()

return render_template(
"vuln.html",
source=source,
Expand Down

0 comments on commit 32c9bb4

Please sign in to comment.