Title: [249884] trunk/Tools
- Revision
- 249884
- Author
- [email protected]
- Date
- 2019-09-15 07:14:59 -0700 (Sun, 15 Sep 2019)
Log Message
block-spammers should obtain credentials the same way as webkit-patch
<https://webkit.org/b/201733>
Reviewed by Lucas Forschler.
* Scripts/block-spammers: Import Credentials from webkitpy.
Remove unused imports. Enable logging at info level to match
webkit-patch.
(get_bugzilla_token): Use Credentials module to get
bugs.webkit.org credentials.
* Scripts/webkitpy/common/net/credentials.py:
(Credentials._run_security_tool): Change logging level from
error to info since multiple attempts are made at reading the
keychain. Fix typos in comment.
(Credentials._credentials_from_security_command): Extract common
logic from Credentials._credentials_from_keychain into new
method.
(Credentials._credentials_from_keychain): Make fallback logic
for checking for credentials in the keychain more consistent and
easier to read. Add error logging if no credentials are found.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (249883 => 249884)
--- trunk/Tools/ChangeLog 2019-09-15 13:30:01 UTC (rev 249883)
+++ trunk/Tools/ChangeLog 2019-09-15 14:14:59 UTC (rev 249884)
@@ -1,3 +1,26 @@
+2019-09-15 David Kilzer <[email protected]>
+
+ block-spammers should obtain credentials the same way as webkit-patch
+ <https://webkit.org/b/201733>
+
+ Reviewed by Lucas Forschler.
+
+ * Scripts/block-spammers: Import Credentials from webkitpy.
+ Remove unused imports. Enable logging at info level to match
+ webkit-patch.
+ (get_bugzilla_token): Use Credentials module to get
+ bugs.webkit.org credentials.
+ * Scripts/webkitpy/common/net/credentials.py:
+ (Credentials._run_security_tool): Change logging level from
+ error to info since multiple attempts are made at reading the
+ keychain. Fix typos in comment.
+ (Credentials._credentials_from_security_command): Extract common
+ logic from Credentials._credentials_from_keychain into new
+ method.
+ (Credentials._credentials_from_keychain): Make fallback logic
+ for checking for credentials in the keychain more consistent and
+ easier to read. Add error logging if no credentials are found.
+
2019-09-13 Youenn Fablet <[email protected]>
WPT importer should check META global tag in .any.js files to generate the valid .html stub files
Modified: trunk/Tools/Scripts/block-spammers (249883 => 249884)
--- trunk/Tools/Scripts/block-spammers 2019-09-15 13:30:01 UTC (rev 249883)
+++ trunk/Tools/Scripts/block-spammers 2019-09-15 14:14:59 UTC (rev 249884)
@@ -28,28 +28,22 @@
import argparse
import atexit
-import re
+import logging
import requests
-import subprocess
+import os
import sys
from dateutil.parser import parse
+from webkitpy.common.net.credentials import Credentials
+_log = logging.getLogger(os.path.basename(__file__))
+logging.basicConfig(level=logging.INFO, format='%(message)s')
+
bugzilla_self_user_id = None
bugzilla_token = None
def get_bugzilla_token():
- security = subprocess.Popen(['/usr/bin/security', 'find-internet-password', '-gs', 'bugs.webkit.org'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- security.wait()
- if security.returncode:
- raise Exception('Could not get bugs.webkit.org credentials from Keychain, exit code ' + str(security.returncode))
- for line in security.stdout:
- m = re.search('^ "acct"<blob>="(.+)"$', line)
- if m:
- account = m.group(1)
- continue
- m = re.search('^password: "(.+)"$', line)
- if m:
- password = m.group(1)
+ credentials = Credentials('bugs.webkit.org', git_prefix='bugzilla')
+ account, password = credentials.read_credentials(use_stored_credentials=True)
if not account or not password:
raise Exception('Could not parse security tool output to get bugs.webkit.org credentials')
Modified: trunk/Tools/Scripts/webkitpy/common/net/credentials.py (249883 => 249884)
--- trunk/Tools/Scripts/webkitpy/common/net/credentials.py 2019-09-15 13:30:01 UTC (rev 249883)
+++ trunk/Tools/Scripts/webkitpy/common/net/credentials.py 2019-09-15 14:14:59 UTC (rev 249884)
@@ -99,26 +99,30 @@
try:
return self.executive.run_command(security_command)
except ScriptError:
- # Failed to either find a keychain entry or somekind of OS-related
- # error occured (for instance, couldn't find the /usr/sbin/security
+ # Failed to either find a keychain entry or some kind of OS-related
+ # error occurred (for instance, couldn't find the /usr/sbin/security
# command).
- _log.error("Could not find a keychain entry for %s." % self.host)
+ _log.info('Could not find a keychain entry for {} using {}.'.format(self.host, command))
return None
- def _credentials_from_keychain(self, username=None):
- if not self._is_mac_os_x():
- return [username, None]
-
- security_output = self._run_security_tool("find-internet-password", username)
+ def _credentials_from_security_command(self, command, username):
+ security_output = self._run_security_tool(command, username)
if security_output:
parsed_output = self._parse_security_tool_output(security_output)
if any(parsed_output):
return parsed_output
- security_output = self._run_security_tool("find-generic-password", username)
- if security_output:
- return self._parse_security_tool_output(security_output)
return [None, None]
+ def _credentials_from_keychain(self, username=None):
+ if not self._is_mac_os_x():
+ return [username, None]
+ credentials = self._credentials_from_security_command('find-internet-password', username)
+ if not any(credentials):
+ credentials = self._credentials_from_security_command('find-generic-password', username)
+ if not any(credentials):
+ _log.error('Could not find a keychain entry for {}.'.format(self.host))
+ return credentials
+
def _read_environ(self, key):
environ_key = self._environ_prefix + key
return os.environ.get(environ_key.upper())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes