aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2025-02-01 21:04:45 +0100
committerJ08nY2025-02-01 22:58:29 +0100
commit3173ff97ed4439b83b90f490a0b92c99c0dd375b (patch)
treeb309840cac7eef7c3b3cdaa2eb83581a1f0a10c0
parentd7ccc163ed1afa9e93c91f4a49443525185be424 (diff)
downloadsec-certs-3173ff97ed4439b83b90f490a0b92c99c0dd375b.tar.gz
sec-certs-3173ff97ed4439b83b90f490a0b92c99c0dd375b.tar.zst
sec-certs-3173ff97ed4439b83b90f490a0b92c99c0dd375b.zip
Revert the FIPS IUT and MIP from_web methods.
-rw-r--r--docs/installation.md2
-rw-r--r--docs/quickstart.md4
-rw-r--r--docs/user_guide.md6
-rw-r--r--src/sec_certs/sample/fips_iut.py24
-rw-r--r--src/sec_certs/sample/fips_mip.py21
-rw-r--r--tests/fips/test_fips_iut.py4
-rw-r--r--tests/fips/test_fips_mip.py4
7 files changed, 45 insertions, 20 deletions
diff --git a/docs/installation.md b/docs/installation.md
index d489b03c..6a33ec22 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -34,7 +34,7 @@ pip install -e .
python -m spacy download en_core_web_sm
```
-Alternatively, our Our [Dockerfile](https://github.com/crocs-muni/sec-certs/blob/main/Dockerfile) represents a reproducible way of setting up the environment.
+Alternatively, our [Dockerfile](https://github.com/crocs-muni/sec-certs/blob/main/Dockerfile) represents a reproducible way of setting up the environment.
:::
::::
diff --git a/docs/quickstart.md b/docs/quickstart.md
index 8371163f..039db94b 100644
--- a/docs/quickstart.md
+++ b/docs/quickstart.md
@@ -10,7 +10,7 @@ from sec_certs.dataset.cc import CCDataset
dset = CCDataset.from_web()
```
-to obtain to obtain freshly processed dataset from [sec-certs.org](https://sec-certs.org).
+to obtain the freshly processed dataset from [sec-certs.org](https://sec-certs.org).
3. Play with the dataset. See [example notebook](./notebooks/examples/cc.ipynb).
:::
@@ -23,7 +23,7 @@ from sec_certs.dataset.fips import FIPSDataset
dset = FIPSDataset.from_web()
```
-to obtain to obtain freshly processed dataset from [sec-certs.org](https://sec-certs.org).
+to obtain the freshly processed dataset from [sec-certs.org](https://sec-certs.org).
3. Play with the dataset. See [example notebook](./notebooks/examples/fips.ipynb).
:::
diff --git a/docs/user_guide.md b/docs/user_guide.md
index 8e6e2f4b..9191f689 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -11,16 +11,16 @@ Our tool matches certificates to their possible CVEs using datasets downloaded f
Our tool can seamlessly download the required NVD datasets when needed. We support two download mechanisms:
1. Fetching datasets with the [NVD API](https://nvd.nist.gov/developers/start-here) (preferred way).
-1. Fetching snapshots from seccerts.org.
+1. Fetching snapshots from sec-certs.org.
The following two keys control the behaviour:
```yaml
-preferred_source_aux_datasets: "api" # set to "sec-certs" to fetch them from sec-certs.org
+preferred_source_remote_datasets: "origin" # set to "sec-certs" to fetch them from sec-certs.org
nvd_api_key: null # or the actual key value
```
-If you aim to fetch the sources from NVD, we advise you to get an [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) and set the `nvd_api_key` setting accordingly. The download from NVD will work even without API key, it will just be slow. No API key is needed when `preferred_source_aux_datasets: "sec-certs"`
+If you aim to fetch the sources from NVD, we advise you to get an [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) and set the `nvd_api_key` setting accordingly. The download from NVD will work even without API key, it will just be slow. No API key is needed when `preferred_source_remote_datasets: "sec-certs"`
## Inferring inter-certificate reference context
diff --git a/src/sec_certs/sample/fips_iut.py b/src/sec_certs/sample/fips_iut.py
index c1c2900b..6d979dde 100644
--- a/src/sec_certs/sample/fips_iut.py
+++ b/src/sec_certs/sample/fips_iut.py
@@ -143,21 +143,31 @@ class IUTSnapshot(ComplexSerializableType):
return cls.from_page(content, snapshot_date)
@classmethod
- def from_web(cls) -> IUTSnapshot:
+ def from_nist_web(cls) -> IUTSnapshot:
"""
Get an IUT snapshot from the FIPS website right now.
"""
- if config.preferred_source_remote_datasets == "origin":
- iut_resp = requests.get(constants.FIPS_IUT_URL)
- else:
- iut_resp = requests.get(config.fips_iut_dataset)
+ iut_resp = requests.get(constants.FIPS_IUT_URL)
if iut_resp.status_code != 200:
raise ValueError(f"Getting IUT snapshot failed: {iut_resp.status_code}")
+ snapshot_date = to_utc(datetime.now())
+ return cls.from_page(iut_resp.content, snapshot_date)
+
+ @classmethod
+ def from_web(cls) -> IUTSnapshot:
+ """
+ Fetch a fresh snapshot from sec-certs.org, if the `preferred_source_remote_datasets` config
+ entry is equal to "sec-certs".
+
+ Otherwise, the same as `from_nist_web`.
+ """
if config.preferred_source_remote_datasets == "origin":
- snapshot_date = to_utc(datetime.now())
- return cls.from_page(iut_resp.content, snapshot_date)
+ return cls.from_nist_web()
else:
+ iut_resp = requests.get(config.fips_iut_latest_snapshot)
+ if iut_resp.status_code != 200:
+ raise ValueError(f"Getting IUT snapshot failed: {iut_resp.status_code}")
with NamedTemporaryFile() as tmpfile:
tmpfile.write(iut_resp.content)
return cls.from_json(tmpfile.name)
diff --git a/src/sec_certs/sample/fips_mip.py b/src/sec_certs/sample/fips_mip.py
index 875f0464..c7d84ad1 100644
--- a/src/sec_certs/sample/fips_mip.py
+++ b/src/sec_certs/sample/fips_mip.py
@@ -246,21 +246,28 @@ class MIPSnapshot(ComplexSerializableType):
return cls.from_page(content, snapshot_date)
@classmethod
- def from_web(cls) -> MIPSnapshot:
+ def from_nist_web(cls) -> MIPSnapshot:
"""
Get a MIP snapshot from the FIPS website right now.
"""
- if config.preferred_source_remote_datasets == "origin":
- mip_resp = requests.get(constants.FIPS_MIP_URL)
- else:
- mip_resp = requests.get(config.fips_mip_dataset)
+ mip_resp = requests.get(constants.FIPS_MIP_URL)
if mip_resp.status_code != 200:
raise ValueError(f"Getting MIP snapshot failed: {mip_resp.status_code}")
+ snapshot_date = to_utc(datetime.now())
+ return cls.from_page(mip_resp.content, snapshot_date)
+
+ @classmethod
+ def from_web(cls) -> MIPSnapshot:
+ """
+ Get a MIP snapshot from the FIPS website right now.
+ """
if config.preferred_source_remote_datasets == "origin":
- snapshot_date = to_utc(datetime.now())
- return cls.from_page(mip_resp.content, snapshot_date)
+ return cls.from_nist_web()
else:
+ mip_resp = requests.get(config.fips_mip_latest_snapshot)
+ if mip_resp.status_code != 200:
+ raise ValueError(f"Getting MIP snapshot failed: {mip_resp.status_code}")
with NamedTemporaryFile() as tmpfile:
tmpfile.write(mip_resp.content)
return cls.from_json(tmpfile.name)
diff --git a/tests/fips/test_fips_iut.py b/tests/fips/test_fips_iut.py
index 17597e1d..191b63d8 100644
--- a/tests/fips/test_fips_iut.py
+++ b/tests/fips/test_fips_iut.py
@@ -46,6 +46,10 @@ def test_iut_snapshot_from_web(preferred_source):
assert IUTSnapshot.from_web()
+def test_from_nist():
+ return IUTSnapshot.from_nist_web()
+
+
def test_iut_matching(processed_dataset: FIPSDataset):
entry = IUTEntry(
module_name="Red Hat Enterprise Linux 7.1 OpenSSL Module",
diff --git a/tests/fips/test_fips_mip.py b/tests/fips/test_fips_mip.py
index 15b0d4bf..8a1c36c9 100644
--- a/tests/fips/test_fips_mip.py
+++ b/tests/fips/test_fips_mip.py
@@ -47,6 +47,10 @@ def test_from_web(preferred_source):
assert MIPSnapshot.from_web()
+def test_from_nist():
+ return MIPSnapshot.from_nist_web()
+
+
def test_mip_matching(processed_dataset: FIPSDataset):
entry = MIPEntry(
module_name="Red Hat Enterprise Linux 7.1 OpenSSL Module",