Commit Graph

974 Commits

Author SHA1 Message Date
Robert Speicher 34a23bda60 Add current_user to filter context 2015-04-20 13:01:43 -04:00
Robert Speicher 43c62ca3f2 Remove Gitlab::Markdown from Gitlab::ReferenceExtractor 2015-04-20 13:01:43 -04:00
Robert Speicher 29604ff2c3 Add permission checking to UserReferenceFilter 2015-04-20 13:01:43 -04:00
Robert Speicher 189c5347be Add name-based referencing to LabelReferenceFilter 2015-04-20 13:01:43 -04:00
Robert Speicher 77a6746a75 Run SanitizationFilter before our reference filters 2015-04-20 13:01:42 -04:00
Robert Speicher 4cb1cc2b64 Make CommitRange and Snippets cross-referable 2015-04-20 13:01:42 -04:00
Robert Speicher 96c2b94048 Reference filters
Commit ranges, commits, external issues, issues, labels, merge requests,
snippets, users.
2015-04-20 13:01:42 -04:00
Douwe Maan c75c6b840b Revert disallowing usernames to end in period. 2015-04-20 12:41:44 +02:00
Dmitriy Zaporozhets bd97715a57 Merge branch 'fix-label-color' into 'master'
Parse GFM references after sanitizing

Parse GFM references - labels, issues, MRs, etc. - after calling the HTML Pipeline `SanitizationFilter` so that we can use non-whitelisted attributes like `style`.  See #2188.

See merge request !1745
2015-04-20 08:40:13 +00:00
Vinnie Okada df9a992c15 Fix GFM extractions
Extract and re-insert links after sanitizing user markup.
2015-04-17 20:39:38 -06:00
Douwe Maan 38982136ec Decrease memory use and increase performance of Google Code importer. 2015-04-17 14:55:51 +02:00
Douwe Maan 7d98c8842d Move import data out of project so it doesn't take ages to load. 2015-04-17 14:49:00 +02:00
Douwe Maan 80097606f5 Make sure user has access to namespace in import tests. 2015-04-15 16:58:43 +02:00
Dmitriy Zaporozhets 345e32d332 Merge branch 'sstanovnik-openssh_fix' into 'master'
Fix generating SSH key fingerprints with OpenSSH 6.8.

Replaces https://github.com/gitlabhq/gitlabhq/pull/9008.

Fixes gitlab-org/gitlab-ce#1289.

cc @jacobvosmaer

See merge request !519
2015-04-15 12:40:30 +00:00
Dmitriy Zaporozhets 4ab22a8c32 Merge branch 'ldap-block_auto_created_users' into 'master'
Add config var to block auto-created LDAP users.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2110.

See merge request !522
2015-04-15 12:36:43 +00:00
Douwe Maan 63b21945d2 Merge branch 'google-code-import' into 'master'
Import projects from Google Code.

Resolves #1257.

Issue import logic almost entirely taken from https://gitlab.com/o9000/google-code-to-gitlab ( ♥️ @o9000).

### To do

- [x] List projects from Google Takeout file
- [x] Import Git repository
- [x] Import issues
- [x] Link to correct attachment URL (https://code.google.com/p/support-tools/issues/detail?id=50)
- [x] Handle deleted attachments
- [x] Handle blockedOn attribute
- [x] Add directions on how to get data from Google Takeout

### Import instructions

![Screen_Shot_2015-04-03_at_16.02.21](https://gitlab.com/gitlab-org/gitlab-ce/uploads/4a87038035fbad9441cf613b8cdcc690/Screen_Shot_2015-04-03_at_16.02.21.png)

### Imported issue

![Screen_Shot_2015-04-03_at_16.25.49](https://gitlab.com/gitlab-org/gitlab-ce/uploads/b2c2eaf5ecfcf57b3c48511eb5d26db4/Screen_Shot_2015-04-03_at_16.25.49.png)

See merge request !471
2015-04-15 06:53:42 +00:00
Douwe Maan 9d00bb0896 Import Google Code issue assignee when mapped. 2015-04-14 23:22:14 +02:00
Douwe Maan 2f797a140b Skip issue comment when its content, updates and attachments are empty. 2015-04-14 23:13:48 +02:00
Douwe Maan 238e4f0295 Add config var to block auto-created LDAP users. 2015-04-14 17:09:05 +02:00
Douwe Maan c43411e97a Non-persisted users already have the identity by way of build_new_user. 2015-04-14 17:08:49 +02:00
Douwe Maan 076494646d Simplify regex. 2015-04-14 15:58:28 +02:00
Douwe Maan dba63d667d Allow user map to be specified. 2015-04-14 14:50:56 +02:00
Douwe Maan f6cb42f3d1 Add comment number to imported Google Code comments. 2015-04-14 13:13:18 +02:00
Douwe Maan dfe659c16d Remove author link since all code.google.com links will be shut down. 2015-04-14 13:11:29 +02:00
Douwe Maan 1221bec56c Refactor key fingerprint generation. 2015-04-14 12:00:43 +02:00
Dmitriy Zaporozhets 4ab717ea6a
Merge branch 'ldap_migration'
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	db/schema.rb
2015-04-13 17:18:02 +03:00
Dmitriy Zaporozhets ecb58dacd6 Merge branch 'reference-access-control' into 'master'
Only allow users to reference groups, projects, issues, MRs, commits they have access to.

Addresses https://dev.gitlab.org/gitlab/gitlabhq/issues/2183.

See merge request !1742
2015-04-13 14:10:25 +00:00
Dmitriy Zaporozhets 6e88d9335b Merge branch 'skip-email-reconfirmation' into 'master'
Skip email confirmation when set by admin or via LDAP.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2203.

See merge request !494
2015-04-13 13:44:56 +00:00
Dmitriy Zaporozhets 7f04a4174e Merge branch 'shell-version-warning' into 'master'
Warn when gitlab-shell version doesn't match requirement.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/1791.

See merge request !495
2015-04-13 13:05:47 +00:00
Jacob Vosmaer 325b66365b Remove special cases for the 'ldap' provider 2015-04-13 11:04:31 +02:00
Dmitriy Zaporozhets 24d139ba97 Merge branch 'rs-revert-preload-lib' into 'master'
Revert "Preload lib/"

This reverts commit 5511a731bc.

The original commit added this because it also enabled threadsafety, a change which was itself later reverted in 66d6c80966, but this got left behind.

I don't fully understand the reasoning behind it so if I'm wrong, please tell me.

My reasoning for reverting it is that it messes with Rails' (and by extension Spring's) class reloading during development. When I was working in `lib/gitlab/markdown` and had to stop and restart the server every time I made a change, I didn't know it at the time, but this was why. That was a huge pain point.

If it's needed for production perhaps we could add a `if Rails.env.production?` clause around it so that it doesn't mess with development.

See merge request !1758
2015-04-10 14:34:57 +00:00
Robert Speicher 5a0ff2f52f Be more explicit about which "Markdown" ReferenceExtractor includes 2015-04-09 17:28:46 -04:00
Robert Speicher c9a1634f31 Move lib/gitlab/contributors to its correct path 2015-04-09 15:34:55 -04:00
Robert Speicher abae9b8d63 Add autoloads for lib/gitlab/satellite/files/*
These files don't match their naming convention, but for organizational
purposes it makes sense.
2015-04-09 14:19:25 -04:00
Robert Speicher 2cefdbb535 Move lib/gitlab/oauth to lib/gitlab/o_auth
Lets Rails autoload these files by name
2015-04-09 14:19:24 -04:00
Douwe Maan 99abbe7dbe Use Projects::CreateService to create imported projects so hooks are executed. 2015-04-06 14:51:09 +02:00
Douwe Maan f915a4b80f Warn when gitlab-shell version doesn't match requirement. 2015-04-06 14:02:49 +02:00
Douwe Maan f2af30f195 Skip email confirmation when set by admin or via LDAP. 2015-04-06 13:27:19 +02:00
Douwe Maan 06399b3261 Show Google Code image attachments inline. 2015-04-04 14:19:05 +02:00
Douwe Maan e33ddfebf2 Refactor ClosingIssueExtractor. 2015-04-03 18:03:26 +02:00
Douwe Maan b492f0f86e Refactor ReferenceExtractor. 2015-04-03 18:03:15 +02:00
Douwe Maan 9d647197da Don't require user to every gfm call. 2015-04-03 18:03:01 +02:00
Douwe Maan c590cd3443 Mask owner email when updated. 2015-04-03 16:21:32 +02:00
Douwe Maan 7b5bc32cad Allow projects to be imported from Google Code. 2015-04-03 15:29:27 +02:00
Douwe Maan 317206300d Merge branch 'configurable-attachment-size' into 'master'
Support configurable attachment size in Application Settings page

### What does this MR do?

This MR provides the ability to configure the maximum size of an attachment inside a note. A parameter has been added to the Application Settings page.

### Are there points in the code the reviewer needs to double check?

What should be done with the legacy note attachment validation? I added code to make the validation work with the configurable setting. I could see an issue where an admin lowers the limit from 10 megabytes to 5 megabytes, which could cause an existing model to be invalid.

### Why was this MR needed?

We often have attachments that exceed 10 MB, and it would be nice to be able to override the defaults.

### What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)?

See Issue #1258

### Screenshots

Before:

![Screen_Shot_2015-03-29_at_3.06.53_PM](https://gitlab.com/gitlab-org/gitlab-ce/uploads/6013a1dbc8cf61a63e93744149937fa0/Screen_Shot_2015-03-29_at_3.06.53_PM.png)

After:

![Screen_Shot_2015-03-29_at_3.12.34_PM](https://gitlab.com/gitlab-org/gitlab-ce/uploads/f3518af7e8653ba40f0a3579456da6ad/Screen_Shot_2015-03-29_at_3.12.34_PM.png)

See merge request !407
2015-04-03 08:47:55 +00:00
Douwe Maan c5d7660000 Fix errors. 2015-04-02 22:36:54 +02:00
Dmitriy Zaporozhets 0d0042d274 Merge branch 'import-current-user' into 'master'
Import GitHub, Bitbucket or GitLab.com projects owned by authenticated user into current namespace.

Addresses #1347.

Untested since I'm in a bit of a hurry. Will definitely have time to test and add unit tests before the 7.10 release :)

See merge request !481
2015-04-02 20:34:52 +00:00
Dmitriy Zaporozhets f8f9750323 Merge branch 'username-period' into 'master'
Don't allow username to end in period.

The current behavior doesn't do username referencing and mentioning in sentences like "I discussed with with @douwe." since `douwe.` is matched as a username.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2174.

See merge request !438
2015-04-02 20:28:23 +00:00
Douwe Maan 65bb0c3406 Only allow users to cross-reference and close issues they have access to. 2015-04-02 10:57:01 +02:00
Douwe Maan 756e7aa8c3 Don't allow full access to guests in ReferenceExtractor 2015-04-02 10:57:01 +02:00
Douwe Maan d2bd606759 Refactor Mentionable mentioned users to use ReferenceExtractor. 2015-04-02 10:57:01 +02:00
Douwe Maan ca58e369c9 Only allow user to reference objects they have access to. 2015-04-02 10:56:04 +02:00
Douwe Maan b1ef1aa59f Slightly refactor ReferenceExtractor. 2015-04-02 10:53:38 +02:00
Stan Hu dfd256f29e Support configurable attachment size via Application Settings
Fix bug where error messages from Dropzone would not be displayed on the issues page

Closes #1258
2015-04-02 00:04:08 -07:00
Marin Jankovski d77f333f9c Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Conflicts:
	lib/gitlab/markdown.rb
2015-03-31 19:03:54 -07:00
Dmitriy Zaporozhets dc3b4321ff Merge branch 'group-information-leak' into 'master'
Don't leak private group existence by redirecting from namespace controller to group controller.

See merge request !440
2015-04-01 01:01:38 +00:00
Douwe Maan 737f322e41 Import GitHub, Bitbucket or GitLab.com projects owned by authenticated user into current namespace. 2015-03-31 16:34:13 +02:00
Vinnie Okada 9deda68257 Parse GFM references after sanitizing
Parse GFM references - labels, issues, MRs, etc. - after calling the
HTML Pipeline `SanitizationFilter` so that we can use non-whitelisted
attributes like `style`.
2015-03-28 08:58:30 -06:00
Douwe Maan 5f93b0e3da Don't allow username to end in period. 2015-03-27 11:10:56 +01:00
Douwe Maan dfe0f9eedf Use more specific regexes. 2015-03-27 11:09:29 +01:00
Douwe Maan 3f7531d6f2 Move User.cleanup_username to Namespace.cleanup_path. 2015-03-27 11:09:29 +01:00
Douwe Maan e08d947e77 Use relative URL for Markdown references, except in mails. 2015-03-27 10:39:05 +01:00
Dmitriy Zaporozhets 99fcb80eb7 Merge pull request #9021 from nicklegr/faster_auto_merge
Faster merge request processing for large repository
2015-03-25 12:18:03 -07:00
Dmitriy Zaporozhets 6199da0cb4 Merge pull request #8007 from mr-vinn/markdown-tags
Allow HTML tags in user Markdown input
2015-03-25 10:21:03 -07:00
Dmitriy Zaporozhets f729f60447 Merge branch 'more-rubocop-styles' into 'master'
More rubocop styles

See merge request !449
2015-03-25 15:37:04 +00:00
nicklegr a30011372f Reset parking branch to HEAD everytime
* Reduces overhead of git checkout
2015-03-25 21:05:06 +09:00
Dmitriy Zaporozhets 8f3f6e9efb Merge branch 'api-internal-errors' into 'master'
Respond with full GitAccess error if user has project read access.

Should help with debugging #1236.

cc @marin

See merge request !437
2015-03-25 04:16:45 +00:00
Vinnie Okada 057c8c344b Merge branch 'master' into markdown-tags 2015-03-24 20:03:22 -06:00
Dmitriy Zaporozhets 69454e36f7 Style/RedundantReturn enabled 2015-03-24 18:35:57 -07:00
Dmitriy Zaporozhets 6ec8ff069c Enable more rubocop style checks 2015-03-24 18:28:10 -07:00
Dmitriy Zaporozhets fc4af9b197 Merge branch 'git-auth-rack-attack-improvements' into 'master'
Reduce Rack Attack false positives causing 403 errors during HTTP authentication

### What does this MR do?

This MR reduces false positives causing `403 Forbidden` messages after HTTP authentication.

A Git client may attempt to access a repository without a password. If it receives a 401 error, the client often will try again, this time supplying a password. The problem is that `grack_auth.rb` considers a blank password an authentication failure and increases a Redis counter each time this happens. With enough requests, an IP can be banned temporarily even though previous attempts may have been successful. This leads users to see `403 Forbidden` errors until the ban times out (default: 1 hour).

To reduce the chance of a false positive, this MR resets the counter upon a successful authentication from an IP.

In addition, this MR logs when a user has been banned and introduces the ability to disable Rack Attack via a config variable.

### Are there points in the code the reviewer needs to double check?

rack-attack v4.2.0 doesn't support the ability to clear counters out of the box, so `rack_attack_helpers.rb` includes a number of monkey patches to make it work. It looks like this functionality may be added in v4.3.0. I've also sent pull requests to rack-attack to add the functionality necessary to delete a key.

Each time an authentication is successful, the Redis counter for that IP is cleared. I deemed it better to clear the counter than to allow for blank passwords, since the latter seems like a security risk.

### Why was this MR needed?

It was quite difficult to figure out why users were seeing `403 Forbidden`, which is why the log message was added. Users were getting a lot of false positives when accessing repositories with HTTPS. Including the username in the HTTPS URL (e.g. `https://username@mydomain.com/account/repo.git`) caused authentication failures because while the git client provided the username, it left the password blank, leading to an authentication failure.

### What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)?

See Issue #1171

https://github.com/kickstarter/rack-attack/issues/113

See merge request !392
2015-03-24 21:51:40 +00:00
Dmitriy Zaporozhets b8ad3647ad Merge branch 'fix-nested-tasks' into 'master'
Fix nested task lists

When nesting task list items, the parent item is wrapped in a `<p>` tag.  Update the task list parser to handle these paragraph wrappers.

cc @sytse

See merge request !413
2015-03-24 20:57:35 +00:00
Douwe Maan 61e8ca8ce0 Don't leak private group existence by redirecting from namespace controller to group controller. 2015-03-24 15:55:12 +01:00
Douwe Maan 4830b2be5e Refactor GitAccess to use instance variables. 2015-03-24 14:11:48 +01:00
Stan Hu 56d87db32c Reduce Rack Attack false positives by clearing out auth failure count upon
successful Git over HTTP authentication.

Add logging when a ban goes into effect for debugging.

Issue #1171
2015-03-24 00:36:46 -07:00
Dmitriy Zaporozhets 2bb4ea8542 Merge branch 'notes-count-without-system' into 'master'
Don't include system notes in issue/MR comment count.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2163.

See merge request !430
2015-03-24 00:10:25 +00:00
Dmitriy Zaporozhets 81d603e2c1 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2015-03-23 09:44:28 -07:00
Dmitriy Zaporozhets e24da35984 Merge branch 'improve-contributions-calendar' into 'master'
Replace commits calendar with contributions calendar

* count opening of issues and merge requests
* dont trigger git repository - use events from database
* count pushes instead of commits for faster and easier counting
* much-much faster since does not affected by repository size

See merge request !420
2015-03-23 16:40:55 +00:00
Douwe Maan 6b92236eeb Don't include system notes in issue/MR comment count. 2015-03-23 16:43:08 +01:00
Douwe Maan d4d0852d2d Merge pull request #8995 from MichaelAlt/patch-1
Faulty LDAP DN name escaping removed
2015-03-23 08:23:19 +01:00
Vinnie Okada 637ca0b388 Merge branch 'master' into markdown-tags 2015-03-22 21:50:28 -06:00
Vinnie Okada a7afc06342 Fix SanitizationFilter bugs
Return a `SafeBuffer` instead of a `String` from the `#gfm_with_options`
method so that Rails doesn't escape our markup.

Also add `<span>` to the sanitization whitelist to avoid breaking syntax
highlighting in code blocks.
2015-03-22 20:17:56 -06:00
Stan Hu 5cce0645b0 Fix OAuth2 issue importing a new project from GitHub and GitLab
Closes #1268
2015-03-22 18:16:48 -07:00
Dmitriy Zaporozhets fb30039668 Merge branch 'disable-ref-generation-in-code-blocks' into 'master'
Disable reference generation in preformatted/code blocks

### Summary

If a user adds text in code or preformatted text via Markdown or HTML that contains `#XXX`, the system adds a note that issue `XXX` was mentioned. This is particularly annoying because we often list gdb backtrace dumps into our issues, and many issues get mentioned as a result. For example:

```
(gdb) bt
#0  0x00000000004004c4 in second () at main.cc:6
#1  0x00000000004004d2 in first () at main.cc:11
#2  0x00000000004004dd in main () at main.cc:17
(gdb)
```

### Steps to reproduce

1. In an issue, write the above text using Markdown or HTML tags (e.g. `<code>`, `<pre>`).
2. Observe that [issue 1](https://gitlab.com/gitlab-org/gitlab-ce/issues/1) and [issue 2](https://gitlab.com/gitlab-org/gitlab-ce/issues/2) have a note that says they were mentioned.

### Expected behavior

Everything enclosed in the code blocks should be ignored as references.

### Observed behavior

Issues get referenced unnecessarily.

### Fix

I've made `reference_extractor.rb` strip out HTML and Markdown blocks before processing. I considered running the raw text through the entire Markdown processor, but this seems overkill and perhaps could lead to some unintended side effects.

See merge request !365
2015-03-22 23:36:07 +00:00
Dmitriy Zaporozhets 8494170550 Improve contribution calendar per day info 2015-03-22 14:52:44 -07:00
Dmitriy Zaporozhets 54aca18cf8 Contribution calendar will use events instead of commits to count contributions 2015-03-22 14:35:27 -07:00
Dmitriy Zaporozhets 43afe46bbd Refactor contributions events and write tests for calendar 2015-03-22 13:55:00 -07:00
Dmitriy Zaporozhets 64891c6c40 Replace commits calendar with contributions calendar
* count opening of issues and merge requests
* dont trigger git repository - use events from database
* much-much faster since does not affected by repository size
2015-03-21 23:48:08 -07:00
Michael Alt 1502fed795 Faulty LDAP DN name escaping removed
The Net::LDAP::Filter.escape function can not be used to escape the DN name because the backslash is required to escape special chars in the DN name. This leads to the error message "Access denied for your LDAP account." and prevents the user from logging in to gitlab.

Example DN: 
CN=Test\, User,OU=Organization,DC=Company
CN=Test User,OU=Organization,DC=Company

http://www.ietf.org/rfc/rfc4514.txt
2015-03-21 22:57:55 +01:00
Vinnie Okada f5e65e2e50 Merge branch 'master' into markdown-tags
Merge updated CHANGELOG entries
2015-03-21 09:03:35 -06:00
Vinnie Okada 1dc90fc455 Fix nested task lists
When nesting task list items, the parent item is wrapped in a `<p>` tag.
Update the task list parser to handle these paragraph wrappers.
2015-03-21 08:45:28 -06:00
Vinnie Okada cc29ce4917 Don't allow style attributes in inline HTML 2015-03-21 08:39:54 -06:00
Kamil Trzcinski 5b432e7671 Extend push_tag event to include tag message and last commit 2015-03-21 11:25:27 +01:00
Vinnie Okada 52bf95ae38 Change HTML sanitization
Use the `SanitizationFilter` class from the html-pipeline gem for inline
HTML instead of calling the Rails `sanitize` method.
2015-03-19 21:24:07 -06:00
Dmitriy Zaporozhets efd8491d49 Revert "Increase timeout for Git-over-HTTP requests."
This reverts commit 516bcabbf4.

Conflicts:
	Gemfile
2015-03-19 18:29:20 -07:00
Stan Hu 83d552d50d Disable reference creation for comments surrounded by code/preformatted blocks 2015-03-19 14:37:35 -07:00
Douwe Maan a5a5ec970e Fewer constants, more helpers. 2015-03-19 10:34:04 +01:00
Marin Jankovski 63f7129483 Move application setting to separate variable. 2015-03-18 13:55:41 -07:00
Vinnie Okada e535d21768 Handle nil restricted visibility settings
Return `true` from `non_restricted_level?` when the
`restricted_visibility_levels` setting is nil.
2015-03-18 12:50:27 -06:00
Dmitriy Zaporozhets fec5f807bb Merge branch 'new-branch-commits' into 'master'
List new commits for newly pushed branch in activity view.

When someone pushes commits, I want to see them, regardless if it's a new or existing branch. If it's a new branch, we compare with the default branch (usually master).

![Screen_Shot_2015-03-17_at_15.49.13](https://dev.gitlab.org/gitlab/gitlabhq/uploads/4cb7e0d833bc83a30197db81d4b273bc/Screen_Shot_2015-03-17_at_15.49.13.png)

See merge request !1711
2015-03-18 17:47:02 +00:00
Douwe Maan 9d938fd77d List new commits for newly pushed branch in activity view. 2015-03-18 14:28:50 +01:00
Hannes Rosenögger 9e5738b007 Extend the commit calendar to show the actual commits for a date 2015-03-18 08:42:42 +01:00
Vinnie Okada feeffc4426 Merge branch 'master' into markdown-tags
Use the latest HTML pipeline gem
2015-03-17 20:53:09 -06:00
Douwe Maan e4ac6bbf82 Merge branch 'atom-xhtml-squashed' into 'master'
Fix invalid Atom feeds when using emoji, horizontal rules, or images

This is a fix for issues #880, #723, #1113.

Markdown must be rendered to XHTML, not HTML, when generating summary content for Atom feeds. Otherwise, content-less tags like *img* and *hr* are not terminated and make the Atom XML invalid. Such tags are generated when issue descriptions, merge request descriptions, comments, or commit messages use emoji, horizontal rules, or images.

To pass this option through from the relevant Haml templates to the proper place in the `gfm()` method, a new method `gfm_with_options()` is introduced. It reuses the options dictionary passed to `markdown()` and interprets options `xhtml` and `parse_tasks` from it (the latter was a convenient replacement for `gfm_with_tasks()`). `xhtml` is already interpreted by Redcarpet::Render::HTML, but that alone was not sufficient, because the post-processing in `gfm()` would convert its XHTML tags back to HTML.

I found no way of passing additional optional options to the existing `gfm()` method without requiring updates to existing callers and without getting in the way of the existing optional arguments, but maybe someone who knows more about Ruby than I can think of one.

Thorough review appreciated since this is the first time I have used Ruby.

See merge request !344
2015-03-17 08:38:38 +00:00
Christian Walther 90aa870c36 Fix invalid Atom feeds when using emoji, horizontal rules, or images.
Fixes issues #880, #723, #1113: Markdown must be rendered to XHTML, not HTML, when generating summary content for Atom feeds. Otherwise, content-less tags like <img> and <hr>, generated when issue descriptions, merge request descriptions, comments, or commit messages use emoji, horizontal rules, or images, are not terminated and make the Atom XML invalid.
2015-03-16 22:05:52 +01:00
Dmitriy Zaporozhets 648f38cd98 Merge branch 'fix-restricted-visibility' into 'master'
Restricted visibility levels - bug fix and new feature

This allows admin users to override restricted visibility settings when creating and updating projects and snippets, and moves the restricted visibility configuration from gitlab.yml to the web UI.  See #1903.

## Move configuration location

I added a new section to the application settings page for restricted visibility levels.  Each level has a checkbox, styled with Bootstrap to look like a toggle button.  A checked box means that the level is restricted.  I added a glowing text shadow and changed the background color for checked buttons because the default styles made it hard to distinguish between checked and unchecked.  This image shows the new section with the "Public" box checked:

![restricted_visibility_settings](https://dev.gitlab.org/Okada/gitlabhq/uploads/629562e4313f89b795e81c3bb0f95893/restricted_visibility_settings.png)

## Allow admins to override

To allow admin users to override the restricted visibility levels, I had to remove the `visibility_level` validation from the `Project` class.  The model doesn't know about the `current_user`, which should determine whether the restrictions can be overridden.  We could use the creator in the validation, but that wouldn't work correctly for projects where a non-admin user is the creator and an admin tries to change the project to a restricted visibility level.

The `Project::UpdateService` and `Project::CreateService` classes already had code to determine whether the current user is allowed to use a given visibility level; now all visibility level validation is done in those classes.  Currently, when a non-admin tries to create or update a project using a restricted level, these classes silently set the visibility level to the global default (create) or the project's existing value (update).  I changed this behavior to be more like an Active Model validation, where using a restricted level causes the entire request to be rejected.

Project and personal snippets didn't have service classes, and restricted visibility levels weren't being enforced in the model or the controllers.  The UI disabled radio buttons for restricted levels, but that wouldn't be difficult to circumvent.  I created the `CreateSnippetService` and `UpdateSnippetService` classes to do the same restricted visibility check that the project classes do.  And since I was dealing with snippet visibility levels, I updated the API endpoints for project snippets to allow users to set and update the visibility level.

## TODO

* [x] Add more tests for restricted visibility functionality

cc @sytse @dzaporozhets

See merge request !1655
2015-03-16 17:49:46 +00:00
Douwe Maan 31fc73f0a9 Use `project_member` instead of `team_member`. 2015-03-15 13:50:38 +01:00
Vinnie Okada ad0ca0499a Merge branch 'master' into fix-restricted-visibility
Conflicts:
	db/schema.rb
2015-03-14 10:49:11 -06:00
Dmitriy Zaporozhets afb694886e Merge branch 'ldap-unblock-user' into 'master'
Unblock user if they were unblocked in AD.

Fixes problem with !1687.

See merge request !1694
2015-03-13 22:25:47 +00:00
Douwe Maan 8fed435208 Unblock user if they were unblocked in AD. 2015-03-13 22:34:11 +01:00
Dmitriy Zaporozhets b8f5e23f27 Merge branch 'tag-branch-hooks' into 'master'
Execute hooks and services when branch or tag is created or deleted through web interface.

Fixes #2095.

Split up into commits to make it easier to see why what was changed :)

See merge request !1692
2015-03-13 16:42:01 +00:00
Douwe Maan 4e49f21b14 Set push data object kind in PushDataBuilder. 2015-03-13 14:51:48 +01:00
Douwe Maan 2718955441 Fix import pages not working after first load. 2015-03-13 13:47:26 +01:00
Dmitriy Zaporozhets e7f4f0ae1d Block user if he/she was blocked in Active Directory 2015-03-12 11:53:21 -07:00
Dmitriy Zaporozhets 158507d942 Add blue theme to GitLab 2015-03-11 21:29:11 -07:00
Dmitriy Zaporozhets b2f6567961 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2015-03-11 09:57:59 -07:00
Dmitriy Zaporozhets e349ca1353 Merge branch 'ldap-filter-eq' into 'master'
Escape wildcards when searching LDAP by username.

Addresses https://dev.gitlab.org/gitlab/gitlabhq/issues/2086.

Also see https://dev.gitlab.org/gitlab/gitlab-ee/merge_requests/344 and https://dev.gitlab.org/gitlab/omniauth-ldap/merge_requests/2.

See merge request !1644
2015-03-11 16:57:28 +00:00
Hannes Rosenögger b0c1bc6657 Merge branch 'generate-valid-json' into 'master'
Generate valid json

This patch helps to be compatible to other programing languages as it improves the validation of hook data. It seems only ruby can handle 'nil' as value while other json decode function will fatal.

See merge request !182
2015-03-11 16:53:10 +00:00
Douwe Maan 383c56efa1 Use Gitlab::Git helper methods and constants as much as possible. 2015-03-10 13:39:31 +01:00
Nicole Cordes b7a31a4b02 Generate valid json for hooks
It seems that ruby can handle 'nil' value but other json processors
(like PHP) throw an error. This is always generated for empty arrays.
2015-03-10 10:07:25 +01:00
Vinnie Okada 928fc94c3d Enforce restricted visibilities for snippets
Add new service classes to create and update project and personal
snippets.  These classes are responsible for enforcing restricted
visibility settings for non-admin users.
2015-03-08 17:57:08 -06:00
Vinnie Okada cacac147de Move restricted visibility settings to the UI
Add checkboxes to the application settings page for restricted
visibility levels, and remove those settings from gitlab.yml.
2015-03-07 13:11:08 -07:00
Douwe Maan 4dddaef866 Automatically link commit ranges to compare page. 2015-03-07 00:46:13 +01:00
Stan Hu 7e204cf389 Added comment notification events to HipChat and Slack services.
Supports four different event types all bundled under the "note" event type:

- comments on a commit
- comments on an issue
- comments on a merge request
- comments on a code snippet
2015-03-06 06:54:00 -08:00
Douwe Maan 757dca2b78 Escape wildcards when searching LDAP by username. 2015-03-06 13:39:57 +01:00
Dmitriy Zaporozhets d07b2e09fe Merge branch 'timeout' into 'master'
Increase timeout for Git-over-HTTP requests.

Fixes #2081 and https://gitlab.com/gitlab-org/gitlab-ce/issues/232.

Normal web requests are bound by the `Rack::Timeout` timeout of 60 seconds, while Grack Git-over-HTTP requests are only bound by Unicorn's timeout which is now set to 1 hour, which should be plenty.

The omnibus package should be updated to no longer use `unicorn['worker_timeout']` for the Unicorn timeout, but to set the `Slowpoke.timeout`.

See merge request !1619
2015-03-05 02:28:58 +00:00
Douwe Maan 516bcabbf4 Increase timeout for Git-over-HTTP requests. 2015-03-04 23:20:47 +01:00
Dmitriy Zaporozhets 63178a9509 Merge branch 'add-more-slack-notifications' into 'master'
Add more Slack notifications for issue and merge request events

From https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/237 by Stan Hu.

See merge request !1556
2015-03-04 21:57:17 +00:00
Valery Sizov 3d9a766d9f Web Hook sends email of pusher 2015-03-04 20:29:25 +02:00
Marin Jankovski 3d6d0e1e77 Merge branch 'fix-namespace-merge-request-url' into 'master'
Fix namespace in merge request url building

Changes in 42387b733b now require namespace specification and broke abc69c8905.

There are additional helper functions in c530ca00b0, but this seemed easier not to rely on them.

See merge request !363
2015-03-04 01:08:52 +00:00
Stan Hu 2088cee935 Fix URL builder to use GitlabRoutingHelper 2015-03-03 15:57:28 -08:00
Dmitriy Zaporozhets 8c47a72a4e Merge branch 'project-existence-leak' into 'master'
Don't leak information about private project existence via Git-over-SSH/HTTP.

Fixes #2040 and https://gitlab.com/gitlab-org/gitlab-ce/issues/343.

Both `Grack::Auth` (used by Git-over-HTTP) and `Api::Internal /allowed` (used by gitlab-shell/Git-over-SSH) now return a generic "Not Found" error when the project exists but the user doesn't have access to it.

See merge request !1578
2015-03-03 20:05:12 +00:00
Jeroen van Baarsen abc69c8905 Merge branch 'fix-merge-request-url-builder' into 'master'
Fix merge request URL passed to Webhooks

If you look at the data structure passed to Webhooks, you will see:

`"url"=>nil`

I don't think any of the Webhooks or services are using this yet, so right now nothing so far depends upon this value being correct.

See merge request !352
2015-03-03 13:18:23 +00:00
Stan Hu afe5d7d209 Issue #595: Support Slack notifications upon issue and merge request events
1) Adds a DB migration for all services to toggle on push, issue, and merge events.

2) Upon an issue or merge request event, fire service hooks.

3) Slack service supports custom messages for each of these events. Other services
not supported at the moment.

4) Label merge request hooks with their corresponding actions.
2015-03-03 11:14:31 +01:00
Douwe Maan dd37a10df4 Don't leak information about private project existence via Git-over-SSH/HTTP. 2015-03-02 17:52:48 +01:00
Nicolas Bouilleaud 8d0690c5c7 Support names starting with a digit or _ for projects and users
This is what’s actually allowed when creating a user or a project in gitlab.
2015-03-02 11:01:17 +01:00
Dmitriy Zaporozhets a52529f9b6 Merge branch 'bitbucket-import'
Conflicts:
	app/views/import/gitorious/status.html.haml
	db/schema.rb
2015-02-25 09:21:45 -08:00
Douwe Maan 3fde1dce1f Satisfy Rubocop. 2015-02-24 15:07:25 +01:00
Douwe Maan 6979b3afd5 Delete deploy key from Bitbucket after importing. 2015-02-24 15:07:24 +01:00
Douwe Maan f2b37de54b Fix specs. 2015-02-24 15:07:24 +01:00
Douwe Maan 448817c4de Load public key in initializer. 2015-02-24 15:07:24 +01:00
Douwe Maan ad6d623234 Add Bitbucket importer. 2015-02-24 15:07:24 +01:00
Valery Sizov 71a844cdae Web Editor: save to new branch 2015-02-24 11:43:20 +02:00
Stan Hu e363f2e675 Fix merge request URL passed to Webhooks.
Previously the symbol "url" in the object_attributes hash would always be nil.
2015-02-24 06:51:24 +00:00
Dmitriy Zaporozhets c87c1cb3b9 Merge branch 'api-empty-commit' into 'master'
Improve error messages when file editing fails

Give more specific errors in API responses and web UI flash messages when a file update fails.  See #1479.

Instead of returning false from `Gitlab::Satellite::Files::EditFileAction#commit!` when a `Grit::Git::CommandFailed` error is raised, now `#commit!` raises a different error depending on whether the failure happened during checkout, commit, or push.

@dzaporozhets Please let me know if you want to change the HTTP status codes or the error messages in `Files::UpdateService`

cc @sytse

See merge request !1569
2015-02-24 02:17:23 +00:00
Dmitriy Zaporozhets d723bf78b8 Fix git-over-http 2015-02-23 10:05:18 -08:00
Vinnie Okada 5f232b5687 Improve error messages when file editing fails
Give more specific errors in API responses and web UI flash messages
when a file update fails.
2015-02-22 16:01:49 -07:00
Vinnie Okada 2a9eed6620 Merge branch 'master' into rails-4.1.9
Conflicts:
	app/views/projects/commits/_commit.html.haml
	app/views/projects/issues/_issue.html.haml
	app/views/projects/issues/_issue_context.html.haml
	app/views/projects/merge_requests/_merge_request.html.haml
	app/views/projects/merge_requests/show/_context.html.haml
2015-02-21 12:55:28 -07:00
Dmitriy Zaporozhets a224a655d8 Merge branch 'mr-commit-comment-diff-lines' into 'master'
Fix commit comments on first line of diff not rendering in Merge Request Discussion view.

Example can be seen near the bottom on this MR: !1533.

Before:

![Screen Shot 2015-02-20 at 10.24.34](https://dev.gitlab.org/uploads/gitlab/gitlabhq/35600b98b5/Screen_Shot_2015-02-20_at_10.24.34.png)

After: the [note](https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/1533/diffs#note_36449) is actually rendered.

See merge request !1552
2015-02-21 02:06:39 +00:00
Marin Jankovski 8ae3112b3f Merge branch 'upload-xss-access-control' into 'master'
Fix note attachments XSS and access control

Replaces the reverted #1528, as proposed in https://gitlab.com/gitlab-org/omnibus-gitlab/issues/434, as discussed with @dzaporozhets and as summarized in #2032.

@marin Could you take a look at the nginx config and apply it to Omnibus once this gets merged?

See merge request !1553
2015-02-20 22:47:54 +00:00