79 Commits

Author SHA1 Message Date
Tom Fifield
dca11a634c Add a conservative page creation rate limit
This patch limits users who are not in the known-good users
list ('autopatrol') to creating 5 pages per day.

The vast majority of our spam comes from the creation of new
pages. This patch will limit the usefulness of each spammer
account, by limiting the number of pages each can create.

By setting the number at 5 initially, it is not expected to
have an impact on legitimate new users playing with the wiki
for the first time. Neither will it have an impact for many spam
accounts, but at least it provides and upper limit for cleanup.

Relevant references:
* Rate limts https://www.mediawiki.org/wiki/Manual:$wgRateLimits
* User rights https://www.mediawiki.org/wiki/Manual:User_rights

Change-Id: Iabe785fedb121a32d8adac5a490d9b5b9f40219f
2016-11-20 14:44:14 +00:00
Tom Fifield
d7dc1746d6 Restrict File Uploads, Page Moves to Known Users
Since https://review.openstack.org/#/c/368114/
introduced the 'autopatrol' group, a team has been proactively
verifying and adding known-good users to the group as edits are
made.

The group currently contains almost 300 members, and most non-spam
edits made on the wiki today are made by users with membership of
this group.

To date, group membership allowed bypassing the CAPTCHA for edits.
This patch proposes 3 additional, low impact, changes to further
help with our ongoing spam problem.

1) Restrict File Uploads to members of the autopatrol group

Non-Spam file uploads on the OpenStack wiki are relatively rare,
particularly for new users, and anyone who has uploaded a file in the
past is already covered by the autopatrol group.
Restricting this ability to verified users would completely remove
a major spam avenue from the current attack.

2) Restrict Page Moves to members of the autopatrol group

Page moves tend to only be conducted by very experienced users of
the OpenStack wiki, who have all been around a long time and are
members of the autopatrol group. They are also very rare outside of
spam situations.

In spam situations, page moves make clean-up doubly difficult and
allow spammers to work around new page creation restrictions.
Restricting this ability assists somewhat with the spam attack

3) Restrict Write API access to members of the autopatrol group
Author is unaware of anyone in the OpenStack community using the
MediaWiki write API, however the fact that it is open for all users
seems to make it a very tempting attack avenue for spammers.

Change-Id: I8a59e2a0d0fcddc0f2774a8a704c1ac57003d6a8
2016-11-08 01:04:56 +08:00
Jeremy Stanley
3b55a5b98d Allow sufficient access to serve image files
Add a grant for all clients to read files from the images directory.
Without this, all requests for images are denied.

Change-Id: I50817ce3170453b6522e01ad3e1a3d503f59f9fb
2016-09-10 17:45:13 +00:00
Jeremy Stanley
35f57bcb4f Make robots.txt reachable
If disallow_robots is enabled, make sure we not only install and
alias the robots.txt file but also grant permission to read it and
omit it from our general article URL rewrites.

Change-Id: I9532dd8fd18010aaad388e8fdcbc3051fc653234
2016-09-10 14:37:29 +00:00
Tom Fifield
f5a6ac32a7 Skip CAPTCHA for autopatrol users
autopatrol users have been human-verified to be legit.
Therefore, they don't need to go through the pain of CAPTCHA

This patch adds the necessary permissions.

Change-Id: I501eae00f471ee13525073d39c8e51a7ccb67fdc
2016-09-10 13:39:41 +00:00
Jeremy Stanley
d79c672d41 Support disallowing robots
Add a disallow_robots parameter which can be used to disallow
indexing of all site content by robots. This is particularly useful
for test deployments where you don't want extra (often stale) copies
of your content to show up in search engines.

Change-Id: Ic62a72555315bd344db338809920a3605f17c8c6
2016-09-07 20:45:25 +00:00
Jeremy Stanley
43b131e06d Conditionally define the default extension source
Since $type and $source are both class parameters, we can't
interpolate $type in the default definition for $source. Instead
redefine $source inside the resource if it's unchanged from the
resource default.

Also make the contents of /src/mediawiki/w require the vcsrepo
resource for it. Early creation of the directory causes vcsrepo to
fail to clone into it.

Change-Id: I9b447173d4966f03a195825047cf25afc1a4afd6
2016-09-07 19:29:00 +00:00
Jeremy Stanley
ea9b6df992 Clean up OpenStack references and genericize
To make this module more downstream-friendly, abstract out any
references to OpenStack and turn them into classvars.

Change-Id: Ie005d5629623a14f4ebd8aef21294f222249232f
2016-08-24 18:18:20 +00:00
Jeremy Stanley
0af7e6addd Clean up old recaptcha parameters
Now that the openstack_project::wiki class no longer sets the old,
unused recaptcha parameters, remove them from the module.

Change-Id: I468b4936582701cf308be269bfc06801276efd18
Depends-On: I9f9ba63399a8885e3694cef37ec987f223ff6dca
2016-08-23 18:23:26 +00:00
Jeremy Stanley
28767a5486 Switch from old recaptcha to recaptcha-nocaptcha
The newer recaptcha-nocaptcha implementation is a little better at
thwarting script-driven spammers and vandals, so switch to it. Leave
the parameter names for the old recaptcha implementation in place
until our consumer in the openstack_project::wiki class no longer
attempts to set it.

Change-Id: I435484cd65a028d774dfd920ca19f3077d4e03fb
2016-08-23 18:23:26 +00:00
Jeremy Stanley
e91131f664 Parameterize database connection settings
So that we can have non-local (e.g., Trove based) databases, and for
general downstream flexibility, allow the database server hostname,
database name and database username to be passed into this module by
the caller.

Change-Id: I26a03e2ce9a6bf8bcd6acbad9e8eaaa98e0f26ab
2016-08-23 18:23:21 +00:00
Jeremy Stanley
c4044a9766 Update scope.lookupvar() calls to shorter @ lookup
Consistent with the vhost template, in Settings.php.erb use the
shorter @ lookups rather than calling the scope.lookupvar()
function.

Change-Id: Ic03dbb55e4931d334a2cf5d4fae6a07cf53dd807
2016-08-23 18:21:18 +00:00
Jeremy Stanley
4cbe39375c Standardize HTTPS and vhost configuration
Adjust the SSL/TLS X.509 file handling to match our flexible
standard, which allows the deployer to choose between managing the
contents in or outside Puppet while still providing for a sane
snakeoil fallback to ease testing and development. Also tune the SSL
configuration to our typical stricter defaults, unconditionally
redirect all HTTP requests to HTTPS, and reformat the vhost
configuration for consistency and ease of future maintenance.

Change-Id: Id5241377665845f8c453cbb833bc40d3a5915d76
2016-08-22 23:21:51 +00:00
Jeremy Stanley
670312c04a Drop Ubuntu Precise compatibility
Since we've already manually upgraded production to Ubuntu Trusty,
let's start with a clean slate for now and just target latest
Mediawiki on a fresh Trusty deployment. This simplifies or removes
some of the conditional logic in this module.

Change-Id: Ia8e74c85667719178c2f50b1458a9719582e8502
2016-08-20 00:36:23 +00:00
Jenkins
742d9c09a9 Merge "Ensure cache directory is owned by the right user/group" 2016-08-19 17:53:59 +00:00
Jenkins
08b779ae7f Merge "Also require php5-memcached" 2016-08-19 17:41:12 +00:00
Jenkins
c36606bd78 Merge "image_scaler: Partially separate packages for Trusty" 2016-08-19 17:39:09 +00:00
Jenkins
fc55c69401 Merge "Puppetise extension repositories" 2016-08-19 07:55:59 +00:00
Jenkins
f7fc800421 Merge "Stick to REL1_27 on Trusty, not master" 2016-08-19 03:38:51 +00:00
Jenkins
bbf120e47e Merge "Also clone the vendor repository for newer MW versions" 2016-08-19 03:24:56 +00:00
Jenkins
864955904c Merge "Puppetise LocalSettings.php -> ../Settings.php symlink" 2016-08-19 02:37:08 +00:00
Jenkins
53885449ef Merge "Add 'autopatrol' group" 2016-08-19 02:00:12 +00:00
Tom Fifield
a03b466574 Add 'autopatrol' group
Patrolled Edits is a feature on mediawiki that allows marking edits as
"known good" (i.e. ham, as opposed to spam). This can be used to
list edits that have not been assessed, which makes spam easier to
identify and deal with.

Automatic patrolling is where this happens without human intervention.
In our version of mediawiki, there is the ability to have defined users
whose edits are automatically marked as 'patrolled'.

This patch makes a new group, so that bureaucrats of the wiki can
assign "known good" users to this group. The group is given the permission
of 'autopatrol', which means users added to this group will have their
edits automatically marked as 'patrolled'.

Further information about this feature and how to verify the syntax for
this patch is available at:
https://www.mediawiki.org/wiki/Help:Patrolled_edits
https://www.mediawiki.org/wiki/Manual:User_rights

Change-Id: I798f3909bc95fb28c3a0f704fb89a490e10b015f
2016-08-18 08:42:32 +08:00
Alex Monk
caf009dc7a Ensure cache directory is owned by the right user/group
Change-Id: I72ac640b70675561ef32f906b47f6d900e76a028
2016-08-10 18:45:13 +01:00
Alex Monk
c35e4acdd2 Also require php5-memcached
Otherwise you get errors about the Memcache class being missing

Change-Id: I4a326a29a1c227442deb6571b0c383120e203488
2016-08-10 18:45:13 +01:00
Alex Monk
42f92653f7 image_scaler: Partially separate packages for Trusty
Change-Id: I95fa1ce6ccb1396a9e6420b89df64ca298fc6d2d
2016-08-10 18:45:13 +01:00
Alex Monk
bde91940c6 Puppetise extension repositories
Most of this list is based on the require/include lines in the
Settings.php.erb template.

Change-Id: Ic4f0a6b810aef1b121fb595fb9f9b67a9e5af485
2016-08-10 18:45:13 +01:00
Alex Monk
6f874ca228 Stick to REL1_27 on Trusty, not master
Change-Id: I76120a31c50da2a058b885a3b1027a5565c46a23
2016-08-10 18:45:13 +01:00
Alex Monk
cfd8d4fdd7 Also clone the vendor repository for newer MW versions
Change-Id: I9805f36daca86cfa0ae1073a51418a6e7b418525
2016-08-10 18:45:13 +01:00
Alex Monk
db94513b69 Puppetise LocalSettings.php -> ../Settings.php symlink
Change-Id: Ida5d01f7bc33e122f69bf8d9a2e6f8b45ace695a
2016-08-10 18:44:49 +01:00
Alex Monk
d63b5653f9 apache: Don't just send 403s on Apache 2.4
Change-Id: I3be37aadf7e33aa84d289beba6445a80c870d21f
2016-08-06 18:02:03 +00:00
JP Maxwell
4b020efa66 Disable Uploads to Prevent Spam
Disabled the uploads to prevent spam as they
were not being guarded by the captcha

Change-Id: I1fbbf947c75a51bca865c9a717247ab114951aa5
2016-07-20 18:36:20 -05:00
Jeremy Stanley
9c6b74b2f4 Revert "Prevent new user registrations except by sysops"
Now that we have a more robust captcha implemented for page edits,
let's allow general account creation again.

This reverts commit 3dc0d18a1c51bdea4187dfb066cafa0a6cedd4c8.

Change-Id: Ie68d01980c6a96619878d588ee2b4114d6cc6c7a
2016-07-19 23:04:01 +00:00
Jeremy Stanley
7bb57637af Quote strings in Settings.php
Add quoting to the strings in Settings.php even when substituted
from an ERB variable expansion.

Change-Id: I873cd4ec3050c450620857646d02a2df8e0ba56a
2016-07-19 21:07:05 +00:00
Jeremy Stanley
f821afdf7d Clean up unused questy captcha variable
Once the dependency for this merges to system-config, remove the
unused wg_captchaquestions variable.

Change-Id: If3ac86edc27bda317fe3a29f984dc9a2acd79e31
Depends-On: I0f184c9bfa2bdaaca2478500d8f3b418c9bf77ae
2016-07-15 17:29:12 +00:00
JP Maxwell
d1f42c7518 Setup ReCaptcha in Wiki to Prevent Spam
Modified settings file to remove questy captcha and add recaptcha.
Setup two new variables to hold public and private recaptcha keys
wg_recaptchapublickey and wg_recaptchaprivatekey.

Change-Id: Idfa2c01fb9d31f06643d6c82438c33db1ff33009
2016-07-15 12:12:23 -05:00
Spencer Krum
82f791aa3d Use new infra_spec_helper for gem dependencies
Change-Id: I272dda6f78a9d22750b2204249b130ff663020d5
2016-06-21 18:39:07 -07:00
Spencer Krum
aad918d279 Pin google-api-client; sanitize Gemfile
Change-Id: I4a38c6fbe8286fa654b69e5ea1526d0a7fa82b84
2016-04-14 15:20:57 -07:00
Jenkins
2c9eaad61c Merge "Order of the classes parameters is refactored" 2016-03-23 15:23:31 +00:00
Andrey Nikitin
a52a06b1af Order of the classes parameters is refactored
Order and intendation of those parameters are changed
to follow Puppet Style Guide recommendation [0].
Moreover, it will allow to an user to find much faster
a variable in a list of variables.

[0]. https://docs.puppetlabs.com/guides/style_guide.html

Change-Id: Ifdd5e7de4b4dc9fbd30535720d5674c211985913
2016-03-21 13:19:16 +03:00
Paul Belanger
46398efa09 Set wgOpenIDUseEmailAsNickname True by default
The goal here is to allow mediawiki to create an openid user while
leaving the createaccount permission false.  According to
documentation[1] this settings should do just that.

We want try and keep createaccount set to false, as this will force
users to use openid.

[1] https://www.mediawiki.org/wiki/Extension:OpenID

Change-Id: Id63a33907f326ddc561ec1049dd1766a7319eb9e
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-03-09 22:44:13 +00:00
Paul Belanger
933853e030 Add SmiteSpam extension
The SmiteSpam extension provides a special page "Special:SmiteSpam"
helping administrators identify and delete spam pages.

An infra-root will need to manually download the extension from:
https://www.mediawiki.org/wiki/Extension:SmiteSpam

Change-Id: I018a4c80b77f64353c0163fe8be8dc330b01fc74
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-03-02 09:35:08 -05:00
Jenkins
1e9616d89d Merge "Disable standard password based auth" 2016-02-29 21:36:01 +00:00
Paul Belanger
16d065bb88 Disable PDF uploads by users
In an effort to mitigate spamming, we are limiting the files we support
for uploads.

Change-Id: I391da321853e0df3b547882b8dfd6dccf4afd922
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-29 13:06:22 -05:00
Marton Kiss
1fc30c9e2f Disable standard password based auth
This patch disable the password based auth, so we are enforced to
use openid login only.

Change-Id: I3ffe75b5c7be9c490a51c28f03425f15165553b1
2016-02-29 18:16:29 +01:00
Paul Belanger
3dc0d18a1c Prevent new user registrations except by sysops
Looking at ListGroupRights[1] users created by OpenID have a different
group to control access. So, new users accounts created outside OpenID
will be disabled, but sysadmins can still manually create them (for
our bots).  Everybody else will be forced into OpenID.

[1] https://wiki.openstack.org/wiki/Special:ListGroupRights

Change-Id: I8bb4f0b07c13da75106bfbf725db372ff11dfd09
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-27 12:08:52 -05:00
Paul Belanger
bc1cad4c0d Install Extension:SpamBlacklist
The SpamBlacklist extension prevents edits that contain URLs whose
domains match regular expression patterns defined in specified files
or wiki pages and registration by users using specified email
addresses.

We also need an infra-root to manual download and install the
extension. See below for instructions

https://www.mediawiki.org/wiki/Extension:SpamBlacklist

Change-Id: If752923483c5d7663ed33043f1b799cef2fface0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-26 18:37:05 -05:00
Paul Belanger
4f33ccc959 Be more aggressive with captcha
Lets enable it for all pages, as spamming is still ongoing.

Change-Id: I7085199143ae28194bc77b3994dcfb84915d4e49
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-26 13:30:35 -05:00
Paul Belanger
0b7b88fbd4 Force users to use captcha on create and edit
In an effort to limit our current spam attack on wiki.o.o we'll be
enabling captcha[1] when a user creates / edits a page.

[1] https://www.mediawiki.org/wiki/Extension:QuestyCaptcha

Change-Id: I33129a5084fa3b3c3e792a61c968f76510bf6078
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-25 05:36:41 +00:00
Paul Belanger
ffe475ba99 Allow user to pass a hash of captcha questions
Change-Id: I102ff6991831901c578dab4107b0c23245da9d4b
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-24 23:56:54 +00:00