Loading
Handle missing SSH mirror host URLs
What does this MR do and why?
Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/4011377
Problem
Requests without an ssh_url parameter made
SshHostKey#normalize_url call inferred_port on nil, resulting
in an unhandled 500 response.
Solution
- Reject blank URLs with
ArgumentError, "Invalid URL". - Reuse the controller's error handling to return a 400 response.
- Add model and controller regression specs.
References
NoMethodError: undefined method `inferred_port' for nil (NoMethodError)
url.port = url.inferred_port
^^^^^^^^^^^^^^
from app/models/ssh_host_key.rb:158:in `normalize_url'
from app/models/ssh_host_key.rb:61:in `initialize'
from app/controllers/projects/mirrors_controller.rb:61:in `new'
from app/controllers/projects/mirrors_controller.rb:61:in `ssh_host_keys'How to set up and validate locally
- Run
bin/rspec spec/models/ssh_host_key_spec.rb spec/controllers/projects/mirrors_controller_spec.rb. - Run RuboCop on the three changed files.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Vasilii Iakliushin