Commit Graph

23 Commits

Author SHA1 Message Date
Stan Hu d03b7bb1e0 Properly handle multiple X-Forwarded-For addresses in runner IP
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24624 extracted
the X-Forwarded-For address directly, but this didn't consider the case
where multiple proxies are in the chain. To fix this, we use the Rails
implementation to filter trusted proxies, as documented by Grape:
https://github.com/ruby-grape/grape#remote-ip

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58103
2019-02-24 14:50:55 -08:00
Steve Azzopardi cb67423d48
Get remote address for runner
Check if `X-Forwarded-For` is set before getting the IP of the request,
with this the real IP address of the runner is shown if it's behind a
proxy.

closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53676
2019-01-24 09:03:14 +01:00
gfyoung 3836d69119 Enable frozen string in lib/api and lib/backup
Partially addresses #47424.

Had to make changes to spec files because
stubbing methods on frozen objects is a mess
in RSpec and leads to failures:

https://github.com/rspec/rspec-mocks/issues/1190
2018-09-29 21:04:50 -07:00
Tomasz Maczukin a6a900256e
Change update entrypoint instead of adding new keep-alive one 2018-06-07 18:45:48 +02:00
Dylan Griffith b5a5fdf0e3 Persist runner IP address on contact (#43489) 2018-02-28 11:54:37 +11:00
Matija Čupić 3366f377c1
Merge branch 'master' into 38265-stuckcijobsworker-wrongly-detects-cancels-stuck-builds-when-per-job-timeout-is-more-than-an-hour 2018-02-04 23:38:59 +01:00
Matija Čupić 38c242126d
Refactor runner attribute caching implementation 2018-02-04 18:34:21 +01:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Matija Čupić bdd3e39b0b
Move info update implementation to Ci::Runner model 2018-01-29 20:56:28 +01:00
Matija Čupić 397442a061
Update runner info on all authenticated requests 2018-01-29 17:21:30 +01:00
Matija Čupić b1c40590e7
Extend Runner API helpers with cache info storage 2018-01-29 00:23:36 +01:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Sean McGivern 5883ce95ef `current_application_settings` belongs on `Gitlab::CurrentSettings`
The initializers including this were doing so at the top level, so every object
loaded after them had a `current_application_settings` method. However, if
someone had rack-attack enabled (which was loaded before these initializers), it
would try to load the API, and fail, because `Gitlab::CurrentSettings` didn't
have that method.

To fix this:

1. Don't include `Gitlab::CurrentSettings` at the top level. We do not need
   `Object.new.current_application_settings` to work.
2. Make `Gitlab::CurrentSettings` explicitly `extend self`, as we already use it
   like that in several places.
3. Change the initializers to use that new form.
2017-08-31 13:38:33 +01:00
Tiago Botelho 34f57b462b Fix current feature related specs 2017-06-28 11:32:34 +01:00
Yorick Peterse d2283f4f0e
Backport API changes needed to fix sticking in EE
These changes are ported over from
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1502 to reduce
the number of merge conflicts that may occur.
2017-03-31 13:56:53 +02:00
Tomasz Maczukin e79ab1115b
Remove legacy Runners support in /api/v4/jobs/request
In Runner v1.3.0 we've started to send User-Agent header with Runner's
version data. Since GitLab v8.12.0 we've started to use this header to check
if used Runner's version supports 204 status code instead of 404 as a
response when there is no jobs to execute by a Runner.

In APIv4 (introduced in GitLab 9.0.0) will require Runner v9.0.0. And
writing more accurately: GitLab Runner v9.0.0 will require GitLab at
least 9.0.0. Because of such breaking change we are able to switch
entirely to 204 response code and there is no need to do check of
User-Agent.

This commit removes useless code and complexity.
2017-03-20 09:40:36 +01:00
Tomasz Maczukin 1bbf2c2cd1
Fix rubocop offenses 2017-03-02 17:45:46 +01:00
Tomasz Maczukin 2a7f555caf
Add artifacts uploading authorize API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin 7e46db0f5a
Add job patch trace API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin d5f7e54211
Add job update API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin bbf5bb7070
Fix rubocop offenses 2017-03-02 17:45:45 +01:00
Tomasz Maczukin 3d26a8d0b6
Add jobs requesting API 2017-03-02 17:45:45 +01:00
Tomasz Maczukin e25f26e550
Rename API::Ci to API::Runner 2017-02-16 01:30:46 +01:00
Renamed from lib/api/helpers/ci.rb (Browse further)