49
49
def get_all_repositories (skip : int = Query (default = 0 , ge = 0 ),
50
50
limit : int = Query (default = DEFAULT_RECORDS_PER_PAGE_LIMIT , ge = 1 ),
51
51
vcsproviders : List [VCSProviders ] = Query (None , alias = "vcsprovider" , title = "VCSProviders" ),
52
- projectfilter : Optional [str ] = Query ('' , regex = r"^[A-z0-9 .\-_%]*$" ),
53
- repositoryfilter : Optional [str ] = Query ('' , regex = r"^[A-z0-9 .\-_%]*$" ),
52
+ projectfilter : Optional [str ] = Query ('' , pattern = r"^[A-z0-9 .\-_%]*$" ),
53
+ repositoryfilter : Optional [str ] = Query ('' , pattern = r"^[A-z0-9 .\-_%]*$" ),
54
54
db_connection : Session = Depends (get_db_connection )) \
55
55
-> PaginationModel [repository_schema .RepositoryRead ]:
56
56
"""
@@ -208,7 +208,7 @@ async def delete_repository(repository_id: int, db_connection: Session = Depends
208
208
})
209
209
@cache (namespace = CACHE_NAMESPACE_REPOSITORY , expire = REDIS_CACHE_EXPIRE )
210
210
def get_distinct_projects (vcsproviders : List [VCSProviders ] = Query (None , alias = "vcsprovider" , title = "VCSProviders" ),
211
- repositoryfilter : Optional [str ] = Query ('' , regex = r"^[A-z0-9 .\-_%]*$" ),
211
+ repositoryfilter : Optional [str ] = Query ('' , pattern = r"^[A-z0-9 .\-_%]*$" ),
212
212
onlyifhasfindings : bool = Query (default = False ),
213
213
db_connection : Session = Depends (get_db_connection )) -> List [str ]:
214
214
"""
@@ -241,7 +241,7 @@ def get_distinct_projects(vcsproviders: List[VCSProviders] = Query(None, alias="
241
241
})
242
242
@cache (namespace = CACHE_NAMESPACE_REPOSITORY , expire = REDIS_CACHE_EXPIRE )
243
243
def get_distinct_repositories (vcsproviders : List [VCSProviders ] = Query (None , alias = "vcsprovider" , title = "VCSProviders" ),
244
- projectname : Optional [str ] = Query ('' , regex = r"^[A-z0-9 .\-_%]*$" ),
244
+ projectname : Optional [str ] = Query ('' , pattern = r"^[A-z0-9 .\-_%]*$" ),
245
245
onlyifhasfindings : bool = Query (default = False ),
246
246
db_connection : Session = Depends (get_db_connection )) -> List [str ]:
247
247
"""
@@ -318,9 +318,9 @@ def get_all_repositories_with_findings_metadata(
318
318
vcsproviders : List [VCSProviders ] = Query (None , alias = "vcsprovider" ,
319
319
title = "VCSProviders" ),
320
320
projectfilter : Optional [str ] = Query ('' ,
321
- regex = r"^[A-z0-9 .\-_%]*$" ),
321
+ pattern = r"^[A-z0-9 .\-_%]*$" ),
322
322
repositoryfilter : Optional [str ] = Query ('' ,
323
- regex = r"^[A-z0-9 .\-_%]*$" ),
323
+ pattern = r"^[A-z0-9 .\-_%]*$" ),
324
324
onlyifhasfindings : bool = Query (default = False ),
325
325
db_connection : Session = Depends (get_db_connection )) \
326
326
-> PaginationModel [repository_enriched_schema .RepositoryEnrichedRead ]:
@@ -383,6 +383,7 @@ def get_all_repositories_with_findings_metadata(
383
383
status_code = status .HTTP_200_OK ,
384
384
responses = {
385
385
200 : {"description" : "Retrieve the latest scan related to a repository" },
386
+ 404 : {"description" : "Scan not found" },
386
387
500 : {"description" : ERROR_MESSAGE_500 },
387
388
503 : {"description" : ERROR_MESSAGE_503 }
388
389
})
@@ -398,7 +399,8 @@ def get_last_scan_for_repository(repository_id: int, db_connection: Session = De
398
399
or empty if no scan was found
399
400
"""
400
401
last_scan = scan_crud .get_latest_scan_for_repository (db_connection , repository_id = repository_id )
401
-
402
+ if last_scan is None :
403
+ raise HTTPException (status_code = 404 , detail = "Scan not found" )
402
404
return last_scan
403
405
404
406
0 commit comments