Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2034
Status: Errored
Duration: 35 minutes and 18 seconds
Commit: 873f5e6 (master)
Author: Fabian Neundorf
Message: [FIX] APISite: Blocked IPv6 usernames in uppercase
The usernames of anonymous users with an IPv6 address are saved with the
letters uppercased. So when querying using such usernames (via bkusers)
those need to be uppercased.
Unfortunately it's possible to fake IPv6 addresses using '::' and those
might have not uppercase letters so it's not uppercasing them.
Change-Id: Iddfb2823cdfae16caa182ba7874beb5a08dd997b
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/ee7548cb7d75...873f5e6c…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/53535568
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] APISite: Blocked IPv6 usernames in uppercase
......................................................................
[FIX] APISite: Blocked IPv6 usernames in uppercase
The usernames of anonymous users with an IPv6 address are saved with the
letters uppercased. So when querying using such usernames (via bkusers)
those need to be uppercased.
Unfortunately it's possible to fake IPv6 addresses using '::' and those
might have not uppercase letters so it's not uppercasing them.
Change-Id: Iddfb2823cdfae16caa182ba7874beb5a08dd997b
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 87cd7f1..9490b07 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -34,6 +34,7 @@
deprecated, deprecate_arg, deprecated_args, remove_last_args,
redirect_func, manage_wrapping, MediaWikiVersion, normalize_username,
)
+from pywikibot.tools.ip import is_IP
from pywikibot.throttle import Throttle
from pywikibot.data import api
from pywikibot.exceptions import (
@@ -3577,6 +3578,12 @@
if blockids:
bkgen.request["bkids"] = blockids
if users:
+ if isinstance(users, basestring):
+ users = users.split('|')
+ # actual IPv6 addresses (anonymous users) are uppercase, but they
+ # have never a :: in the username (so those are registered users)
+ users = [user.upper() if is_IP(user) and '::' not in user else user
+ for user in users]
bkgen.request["bkusers"] = users
return bkgen
--
To view, visit https://gerrit.wikimedia.org/r/195085
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iddfb2823cdfae16caa182ba7874beb5a08dd997b
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [i18n] localize comma and semicolon separator
......................................................................
[i18n] localize comma and semicolon separator
- use mediawiki_message() for to localize comma and semicolon
separators
- use Page.title(asLink=True) for formatting
- join generators if possible
- remove old /dev/null setting
- dont re-use variable 'cat' in category.py loop
Change-Id: I96d9f784e0a7880ce4931b9450b2a0d397a1332d
---
M scripts/archivebot.py
M scripts/category.py
M scripts/interwiki.py
M scripts/replace.py
4 files changed, 36 insertions(+), 37 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 6563a83..021ac22 100644
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -428,8 +428,8 @@
def attr2text(self):
return '{{%s\n%s\n}}' \
% (self.tpl.title(withNamespace=(self.tpl.namespace() != 10)),
- '\n'.join(['|%s = %s' % (a, self.get_attr(a))
- for a in self.saveables()]))
+ '\n'.join('|%s = %s' % (a, self.get_attr(a))
+ for a in self.saveables()))
def key_ok(self):
s = md5()
@@ -455,7 +455,7 @@
If it doesn't exist yet, create it.
If archive name is an empty string (or None),
- discard the thread (/dev/null).
+ discard the thread.
Also checks for security violations.
"""
@@ -544,12 +544,11 @@
return
self.page.header = rx.sub(self.attr2text(), self.page.header)
self.comment_params['count'] = self.archived_threads
+ comma = self.site.mediawiki_message('comma-separator')
self.comment_params['archives'] \
- = ', '.join(['[[' + a.title() + ']]'
- for a in self.archives.values()])
- if not self.comment_params['archives']:
- self.comment_params['archives'] = '/dev/null'
- self.comment_params['why'] = ', '.join(whys)
+ = comma.join(a.title(asLink=True)
+ for a in self.archives.values())
+ self.comment_params['why'] = comma.join(whys)
comment = i18n.twntranslate(self.site.code,
'archivebot-page-summary',
self.comment_params)
diff --git a/scripts/category.py b/scripts/category.py
index 1db584f..b1f51a5 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -630,10 +630,10 @@
# Some preparing
pywikibot.output('Moving text from %s to %s.' % (
self.oldcat.title(), self.newcat.title()))
- authors = ', '.join(self.oldcat.contributingUsers())
+ comma = self.site.mediawiki_message('comma-separator')
+ authors = comma.join(self.oldcat.contributingUsers())
template_vars = (self.oldcat.title(), authors)
- comment = i18n.twtranslate(self.site,
- 'category-renamed') % template_vars
+ comment = i18n.twtranslate(self.site, 'category-renamed', template_vars)
self.newcat.text = self.oldcat.text
# Replace stuff
REGEX = r"<!--BEGIN CFD TEMPLATE-->.*?<!--END CFD TEMPLATE-->"
@@ -995,19 +995,19 @@
if currentDepth < self.maxDepth // 2:
# noisy dots
pywikibot.output('.', newline=False)
- # Find out which other cats are supercats of the current cat
- supercat_names = []
- for cat in self.catDB.getSupercats(cat):
- # create a list of wiki links to the supercategories
- if cat != parent:
- supercat_names.append(cat.title(asLink=True,
- textlink=True,
- withNamespace=False))
+ # Create a list of other cats which are supercats of the current cat
+ supercat_names = [super_cat.title(asLink=True,
+ textlink=True,
+ withNamespace=False)
+ for super_cat in self.catDB.getSupercats(cat)
+ if super_cat != parent]
+
if supercat_names:
# print this list, separated with commas, using translations
- # given in also_in_cats
+ # given in 'category-also-in'
+ comma = self.site.mediawiki_message('comma-separator')
result += ' ' + i18n.twtranslate(self.site, 'category-also-in',
- {'alsocat': ', '.join(
+ {'alsocat': comma.join(
supercat_names)})
del supercat_names
result += '\n'
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index becd5de..41b4a67 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2397,21 +2397,20 @@
useFrom = False
if adding or removing or modifying:
- # Version info marks bots without unicode error
- # This also prevents abuse filter blocking on de-wiki
-
- # if not pywikibot.unicode_error:
- # mcomment += u'r%s) (' % sys.version.split()[0]
-
mcomment += globalvar.summary
+ comma = insite.mediawiki_message('comma-separator')
- changes = {'adding': ', '.join([fmt(new, x) for x in adding]),
- 'removing': ', '.join([fmt(old, x) for x in removing]),
- 'modifying': ', '.join([fmt(new, x) for x in modifying]),
+ changes = {'adding': comma.join(fmt(new, x) for x in adding),
+ 'removing': comma.join(fmt(old, x) for x in removing),
+ 'modifying': comma.join(fmt(new, x) for x in modifying),
'from': u'' if not useFrom else old[modifying[0]]}
+ en_changes = {'adding': ', '.join(fmt(new, x) for x in adding),
+ 'removing': ', '.join(fmt(old, x) for x in removing),
+ 'modifying': ', '.join(fmt(new, x) for x in modifying),
+ 'from': u'' if not useFrom else old[modifying[0]]}
- mcomment += i18n.twtranslate(insite.lang, commentname) % changes
- mods = i18n.twtranslate('en', commentname) % changes
+ mcomment += i18n.twtranslate(insite.lang, commentname, changes)
+ mods = i18n.twtranslate('en', commentname, en_changes)
return mods, mcomment, adding, removing, modifying
diff --git a/scripts/replace.py b/scripts/replace.py
index cbc9a43..efbb9c6 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -517,15 +517,16 @@
if self.summary:
summary_messages.insert(0, self.summary)
else:
- default_summary = ', '.join(
+ comma = self.site.mediawiki_message('comma-separator')
+ default_summary = comma.join(
u'-{0} +{1}'.format(*default_summary)
for default_summary in default_summaries)
summary_messages.insert(0, i18n.twtranslate(
- pywikibot.Site(), 'replace-replacing',
- {'description':
- u' ({0})'.format(default_summary)}
+ self.site, 'replace-replacing',
+ {'description': u' ({0})'.format(default_summary)}
))
- return u'; '.join(summary_messages)
+ semicolon = self.site.mediawiki_message('semicolon-separator')
+ return semicolon.join(summary_messages)
def run(self):
"""Start the bot."""
--
To view, visit https://gerrit.wikimedia.org/r/191958
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I96d9f784e0a7880ce4931b9450b2a0d397a1332d
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: introducing new config variable: private_files_permission
......................................................................
introducing new config variable: private_files_permission
Change-Id: I8b4d560a5c0ce17056a3edb1a340a1369100af8e
---
M generate_user_files.py
M pywikibot/config2.py
M pywikibot/login.py
3 files changed, 46 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index c98c535..825f948 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -79,7 +79,7 @@
break
else:
try:
- os.mkdir(new_base, 0o700)
+ os.mkdir(new_base, pywikibot.config2.private_files_permission)
except Exception:
pywikibot.error("ERROR: directory creation failed")
continue
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 3792be5..0343338 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -24,6 +24,7 @@
import collections
import os
+import stat
import sys
from warnings import warn
@@ -37,7 +38,7 @@
# Please keep _imported_modules in sync with the imports above
-_imported_modules = ('os', 'sys', 'collections')
+_imported_modules = ('collections', 'os', 'stat', 'sys')
# IMPORTANT:
# Do not change any of the variables in this file. Instead, make
@@ -151,6 +152,27 @@
# relevant summary for bot edits
default_edit_summary = u'Pywikibot v.2'
+# What permissions to use to set private files to it
+# such as password file.
+#
+# stat.S_IRWXU 0o700 mask for owner permissions
+# stat.S_IRUSR 0o400 read permission for owner
+# stat.S_IWUSR 0o200 write permission for owner
+# stat.S_IXUSR 0o100 execute permission for owner
+# stat.S_IRWXG 0o070 mask for group permissions
+# stat.S_IRGRP 0o040 read permission for group
+# stat.S_IWGRP 0o020 write permission for group
+# stat.S_IXGRP 0o010 execute permission for group
+# stat.S_IRWXO 0o007 mask for others permissions
+# stat.S_IROTH 0o004 read permission for others
+# stat.S_IWOTH 0o002 write permission for others
+# stat.S_IXOTH 0o001 execute permission for others
+private_files_permission = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
+
+# Allow user to stop warnings about file security
+# by setting this to true.
+ignore_file_security_warnings = False
+
def get_base_dir(test_directory=None):
r"""Return the directory in which user-specific information is stored.
@@ -226,7 +248,7 @@
for dir in base_dir_cand:
dir = os.path.join(*dir)
if not os.path.isdir(dir):
- os.makedirs(dir, mode=0o700)
+ os.makedirs(dir, mode=private_files_permission)
if exists(dir):
base_dir = dir
break
@@ -916,6 +938,17 @@
"Defaulting to family='test' and mylang='test'.")
family = mylang = 'test'
+# SECURITY WARNINGS
+if (not ignore_file_security_warnings and
+ private_files_permission & (stat.S_IRWXG | stat.S_IRWXO) != 0):
+ print("CRITICAL SECURITY WARNING: 'private_files_permission' is set"
+ " to allow access from the group/others which"
+ " could give them access to the sensitive files."
+ " To avoid giving others access to sensitive files, pywikibot"
+ " won't run with this setting. Choose a more restrictive"
+ " permission or set 'ignore_file_security_warnings' to true.")
+ sys.exit(1)
+
#
# When called as main program, list all configuration variables
#
diff --git a/pywikibot/login.py b/pywikibot/login.py
index b2ace77..dff941b 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -10,6 +10,9 @@
__version__ = '$Id$'
#
import codecs
+import os
+import stat
+
from warnings import warn
import pywikibot
@@ -174,6 +177,13 @@
(u"wikipedia", u"my_wikipedia_user", u"my_wikipedia_pass")
(u"en", u"wikipedia", u"my_en_wikipedia_user", u"my_en_wikipedia_pass")
"""
+ # We fix password file permission first,
+ # lift upper permission (regular file) from st_mode
+ # to compare it with private_files_permission.
+ if os.stat(config.password_file).st_mode - stat.S_IFREG \
+ != config.private_files_permission:
+ os.chmod(config.password_file, config.private_files_permission)
+
password_f = codecs.open(config.password_file, encoding='utf-8')
for line in password_f:
if not line.strip():
--
To view, visit https://gerrit.wikimedia.org/r/192253
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8b4d560a5c0ce17056a3edb1a340a1369100af8e
Gerrit-PatchSet: 10
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mjbmr <mjbmri(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mjbmr <mjbmri(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>