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

don't check minimum key size when disabled #1754

Merged
merged 3 commits into from
Oct 26, 2017
Merged

Conversation

Gibheer
Copy link
Contributor

@Gibheer Gibheer commented May 19, 2017

This fixes an issue that the key size was checked even when the config option was disabled. This led to errors on systems where ssh-keygen didn't report the key options in the expected format.

The other commit removes some older comments which are not correct anymore.

These comments were added when x/crypto/ed25519 could not yet handle
ed25519. It does now, so it should be removed.
Also the key type is now replaced with the proper constant.
This moves the actual config lookup before any check is done. This
avoids problems with calling to ssh-keygen which doesn't support the
expected output format and returning an error, when the check is disabled.
@sapk
Copy link
Member

sapk commented May 19, 2017

Is this related to a issue encounter ? because https://github.com/go-gitea/gitea/blob/master/models/ssh_key.go#L278 would block at start the check.
Placing the check for size in SSHNativeParsePublicKey would disable the check for not built-in ssh server.

For https://github.com/Gibheer/gitea/blob/ab376ba9fb202b3c9189c57fa69476ae0f18216f/models/ssh_key.go#L268 👍

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 19, 2017
@Gibheer
Copy link
Contributor Author

Gibheer commented May 19, 2017

Yes, this is because of an issue encountered in gogs ( #4507 ).
When you are running gitea on an older system where openssh is a tad older, the output format of ssh-keygen was different. This shouldn't be a problem when you don't want to check the minimum key size at all.
But the way it was before, ssh-keygen was called and the output parsed before the config option was checked if that should be done at all. By moving the code line a couple lines up, we have the correct order by first checking the config option and then proceeding with parsing the key.

@sapk
Copy link
Member

sapk commented May 19, 2017

yes but it disable the check for running with OS ssh server and not the internal. The solution could be to check the version of ssh-keygen for OS ssh server case and make the proper analyze based on that. We could also error on too old ssh-keygen version and suggest to use the internal ssh server in place.

@sapk
Copy link
Member

sapk commented May 19, 2017

We could also just warn that we couldn't check the size of key in too old version of ssh-keygen.

@Gibheer
Copy link
Contributor Author

Gibheer commented May 24, 2017

I wouldn't like to just warn the admin about the issue. If he wants to use the feature, he should be able to recognize the problem through errors. Then he can decide if he wants to upgrade or disable the feature, pretty easy.
The issue does not happen with the inbuilt server, as the check for the inbuilt server will never call ssh-keygen.
As for figuring out the version used on the server - I don't think there are that many old versions still in use. CentOS 5 is using an old version, but these servers should be upgraded regardless. Adding such a check might also cause problems in the future, when the format is changed again.
In that case, the admin is able to just disable the feature for some time or downgrade the installation again until we have a fix. But adding version checks would result in maintenance load with every openssh release,as we would need to add the new version to a list or something like that.

@lunny lunny added this to the 1.3.0 milestone May 25, 2017
@lafriks
Copy link
Member

lafriks commented Oct 25, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 25, 2017
@lunny
Copy link
Member

lunny commented Oct 26, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 26, 2017
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@eca05b0). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1754   +/-   ##
=========================================
  Coverage          ?   27.21%           
=========================================
  Files             ?       88           
  Lines             ?    17348           
  Branches          ?        0           
=========================================
  Hits              ?     4721           
  Misses            ?    11942           
  Partials          ?      685
Impacted Files Coverage Δ
models/ssh_key.go 10.6% <0%> (ø)

Continue to review full report at Codecov.

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

@lunny lunny merged commit bc84110 into go-gitea:master Oct 26, 2017
vdbt pushed a commit to vdbt/gitea that referenced this pull request Oct 27, 2017
* cleanup old comments for ed25519

These comments were added when x/crypto/ed25519 could not yet handle
ed25519. It does now, so it should be removed.
Also the key type is now replaced with the proper constant.

* move the minimum key size config before the check

This moves the actual config lookup before any check is done. This
avoids problems with calling to ssh-keygen which doesn't support the
expected output format and returning an error, when the check is disabled.
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants