imbi-plugin-github 2.52.0__py3-none-any.whl → 2.54.0__py3-none-any.whl

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.
@@ -63,6 +63,12 @@ LOGGER = logging.getLogger(__name__)
63
63
  PURPOSE_PERMISSIONS: dict[str, dict[str, str]] = {
64
64
  'workspace_checkout': {'contents': 'read'},
65
65
  'marketplace_fetch': {'contents': 'read'},
66
+ 'github_read': {
67
+ 'actions': 'read',
68
+ 'contents': 'read',
69
+ 'issues': 'read',
70
+ 'pull_requests': 'read',
71
+ },
66
72
  'github_write': {
67
73
  'contents': 'write',
68
74
  'pull_requests': 'write',
@@ -70,6 +76,18 @@ PURPOSE_PERMISSIONS: dict[str, dict[str, str]] = {
70
76
  },
71
77
  }
72
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
+
73
91
  #: The binding test asks for the smallest permission set.
74
92
  _TEST_PERMISSIONS = {'metadata': 'read'}
75
93
 
@@ -278,6 +296,25 @@ def _options(raw: object) -> dict[str, typing.Any]:
278
296
  return {}
279
297
 
280
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
+
281
318
  def _expiry(value: object) -> datetime.datetime:
282
319
  if isinstance(value, str):
283
320
  try:
@@ -645,6 +682,7 @@ class GitHubApp(secrets.SecretProvider):
645
682
  raise secrets.BrokerError(
646
683
  'secret_access_denied', 'purpose_not_supported'
647
684
  )
685
+ optional = PURPOSE_OPTIONAL_PERMISSIONS.get(context.purpose, {})
648
686
  repositories: list[str] = []
649
687
  repository_ids: list[int] | None = None
650
688
  if context.purpose == 'marketplace_fetch':
@@ -692,7 +730,7 @@ class GitHubApp(secrets.SecretProvider):
692
730
  client, repositories, repository_ids
693
731
  )
694
732
  installation_id = str(installation['id'])
695
- elif repositories:
733
+ elif repositories or optional:
696
734
  installation = await self._installation(
697
735
  client, installation_id
698
736
  )
@@ -702,7 +740,7 @@ class GitHubApp(secrets.SecretProvider):
702
740
  token, expires_at = await self._mint(
703
741
  client,
704
742
  installation_id,
705
- permissions,
743
+ _with_granted(permissions, optional, installation),
706
744
  names,
707
745
  repository_ids,
708
746
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: imbi-plugin-github
3
- Version: 2.52.0
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.52.0
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
@@ -12,7 +12,7 @@ imbi/plugins/github/plugin.py,sha256=LDFCqj6e2jfF9io3U7cC0eVOUAxw1ENvFS-0AWOMuDc
12
12
  imbi/plugins/github/public.py,sha256=GZnTLbj_Gl5sHWuRqFuajnoO2xPudNQumAt4h_uJpYw,3114
13
13
  imbi/plugins/github/pull_requests.py,sha256=DH9CnJoCpY5Ats5sZ_ktLvy54kBwK9g_-CDMlAIOq7Y,32553
14
14
  imbi/plugins/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- imbi/plugins/github/secret_provider.py,sha256=6o8-RK22CqoJxeLYFP_sm976anIR_2XR0FAGCfNrnkg,29447
16
- imbi_plugin_github-2.52.0.dist-info/METADATA,sha256=onrTjQyCvg9pbXbt7PBn7oL4xKnbKtn3jFeHPGM69BM,8977
17
- imbi_plugin_github-2.52.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
- imbi_plugin_github-2.52.0.dist-info/RECORD,,
15
+ imbi/plugins/github/secret_provider.py,sha256=E8TKo1O6YSnZO6YUWwK4x3dO-5cg1_M8o2Jd-0YCa_8,30743
16
+ imbi_plugin_github-2.54.0.dist-info/METADATA,sha256=AxQh_xVo-MUtkMGwXZXeBXyvaIoYJHiQjQ8afY7bkRs,8977
17
+ imbi_plugin_github-2.54.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ imbi_plugin_github-2.54.0.dist-info/RECORD,,