[DUP-3] Small duplicates: serial-lookup loop, pem_to_der_b64, issuer-CN filter ×3, SOAP retry ladder, hash_secret/generate_secret, base-URL default ×3, XML escaping lib↔script #38

Closed
opened 2026-11-14 18:29:00 +01:00 by amiryahaya · 1 comment
Owner

Finding

The CertSerialNumber.lookup_variants |> Enum.reduce_while lookup is duplicated controller↔OCSP responder; pem_to_der_b64/1 verbatim ×2; the optional-issuer-CN filter exists ×3; the SOAP check-then-retry-with-issuer ladder ×2 (+test); hash_secret/generate_secret duplicated client_credentials↔token; the https://mdidws.mypqc.com.my default string ×3 (see M-14); XML escaping duplicated between national_id_client.ex and scripts/10_soap_enroll.sh.

Evidence

  • cert_management_controller.ex:216-226 vs ocsp_responder.ex:142-153; renewal.ex:572-579 vs cert_management_controller.ex:633-640; renewal.ex:436-441 vs cert_management_controller.ex:354-359, 597-601; enrollment.ex:99-124 vs renewal.ex:268-289; client_credentials.ex:24-26, 56-58 vs token.ex:138-144; crl_publisher.ex:49 / ocsp_responder.ex:15 / issuer_manager.ex:23; national_id_client.ex:397-405 vs scripts/10_soap_enroll.sh:64-69

Impact

Divergence risk on every copy; the base-URL trio directly causes M-14.

Fix

  • Hoist each into the owning module (CertSerialNumber, a PEM util, one issuer-filter helper, one SOAP status ladder, one crypto secrets module, one URL config, one escaping helper)

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding The `CertSerialNumber.lookup_variants |> Enum.reduce_while` lookup is duplicated controller↔OCSP responder; `pem_to_der_b64/1` verbatim ×2; the optional-issuer-CN filter exists ×3; the SOAP check-then-retry-with-issuer ladder ×2 (+test); `hash_secret`/`generate_secret` duplicated client_credentials↔token; the `https://mdidws.mypqc.com.my` default string ×3 (see M-14); XML escaping duplicated between national_id_client.ex and scripts/10_soap_enroll.sh. ## Evidence - `cert_management_controller.ex:216-226` vs `ocsp_responder.ex:142-153`; `renewal.ex:572-579` vs `cert_management_controller.ex:633-640`; `renewal.ex:436-441` vs `cert_management_controller.ex:354-359, 597-601`; `enrollment.ex:99-124` vs `renewal.ex:268-289`; `client_credentials.ex:24-26, 56-58` vs `token.ex:138-144`; `crl_publisher.ex:49` / `ocsp_responder.ex:15` / `issuer_manager.ex:23`; `national_id_client.ex:397-405` vs `scripts/10_soap_enroll.sh:64-69` ## Impact Divergence risk on every copy; the base-URL trio directly causes M-14. ## Fix - [ ] Hoist each into the owning module (CertSerialNumber, a PEM util, one issuer-filter helper, one SOAP status ladder, one crypto secrets module, one URL config, one escaping helper) _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Author
Owner

Closing as done. B6 (PR #59) fixed the real duplication: serial lookup, PEM helper, issuer-CN filter, secret hashing, base-URL default. Two items are intentionally not unified. (1) The SOAP check-then-retry ladders in enrollment.ex and renewal.ex differ on purpose: enrollment lets the issuer lookup decide when the IC-only lookup fails; renewal fails closed on the first failure (#23). A shared helper would change that or add a SOAP call per failure. Pinned by two tests in the test PR. (2) XML escaping in national_id_client.ex vs scripts/10_soap_enroll.sh is Elixir vs shell; it cannot share code.

Closing as done. B6 (PR #59) fixed the real duplication: serial lookup, PEM helper, issuer-CN filter, secret hashing, base-URL default. Two items are intentionally not unified. (1) The SOAP check-then-retry ladders in enrollment.ex and renewal.ex differ on purpose: enrollment lets the issuer lookup decide when the IC-only lookup fails; renewal fails closed on the first failure (#23). A shared helper would change that or add a SOAP call per failure. Pinned by two tests in the test PR. (2) XML escaping in national_id_client.ex vs scripts/10_soap_enroll.sh is Elixir vs shell; it cannot share code.
Sign in to join this conversation.
No description provided.