New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add markers to known_hosts parser re paramiko#771 #2270
base: main
Are you sure you want to change the base?
Conversation
Not complete! Adds basic parser support for a marker in the first field. Additional handling of cert-authority should be discussed before being implemented. Adds sample keys to test_hostkeys.py.
Applied |
@MajorDallas, since we know this is not ready for merge yet, please convert to a draft PR. |
I hadn't seen #2251 / #2254 before now. Aside: how do we feel about type annotations? I will gladly start adding them where I'm touching code if there's no opposition to it. |
100%, @MajorDallas, good catch. |
Type annotations will be up to bitprophet. I don't believe there are currently plans to type the codebase, though. (Now that Py2 is dropped, it might be less of a headache than in the past, though.) |
Thanks for this! Yes, the overall "host keys parser doesn't understand Also, for both the submitter and @bskinn: I don't mind patches adding mypy type annotations; it'll be awhile before it's worth explicitly annotating the entire codebase (we just did Invoke, a somewhat smaller and more modern codebase, a while ago and that was even a chore) but since new type hints are backwards compatible with "not caring about type hints"...it's fine! and means less work in the future. |
馃憤 good to know re the type hints posture, thanks @bitprophet! |
Right, specific feedback was requested too...
|
Correct: my goal was merely to successfully parse |
I'm looking at adding
Looking at hostfile.c, their parsing function returns the marker and it's recorded in a struct field. In ssh-add.c, presence of an But, if their |
One other small thing: I'm also looking at adding type annotations for Assuming this method isn't supposed to be part of the public API, I'd recommend removing the default to |
Even if it's not supposed to be part of the public API, there's a nonzero chance that this function has use in the wild, and changing this behavior would be considered a regression. Given that this function could be used as an independent test of proper known_hosts line formatting, in which case the
Indeed, as well as tightening the type to However, as long as a |
The last couple of months have been crazy busy with work, but I'm finally ready to take another look at this. Two questions:
|
!IMPORTANT I am not the maintainer of this repository, but based on what I saw in the git history: Short answer:You should rebase. Longer answer:At least You should try - if You do not run into merge conflicts then it should be all good. Longest answer:@MajorDallas I would be glad to help - as I see this is the currently worked / active PR. PS.: I have an open PR I would like to get reviewed, so I hope the sooner this one is resolved, the sooner mine might :) |
* Adds some type annotations * Includes _marker in the output of `to_line` * Sets _marker when constructing `HostKeyEntry` in `from_line`
e908acc
to
1a9abf0
Compare
So I attempted a rebase in a back-up copy and it worked just fine... but there are only two commits in this branch, so I'm not sure it even makes a difference? I know (basically) how rebase is different from merge, but not sure why, in this case, it should be one or the other. |
Cool, good to know it was not a big deal :) As far as I know, most projects prefer to have a linear history, because it is much easier to the eye and to argue about. While one merge commit is not an issue, in the long run merge commits can introduce a lot of parallel branches with a git history that is hard to see through. Lastly, a merge commit is usually dud - usually it does not convey much information, if not looked after these empty commits can take a big portion of the history. I hope I was able to provide help with my experiences :) |
Fixes #771. Copying one of my comments from there on what's needed:
I wasn't sure whether to add an attribute to
HostKeyEntry
for the marker, if such an attribute would need to be consumed somewhere or how, so I left that off and just implemented the parser logic insideHostKeyEntry.from_line
. Based on the return ofNone
if the key type is unknown, it returnsNone
if the marker is@revoked
, but that can be adjusted.I added sample cert-authority and revoked keys to the sample data in
test_hostkeys.py
, as well, adjusted a couple ofassert
s accordingly, and have passing tests 馃槂Just need to discuss what, if anything, to do with the markers once we have them.