github-agent 2.4.1__py3-none-any.whl → 2.4.3__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.
- github_agent/__init__.py +1 -1
- github_agent/connectors/tool_schema_fingerprints.json +1 -1
- github_agent/github_http.py +11 -7
- github_agent/kg_ingest.py +2 -2
- github_agent/mcp_server.py +1 -1
- github_agent/ontology/certification.json +3 -3
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/METADATA +3 -3
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/RECORD +14 -13
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/WHEEL +1 -1
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/entry_points.txt +3 -0
- tests/test_fleet_name.py +53 -0
- tests/test_github_http.py +65 -0
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/licenses/LICENSE +0 -0
- {github_agent-2.4.1.dist-info → github_agent-2.4.3.dist-info}/top_level.txt +0 -0
github_agent/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.4.
|
|
1
|
+
__version__ = "2.4.3"
|
github_agent/github_http.py
CHANGED
|
@@ -4,21 +4,23 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import http.client
|
|
6
6
|
import json
|
|
7
|
-
import os
|
|
8
7
|
import ssl
|
|
9
8
|
from typing import Any
|
|
10
9
|
|
|
10
|
+
from agent_connector_sdk.tls.errors import TransportSecurityError
|
|
11
|
+
from agent_connector_sdk.tls.profile import ResolvedTLSProfile
|
|
12
|
+
from agent_connector_sdk.tls.resolve import resolve_tls_profile
|
|
13
|
+
|
|
11
14
|
GITHUB_API_HOST = "api.github.com"
|
|
12
15
|
MAX_REQUEST_BYTES = 1 * 1024 * 1024
|
|
13
16
|
MAX_RESPONSE_BYTES = 8 * 1024 * 1024
|
|
14
17
|
|
|
15
18
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
capath = os.environ.get("SSL_CERT_DIR")
|
|
19
|
+
def _tls_profile() -> ResolvedTLSProfile:
|
|
20
|
+
"""Resolve the GitHub TLS profile from the SDK (SDK-CONNECTOR-CONTROL-R017)."""
|
|
19
21
|
try:
|
|
20
|
-
return
|
|
21
|
-
except
|
|
22
|
+
return resolve_tls_profile("github")
|
|
23
|
+
except TransportSecurityError:
|
|
22
24
|
raise RuntimeError("runtime TLS trust configuration is invalid") from None
|
|
23
25
|
|
|
24
26
|
|
|
@@ -103,11 +105,12 @@ def github_json_request(
|
|
|
103
105
|
_validate_token_shape(token)
|
|
104
106
|
body = _encode_request_body(payload)
|
|
105
107
|
headers = _request_headers(token)
|
|
108
|
+
profile = _tls_profile()
|
|
106
109
|
connection = http.client.HTTPSConnection(
|
|
107
110
|
GITHUB_API_HOST,
|
|
108
111
|
443,
|
|
109
112
|
timeout=30,
|
|
110
|
-
context=
|
|
113
|
+
context=profile.ssl_context,
|
|
111
114
|
)
|
|
112
115
|
try:
|
|
113
116
|
connection.request(method, path, body=body, headers=headers)
|
|
@@ -118,3 +121,4 @@ def github_json_request(
|
|
|
118
121
|
raise RuntimeError("GitHub service is unavailable") from None
|
|
119
122
|
finally:
|
|
120
123
|
connection.close()
|
|
124
|
+
profile.cleanup()
|
github_agent/kg_ingest.py
CHANGED
|
@@ -35,8 +35,8 @@ from agent_connector_sdk.ingest import (
|
|
|
35
35
|
|
|
36
36
|
logger = logging.getLogger("github_agent.kg")
|
|
37
37
|
|
|
38
|
-
_ENTITY_BINDING = IngestBinding(connector="github-
|
|
39
|
-
_DOCUMENT_BINDING = IngestBinding(connector="github-
|
|
38
|
+
_ENTITY_BINDING = IngestBinding(connector="github-mcp", stream="github")
|
|
39
|
+
_DOCUMENT_BINDING = IngestBinding(connector="github-mcp", stream="github-documents")
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def _to_entity(record: dict[str, Any]) -> Entity:
|
github_agent/mcp_server.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"api_version": "arbora.io/v1",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"connector_manifest.yml": "
|
|
4
|
+
"connector_manifest.yml": "8c377374f2ab87e99a765d3340b269b312ae6aa971c91ebe874b3dbf8f76b358",
|
|
5
5
|
"github_agent/connectors/mcp_source_presets.json": "312ec35c48d40253afcd8dba445afee9f41b5ac910e11a435d7c02ee63b5967f",
|
|
6
|
-
"github_agent/connectors/tool_schema_fingerprints.json": "
|
|
6
|
+
"github_agent/connectors/tool_schema_fingerprints.json": "36982e09c3dba96cc187fc6cd99431deb4899b24399e3b8dc206f228cb980ce7",
|
|
7
7
|
"github_agent/ontology/fixtures/records.json": "12f5b54b0ae98770f279f99e136788d063340042a9d6ff4bac0c22a886d2dc7b",
|
|
8
8
|
"github_agent/ontology/github.ttl": "ad0ad6d295143b38725866b5b5c59a824f10bfc4219794ac2d9a2274f11bbdb5",
|
|
9
9
|
"github_agent/ontology/mappings/source.yaml": "7ff7a37550f825a61fe6d0f9529206f4efe2727431e32b8ab95a39a32bdced43",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"bundle_schema": "2",
|
|
23
23
|
"epistemic_graph": ">=2.27.0,<3"
|
|
24
24
|
},
|
|
25
|
-
"connector": "github-
|
|
25
|
+
"connector": "github-mcp",
|
|
26
26
|
"kind": "ConnectorSourceAttestation",
|
|
27
27
|
"live_certified": false,
|
|
28
28
|
"mode": "offline-source",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: github-agent
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.3
|
|
4
4
|
Summary: GitHub Agent for MCP
|
|
5
5
|
Author-email: Project Maintainers <maintainers@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: gql[requests]>=4.4.0
|
|
16
16
|
Requires-Dist: requests>=2.34.2
|
|
17
|
-
Requires-Dist: agent-connector-sdk[mcp]<1.0.0,>=0.3.
|
|
17
|
+
Requires-Dist: agent-connector-sdk[mcp]<1.0.0,>=0.3.11
|
|
18
18
|
Provides-Extra: mcp
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Provides-Extra: test
|
|
@@ -45,7 +45,7 @@ Dynamic: license-file
|
|
|
45
45
|

|
|
46
46
|

|
|
47
47
|
|
|
48
|
-
*Version: 2.4.
|
|
48
|
+
*Version: 2.4.3*
|
|
49
49
|
|
|
50
50
|
> **Documentation** — Installation, deployment, and usage across the MCP, API, and
|
|
51
51
|
> [official documentation](https://knuckles-team.github.io/github-agent/).
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
github_agent/__init__.py,sha256=
|
|
1
|
+
github_agent/__init__.py,sha256=OPBnVa8RJVtYMGheuiuNN0f5i8tn6elz4XCmUBGelSo,22
|
|
2
2
|
github_agent/__main__.py,sha256=O4Xg__fMvKfUsA6m61pLV56jlYY6EORiLhgDLlp0vJ8,92
|
|
3
3
|
github_agent/api_client.py,sha256=O69YfkXBKyVd59EC8szaMlw3_ZxwEEvsLSvhWlfYnvk,1581
|
|
4
4
|
github_agent/auth.py,sha256=isNd6DYbl_syB_wIbC399d_-157jqH1jqJfDmBn8h-0,4671
|
|
5
5
|
github_agent/github_gql.py,sha256=GdkazLUDRwu5AKv2cikT8evpQAGHD1nBZ4f4BtJ2f84,5382
|
|
6
|
-
github_agent/github_http.py,sha256=
|
|
6
|
+
github_agent/github_http.py,sha256=v-H9Nny1Q45yQH-1vsDpog4GOvAUSI786XFkctmXdik,4362
|
|
7
7
|
github_agent/github_input_models.py,sha256=yqqPGHb206th736MZvbnxq9F1JRsBUBODNeNVc08F3A,15568
|
|
8
8
|
github_agent/github_response_models.py,sha256=mllSt0frBgzklUtfuHywJ2Ald3m99So948Xikt3H2Tc,8859
|
|
9
|
-
github_agent/kg_ingest.py,sha256=
|
|
9
|
+
github_agent/kg_ingest.py,sha256=iH_NKpd8a6GtNxfZTp8Oah8VZkcXjI74KDf8P9NbtjA,17978
|
|
10
10
|
github_agent/mcp_config.json,sha256=2OOXrwO1sDLyHQqpZwhvDHizPIe3by6YmK4KFE333gI,23
|
|
11
|
-
github_agent/mcp_server.py,sha256=
|
|
11
|
+
github_agent/mcp_server.py,sha256=ChllOlIhkx8PzIJxtDwtDGzH2F6ybRTr0B5YuJmAgbg,126620
|
|
12
12
|
github_agent/api/__init__.py,sha256=ntaEPqk-dsAV3HyyDLc2hYpc9nTTyG5CKI-SVDDjc24,27
|
|
13
13
|
github_agent/api/api_client_base.py,sha256=tMXKrZIXg6aQ6OK4kNKBDcNc8BrM0Vml_66SwA5ZgEw,7485
|
|
14
14
|
github_agent/api/api_client_branches.py,sha256=bCmqGUWQ27GFTGxcFkQ7D-ZEltKp6APVsk_Fw9wzdjY,3940
|
|
@@ -26,7 +26,7 @@ github_agent/api/api_client_search.py,sha256=zWFexkXZYFzDvWackxM33uWdEDYsA54lWlO
|
|
|
26
26
|
github_agent/api/api_client_workflows.py,sha256=Y6iHgLujZksI9jAZb1tkFnEv3f-l4bd-fiUtSu3vVw4,5799
|
|
27
27
|
github_agent/connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
github_agent/connectors/mcp_source_presets.json,sha256=MS7DXEjUAlOvzY26RFr-6fQbWskQ4RpDXXwC7mO1ln8,699
|
|
29
|
-
github_agent/connectors/tool_schema_fingerprints.json,sha256=
|
|
29
|
+
github_agent/connectors/tool_schema_fingerprints.json,sha256=NpguCcPbqWzBh_xs2ZQx3rSJmyQ5njuNwgbyKMuYDOc,239
|
|
30
30
|
github_agent/mcp/__init__.py,sha256=mO-LvCC1TIs-T9f7oDToOq7LsZUMx04Aa3h0LjIi6eA,1290
|
|
31
31
|
github_agent/mcp/mcp_action.py,sha256=oz3CcAMw8Uc_MC7us_pUn4nbwdNqR_ePIjDzckID5Wo,9583
|
|
32
32
|
github_agent/mcp/mcp_branch.py,sha256=lACUOIPRPiLD9lv4DzKJ2n9IvOsq97mHk8lxTat1zWk,4785
|
|
@@ -41,7 +41,7 @@ github_agent/mcp/mcp_release.py,sha256=WnuZ2wjcTBVl8Jzog_4a9HjbxDAh6aXdN-mdzDUZt
|
|
|
41
41
|
github_agent/mcp/mcp_repo.py,sha256=ny5GdawCFZxlbjpOc3ttnn-NIs9QDQLAxRdAWEWLUdc,18344
|
|
42
42
|
github_agent/mcp/mcp_search.py,sha256=3ZBGNKkVu5oBXgN9MBWd-ve4NDCzcwP9sY22bp4hqKs,2963
|
|
43
43
|
github_agent/ontology/__init__.py,sha256=-qc7ZPSgdaCLrD1AH_7TFXWikEpSH9rVmBciCC9gtCY,552
|
|
44
|
-
github_agent/ontology/certification.json,sha256=
|
|
44
|
+
github_agent/ontology/certification.json,sha256=nUT_C-AtTjtb4bDAs3cDT2vlk7kK_8RPFfbyIWXCMw0,1664
|
|
45
45
|
github_agent/ontology/github.ttl,sha256=socWm6ST7jnTqZFxurxYdNIY1Ivx6JaW7MiJiX3-onk,9154
|
|
46
46
|
github_agent/ontology/fixtures/records.json,sha256=EvW1Swrph3DyefmeE2eI0GM0AEKp1v9LrAwiqIbS3Hs,543
|
|
47
47
|
github_agent/ontology/mappings/source.yaml,sha256=f_ejdVD4JaYf5tD5UpIG9O_icnQx4yuKuVo5oyvc7UM,533
|
|
@@ -92,7 +92,7 @@ github_agent/skills/github-triage-resolver/WORKFLOW.md,sha256=orvcRmaV-qb_JKoGSw
|
|
|
92
92
|
github_agent/skills/github-triage-resolver/references/resolution-rules.md,sha256=lGPvfLCSHpNIeh2rKWcH2k_2lla3ovgBxzwvtMmyQ-0,4133
|
|
93
93
|
github_agent/skills/github-triage-resolver/scripts/classify_safe.py,sha256=8BhcDF9Q8rjJIEVOmdyO-dO-eHBjW7T-bzaYC16uY5I,9556
|
|
94
94
|
github_agent/skills/github-triage-resolver/scripts/gh_write.py,sha256=SL5oA1A3lFRLepNri4CzEcuEsg9D5WKJ1000fCRKBEM,4125
|
|
95
|
-
github_agent-2.4.
|
|
95
|
+
github_agent-2.4.3.dist-info/licenses/LICENSE,sha256=5ALbh4fIALWVsUhO7q1nFT1bQb-CL9sWKf7p3GgLEG8,1070
|
|
96
96
|
scripts/security_sanitizer.py,sha256=gE65xtYMGx43oYUnK0kozBm73Hx97mCdrQUM7GGzIbk,9449
|
|
97
97
|
scripts/verify_api_integration.py,sha256=3AK8HKW52o1yxCDaEUtXngnh7CjYw6NiG9Eb3EIoXNE,10256
|
|
98
98
|
tests/conftest.py,sha256=kgpOLUp_q8IZaI6Xd7F1tbFuio81-_l5Gd4jaGiMrnY,3636
|
|
@@ -101,10 +101,11 @@ tests/test_api_client_endpoints.py,sha256=Hbw0vssQU5Up-KvJmUDLDCP4t2u8pU-xPfWAhF
|
|
|
101
101
|
tests/test_api_validation.py,sha256=CRZq7kfc1U8CLZJRTGusBhTN2Tlfc1FIeDqIm895XoI,3301
|
|
102
102
|
tests/test_auth_client_edge_cases.py,sha256=QjQAtjd7vDDsSSvIZuUXbd9Z58te8Xp9giPFmwJTBsA,6470
|
|
103
103
|
tests/test_comment_crud.py,sha256=mHA0scds_0W0oND-VI0QMvNaYarYkHjiXd4H9-9d5kE,27341
|
|
104
|
+
tests/test_fleet_name.py,sha256=qCLzYTPuiaS3y0I0NLuMRloXlf_o0sue0aVH-Sn-tYQ,1893
|
|
104
105
|
tests/test_github_agent_api_brute_force_coverage.py,sha256=5jWW6oVU7cmXL2sS3OZ-3gbYGhyjlYPIWqH2rsdF2fw,7347
|
|
105
106
|
tests/test_github_agent_brute_force_coverage.py,sha256=Z_voXtChOYRqaNEmNzMfzvwQMj2xFBn1m8mXx5ubUe8,4849
|
|
106
107
|
tests/test_github_gql.py,sha256=mpn814s9UhN4jnlp1TB8XE3OZ04adR9nhfPM9j0Gpyc,1892
|
|
107
|
-
tests/test_github_http.py,sha256=
|
|
108
|
+
tests/test_github_http.py,sha256=uuSMrot71Kj8WQf-QyazO4rWzpWSucRTQ1tt5wRvC_E,9563
|
|
108
109
|
tests/test_hardening.py,sha256=sdlKmtk7B5yncc-r1LuFgoJfro6wNlCqY0xI73IVC4M,3710
|
|
109
110
|
tests/test_init_dynamics.py,sha256=fPE_4M-bONKiqvtWLn12A0q18CUlzQhdx1UoXYkbbPk,1839
|
|
110
111
|
tests/test_kg_ingest.py,sha256=TeHjWz74LiuSxpI7N6HHrdj0H1mRsJHceQDNYvre4To,9462
|
|
@@ -122,8 +123,8 @@ tests/test_skill_org_remediation_classify_fix_risk.py,sha256=0Y8289lhxtJ3pxYUHzO
|
|
|
122
123
|
tests/test_skill_pr_review_sweep_summarize_prs.py,sha256=NrNaucQvM7K-k1WBcOBKtTGjxJbW16VgTHbC7dSsjm4,3821
|
|
123
124
|
tests/test_skill_triage_resolver_classify_safe.py,sha256=B-aDeVmsKTsxYO8TwMEx-cmpVSmZdlKXw5993Da2ubc,9489
|
|
124
125
|
tests/test_startup.py,sha256=Ix_g69k0tsZbY0-Vkeh8ADWojUdbYwTwwmnM4_hVuCc,1245
|
|
125
|
-
github_agent-2.4.
|
|
126
|
-
github_agent-2.4.
|
|
127
|
-
github_agent-2.4.
|
|
128
|
-
github_agent-2.4.
|
|
129
|
-
github_agent-2.4.
|
|
126
|
+
github_agent-2.4.3.dist-info/METADATA,sha256=p61ZwVHzoGYvHKxzHWA7ulhSIKJhb9w1ofIF_LneNBU,34536
|
|
127
|
+
github_agent-2.4.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
128
|
+
github_agent-2.4.3.dist-info/entry_points.txt,sha256=Wi6GhziOqmJl-22qTYkjfVuIHEHKRrBvyyloc7NqV80,367
|
|
129
|
+
github_agent-2.4.3.dist-info/top_level.txt,sha256=53Ecr8n7o_EMIqZClc11PBU07uQIggYZOk5WnvBbeOQ,50
|
|
130
|
+
github_agent-2.4.3.dist-info/RECORD,,
|
tests/test_fleet_name.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""CONN-GITHUB-AGENT-CONNECTOR-IDENTITY-R001: the connector is filed under its fleet name, github-mcp."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
import tomllib
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
14
|
+
PACKAGE = ROOT / "github_agent"
|
|
15
|
+
FLEET = "github-mcp"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _call_connectors(path: Path) -> list[str]:
|
|
19
|
+
names = []
|
|
20
|
+
for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))):
|
|
21
|
+
if isinstance(node, ast.Call) and getattr(
|
|
22
|
+
node.func, "id", getattr(node.func, "attr", "")
|
|
23
|
+
) in {
|
|
24
|
+
"IngestBinding",
|
|
25
|
+
"ConnectorContent",
|
|
26
|
+
}:
|
|
27
|
+
names += [
|
|
28
|
+
str(k.value.value)
|
|
29
|
+
for k in node.keywords
|
|
30
|
+
if k.arg == "connector" and isinstance(k.value, ast.Constant)
|
|
31
|
+
]
|
|
32
|
+
return names
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.spec("CONN-GITHUB-AGENT-CONNECTOR-IDENTITY-R001")
|
|
36
|
+
def test_connector_name_is_the_fleet_name() -> None:
|
|
37
|
+
pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))
|
|
38
|
+
assert pyproject["project"]["entry-points"]["agent_connector_sdk.connector"] == {
|
|
39
|
+
FLEET: "github_agent"
|
|
40
|
+
}
|
|
41
|
+
manifest_path = PACKAGE / "connector_manifest.yml"
|
|
42
|
+
if not manifest_path.is_file():
|
|
43
|
+
manifest_path = ROOT / "connector_manifest.yml"
|
|
44
|
+
manifest = manifest_path.read_text(encoding="utf-8")
|
|
45
|
+
match = re.search(r'^\s*"?connector"?\s*:\s*"?([^"\s,]+)', manifest, re.MULTILINE)
|
|
46
|
+
assert match is not None and match.group(1) == FLEET
|
|
47
|
+
fingerprints = PACKAGE / "connectors" / "tool_schema_fingerprints.json"
|
|
48
|
+
if fingerprints.is_file():
|
|
49
|
+
assert (
|
|
50
|
+
json.loads(fingerprints.read_text(encoding="utf-8"))["connector"] == FLEET
|
|
51
|
+
)
|
|
52
|
+
for module in sorted(PACKAGE.glob("*.py")):
|
|
53
|
+
assert all(name == FLEET for name in _call_connectors(module)), module.name
|
tests/test_github_http.py
CHANGED
|
@@ -163,3 +163,68 @@ def test_github_json_request_encodes_payload_as_compact_json():
|
|
|
163
163
|
assert value == {"created": True}
|
|
164
164
|
sent_kwargs = connection.request.call_args.kwargs
|
|
165
165
|
assert sent_kwargs["body"] == json.dumps({"title": "hi"}, separators=(",", ":")).encode()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@pytest.mark.spec("CONN-GITHUB-AGENT-TRANSPORT-TLS-R001")
|
|
169
|
+
def test_request_uses_sdk_tls_profile_context():
|
|
170
|
+
"""CONN-GITHUB-AGENT-TRANSPORT-TLS-R001: the connection uses the profile's context."""
|
|
171
|
+
connection, _ = _mock_connection()
|
|
172
|
+
profile = MagicMock()
|
|
173
|
+
with (
|
|
174
|
+
patch("github_agent.github_http.resolve_tls_profile", return_value=profile) as resolve,
|
|
175
|
+
patch("github_agent.github_http.http.client.HTTPSConnection", return_value=connection) as conn_cls,
|
|
176
|
+
):
|
|
177
|
+
github_json_request("GET", "/repos/x/y", "tok")
|
|
178
|
+
resolve.assert_called_once_with("github")
|
|
179
|
+
assert conn_cls.call_args.kwargs["context"] is profile.ssl_context
|
|
180
|
+
profile.cleanup.assert_called_once()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@pytest.mark.spec("CONN-GITHUB-AGENT-TRANSPORT-TLS-R001")
|
|
184
|
+
def test_private_ca_is_carried_through_the_profile(tmp_path, monkeypatch):
|
|
185
|
+
"""CONN-GITHUB-AGENT-TRANSPORT-TLS-R001: a configured CA bundle reaches the profile."""
|
|
186
|
+
from cryptography import x509
|
|
187
|
+
from cryptography.hazmat.primitives import hashes, serialization
|
|
188
|
+
from cryptography.hazmat.primitives.asymmetric import ec
|
|
189
|
+
import datetime
|
|
190
|
+
|
|
191
|
+
from github_agent.github_http import _tls_profile
|
|
192
|
+
|
|
193
|
+
key = ec.generate_private_key(ec.SECP256R1())
|
|
194
|
+
name = x509.Name([x509.NameAttribute(x509.oid.NameOID.COMMON_NAME, "test-ca")])
|
|
195
|
+
now = datetime.datetime.now(datetime.timezone.utc)
|
|
196
|
+
cert = (
|
|
197
|
+
x509.CertificateBuilder()
|
|
198
|
+
.subject_name(name)
|
|
199
|
+
.issuer_name(name)
|
|
200
|
+
.public_key(key.public_key())
|
|
201
|
+
.serial_number(1)
|
|
202
|
+
.not_valid_before(now)
|
|
203
|
+
.not_valid_after(now + datetime.timedelta(days=1))
|
|
204
|
+
.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True)
|
|
205
|
+
.sign(key, hashes.SHA256())
|
|
206
|
+
)
|
|
207
|
+
ca = tmp_path / "ca.pem"
|
|
208
|
+
ca.write_bytes(cert.public_bytes(serialization.Encoding.PEM))
|
|
209
|
+
monkeypatch.setenv("GITHUB_CA_BUNDLE", str(ca))
|
|
210
|
+
profile = _tls_profile()
|
|
211
|
+
try:
|
|
212
|
+
assert profile.ca_bundle_path == ca
|
|
213
|
+
assert profile.verify_enabled
|
|
214
|
+
finally:
|
|
215
|
+
profile.cleanup()
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@pytest.mark.spec("CONN-GITHUB-AGENT-TRANSPORT-TLS-R001")
|
|
219
|
+
def test_no_hand_built_ssl_context_remains():
|
|
220
|
+
"""CONN-GITHUB-AGENT-TRANSPORT-TLS-R001: no package code builds its own context."""
|
|
221
|
+
from pathlib import Path
|
|
222
|
+
|
|
223
|
+
import github_agent
|
|
224
|
+
|
|
225
|
+
root = Path(github_agent.__file__).parent
|
|
226
|
+
for path in root.rglob("*.py"):
|
|
227
|
+
text = path.read_text(encoding="utf-8")
|
|
228
|
+
assert "create_default_context" not in text, path
|
|
229
|
+
assert "verify=False" not in text, path
|
|
230
|
+
assert "disable_warnings" not in text, path
|
|
File without changes
|
|
File without changes
|