diff options
| author | Ján Jančár | 2025-04-03 18:07:31 +0200 |
|---|---|---|
| committer | GitHub | 2025-04-03 18:07:31 +0200 |
| commit | 617f4ce42b03c4d5cd322221379e09c576ae7ff3 (patch) | |
| tree | bbec5d50601140e3b5b7690a4cf8a29a06a6de82 | |
| parent | a46b3470f5c7c83798ac5339f5cb580c4ab82bf1 (diff) | |
| parent | 7c902e872abe246128e0764a84d6f6f8030646b3 (diff) | |
| download | sec-certs-617f4ce42b03c4d5cd322221379e09c576ae7ff3.tar.gz sec-certs-617f4ce42b03c4d5cd322221379e09c576ae7ff3.tar.zst sec-certs-617f4ce42b03c4d5cd322221379e09c576ae7ff3.zip | |
Merge pull request #495 from crocs-muni/fix/schemes-again2
Fix/schemes again2
| -rw-r--r-- | .github/workflows/cron.yml | 13 | ||||
| -rw-r--r-- | .github/workflows/tests.yml | 13 | ||||
| -rw-r--r-- | src/sec_certs/constants.py | 6 | ||||
| -rw-r--r-- | src/sec_certs/sample/cc_scheme.py | 103 |
4 files changed, 88 insertions, 47 deletions
diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 9640f86d..3ca22f49 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -32,9 +32,20 @@ jobs: pip install -e . python -m spacy download en_core_web_sm - name: Run tests - run: pytest --cov=sec_certs -m "remote" tests + run: pytest --cov=sec_certs -m "remote" --junitxml=junit.xml -o junit_family=legacy tests continue-on-error: true + - name: Test summary + if: always() + uses: test-summary/action@v2 + with: + paths: junit.xml + show: "fail, skip" - name: Code coverage upload uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }}
\ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 69f55e40..69e173b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,8 +31,19 @@ jobs: pip install -e . python -m spacy download en_core_web_sm - name: Run tests - run: pytest --cov=sec_certs -m "not remote" tests + run: pytest --cov=sec_certs -m "not remote" --junitxml=junit.xml -o junit_family=legacy tests + - name: Test summary + if: always() + uses: test-summary/action@v2 + with: + paths: junit.xml + show: "fail, skip" - name: Code coverage upload uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }}
\ No newline at end of file diff --git a/src/sec_certs/constants.py b/src/sec_certs/constants.py index fc3dd3a5..59c54386 100644 --- a/src/sec_certs/constants.py +++ b/src/sec_certs/constants.py @@ -165,9 +165,9 @@ CC_KOREA_CERTIFIED_URL = CC_KOREA_BASE_URL + "/certprod/listA.do" CC_KOREA_SUSPENDED_URL = CC_KOREA_BASE_URL + "/certprod/listB.do" CC_KOREA_ARCHIVED_URL = CC_KOREA_BASE_URL + "/certprod/listD.do" CC_KOREA_PRODUCT_URL = CC_KOREA_BASE_URL + "/certprod/view.do?product_id={}&product_class={}" -CC_POLAND_BASE_URL = "https://en.nask.pl" -CC_POLAND_CERTIFIED_URL = CC_POLAND_BASE_URL + "/eng/activities/certification/list-of-certificates" -CC_POLAND_INEVAL_URL = CC_POLAND_BASE_URL + "/eng/activities/certification/ongoing-certifications" +CC_POLAND_BASE_URL = "https://certyfikacja.nask.pl/" +CC_POLAND_CERTIFIED_URL = CC_POLAND_BASE_URL + "/een/certificates/" +CC_POLAND_INEVAL_URL = CC_POLAND_BASE_URL + "/en/certifications-in-progress/" CC_SINGAPORE_BASE_URL = "https://www.csa.gov.sg" CC_SINGAPORE_CERTIFIED_URL = ( CC_SINGAPORE_BASE_URL + "/Programmes/certification-and-labelling-schemes/csa-common-criteria/product-list" diff --git a/src/sec_certs/sample/cc_scheme.py b/src/sec_certs/sample/cc_scheme.py index 2cc9fc48..f9c22b3f 100644 --- a/src/sec_certs/sample/cc_scheme.py +++ b/src/sec_certs/sample/cc_scheme.py @@ -1345,7 +1345,7 @@ def get_korea_archived(enhanced: bool = True, artifacts: bool = False) -> list[d ) -def get_poland_certified(artifacts: bool = False) -> list[dict[str, Any]]: +def get_poland_certified(artifacts: bool = False) -> list[dict[str, Any]]: # noqa: C901 """ Get Polish "certified product" entries. @@ -1353,33 +1353,47 @@ def get_poland_certified(artifacts: bool = False) -> list[dict[str, Any]]: :return: The entries. """ soup = _get_page(constants.CC_POLAND_CERTIFIED_URL) - table = soup.find("table", class_="cert_tb") + accordion = soup.find("div", class_="gs-accordion") results = [] - for tr in tqdm(table.find_all("tr")[1:], desc="Get PL scheme certified."): - tds = tr.find_all("td") - cert = { - "client": sns(tds[0].text), - "product": sns(tds[1].text), - "certification_date": parse_date(sns(tds[4].text), "%d.%m.%Y"), - "expiration_date": parse_date(sns(tds[5].text), "%d.%m.%Y"), - } - cc_entry = sns(tds[2].text) - cc_split = None - if cc_entry and "\n" in cc_entry: - cc_split = cc_entry.split("\n") - elif cc_entry and "," in cc_entry: - cc_split = cc_entry.split(",") - if cc_split: - cert["cc_version"] = cc_split[0].strip() - cert["assurance_level"] = ", ".join(cc_split[1:]).strip() - - for name, i in (("report", 6), ("target", 7), ("cert", 8)): - a = tds[i].find("a") - if a: - href = urljoin(constants.CC_POLAND_BASE_URL, a["href"]) - cert[f"{name}_link"] = href + for div in tqdm(accordion.find_all("div", class_="gs-accordion-item"), desc="Get PL scheme certified."): + head = sns(div.find("div", class_="gs-accordion-item__heading").text) + cert = {"product": head} + for row in div.find_all("div", class_="gspb_row"): + ps = list(row.find_all("p")) + label = sns(ps[0].text) + val = sns(ps[1].text) + a = ps[1].find("a") + href = urljoin(constants.CC_POLAND_BASE_URL, a["href"]) if a else None + if label == "Client’s name and address": + cert["client"] = val + elif label == "Certification scope": + cc_entry = val + cc_split = None + if cc_entry and "\n" in cc_entry: + cc_split = cc_entry.split("\n") + elif cc_entry and "," in cc_entry: + cc_split = cc_entry.split(",") + if cc_split: + cert["cc_version"] = cc_split[0].strip() + cert["assurance_level"] = ", ".join(cc_split[1:]).strip() + elif label == "Certificate decision date": + cert["decision_date"] = parse_date(val, "%d.%m.%Y") + elif label == "Certificate issue date": + cert["certification_date"] = parse_date(val, "%d.%m.%Y") + elif label == "End of validity": + cert["expiration_date"] = parse_date(val, "%d.%m.%Y") + elif label == "Certification Report" and href: + cert["report_link"] = href if artifacts: - cert[f"{name}_hash"] = _get_hash(href) + cert["report_hash"] = _get_hash(href) + elif label == "Security Target" and href: + cert["target_link"] = href + if artifacts: + cert["target_hash"] = _get_hash(href) + elif label == "Certificate" and href: + cert["cert_link"] = href + if artifacts: + cert["cert_hash"] = _get_hash(href) results.append(cert) return results @@ -1391,23 +1405,28 @@ def get_poland_ineval() -> list[dict[str, Any]]: :return: The entries. """ soup = _get_page(constants.CC_POLAND_INEVAL_URL) - table = soup.find("table", class_="cert_tb") + accordion = soup.find("div", class_="gs-accordion") results = [] - for tr in tqdm(table.find_all("tr")[1:], desc="Get PL scheme in evaluation."): - tds = tr.find_all("td") - cert = { - "client": sns(tds[0].text), - "product": sns(tds[1].text), - } - cc_entry = sns(tds[2].text) - cc_split = None - if cc_entry and "\n" in cc_entry: - cc_split = cc_entry.split("\n") - elif cc_entry and "," in cc_entry: - cc_split = cc_entry.split(",") - if cc_split: - cert["cc_version"] = cc_split[0].strip() - cert["assurance_level"] = ", ".join(cc_split[1:]).strip() + for div in tqdm(accordion.find_all("div", class_="gs-accordion-item"), desc="Get PL scheme in evaluation."): + head = sns(div.find("div", class_="gs-accordion-item__heading").text) + cert = {"client": head} + for row in div.find_all("div", class_="gspb_row"): + one = row.find("div", class_="gspb_row__content") + ps = list(one.find_all("div", recursive=False)) + label = sns(ps[0].text) + val = sns(ps[1].text) + if label == "Product, version": + cert["product"] = val + elif label == "Certification scope": + cc_entry = val + cc_split = None + if cc_entry and "\n" in cc_entry: + cc_split = cc_entry.split("\n") + elif cc_entry and "," in cc_entry: + cc_split = cc_entry.split(",") + if cc_split: + cert["cc_version"] = cc_split[0].strip() + cert["assurance_level"] = ", ".join(cc_split[1:]).strip() results.append(cert) return results |
