diff options
author | Stan Hu <stanhu@gmail.com> | 2018-12-09 21:23:15 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-12-09 21:56:31 -0800 |
commit | 384a92b7362ad75801add04292f6ef7938207fc4 (patch) | |
tree | 4560a7133fb537fff637c9455b34e5a0cccfa99e /app/controllers/concerns | |
parent | 7cb0dd98590e8fdd7483b9f61643a0daa23c2b67 (diff) | |
download | gitlab-ce-384a92b7362ad75801add04292f6ef7938207fc4.tar.gz |
Check for valid refs in CommitController before doing anything
Before a 404 would be rendered only after a request to Gitaly would
return with an InvalidArgument error. Now we check that the ref have a
valid format before sending it to Gitaly. In both cases, a 404 is
returned to the user, but this change prevents Gitaly from generating
error noise in production.
Closes https://gitlab.com/gitlab-org/gitaly/issues/1425
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/renders_commits.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/controllers/concerns/renders_commits.rb b/app/controllers/concerns/renders_commits.rb index f48e0586211..ed9b898a2a3 100644 --- a/app/controllers/concerns/renders_commits.rb +++ b/app/controllers/concerns/renders_commits.rb @@ -26,4 +26,10 @@ module RendersCommits commits end + + def valid_ref?(ref_name) + return true unless ref_name.present? + + Gitlab::GitRefValidator.validate(ref_name) + end end |