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

Move PP dataset URL. #270

Merged
merged 1 commit into from
Oct 7, 2022
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
4 changes: 4 additions & 0 deletions sec_certs/config/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@
"cc_maintenances_latest_snapshot": {
"$ref": "#/definitions/settings_url_entry"
},
"pp_latest_snapshot": {
"$ref": "#/definitions/settings_url_entry"
},
"ignore_first_page": {
"$ref": "#/definitions/settings_boolean_entry"
},
Expand Down Expand Up @@ -170,6 +173,7 @@
"cpe_n_max_matches",
"cc_latest_snapshot",
"cc_maintenances_latest_snapshot",
"pp_latest_snapshot",
"ignore_first_page",
"cert_threshold",
"fips_latest_snapshot",
Expand Down
9 changes: 6 additions & 3 deletions sec_certs/config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ cpe_n_max_matches:
description: Maximum number of candidate CPE items that may be related to given certificate, >0
value: 100
cc_latest_snapshot:
description: Url from where to fetch the latest snapshot of fully processed CC dataset
description: URL from where to fetch the latest snapshot of fully processed CC dataset
value: https://seccerts.org/cc/dataset.json
cc_maintenances_latest_snapshot:
description: Url from where to fetch the latest snapshot of CC maintenance updates
description: URL from where to fetch the latest snapshot of CC maintenance updates
value: https://seccerts.org/cc/maintenance_updates.json
pp_latest_snapshot:
description: URL from where to fetch the latest snapshot of the PP dataset
value: https://seccerts.org/static/pp.json
ignore_first_page:
description: During keyword search, first page usually contains addresses - ignore it.
value: true
cert_threshold:
description: Used with --higher-precision-results. Determines the amount of mismatched algorithms to be considered faulty.
value: 5
fips_latest_snapshot:
description: Url for the latest snapshot of FIPS dataset
description: URL for the latest snapshot of FIPS dataset
value: https://seccerts.org/fips/dataset.json
minimal_token_length:
description: Minimal length of a string that will be considered as a token during keyword extraction in CVE matching
Expand Down
10 changes: 5 additions & 5 deletions sec_certs/dataset/protection_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import tempfile
from dataclasses import dataclass
from pathlib import Path
from typing import ClassVar, Dict, Optional, Tuple, Union
from typing import Dict, Optional, Tuple, Union

import sec_certs.utils.helpers as helpers
from sec_certs.config.configuration import config
from sec_certs.sample.protection_profile import ProtectionProfile

logger = logging.getLogger(__name__)


@dataclass
class ProtectionProfileDataset:
static_dataset_url: ClassVar[str] = "https://ajanovsky.cz/pp_data_complete_processed.json"

pps: Dict[Tuple[str, Optional[str]], ProtectionProfile]

def __iter__(self):
Expand Down Expand Up @@ -48,12 +47,13 @@ def from_json(cls, json_path: Union[str, Path]):

@classmethod
def from_web(cls, store_dataset_path: Optional[Path] = None):
logger.info(f"Downloading static PP dataset from: {cls.static_dataset_url}")

logger.info(f"Downloading static PP dataset from: {config.pp_latest_snapshot}")
if not store_dataset_path:
tmp = tempfile.TemporaryDirectory()
store_dataset_path = Path(tmp.name) / "pp_dataset.json"

helpers.download_file(cls.static_dataset_url, store_dataset_path)
helpers.download_file(config.pp_latest_snapshot, store_dataset_path)
obj = cls.from_json(store_dataset_path)

if not store_dataset_path:
Expand Down