Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for obscure ssh_config(5) rules #68

Merged
merged 7 commits into from
Aug 8, 2023

Conversation

BenjaminGrayNp1
Copy link
Contributor

There are some obscure interactions in the SSH config parsing rules. This PR extends support for some of these, which addresses the bug that prompted jeanp413/open-remote-ssh#103.

The canonical criteria is not properly supported in this series because I don't use it, so don't really have a sense for what it should be doing. It shouldn't be too hard to extend support for it too though, now that the second pass is possible.

It's reasonable to end the config with a section directive (e.g.,
Match final' to trigger a re-parse), in which case there is no prior
line within the config to attach the whitespace to. Extend the logic
to annotate the most recent section directive if it's sub-config
is empty.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
ssh_config(5) defines three Match criteria that don't take any
arguments: 'all', 'canonical', and 'final'. Update the criteria parsing
logic to recognise these.

The value is irrelevant, but the criteria are stored in a map, so an
empty array is chosen here. Consumers really shouldn't be trying to
use any particular value though.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Add some testing to assert that Match criteria without arguments ('all',
'canonical', and 'final') are parsed correctly.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
When User is passed in the params, it acts as if the config started with
an unconditional User line.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
When a user is passed explicitly to .compute, it should not switch
because of any User lines.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Computing a config potentially performs multiple passes, with some
quirks around what exactly the host is in 'Host' and 'Match host'
sections.

Extend .compute to handle more cases of 'all' and 'final'.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Test some cases of parsing configs with second passes due to Match final
or similar.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2023

Codecov Report

Patch coverage: 96.86% and project coverage change: -3.04% ⚠️

Comparison is base (ebbeb2b) 100.00% compared to head (3626b14) 96.96%.
Report is 27 commits behind head on master.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##            master      #68      +/-   ##
===========================================
- Coverage   100.00%   96.96%   -3.04%     
===========================================
  Files            2        3       +1     
  Lines          231      297      +66     
  Branches         0       81      +81     
===========================================
+ Hits           231      288      +57     
- Misses           0        4       +4     
- Partials         0        5       +5     
Files Changed Coverage Δ
src/ssh-config.ts 96.76% <96.76%> (ø)
index.ts 100.00% <100.00%> (ø)
src/glob.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cyjake cyjake merged commit da978de into cyjake:master Aug 8, 2023
4 checks passed
@cyjake
Copy link
Owner

cyjake commented Aug 8, 2023

v4.3.0 released

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