• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

skeema / knownhosts
93%
main: 93%

Build:
Build:
LAST BUILD BRANCH: refs/tags/v1.3.1
DEFAULT BRANCH: main
Repo Added 24 Mar 2023 09:49PM UTC
Files 1
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

LAST BUILD ON BRANCH fix-wildcards-port-match
branch: fix-wildcards-port-match
CHANGE BRANCH
x
Reset
  • fix-wildcards-port-match
  • actions-tweaks
  • certs-backwards-compat
  • main
  • refs/tags/v1.3.0
  • refs/tags/v1.3.1

15 Jul 2024 08:22PM UTC coverage: 93.305% (+0.4%) from 92.857%
9946292371

Pull #10

github

evanelias
host matching: handle wildcards with non-standard port

In OpenSSH, wildcard host pattern entries in a known_hosts file can match
hosts regardless of their port number. However, x/crypto/ssh/knownhosts does
not follow this behavior, instead requiring strict port equality; see bug
https://github.com/golang/go/issues/52056 for background.

This commit implements a workaround in skeema/knownhosts, which is enabled
when using the NewDB constructor. Conceptually, the workaround works like
this:

* At constructor time, when re-reading the known_hosts file (originally to
  look for @cert-authority lines), also look for lines that have wildcards
  in the host pattern and no port number specified. Track these lines in a
  new field of the HostKeyDB struct for later use.

* When a host key callback returns no matches (KeyError with empty Want slice)
  and the host had a nonstandard (non-22) port number, try the callback again,
  this time manipulating the host arg to be on port 22.

* If this second call returned nil error, that means the host key now matched
  a known_hosts entry on port 22, so consider the host as known.

* If this second call returned a KeyError with non-empty Want slice, filter
  down the resulting keys to only correspond to lines with known wildcards,
  using the preprocessed information from the first step. This ensures we
  aren't incorrectly returning non-wildcard entries among the Want slice.

The implementation for the latter 3 bullets gets embedded directly in the
host key callback returned by HostKeyDB.HostKeyCallback, by way of some
nested callback wrapping. This only happens if the first bullet actually
found at least one wildcard in the file.
Pull Request #10: host matching: handle wildcards with non-standard port

49 of 51 new or added lines in 1 file covered. (96.08%)

223 of 239 relevant lines covered (93.31%)

20.41 hits per line

Relevant lines Covered
Build:
Build:
239 RELEVANT LINES 223 COVERED LINES
20.41 HITS PER LINE
Source Files on fix-wildcards-port-match
  • List 1
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
9946292371 fix-wildcards-port-match host matching: handle wildcards with non-standard port In OpenSSH, wildcard host pattern entries in a known_hosts file can match hosts regardless of their port number. However, x/crypto/ssh/knownhosts does not follow this behavior, instead requir... Pull #10 15 Jul 2024 08:36PM UTC evanelias github
93.31
9946123898 fix-wildcards-port-match host matching: handle wildcards with non-standard port In OpenSSH, wildcard host pattern entries in a known_hosts file can match hosts regardless of their port number. However, x/crypto/ssh/knownhosts does not follow this behavior, instead requir... push 15 Jul 2024 08:23PM UTC evanelias github
93.31
9945926980 fix-wildcards-port-match host matching: handle wildcards with non-standard port In OpenSSH, wildcard host pattern entries in a known_hosts file can match hosts regardless of their port number. However, x/crypto/ssh/knownhosts does not follow this behavior, instead requir... push 15 Jul 2024 08:08PM UTC evanelias github
93.31
9945602028 fix-wildcards-port-match WIP: implement workaround for wildcards and non-standard port *** This is a work-in-progress commit, which will be amended/rewritten *** push 15 Jul 2024 07:41PM UTC evanelias github
93.31
9914456156 fix-wildcards-port-match WIP: implement workaround for wildcards and non-standard port *** This is a work-in-progress commit, which will be amended/rewritten *** push 12 Jul 2024 09:39PM UTC evanelias github
93.31
9914381975 fix-wildcards-port-match WIP: implement workaround for wildcards and non-standard port *** This is a work-in-progress commit, which will be amended/rewritten *** push 12 Jul 2024 09:32PM UTC evanelias github
93.31
See All Builds (24)
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc