Skip to content

Commit

Permalink
Ignore unknown distributions on source search
Browse files Browse the repository at this point in the history
  • Loading branch information
credbbl committed Dec 19, 2023
1 parent 319340f commit cd73635
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/glvd/web/v1_cves.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,27 @@ async def get_sources() -> tuple[Any, int, dict[str, str]]:
# can remove the enormous time spent on compiling queries
stmts_source = []
for i, j in source_by_dist.items():
dist = DistCpeMapper.new(i[0])(i[1])
dist_id = (await conn.execute(
sa.select(DistCpe.id)
.where(DistCpe.cpe_vendor == dist.cpe_vendor)
.where(DistCpe.cpe_product == dist.cpe_product)
.where(DistCpe.cpe_version == dist.cpe_version)
)).one()[0]

for source, version in j:
stmts_source.append(
sa.select(
sa.literal(dist_id).label('dist_id'),
sa.literal(source).label('deb_source'),
sa.cast(sa.literal(version), DebVersion).label('deb_version'),
try:
dist = DistCpeMapper.new(i[0].lower())(i[1].lower())
except KeyError:
# XXX: How to handle unknown distributions?
pass
else:
dist_id = (await conn.execute(
sa.select(DistCpe.id)
.where(DistCpe.cpe_vendor == dist.cpe_vendor)
.where(DistCpe.cpe_product == dist.cpe_product)
.where(DistCpe.cpe_version == dist.cpe_version)
)).one()[0]

for source, version in j:
stmts_source.append(
sa.select(
sa.literal(dist_id).label('dist_id'),
sa.literal(source).label('deb_source'),
sa.cast(sa.literal(version), DebVersion).label('deb_version'),
)
)
)

# If we found no source at all
if not stmts_source:
Expand Down

0 comments on commit cd73635

Please sign in to comment.