Skip to content

Commit

Permalink
Avoiding empty attributes from CVE search result's
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Bogulean authored and binareio committed Aug 15, 2024
1 parent 78b5a65 commit 84e1a43
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/common/models/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Config:

class CveItem(BaseModel):
class Config:
extra = Extra.forbid
extra = Extra.ignore

id: constr(regex=r'^CVE-[0-9]{4}-[0-9]{4,}$')
sourceIdentifier: Optional[str] = None
Expand Down
4 changes: 2 additions & 2 deletions src/web/routers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def search(appctx: ApplicationContext, opts: SearchOptions) -> any:


# ------------------------------------------------------------------------------
@router.get("/cve", name="Search CVE", response_model=CveOutput)
@router.get("/cve", name="Search CVE", response_model=CveOutput, response_model_exclude_unset=True)
async def search_cve(cmn_opts: SearchInputCommon = Depends(SearchInputCommon),
cve_opts: SearchInputCve = Depends(SearchInputCve),
appctx: ApplicationContext = Depends(get_app_cntxt),
Expand Down Expand Up @@ -80,7 +80,7 @@ async def search_cve(cmn_opts: SearchInputCommon = Depends(SearchInputCommon),


# ------------------------------------------------------------------------------
@router.get("/cpe", name="Search CPE", response_model=CpeOutput)
@router.get("/cpe", name="Search CPE", response_model=CpeOutput, response_model_exclude_unset=True)
async def search_cpe(cmn_opts: SearchInputCommon = Depends(SearchInputCommon),
cpe_opts: SearchInputCpe = Depends(SearchInputCpe),
appctx: ApplicationContext = Depends(get_app_cntxt),
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_cve_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def test_cve_search_by_id(cli_runner):
"""Search CVEs by ID and requests output as ID"""

import pdb; pdb.set_trace()
result = cli_runner.runcommand("docker exec fastcve search --search-info cve --cve CVE-1999-0001 --output id")
assert result.returncode == 0
assert result.stdout[:13] == 'CVE-1999-0001'
Expand Down

0 comments on commit 84e1a43

Please sign in to comment.