veeso / ssh2-config

a ssh config parser for ssh2-rs
MIT License
10 stars 8 forks source link

fix: correctly apply configuration precedence in reverse parsing order #12

Closed LeoniePhiline closed 11 months ago

LeoniePhiline commented 11 months ago

11 - Correctly apply configuration precedence in reverse parsing order

Fixes #11

Commits

Commits contain logically distinct changes are are best reviewed individually.

  1. Bugfix (a2a3be23beeba741fb55076d3812c3d3ab482d9a)
  2. Error-test improvement (a0b086a1b20e58c8c786f1a3213aca766d32529a)
  3. stylistic improvement (a59885773d0b9508f85089f27636c1c869c632e9).

Read https://github.com/veeso/ssh2-config/pull/12#issuecomment-1840801476 for more details.

Description

Previously, the order of precedence applied to parsed configuration was incorrect.

Configuration was parsed, then sorted in alphabetical order.

Algorithms (ciphers, key exchange algorithms, MACs, etc.) were incorrectly applied during parsing.

The correct precedence order follows https://linux.die.net/man/5/ssh_config: the configuration is read from top to bottom, precedence is applied from bottom (lowest) to the top (highest precedence).

Options preceding the first Host block are considered implicit command line options, in line with OpenSSH's own implementation.

This patch includes the following changes:

Type of change

This is a bugfix, but some users may depend on the old, broken algorithm. For these users, this change could be considered breaking. On the other hand, this can be said about any bugfix: There might always be someone who abused the previous, incorrect behavior.

Please select relevant options.

Checklist

Acceptance tests

wait for a project maintainer to fulfill this section...

LeoniePhiline commented 11 months ago

@veeso I will push two additional commits with improvements made along the journey of fixing this bug.

These two additional commits are optional and can be reviewed and accepted or rejected separately from the bugfix commit.

In detail:

coveralls commented 11 months ago

Pull Request Test Coverage Report for Build 7101669807


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser/mod.rs 164 180 91.11%
<!-- Total: 284 300 94.67% -->
Totals Coverage Status
Change from base Build 5712204231: -0.3%
Covered Lines: 1193
Relevant Lines: 1224

💛 - Coveralls
veeso commented 11 months ago

Amazing job, thank you