imbi-plugin-github 2.37.0__py3-none-any.whl → 2.38.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.
- imbi/plugins/github/_app_auth.py +14 -1
- imbi/plugins/github/deployment.py +21 -0
- imbi/plugins/github/doctor.py +32 -0
- {imbi_plugin_github-2.37.0.dist-info → imbi_plugin_github-2.38.0.dist-info}/METADATA +2 -2
- {imbi_plugin_github-2.37.0.dist-info → imbi_plugin_github-2.38.0.dist-info}/RECORD +6 -6
- {imbi_plugin_github-2.37.0.dist-info → imbi_plugin_github-2.38.0.dist-info}/WHEEL +0 -0
imbi/plugins/github/_app_auth.py
CHANGED
|
@@ -255,7 +255,11 @@ async def _discover_installation_id(
|
|
|
255
255
|
|
|
256
256
|
|
|
257
257
|
async def _mint(
|
|
258
|
-
client: httpx.AsyncClient,
|
|
258
|
+
client: httpx.AsyncClient,
|
|
259
|
+
installation_id: str,
|
|
260
|
+
scope: FrozenScope,
|
|
261
|
+
repositories: collections.abc.Sequence[str] | None = None,
|
|
262
|
+
repository_ids: collections.abc.Sequence[int] | None = None,
|
|
259
263
|
) -> tuple[str, object]:
|
|
260
264
|
"""Exchange the App JWT for an installation access token.
|
|
261
265
|
|
|
@@ -265,6 +269,11 @@ async def _mint(
|
|
|
265
269
|
installation does not hold is a ``422``, which is the right failure:
|
|
266
270
|
a capability asking for authority the App was never given should say
|
|
267
271
|
so rather than act with less.
|
|
272
|
+
|
|
273
|
+
``repositories`` (names without the owner) limits the token to those
|
|
274
|
+
repositories of the installation. ``repository_ids`` does the same
|
|
275
|
+
with the numeric repository ids; GitHub refuses an id that is not in
|
|
276
|
+
the installation (``422``).
|
|
268
277
|
"""
|
|
269
278
|
# ``is not None`` rather than truthiness: ``freeze_scope({})`` is an
|
|
270
279
|
# empty tuple, and asking GitHub for *no* permissions must send
|
|
@@ -274,6 +283,10 @@ async def _mint(
|
|
|
274
283
|
body: dict[str, typing.Any] | None = (
|
|
275
284
|
{'permissions': dict(scope)} if scope is not None else None
|
|
276
285
|
)
|
|
286
|
+
if repositories is not None:
|
|
287
|
+
body = {**(body or {}), 'repositories': list(repositories)}
|
|
288
|
+
if repository_ids is not None:
|
|
289
|
+
body = {**(body or {}), 'repository_ids': list(repository_ids)}
|
|
277
290
|
resp = await client.post(
|
|
278
291
|
f'/app/installations/{installation_id}/access_tokens', json=body
|
|
279
292
|
)
|
|
@@ -1171,6 +1171,27 @@ class GitHubDeployment(DeploymentCapability):
|
|
|
1171
1171
|
return None
|
|
1172
1172
|
return await self._blob_text(client, blob_sha)
|
|
1173
1173
|
|
|
1174
|
+
async def get_file(
|
|
1175
|
+
self,
|
|
1176
|
+
ctx: PluginContext,
|
|
1177
|
+
credentials: dict[str, str],
|
|
1178
|
+
path: str,
|
|
1179
|
+
ref: str,
|
|
1180
|
+
) -> str | None:
|
|
1181
|
+
"""Read ``path`` at ``ref`` through the contents API, raw."""
|
|
1182
|
+
async with self._client(
|
|
1183
|
+
ctx, credentials, SCOPE_CONTENTS_READ
|
|
1184
|
+
) as client:
|
|
1185
|
+
response = await client.get(
|
|
1186
|
+
f'/contents/{urllib.parse.quote(path)}',
|
|
1187
|
+
params={'ref': ref},
|
|
1188
|
+
headers={'Accept': 'application/vnd.github.raw+json'},
|
|
1189
|
+
)
|
|
1190
|
+
if response.status_code == 404:
|
|
1191
|
+
return None
|
|
1192
|
+
response.raise_for_status()
|
|
1193
|
+
return response.text
|
|
1194
|
+
|
|
1174
1195
|
async def list_commit_notes(
|
|
1175
1196
|
self,
|
|
1176
1197
|
ctx: PluginContext,
|
imbi/plugins/github/doctor.py
CHANGED
|
@@ -411,6 +411,7 @@ class GitHubDoctor(AnalysisCapability):
|
|
|
411
411
|
f'the GitHub API id {api_id!r}.',
|
|
412
412
|
)
|
|
413
413
|
)
|
|
414
|
+
results.append(_verified_item(connection, api_id))
|
|
414
415
|
else:
|
|
415
416
|
results.append(
|
|
416
417
|
_item(
|
|
@@ -681,6 +682,7 @@ class GitHubDoctor(AnalysisCapability):
|
|
|
681
682
|
if connection is not None:
|
|
682
683
|
already_correct = (
|
|
683
684
|
connection.identifier == str(api_id)
|
|
685
|
+
and connection.verified_identifier == str(api_id)
|
|
684
686
|
and connection.canonical_url == desired_canonical
|
|
685
687
|
and ctx.project_links.get(slug) == html_url
|
|
686
688
|
)
|
|
@@ -704,6 +706,36 @@ class GitHubDoctor(AnalysisCapability):
|
|
|
704
706
|
)
|
|
705
707
|
|
|
706
708
|
|
|
709
|
+
def _verified_item(
|
|
710
|
+
connection: ServiceConnection, api_id: str
|
|
711
|
+
) -> AnalysisResultItem:
|
|
712
|
+
"""Check that this plugin wrote the identifier from GitHub.
|
|
713
|
+
|
|
714
|
+
The ``github_app`` secret provider issues tokens only for a verified
|
|
715
|
+
identifier. An edge that a user created or edited by hand is not
|
|
716
|
+
verified until the repair writes it again from GitHub.
|
|
717
|
+
"""
|
|
718
|
+
if connection.verified_identifier == api_id:
|
|
719
|
+
return _item(
|
|
720
|
+
'identifier-verified',
|
|
721
|
+
'Identifier verified',
|
|
722
|
+
'pass',
|
|
723
|
+
f'GitHub verified the EXISTS_IN identifier {api_id!r}.',
|
|
724
|
+
)
|
|
725
|
+
return _item(
|
|
726
|
+
'identifier-verified',
|
|
727
|
+
'Identifier verified',
|
|
728
|
+
'warn',
|
|
729
|
+
f'GitHub has not verified the EXISTS_IN identifier {api_id!r}. '
|
|
730
|
+
'GitHub App tokens are not issued for this project until you use '
|
|
731
|
+
'the Fix action.',
|
|
732
|
+
RemediationOffer(
|
|
733
|
+
id=_REPAIR_EDGE,
|
|
734
|
+
label='Verify the EXISTS_IN edge from GitHub',
|
|
735
|
+
),
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
|
|
707
739
|
def _body_unavailable_items() -> list[AnalysisResultItem]:
|
|
708
740
|
"""Return warn items for body-dependent checks when the fetch fails."""
|
|
709
741
|
return [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: imbi-plugin-github
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.38.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.38.0
|
|
16
16
|
Requires-Dist: pydantic>=2
|
|
17
17
|
Requires-Dist: pyjwt[crypto]>=2.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
imbi/plugins/github/README.md,sha256=HUD61Mvn9fSykQ4I-oUoZ62wd9tdhJ8jqoaPnpuPasM,7121
|
|
2
2
|
imbi/plugins/github/__init__.py,sha256=L_5_kr22VkjJob6SVLVzCkIvnWddxi54GIrM2cNs2rg,441
|
|
3
|
-
imbi/plugins/github/_app_auth.py,sha256=
|
|
3
|
+
imbi/plugins/github/_app_auth.py,sha256=qr3azBExZSI0vDIIKMKV8nSllJNKCJLKBXV86lIp9jE,19015
|
|
4
4
|
imbi/plugins/github/_hosts.py,sha256=sYuE3f7934125VZ6GGTqm8t3sVa3m0DNt3jL9Hb8nM0,4014
|
|
5
5
|
imbi/plugins/github/_repos.py,sha256=BeSwrpzQnFBtlUGW-eP7v6_gAcSaSkqObq-vhj5wcYA,6575
|
|
6
6
|
imbi/plugins/github/commits.py,sha256=wHs_NUl4cmhfvD3WrnOCmqaaJS-Eku-E-lOMh6Cb8IU,71882
|
|
7
|
-
imbi/plugins/github/deployment.py,sha256=
|
|
8
|
-
imbi/plugins/github/doctor.py,sha256=
|
|
7
|
+
imbi/plugins/github/deployment.py,sha256=pRlYWWIDr1bFkjX1CMWiI_cfRsk4raMNrligGoMsCbE,111061
|
|
8
|
+
imbi/plugins/github/doctor.py,sha256=SIe3Rmaui3Qooc17S7WNEWLUKDq9PzyNslsypoR-Abc,28295
|
|
9
9
|
imbi/plugins/github/identity.py,sha256=9t_e-_jUbQ1iL0Vb6vaK2d7bT1ki6pw9aWwc4ics6gI,10354
|
|
10
10
|
imbi/plugins/github/lifecycle.py,sha256=KJSzB36zFqetQBY5HNXLsRGRoIwGhrBJ-I1mA8G9H_Q,37711
|
|
11
11
|
imbi/plugins/github/plugin.py,sha256=V1BzHPR5a0gGr1ttSqo_yTVdK5ShKs26AcReX2N-eOg,15531
|
|
12
12
|
imbi/plugins/github/pull_requests.py,sha256=FiHbjdGqghJ2Q1--d15XfOtpUe_KZE7hYRb8JLQ5U1I,13510
|
|
13
13
|
imbi/plugins/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
imbi_plugin_github-2.
|
|
15
|
-
imbi_plugin_github-2.
|
|
16
|
-
imbi_plugin_github-2.
|
|
14
|
+
imbi_plugin_github-2.38.0.dist-info/METADATA,sha256=08oa51ZVPiJhHa8UxE2n_gGinDfdZgIpBEEH99rvD-A,7618
|
|
15
|
+
imbi_plugin_github-2.38.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
16
|
+
imbi_plugin_github-2.38.0.dist-info/RECORD,,
|
|
File without changes
|