Skip to content

fix: anchor domain regex in validateIp to reject trailing input#58

Merged
dopecodez merged 1 commit into
dopecodez:masterfrom
lissy93-forks:fix/domain-validation-regex
Jun 6, 2026
Merged

fix: anchor domain regex in validateIp to reject trailing input#58
dopecodez merged 1 commit into
dopecodez:masterfrom
lissy93-forks:fix/domain-validation-regex

Conversation

@lissy93

@lissy93 lissy93 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Hey @dopecodez

Noticed that on the hostname check, it correctly matches a valid prefix, but ignored anything after that.
So this pr just adds $ to the end of the regex to anchor it at the end too

e.g. previously a.co; rm -rf / was passing validation.
This isn't a security issue, since pingman correctly runs the ping via a spawn. But just thought we could neaten it up, and add some defence in depth so that we throw the ERROR_MESSAGES.IP_NOT_VALID message much earlier

Also added a unit test for this :)

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.70%. Comparing base (bc1708d) to head (d4acdd4).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #58   +/-   ##
=======================================
  Coverage   78.70%   78.70%           
=======================================
  Files          14       14           
  Lines         385      385           
  Branches      116      116           
=======================================
  Hits          303      303           
  Misses          3        3           
  Partials       79       79           
Files with missing lines Coverage Δ
src/helper.ts 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc1708d...d4acdd4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dopecodez

Copy link
Copy Markdown
Owner

Thanks for the MR @lissy93 🥇 . The older regex was ignoring everything after the match, so this is a much better check to have.

@dopecodez
dopecodez merged commit fde4a04 into dopecodez:master Jun 6, 2026
4 checks passed
@dopecodez

Copy link
Copy Markdown
Owner

A new build with these changes have been released - v2.2.0 on github or the latest on npm. Thanks again for the changes @lissy93 🐐

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.

3 participants