Commit Graph

441 Commits

Author SHA1 Message Date
Yorick Peterse ad8eea3834
Merge dev.gitlab.org@master into GitLab.com@master 2019-10-30 15:22:45 +01:00
GitLab Release Tools Bot a7329f4372 Merge branch 'security-remove-leaky-401-responses-master' into 'master'
Private/internal repository enumeration via bruteforce on a vulnerable URL

See merge request gitlab/gitlabhq!3454
2019-10-29 15:58:14 +00:00
GitLab Bot 6d43720a1a Add latest changes from gitlab-org/gitlab@master 2019-10-25 00:06:14 +00:00
GitLab Bot 4682f5015a Add latest changes from gitlab-org/gitlab@master 2019-10-18 21:06:37 +00:00
GitLab Bot 308146dc39 Add latest changes from gitlab-org/gitlab@master 2019-10-10 00:06:44 +00:00
Kerri Miller 8395032721 Avoid #authenticate_user! in #route_not_found
This method, #route_not_found, is executed as the final fallback for
unrecognized routes (as the name might imply.) We want to avoid
`#authenticate_user!` when calling `#route_not_found`;
`#authenticate_user!` can, depending on the request format, return a 401
instead of redirecting to a login page. This opens a subtle security
exploit where anonymous users will receive a 401 response when
attempting to access a private repo, while a recognized user will
receive a 404, exposing the existence of the private, hidden repo.
2019-10-09 10:47:45 -07:00
GitLab Bot ed3b169888 Add latest changes from gitlab-org/gitlab@master 2019-10-01 18:06:28 +00:00
GitLab Bot e08eba1838 Add latest changes from gitlab-org/gitlab@master 2019-09-28 00:06:20 +00:00
GitLab Bot 4309992515 Add latest changes from gitlab-org/gitlab@master 2019-09-26 21:06:29 +00:00
GitLab Bot 5707f305f4 Add latest changes from gitlab-org/gitlab@master 2019-09-26 12:06:00 +00:00
GitLab Bot b7dfe2ae40 Add latest changes from gitlab-org/gitlab@master 2019-09-13 13:26:31 +00:00
dineshpanda 980303b542 Avoid calling freeze on already frozen strings in app/controllers 2019-09-01 01:57:25 +05:30
Grzegorz Bizon b1604f7d8f Merge branch '47003-user-onboarding-replace-current-email-confirmation-flow-with-a-soft-email-confirmation-flow' into 'master'
Soft email confirmation flow

Closes #47003

See merge request gitlab-org/gitlab-ce!31245
2019-08-16 12:31:16 +00:00
George Koltsov 2857a40950 Swap clauses as per code review suggestion 2019-08-15 10:11:35 +01:00
George Koltsov 10b2383f02 Exclude json content type from workhorse interception 2019-08-14 12:07:42 +01:00
Alex Buijs 2bc0f0cfcf
Add ConfirmEmailWarning concern 2019-08-08 13:34:11 +02:00
Heinrich Lee Yu 1ce5bcacdb Remove code related to object hierarchy in MySQL
These are not required because MySQL is not
supported anymore
2019-07-25 15:35:06 +08:00
manojmj 3c9d75e045 CE Port: Log impersonation actions in audit log
This change adds audit logs for user impersonation
when an admin starts/stops impersonating
another user.
2019-07-23 11:44:09 +05:30
Stan Hu ee791d3f40 Enable Gitaly ref caching for SearchController
As we noticed in
https://gitlab.com/gitlab-org/gitlab-ce/issues/56627#note_185828742,
clicking on the "Issues" tab often requests the same reference in
rendering Markdown.
2019-06-26 16:24:46 -07:00
James Edwards-Jones 866f544c3e Avoid setting Gitlab::Session on sessionless requests 2019-06-05 19:07:20 +01:00
Bob Van Landuyt 589b2db06c Setup Phabricator import
This sets up all the basics for importing Phabricator tasks into
GitLab issues.

To import all tasks from a Phabricator instance into GitLab, we'll
import all of them into a new project that will have its repository
disabled.

The import is hooked into a regular ProjectImport setup, but similar
to the GitHub parallel importer takes care of all the imports itself.

In this iteration, we're importing each page of tasks in a separate
sidekiq job.

The first thing we do when requesting a new page of tasks is schedule
the next page to be imported. But to avoid deadlocks, we only allow a
single job per worker type to run at the same time.

For now we're only importing basic Issue information, this should be
extended to richer information.
2019-05-31 09:40:54 +02:00
James Edwards-Jones 5faa98f481 Session stored globally per request
- This can be accessed with Session.current and is restored after.
- Data can be stored under a key with NamespacedSessionStore
2019-05-02 12:28:26 +07:00
Andrew Newdigate 4f4de36cac Migrate correlation and tracing code to LabKit
This change is a fairly straightforward refactor to extract the tracing
and correlation-id code from the gitlab rails codebase into the new
LabKit-Ruby project.

The corresponding import into LabKit-Ruby was in
https://gitlab.com/gitlab-org/labkit-ruby/merge_requests/1

The code itself remains very similar for now.

Extracting it allows us to reuse it in other projects, such as
Gitaly-Ruby. This will give us the advantages of correlation-ids and
distributed tracing in that project too.
2019-04-18 09:57:16 +02:00
Martin Wortschack 76e8960f4a Externalize strings in flash messages
- Externalize strings in controllers
- Update PO file
2019-04-08 14:17:45 +00:00
Rémy Coutable d193318338
Fix ETag caching not being used for AJAX requests
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-02-26 12:54:31 +01:00
Stan Hu 51ca79228b Log queue duration in production_json.log
`queue_duration` is a useful metric that is currently in api_json.log
but not in production_json.log. We should add it because it tells us how
long the request sat in Workhorse before Unicorn processed it. Having
this field enables the support team to better troubleshoot when delays
began to happen.
2019-02-12 06:58:55 -08:00
Luke Bennett 3bd306ddfa
Show the correct error page when access is denied 2019-01-15 20:42:10 +00:00
Jasper Maes fbdb463580 Fix deprecation: redirect_to :back is deprecated 2019-01-02 19:48:07 +01:00
Jarka Košanová b1c3955385 Rename GroupHierarchy into ObjectHierarchy
- we now use the hierarchy class also for epics
- also rename supports_nested_groups? into supports_nested_objects?
  - move it to a concern
2018-12-19 15:24:29 +01:00
Jasper Maes 56296f1eda Remove rails4 specific code 2018-12-16 10:48:41 +01:00
Kamil Trzciński 39c1731a53 Log and pass correlation-id between Unicorn, Sidekiq and Gitaly
The Correlation ID is taken or generated from received X-Request-ID.
Then it is being passed to all executed services (sidekiq workers
or gitaly calls).

The Correlation ID is logged in all structured logs as `correlation_id`.
2018-12-06 20:46:14 +01:00
Imre Farkas bd3a484032
Add config to disable impersonation
Adds gitlab.impersonation_enabled config option defaulting to true to
keep the current default behaviour.

Only the act of impersonation is modified, impersonation token
management is not affected.
2018-11-29 09:37:16 +01:00
Cindy Pallares fe5f75930e
Merge branch 'security-fix-pat-web-access' into 'master'
[master] Resolve "Personal access token with only `read_user` scope can be used to authenticate any web request"

See merge request gitlab/gitlabhq!2583
2018-11-28 19:13:59 -05:00
Sean McGivern a1c08c12c8 Merge branch 'rails5-env-deprecated' into 'master'
Rails5: env is deprecated and will be removed from Rails 5.1

Closes #54384

See merge request gitlab-org/gitlab-ce!22626
2018-11-23 06:40:49 +00:00
Imre Farkas 02326fa4b1
Backport of ee/8120: Smartcard authentication 2018-11-18 21:00:28 +01:00
Jasper Maes 616fbd028c Rails5: env is deprecated and will be removed from Rails 5.1 2018-11-15 08:12:24 +01:00
James Lopez 782badd0a2
Fix content caching for non auth users 2018-10-23 16:22:12 +02:00
Jan Provaznik c6a4c9231e Use InvalidUTF8ErrorHandler only for rails 4
In Rails 5 catches invalid UTF8 characters in querystring in a
params middleware, errors are handled by a params middleware and
raises a BadRequest exception. This means that these UTF8 errors
are not raised deeper in application stack and these can't also
be handled on application level.

If we would want to have custom handler for these errors, we would
have to create a new middleware and insert it before actionpack's
params middleware and rescue BadRequest exceptions there. But there
is no need to do this currently (see discussion on
https://gitlab.com/gitlab-org/gitlab-ce/issues/51908)
2018-10-13 19:45:27 +02:00
Zeger-Jan van de Weg 30b4ce940d
Remove Git circuit breaker
Was introduced in the time that GitLab still used NFS, which is not
required anymore in most cases. By removing this, the API it calls will
return empty responses. This interface has to be removed in the next
major release, expected to be 12.0.
2018-10-10 09:08:18 +02:00
Stan Hu 7fa3180883 Remove duplicate Sentry logging for GRPC messages
Raven.capture_exception is already called by log_exception.
2018-10-07 23:30:29 -07:00
David fea4efe42f Add custom header for error responses 2018-10-01 17:43:40 +00:00
Rémy Coutable d2afddfeff
Refactor EventFilter and increase its test coverage
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-09-26 18:34:26 +02:00
Igor Kapkov 65cf805278
Allow events filter to be set in the URL in addition to cookie 2018-09-26 18:34:26 +02:00
Stan Hu 0920342094 Merge branch 'fa-handle_invalid_utf8_errors' into 'master'
Render 412 when invalid UTF-8 is passed as parameter

See merge request gitlab-org/gitlab-ce!21774
2018-09-25 16:35:10 +00:00
Felipe Artur 1fcc7f9ba2 Render 412 for invalid UTF-8 parameters
Renders 412 error page when invalid UTF-8 is passed
as parameters in controllers.
2018-09-22 12:15:53 -03:00
gfyoung 73322a0e55 Enable frozen string in app/controllers/**/*.rb
Enables frozen string for the following:

* app/controllers/*.rb
* app/controllers/admin/**/*.rb
* app/controllers/boards/**/*.rb
* app/controllers/ci/**/*.rb
* app/controllers/concerns/**/*.rb

Partially addresses #47424.
2018-09-18 21:22:45 -07:00
Jan Provaznik a415a904b8 Ask user explicitly about usage stats agreement 2018-09-07 14:32:28 +00:00
Stan Hu 93005b4e81 Add User-Agent to production_json.log
This will help production gain more visibility which browsers may be
having issues.
2018-09-05 14:43:09 -07:00
Stan Hu a7e2f96b59 Fix logins via OAuth2 geting logged out in an hour
Users without GitLab 2FA enabled would be logged out after an hour
due to a regression in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20700.

The OAuth2 controller sets the current_user after the controller is finished, so
we should only limit session times after this has been done.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50210
2018-08-10 14:41:59 -07:00
Peter Leitzen ffcf50c872 Don't set gon variables in JSON requests 2018-08-07 21:28:57 +00:00
Tim Zallmann d737abc537 Merge branch 'sh-support-bitbucket-server-import' into 'master'
Add support for Bitbucket Server imports

Closes #25393

See merge request gitlab-org/gitlab-ce!20164
2018-08-06 17:32:12 +00:00
Grzegorz Bizon 98e9f52cf4 Improve blocked user tracking code readability 2018-08-03 12:58:00 +02:00
Grzegorz Bizon e698a22e10 Skip redunant before_logout warden events 2018-08-02 15:41:14 +02:00
Grzegorz Bizon 9c6aa0a0a6 Improve authentication events-related code readability 2018-08-01 17:08:59 +02:00
Grzegorz Bizon 4eb9d6a96f Do not implicitly authenticate user during session creation 2018-08-01 16:57:59 +02:00
Grzegorz Bizon 4bcf72e734 Improve blocked user tracking and fire some events only once 2018-08-01 14:23:06 +02:00
Stan Hu fe16ce0acb Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-31 08:57:00 -07:00
Sean McGivern e6dd3c5276 Merge branch 'feature/gb/login-activity-metrics' into 'master'
Add user authentication activity metrics

Closes #47789

See merge request gitlab-org/gitlab-ce!20668
2018-07-31 10:44:22 +00:00
Grzegorz Bizon 00e4d918a3 Add authentication metrics for sessionless sign in 2018-07-27 12:56:34 +02:00
Stan Hu 930ca2d599 Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-18 21:35:24 -07:00
Stan Hu c559c43daf Limit the TTL for anonymous sessions to 1 hour
By default, all sessions are given the same expiration time configured in the
session store (e.g. 1 week). However, unauthenticated users can generate a lot
of sessions, primarily for CSRF verification. It makes sense to reduce the TTL
for unauthenticated to something much lower than the default (e.g. 1 hour) to
limit Redis memory. In addition, Rails creates a new session after login,
so the short TTL doesn't even need to be extended.

Closes #48101
2018-07-18 12:39:51 -07:00
Stan Hu 2d3fd6a142 Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-12 05:21:37 -07:00
Dmitriy Zaporozhets 6743147b7d Improve manifest feature after backend review
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-07-11 12:22:57 +03:00
Dmitriy Zaporozhets 98d29f6e78 Add ability to disable manifest import
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-07-11 12:22:57 +03:00
Stan Hu ebd8e4333a WIP: Add support for Bitbucket Server imports 2018-06-25 13:06:10 -07:00
blackst0ne 6fef87f17f [Rails5] Force the `protect_from_forgery` callback run first
Since Rails 5.0 the `protect_from_forgery` callback doesn't run first by
default anymore. [1]

Instead it gets inserted into callbacks chain where callbacks get
called in order.

This commit forces the callback to run first.

[1]: 3979403781
2018-06-21 21:44:31 +11:00
Bob Van Landuyt 7fe92d9981 Render access denied without message
The `errors/access_denied` page should not fail to render when no
message is provided.

When accessing something as a sessionless user, we should also display
the terms message if possible.
2018-06-13 17:03:48 +02:00
Stan Hu 5d3abdf9a7 Log response body to production_json.log when a controller responds with a 422 status
We have a number of import errors occurring with 422 errors, and
it's hard to determine why they are happening. This change will
surface the errors in the log lines.

Relates to #47365
2018-06-06 13:16:15 -07:00
Bob Van Landuyt 491e1fc905 Render a 403 when showing an access denied message
When we want to show an access denied message to a user, we don't have
to hide the resource's existence.

So in that case we render a 403, this 403 is not handled by nginx on
omnibus installs, making sure the message is visible to the user.
2018-06-05 10:29:27 +02:00
Paul Slaughter bbff2d680d Update 404 and 403 pages 2018-05-31 21:28:19 +00:00
Bob Van Landuyt a5cb2fe2e0 Allow a user to sign out when on the terms page
Before we would block the `sign_out` request when the user did not
accept the terms, therefore redirecting them to the terms again.

By allowing all request to devise controllers, we avoid this problem.
2018-05-11 08:27:43 +02:00
Bob Van Landuyt 7684217d68 Enforces terms in the web application
This enforces the terms in the web application. These cases are
specced:

- Logging in: When terms are enforced, and a user logs in that has not
  accepted the terms, they are presented with the screen. They get
  directed to their customized root path afterwards.
- Signing up: After signing up, the first screen the user is presented
  with the screen to accept the terms. After they accept they are
  directed to the dashboard.
- While a session is active:
  - For a GET: The user will be directed to the terms page first,
    after they accept the terms, they will be directed to the page
    they were going to
  - For any other request: They are directed to the terms, after they
    accept the terms, they are directed back to the page they came
    from to retry the request. Any information entered would be
    persisted in localstorage and available on the page.
2018-05-04 13:54:43 +02:00
blackst0ne 991db50f88 [Rails5] Update `ApplicationController#log_exception` to fix `undefined method 'clean'` error
This commit fixes the error:
```
  1) Projects::TodosController Merge Requests POST create when not authorized for merge_request doesn't create todo
     Failure/Error: application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace

     NoMethodError:
       undefined method `clean' for #<Hash:0x000055be5bda35d0>
       Did you mean?  clear
     # ./app/controllers/application_controller.rb:113:in `log_exception'
     # ./app/controllers/application_controller.rb:40:in `block in <class:ApplicationController>'
     # ./spec/controllers/projects/todos_controller_spec.rb:80:in `go'
     # ./spec/controllers/projects/todos_controller_spec.rb:138:in `block (6 levels) in <top (required)>'
     # ./spec/controllers/projects/todos_controller_spec.rb:138:in `block (5 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # ActiveRecord::RecordNotFound:
     #   Couldn't find MergeRequest
     #   ./app/finders/concerns/finder_methods.rb:19:in `raise_not_found_unless_authorized'

Finished in 7.53 seconds (files took 12.8 seconds to load)
1 example, 1 failure
```

Also see 6d85804bc6
2018-04-28 20:01:31 +11:00
blackst0ne eddf3febd7 [Rails5] Add `safe_params` helper
Rails 5.0 requires to explicitly permit attributes when building a URL
using current `params` object.

The `safe_params` helper allows developers to just call `safe_params.merge(...)`
instead of manually adding `permit` to every call.

https://github.com/rails/rails/pull/20868
2018-04-08 15:35:30 +11:00
Francisco Javier López ae84eaeba7 Add better LDAP connection handling 2018-04-04 09:07:28 +00:00
Horatiu Eugen Vlad 1ad5df49b1 Moved o_auth/saml/ldap modules under gitlab/auth 2018-02-28 16:53:02 +01:00
Bob Van Landuyt 148816cd67 Port `read_cross_project` ability from EE 2018-02-22 17:11:36 +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
Stan Hu 79a829a037 Return a blank JSON response for a missing .js file to prevent Rails CSRF errors
The default 404 handler would return the Content-Type format based on the
given format extension. This would cause the Rails CSRF protection to flag an
error, since the .js extension gets mapped to text/javascript format.

Closes #40771
2018-01-23 22:24:30 -08:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Tiago Botelho 053a198846 Impersonation no longer gets stuck on password change. 2017-11-20 18:02:41 +01:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Francisco Lopez aecc3eb080 Applied some code review comments 2017-11-17 10:02:10 +01:00
Francisco Lopez 41ebd06ddc Some fixes after rebase 2017-11-17 10:01:20 +01:00
Michael Kozono 43a682ccaa Fix OAuth API and RSS rate limiting 2017-11-17 09:58:18 +01:00
Michael Kozono dc9266fbea Add request throttles 2017-11-17 09:58:18 +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
Douwe Maan 294fa6fcdc Remove authentication using user.private_token 2017-11-02 11:39:02 +01:00
Toon Claes d8d7faf68c URI decode Page-Title header to preserve UTF-8 characters 2017-10-20 16:44:29 +00:00
Stan Hu 5d52bb59dc Fix username and ID not logging in production_json.log for Git activity
Devise sets `current_user`, but not all controllers authenticate users by
session tokens. Try to use the controller-defined `authenticated_user` if
`current_user` is not available.

Closes gitlab-org/gitlab-ee#3611
2017-10-04 11:47:36 -07:00
Douwe Maan 5adae3d85b Encode Page-Title header as ISO-8859-1 2017-09-26 18:05:19 +02:00
Douwe Maan 711bb28568 Add Page-Title header to tree and blob JSON endpoints 2017-09-26 17:31:47 +02:00
Tiago Botelho 37383d9a9d Rollsback changes made to signing_enabled. 2017-09-01 10:51:40 +01:00
Rémy Coutable c946ee1282
Enable the Layout/SpaceBeforeBlockBraces cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-09 11:52:22 +02:00
Bob Van Landuyt faabcbd3ae GRPC::Unavailable (< GRPC::BadStatus) is wrapped in a CommandError 2017-08-07 14:37:01 +02:00
Bob Van Landuyt 3598e60bf2 Add a Circuitbreaker for storage paths 2017-08-04 15:38:48 +02:00
Stan Hu 9bc176b2c3 Add remote IP, user ID and username to JSON lograge output
This makes the logs a bit more useful to search requests by users.
2017-07-28 00:48:03 -05:00
Robin Bobbitt 672a68d372 Fixes needed when GitLab sign-in is not enabled
When sign-in is disabled:
 - skip password expiration checks
 - prevent password reset requests
 - don’t show Password tab in User Settings
 - don’t allow login with username/password for Git over HTTP requests
 - render 404 on requests to Profiles::PasswordsController
2017-07-13 10:08:27 -04:00
Rémy Coutable 186048a404 Allow to enable the performance bar per user or Flipper group
A `performance_team` Flipper group has been created. By default this
group is nil but this can be customized in `gitlab.yml` via the
performance_bar.allowed_group setting.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-06 11:18:25 +02:00
Stan Hu 73d019e11f Log rescued exceptions to Sentry
Support noticed that a number of exceptions, such as
"Encoding::CompatibilityError (incompatible character encodings: UTF-8 and
ASCII-8BIT)", failed to report to Sentry. The `rescue_from` in the
ApplicationController prevented these exceptions from being recorded.
This change ensures that these exceptions are properly captured.
2017-07-04 14:03:46 -07:00