Title: [295612] trunk/Tools/Scripts/libraries
Revision
295612
Author
jbed...@apple.com
Date
2022-06-16 13:45:19 -0700 (Thu, 16 Jun 2022)

Log Message

[webkitcorepy] Validate cached credentials
https://bugs.webkit.org/show_bug.cgi?id=241664
<rdar://problem/95254368>

Reviewed by Aakash Jain.

* Tools/Scripts/libraries/webkitbugspy/setup.py: Bumpv version.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py: Add user endpoint.
* Tools/Scripts/libraries/webkitcorepy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/credentials.py:
(credentials): Validate cached credentials, do not reload credentials which fail validation
from the keychain.

Canonical link: https://commits.webkit.org/251617@main

Modified Paths

Diff

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/setup.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitbugspy/setup.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/setup.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -30,7 +30,7 @@
 
 setup(
     name='webkitbugspy',
-    version='0.6.3',
+    version='0.6.4',
     description='Library containing a shared API for various bug trackers.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 6, 3)
+version = Version(0, 6, 4)
 
 from .user import User
 from .issue import Issue

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -285,6 +285,13 @@
         if match and method == 'GET':
             return self._user(url, match.group('username'))
 
+        match = re.match(r'{}/user$'.format(self.hosts[1]), stripped_url)
+        if match and method == 'GET':
+            user = self.users.get(auth.username) if auth else None
+            if not user:
+                return mocks.Response.create404(url=""
+            return self._user(url, user.username)
+
         match = re.match(r'{}/issues/(?P<id>\d+)$'.format(self.api_remote), stripped_url)
         if match and method in ('GET', 'PATCH'):
             return self._issue(url, int(match.group('id')), data="" if method == 'PATCH' else None)

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/setup.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitcorepy/setup.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/setup.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -30,7 +30,7 @@
 
 setup(
     name='webkitcorepy',
-    version='0.13.8',
+    version='0.13.9',
     description='Library containing various Python support classes and functions.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -44,7 +44,7 @@
 from webkitcorepy.editor import Editor
 from webkitcorepy.file_lock import FileLock
 
-version = Version(0, 13, 8)
+version = Version(0, 13, 9)
 
 from webkitcorepy.autoinstall import Package, AutoInstall
 if sys.version_info > (3, 0):

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/credentials.py (295611 => 295612)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/credentials.py	2022-06-16 20:41:38 UTC (rev 295611)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/credentials.py	2022-06-16 20:45:19 UTC (rev 295612)
@@ -32,10 +32,18 @@
 def credentials(url, required=True, name=None, prompt=None, key_name='password', validater=None, validate_existing_credentials=False, retry=3, save_in_keyring=None):
     global _cache
 
+    ignore_entry = False
     name = name or url.split('/')[2].replace('.', '_')
     if _cache.get(name):
-        return _cache.get(name)
+        if not validate_existing_credentials:
+            return _cache[name]
+        elif validater and validater(*_cache.get(name)):
+            return _cache[name]
 
+        # If we've failed the validation check, invalidate cache and ignore the current keychain entry
+        del _cache[name]
+        ignore_entry = True
+
     username = Environment.instance().get('{}_USERNAME'.format(name.upper()))
     key = Environment.instance().get('{}_{}'.format(name.upper(), key_name.upper()))
 
@@ -53,6 +61,8 @@
     key_prompted = False
 
     for attempt in range(retry):
+        if not attempt and ignore_entry:
+            continue
         if attempt:
             sys.stderr.write('Ignoring keychain values and re-prompting user\n')
         if not username:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to