Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NVD tests. #414

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ env:
jobs:
test:
runs-on: ubuntu-22.04
env:
SECCERTS_NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
steps:
- name: apt-get update
run: sudo apt-get update
Expand All @@ -31,4 +33,6 @@ jobs:
- name: Run tests
run: pytest --cov=sec_certs tests
- name: Code coverage upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion src/sec_certs/utils/nvd_dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _init_new_dataset() -> CVEDataset:
class CpeMatchNvdDatasetBuilder(NvdDatasetBuilder[dict]):
_ENDPOINT: Final[str] = "CPEMatch"
_ENDPOINT_URL: Final[str] = "https://services.nvd.nist.gov/rest/json/cpematch/2.0"
_RESULTS_PER_PAGE: Final[int] = 5000
_RESULTS_PER_PAGE: Final[int] = 500
_VERSION_KEYS: Final[list[str]] = [
"versionStartIncluding",
"versionStartExcluding",
Expand Down
7 changes: 3 additions & 4 deletions tests/test_nvd_dataset_builder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import date, datetime, timedelta
from importlib import resources
from importlib.resources import files
from typing import Any

import pytest

import tests.data.common
from sec_certs.configuration import config
from sec_certs.dataset import CCDataset, CPEDataset, CVEDataset
from sec_certs.utils.nvd_dataset_builder import (
Expand All @@ -17,7 +16,7 @@

@pytest.fixture(autouse=True)
def load_test_config():
with resources.path(tests.data.common, "settings_tests.yml") as path:
with files("tests.data.common") / "settings_tests.yml" as path:
config.load_from_yaml(path)


Expand Down Expand Up @@ -62,7 +61,7 @@ def get_dataset_len(dset) -> int:
return len(dset["match_strings"])

config.preferred_source_nvd_datasets = "api"
with builder_class() as dataset_builder:
with builder_class(api_key=config.nvd_api_key) as dataset_builder:
dataset = dataset_builder._init_new_dataset()
assert dataset == default_dataset
last_update = dataset_builder._get_last_update_from_previous_data(dataset)
Expand Down
Loading