imbi-plugin-github 2.53.0__tar.gz → 2.54.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/PKG-INFO +2 -2
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/pyproject.toml +2 -2
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/secret_provider.py +34 -2
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_secret_provider.py +49 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/.gitignore +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/README.md +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/moon.yml +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/README.md +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/__init__.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/_app_auth.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/_hosts.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/_repos.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/commits.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/deployment.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/doctor.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/identity.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/lifecycle.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/plugin.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/public.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/pull_requests.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/py.typed +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/__init__.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_app_auth_scopes.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_commits.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_deployment.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_doctor.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_hosts.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_identity.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_lifecycle.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_public.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_pull_requests.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_repos.py +0 -0
- {imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/tests/test_secret_provider_live.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: imbi-plugin-github
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.54.0
|
|
4
4
|
Summary: GitHub identity plugin for Imbi (github.com / GHEC / GHES)
|
|
5
5
|
Author-email: "Gavin M. Roy" <gavinr@aweber.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.14
|
|
13
13
|
Requires-Python: >=3.14
|
|
14
14
|
Requires-Dist: httpx>=0.27
|
|
15
|
-
Requires-Dist: imbi-common[databases]==2.
|
|
15
|
+
Requires-Dist: imbi-common[databases]==2.54.0
|
|
16
16
|
Requires-Dist: pydantic>=2
|
|
17
17
|
Requires-Dist: pyjwt[crypto]>=2.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "imbi-plugin-github"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.54.0"
|
|
4
4
|
description = "GitHub identity plugin for Imbi (github.com / GHEC / GHES)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.14"
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
20
|
"httpx>=0.27",
|
|
21
|
-
"imbi-common[databases]==2.
|
|
21
|
+
"imbi-common[databases]==2.54.0",
|
|
22
22
|
"pydantic>=2",
|
|
23
23
|
"pyjwt[crypto]>=2.8",
|
|
24
24
|
]
|
{imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/secret_provider.py
RENAMED
|
@@ -76,6 +76,18 @@ PURPOSE_PERMISSIONS: dict[str, dict[str, str]] = {
|
|
|
76
76
|
},
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
#: CI read permissions that a purpose adds when the installation grants
|
|
80
|
+
#: them, so an agent can wait for and read checks. Asking for one the
|
|
81
|
+
#: installation lacks would make GitHub refuse the whole token (422).
|
|
82
|
+
PURPOSE_OPTIONAL_PERMISSIONS: dict[str, dict[str, str]] = {
|
|
83
|
+
'github_read': {'checks': 'read', 'statuses': 'read'},
|
|
84
|
+
'github_write': {
|
|
85
|
+
'actions': 'read',
|
|
86
|
+
'checks': 'read',
|
|
87
|
+
'statuses': 'read',
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
|
|
79
91
|
#: The binding test asks for the smallest permission set.
|
|
80
92
|
_TEST_PERMISSIONS = {'metadata': 'read'}
|
|
81
93
|
|
|
@@ -284,6 +296,25 @@ def _options(raw: object) -> dict[str, typing.Any]:
|
|
|
284
296
|
return {}
|
|
285
297
|
|
|
286
298
|
|
|
299
|
+
def _with_granted(
|
|
300
|
+
permissions: dict[str, str],
|
|
301
|
+
optional: dict[str, str],
|
|
302
|
+
installation: dict[str, typing.Any] | None,
|
|
303
|
+
) -> dict[str, str]:
|
|
304
|
+
"""``permissions`` plus each optional one the installation grants."""
|
|
305
|
+
if not optional or installation is None:
|
|
306
|
+
return permissions
|
|
307
|
+
granted = typing.cast(
|
|
308
|
+
dict[str, str], installation.get('permissions') or {}
|
|
309
|
+
)
|
|
310
|
+
extra = {
|
|
311
|
+
name: level
|
|
312
|
+
for name, level in optional.items()
|
|
313
|
+
if name not in permissions and granted.get(name) in (level, 'write')
|
|
314
|
+
}
|
|
315
|
+
return permissions | extra
|
|
316
|
+
|
|
317
|
+
|
|
287
318
|
def _expiry(value: object) -> datetime.datetime:
|
|
288
319
|
if isinstance(value, str):
|
|
289
320
|
try:
|
|
@@ -651,6 +682,7 @@ class GitHubApp(secrets.SecretProvider):
|
|
|
651
682
|
raise secrets.BrokerError(
|
|
652
683
|
'secret_access_denied', 'purpose_not_supported'
|
|
653
684
|
)
|
|
685
|
+
optional = PURPOSE_OPTIONAL_PERMISSIONS.get(context.purpose, {})
|
|
654
686
|
repositories: list[str] = []
|
|
655
687
|
repository_ids: list[int] | None = None
|
|
656
688
|
if context.purpose == 'marketplace_fetch':
|
|
@@ -698,7 +730,7 @@ class GitHubApp(secrets.SecretProvider):
|
|
|
698
730
|
client, repositories, repository_ids
|
|
699
731
|
)
|
|
700
732
|
installation_id = str(installation['id'])
|
|
701
|
-
elif repositories:
|
|
733
|
+
elif repositories or optional:
|
|
702
734
|
installation = await self._installation(
|
|
703
735
|
client, installation_id
|
|
704
736
|
)
|
|
@@ -708,7 +740,7 @@ class GitHubApp(secrets.SecretProvider):
|
|
|
708
740
|
token, expires_at = await self._mint(
|
|
709
741
|
client,
|
|
710
742
|
installation_id,
|
|
711
|
-
permissions,
|
|
743
|
+
_with_granted(permissions, optional, installation),
|
|
712
744
|
names,
|
|
713
745
|
repository_ids,
|
|
714
746
|
)
|
|
@@ -398,6 +398,55 @@ class GitHubAppTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
398
398
|
)
|
|
399
399
|
self.assertEqual(ctx.exception.reason, 'installation_not_found')
|
|
400
400
|
|
|
401
|
+
@respx.mock
|
|
402
|
+
async def test_ci_read_only_when_the_installation_grants_it(
|
|
403
|
+
self,
|
|
404
|
+
) -> None:
|
|
405
|
+
"""CI permissions the installation lacks are never asked for."""
|
|
406
|
+
respx.get(INSTALLATION_URL).mock(
|
|
407
|
+
return_value=httpx.Response(
|
|
408
|
+
200,
|
|
409
|
+
json=INSTALLATION
|
|
410
|
+
| {
|
|
411
|
+
'permissions': {
|
|
412
|
+
'contents': 'write',
|
|
413
|
+
'checks': 'write',
|
|
414
|
+
'statuses': 'read',
|
|
415
|
+
'metadata': 'read',
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
)
|
|
419
|
+
)
|
|
420
|
+
route = respx.post(TOKENS_URL).mock(
|
|
421
|
+
return_value=httpx.Response(
|
|
422
|
+
201,
|
|
423
|
+
json={'token': TOKEN, 'expires_at': '2099-01-01T00:00:00Z'},
|
|
424
|
+
)
|
|
425
|
+
)
|
|
426
|
+
await APP.resolve(CONFIG, LOCATOR, None, _context('github_write'))
|
|
427
|
+
self.assertEqual(
|
|
428
|
+
json.loads(route.calls.last.request.content)['permissions'],
|
|
429
|
+
{
|
|
430
|
+
'checks': 'read',
|
|
431
|
+
'contents': 'write',
|
|
432
|
+
'issues': 'write',
|
|
433
|
+
'pull_requests': 'write',
|
|
434
|
+
'statuses': 'read',
|
|
435
|
+
},
|
|
436
|
+
)
|
|
437
|
+
await APP.resolve(CONFIG, LOCATOR, None, _context('github_read'))
|
|
438
|
+
self.assertEqual(
|
|
439
|
+
json.loads(route.calls.last.request.content)['permissions'],
|
|
440
|
+
{
|
|
441
|
+
'actions': 'read',
|
|
442
|
+
'checks': 'read',
|
|
443
|
+
'contents': 'read',
|
|
444
|
+
'issues': 'read',
|
|
445
|
+
'pull_requests': 'read',
|
|
446
|
+
'statuses': 'read',
|
|
447
|
+
},
|
|
448
|
+
)
|
|
449
|
+
|
|
401
450
|
@respx.mock
|
|
402
451
|
async def test_disallowed_host_gets_no_jwt(self) -> None:
|
|
403
452
|
"""A host that left the allowlist after the provider was saved."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/_app_auth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/deployment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/lifecycle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.53.0 → imbi_plugin_github-2.54.0}/src/imbi/plugins/github/pull_requests.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|