Commit Graph

15065 Commits

Author SHA1 Message Date
dependabot-preview[bot]
a1d8dd0966 [Security] Bump puma from 4.3.0 to 4.3.1
Bumps [puma](https://github.com/puma/puma) from 4.3.0 to 4.3.1. **This update includes a security fix.**
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v4.3.0...v4.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-05 19:39:57 +00:00
taitus
d1c9df5f91 Sanitize resource fields values
Sanitize resource fields values from ddbb before send
to remote translate client.
2019-12-04 17:03:57 +01:00
Javier Martín
f9ee34557d Merge pull request #3873 from consul/bump_knapsack_pro
Bump knapsack_pro from 1.1.0 to 1.15.0
2019-12-04 13:44:22 +01:00
Javi Martín
92ea3c3d43 Bump knapsack_pro from 1.1.0 to 1.15.0 2019-12-03 14:11:19 +01:00
Javi Martín
1910115469 Use symbols instead of strings for SMTP settings
ActionMailer does differenciate between symbols and strings, and the
code stringifying keys comes from an early version which we forgot to
remove.
2019-12-01 20:30:45 +01:00
Javi Martín
c4ebea27a7 Add CSRF protection to Omniauth requests
More info:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-9284
https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284
2019-11-29 03:18:53 +01:00
Javier Martín
11adacfdb9 Merge pull request #3870 from rockandror/update-secrets-example
Add smtp settings for staging environment on secrets
2019-11-26 17:44:12 +01:00
taitus
0025fcb43e Update secrets.yml.example
Add smtp settings for staging environment
2019-11-26 16:52:46 +01:00
Javier Martín
24359294e4 Merge pull request #3868 from andrewcameronsims/legislation_categories_persist
Fix categories being removed when a legislation process is changed
2019-11-25 13:19:45 +01:00
Andrew Sims
5d3748d863 Bugfix: categories are shown on process update
These changes fix a bug that causes categories
of a legislation process to be wiped on update
of the process. It also adds a regression test
for this fix.
2019-11-25 18:45:53 +11:00
Javier Martín
c3d0e2b917 Merge pull request #3866 from consul/releasing_new_version
Make it easier to release a new version of CONSUL
2019-11-23 16:33:41 +01:00
Javi Martín
96be43ae86 Don't generate authors in the CHANGELOG
We were removing the authors manually after they were generated.
2019-11-23 14:15:48 +01:00
Javi Martín
7ec24d76f9 Don't check issues while generating the CHANGELOG
We only include pull requests, so checking issues isn't useful and takes
time.
2019-11-23 14:10:14 +01:00
Julian Herrero
be4f6bc07e Make it easier to release a new version of CONSUL
With this change we no longer need the branch `changelog` and it will
be easier to release new versions of CONSUL.
2019-11-23 14:06:53 +01:00
Javier Martín
98d6477481 Merge pull request #3858 from consul/dependabot/bundler/nokogiri-1.10.5
[Security] Bump nokogiri from 1.10.4 to 1.10.5
2019-11-20 00:11:19 +01:00
Javier Martín
3a750fdf1c Merge pull request #3864 from consul/fix_random_titles
Avoid invalid random titles in dashboard specs
2019-11-19 23:58:54 +01:00
Javi Martín
12eee3f5d1 Avoid invalid random titles in dashboard specs
Generating a random title with `Faker::Lorem.sentence` sometimes caused
validation errors in tests because the generated sentence was more than
80 characters long.
2019-11-19 23:32:12 +01:00
Javier Martín
0082c2fa42 Merge pull request #3859 from consul/reboot
Restart the application on every reboot
2019-11-19 22:03:31 +01:00
Javi Martín
69be13f7a7 Keep default puma settings in the test environment
The test environment was using the file in `config/puma.rb`, meaning it
wouldn't work with Rails 5.1, which uses a different setup for Puma.

I've decided to create a new file called `defaults.rb`, which will be
used in every environment but development and test. We could also add an
empty file in `config/puma/test.rb`; I think that's less intuitive, but
it's a subjective opinion.
2019-11-19 21:33:22 +01:00
Javier Martín
e629e4e245 Merge pull request #3861 from consul/newsletter_back
Fix "go back" link in newsletters
2019-11-18 20:41:52 +01:00
Javi Martín
1fdc34deac Fix "go back" link in newsletters
The link was pointing to the previous page, which was strange in many
scenarios, including cases where the previous page was the current page.
2019-11-18 20:14:45 +01:00
Javier Martín
c8bbcedbd2 Merge pull request #3860 from consul/remove_browser
Remove browser gem direct dependency
2019-11-18 14:21:23 +01:00
Javi Martín
442baf8384 Remove browser gem direct dependency
While the browser gem is great, we don't need it in this case for such a
simple usage.

There are a few really small differences between this code and the old
one: matching `/MSIE/` will return true for Opera 12 and false for
certain versions of IE11. Since we're only rendering a comment for IE8
and below, we don't care about IE11, and Opera 12 is six years old and
its users won't be affected by the comment.

Note we're still using the browser gem because ahoy_matey depends on it,
but now it's an indirect dependency.
2019-11-18 13:12:35 +01:00
Javier Martín
5f62916394 Merge pull request #3425 from pocman/patch-1
Upgrade Ruby version in Dockerfile
2019-11-18 01:18:51 +01:00
Javier Martín
0824cc3f2d Merge pull request #3848 from consul/dependabot/bundler/sitemap_generator-6.0.2
Bump sitemap_generator from 6.0.1 to 6.0.2
2019-11-17 23:19:02 +01:00
Javi Martín
755bc8e88a Restart the application on deploy:restart
The task `deploy:restart` was doing nothing since we moved from unicorn
to puma.

Now we're also restarting delayed jobs on `deploy:restart`, which is
probably what's expected in most cases.
2019-11-17 22:55:42 +01:00
Javi Martín
69b4740ec8 Remove redundant cleanup task
Capistrano automatically runs `deploy:cleanup` after finishing.
2019-11-17 22:55:27 +01:00
Javi Martín
dd07a863cb Allow restarting puma with rails restart
So now the way to restart the application does not depend on whether we
use puma or passenger.

What this plugin actually does is restarting puma when we touch the
`tmp/restart.txt` file, which is what `rails restart` does.
2019-11-17 22:55:27 +01:00
Javi Martín
b0f9287000 Restart the application on every reboot
This way we don't have to start it manually every time the server is
restarted.

Note if we start the application with `bin/rails s start -e production`,
as we'd probably want to do so this task doesn't depend on the server we
use, the application will crash when we restart it because it will be
restarted in the development environment. Maybe this issue will be fixed
in future versions of Rails and/or Puma.

Also note we're passing `2` workers to delayed job, and this number must
be the same number we use for the `delayed_job_workers` variable in
capistrano. I haven't found a way to share this variable between
whenever and capistrano.
2019-11-17 22:55:23 +01:00
Javi Martín
1ff20921d3 Daemonize puma on production
We're already doing this thanks to capistrano3-puma, but it's easy to
forget this option when starting puma manually.
2019-11-17 22:11:47 +01:00
Javier Martín
815a080460 Merge pull request #3857 from consul/rvm_updating
Update Ruby after `deploy:updating`
2019-11-17 22:07:21 +01:00
dependabot-preview[bot]
551a2fe4e4 [Security] Bump nokogiri from 1.10.4 to 1.10.5
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.4 to 1.10.5. **This update includes a security fix.**
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.4...v1.10.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-17 20:43:00 +00:00
Javi Martín
6b5d25b28e Update Ruby after deploy:updating
We need to download the most recent CONSUL and check its `.ruby-version`
file before installing Ruby.

The `rvm1-capistrano` gem knows it and was invoking the `updating` task
before installing Ruby. So we were getting a warning in Capistrano about
the `updating` task being executed twice.
2019-11-17 17:17:17 +01:00
Julian Nicolas Herrero
81cf1635bb Merge pull request #3808 from consul/chromedriver_upgrade
Update chromeOptions for newer versions of chromedriver
2019-11-14 20:05:09 +07:00
Javier Martín
6c80da71ad Merge pull request #3853 from consul/fix_first_deployment
Fix secrets task on first deployments
2019-11-14 13:32:32 +01:00
Javier Martín
8ead74c59b Merge pull request #3850 from consul/puma_rb
Add puma configuration to version control
2019-11-14 13:31:11 +01:00
Julian Herrero
cb3a1f2860 Update chromeOptions for newer versions of chromedriver 2019-11-14 11:58:39 +07:00
Javi Martín
0c33c4061d Fix secrets task on first deployments
New CONSUL instances who didn't use the newest installer and haven't
done any deployments with capistrano would get an exception because the
`current` capistrano folder doesn't exist yet.
2019-11-14 00:15:19 +01:00
Javier Martín
70cc7dee73 Merge pull request #3851 from consul/security
Reduce false positives count in security reports
2019-11-13 20:15:18 +01:00
Javi Martín
a76ed31a94 Remove unneeded scope
In this case using `joins` doesn't prevent N+1 queries to get titles for
every record, and since we cannot order translations with just SQL due
to fallbacks, we don't need it.

Automatic SQL injection checks were showing a false positive in this
scope; there was no real vulnerability here because foreign keys, table
names and locales were under our control.
2019-11-13 19:52:15 +01:00
Javi Martín
e470ea1cc1 Avoid JavaScript execution in banner URLs
Using `sanitize` we make sure the `href` attribute does not execute any
dangerous code. The possibility of a banner pointing to a dangerous URL
was very reduced, though, since only administrators can edit this
attribute.
2019-11-13 19:52:15 +01:00
Javi Martín
6cb3047da2 Reuse partial to render a banner 2019-11-13 19:52:15 +01:00
Javi Martín
55d339572c Simplify setting tsvector values
We make the code easier to read and at the same time we remove a SQL
injection false positive regarding the use of `WHERE id = #{id}`.

We still get a warning about SQL injection regarding the `tsv =` part.
It's a false positive, since the value of that parameter does not
depend on user input.
2019-11-13 19:52:15 +01:00
Javi Martín
1e32455cd9 Add puma configuration to version control
We were using Capistrano's shared folder because it was the default
folder used by the capistrano-puma gem. However, it's easier to manage
it if it's under version control.

So we're moving the old `puma.rb` to `puma/development.rb`, and we use
the new `puma.rb` file for all environments except development. Anyone
installing CONSUL can change these files at will or change the specific
files for preproduction, production and staging environments.
2019-11-13 13:28:27 +01:00
Javi Martín
d746401862 Avoid a format validation security warning
This was actually a false positive, since our new regular expression
does the exact same thing. However, false positives generate noise and
make it harder to deal with real issues, so I'm changing it anyway.

We could add a more advanced regular expression, like
`URI::MailTo::EMAIL_REGEXP`. However, this expression marks emails with
non-English characters as invalid, when in practice it's possible to
have an email address with non-English characters.
2019-11-13 01:50:08 +01:00
Javi Martín
58157beb01 Add CSRF protection to management controllers 2019-11-13 01:33:56 +01:00
Javi Martín
0e7c3b4cc0 Remove redundant method to set order
It was being incorrectly detected as used in a dangerous send. We can
get rid of the warning by taking advantage of the `has_orders` method
and getting rid of this code.
2019-11-13 01:33:06 +01:00
João Lutz
f4ae9725c6 Allow create legislation proposals on process draft phase (Merge #3532) 2019-11-13 01:23:59 +01:00
Javi Martín
82e96edf1f Remove duplication in deploy environment files
Deploy environment files were loaded after config/deploy.rb was loaded,
meaning if we used settings like `deploy_to` or `current_path` to set
variables inside the config/deploy.rb file, we'd be using the default
settings instead of the ones dictated by the deploy environment files.
2019-11-12 20:20:45 +01:00
Javi Martín
1f4f70b4a9 Remove redundant stage settings
These files are only loaded when the stage already has the value set
inside them, so we don't need to set it again.

On the other hand, the `rails_env` setting is configured in the
`config/deploy.rb` file.
2019-11-12 20:20:45 +01:00