Skip to content

Normalize domain inputs in the library entry point - #272

Open
rksharma-owg wants to merge 1 commit into
cisagov:developfrom
rksharma-owg:fix/normalize-library-domain-inputs
Open

rksharma-owg wants to merge 1 commit into
cisagov:developfrom
rksharma-owg:fix/normalize-library-domain-inputs

Conversation

@rksharma-owg

Copy link
Copy Markdown

🗣 Description

Normalize input domains in inspect_domains() using the existing utils.format_domains() helper. Library callers currently pass inputs such as https://www.example.com straight to inspect(), whereas the CLI strips those prefixes first.

The CLI now delegates normalization and its optional sorting to the library. Sorting happens after normalization, and normalization runs only once, preserving the existing treatment of a name such as www.www.example.com.

💭 Motivation and context

Fixes #133. Existing bare-domain input keeps its order unless sorting is requested. Explicit ports and duplicate entries are preserved, and the input list is not modified. The existing helper's normalization rules are unchanged.

🧪 Testing

  • pytest -o addopts='' -q: 41 passed, 5 skipped on macOS, CPython 3.10.20 x86_64 with SSLyze 4.1.0. The five skips already exist upstream.
  • Baseline suite: 31 passed, 5 skipped. Before the implementation change, six of the ten new test cases failed; all pass afterward.
  • Regression coverage includes HTTP/HTTPS and www prefixes, stripping only one www prefix, explicit ports, empty input, iterables, input immutability, order/duplicates, and the actual CLI parser with --sorted --json.
  • External data initialization and network inspection are mocked; no public domains are scanned.
  • pre-commit run --files src/pshtt/cli.py src/pshtt/pshtt.py tests/test_cli.py tests/test_pshtt.py: passed, including Black, Flake8, isort, mypy, and Bandit.
  • git diff --check: passed.

The x86_64 runtime was used because the existing ARM macOS nassl wheel fails to import with a missing _SSLv2_method symbol. No dependency changes are included.

✅ Pre-approval checklist

  • Focused change and informative title.
  • Contribution instructions checked and related issue linked.
  • Regression tests added and local suite passed.
  • Relevant pre-commit checks passed.

✅ Pre-merge checklist

  • Maintainer review and CI completed.

@rksharma-owg

Copy link
Copy Markdown
Author

CI triage posted on behalf of @rksharma-owg by OpenAI Codex (autonomous).

The second labeling attempt failed because actions/labeler@v6 could not set labels: Resource not accessible by integration. The job setup confirms PullRequests: read, although .github/workflows/label-prs.yml requests pull-requests: write. This is a permissions failure in the existing fork-PR labeling workflow; this PR does not change workflow files.

Could a maintainer handle the labels and review the workflow's fork-PR behavior? Application changes would not address this failure, and this account has no repository write access. The separate build and analysis runs are still in progress.

Failed label job: https://github.com/cisagov/pshtt/actions/runs/34401625336/job/102919823424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move utils.format_domains call into main pshtt lib

1 participant