Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 55 additions & 18 deletions dependency_live_roadmap_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,25 @@ def _private_package(name):
return osv_offline.private_package(name, os.environ.get("DEPLOOM_DRAFT_PRIVATE_SCOPES", ""))


def _public_evidence_block_reason(package=None):
from registry_privacy import public_evidence_block_reason
return public_evidence_block_reason(os.environ, package)


def _github_authorization(url, hosts):
"""A GitHub token belongs only to an exact HTTPS GitHub origin."""
try:
parsed = urlparse(url)
if (parsed.scheme != "https" or parsed.hostname not in hosts
or parsed.port not in (None, 443) or parsed.username is not None
or parsed.password is not None or any(ord(char) < 33 or ord(char) == 127 for char in url)):
return {}
except (TypeError, ValueError):
return {}
token = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN")
return {"Authorization": f"Bearer {token}"} if token else {}


def _corporate_advisory_fallback(registry):
return (os.environ.get("DEPLOOM_DRAFT_DISABLE_EXTERNAL_EVIDENCE") == "1"
and corporate_advisory_source_matches(
Expand Down Expand Up @@ -3812,20 +3831,34 @@ def fetch_osv_vuln(self, vuln_id: str) -> Dict[str, Any]:
) from e


@contextmanager
def _public_evidence_session(self, url):
# Preserve the configured proxy and CA route, without carrying registry
# auth, cookies, headers, query parameters or client certificates to a
# public source. trust_env=False also prevents implicit netrc auth.
settings = self.session.merge_environment_settings(url, {}, True, None, None)
with requests.Session() as session:
session.trust_env = False
session.proxies.update(settings["proxies"])
session.verify = settings["verify"]
yield session

def fetch_text(self, url: str, quiet: bool = True) -> Optional[str]:
if _public_evidence_block_reason():
return None
if url in self.text_cache:
return self.text_cache[url]
self.progress(operation="fetch text", step="scan")
try:
headers = {"Accept": "text/plain, text/markdown, application/json"}
token = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN")
if token and "github" in url:
headers["Authorization"] = f"Bearer {token}"
response = self._supervised(
lambda url=url, headers=headers: self.session.get(url, timeout=self._budgeted_timeout(), headers=headers, stream=True)
)
response.raise_for_status()
text = self._bounded_text(response)
headers.update(_github_authorization(url, {"github.com", "api.github.com", "raw.githubusercontent.com"}))
with self._public_evidence_session(url) as session:
response = self._supervised(
lambda: session.get(url, timeout=self._budgeted_timeout(), headers=headers, stream=True)
)
with response:
response.raise_for_status()
text = self._bounded_text(response)
self.text_cache[url] = text
self._bounded_sleep(self.sleep_sec)
return text
Expand All @@ -3838,19 +3871,21 @@ def fetch_text(self, url: str, quiet: bool = True) -> Optional[str]:
return None

def fetch_json_url(self, url: str, quiet: bool = True) -> Optional[Any]:
if _public_evidence_block_reason():
return None
if url in self.json_cache:
return self.json_cache[url]
self.progress(operation="fetch json", step="scan")
try:
headers = {"Accept": "application/vnd.github+json, application/json"}
token = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN")
if token and "api.github.com" in url:
headers["Authorization"] = f"Bearer {token}"
response = self._supervised(
lambda url=url, headers=headers: self.session.get(url, timeout=self._budgeted_timeout(), headers=headers, stream=True)
)
response.raise_for_status()
data = self._bounded_json(response)
headers.update(_github_authorization(url, {"api.github.com"}))
with self._public_evidence_session(url) as session:
response = self._supervised(
lambda: session.get(url, timeout=self._budgeted_timeout(), headers=headers, stream=True)
)
with response:
response.raise_for_status()
data = self._bounded_json(response)
self.json_cache[url] = data
self._bounded_sleep(self.sleep_sec)
return data
Expand Down Expand Up @@ -3927,6 +3962,8 @@ def _bounded_read_max(self, response, max_bytes: int) -> bytes:
return b"".join(chunks)

def fetch_release_intelligence(self, package: str, meta: Dict[str, Any], current: str, target: str) -> ReleaseIntelligence:
if _public_evidence_block_reason(package):
return build_release_intelligence(self, package, meta, current, target)
cache_key = (package, current, target)
if cache_key in self.release_intelligence_cache:
return self.release_intelligence_cache[cache_key]
Expand Down Expand Up @@ -4335,9 +4372,9 @@ def analyze_release_text(text: str, current: str, target: str, source_count: int
def build_release_intelligence(client: LiveDataClient, package: str, meta: Dict[str, Any], current: str, target: str) -> ReleaseIntelligence:
if not target_is_action(target):
return ReleaseIntelligence(target=target, status="not-applicable", summary="Для строки нет target-обновления")
if _private_package(package):
if reason := _public_evidence_block_reason(package):
return ReleaseIntelligence(target=target, status="unavailable",
summary="External release lookups are disabled for private packages")
summary=f"External release lookups unavailable: {reason}")
repo_url = repository_url_from_metadata(meta, target)
repo = github_repo_parts(repo_url)
sources: List[Dict[str, str]] = []
Expand Down
7 changes: 7 additions & 0 deletions docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ The [headless Core CI](../.github/workflows/ci.yml) runs every
- Ubuntu + Python 3.12
- Ubuntu + Python 3.13
- Windows + Python 3.12
- Ubuntu + Python 3.14
- Windows + Python 3.14
- macOS arm64 + Python 3.14

Separate required jobs exercise Linux PID-namespace ownership and native macOS
arm64 process lifecycle on Python 3.12 and 3.13. The Python 3.14 matrix legs also
install and inspect the built wheel outside the checkout.

This is a **single selected contract suite**, not a filtered invocation that
silently ignores newly added files. Regression failures block the PR.
Expand Down
77 changes: 77 additions & 0 deletions docs/audits/2026-12-01/core-second-pass.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Core independent second pass — 2026-12-01

Baseline: `be67725766106529a2d9fdd76cd0abad617326f9`.
This checkpoint supplements the earlier [Core boundary audit](core-boundaries.md).
It records source fixes and local verification, not publication or installed
release acceptance.

## Reproduced findings

| ID | Priority | Reproducer and scope | Correction |
| --- | --- | --- | --- |
| C01 | P1 | The public `migration_research.collect` helper accepted `--include-osv` for a host-private package and dispatched its identity to the public lookup callback. Public release intelligence also ignored the host's external-evidence restriction for an ordinary public package. Calls were intercepted with synthetic names; no private data was transmitted. | Optional public research and release lookups now check the union of Core and MCP host restrictions before transport or evidence reuse. A private package, malformed scope policy or restricted host produces an explicit unavailable/unknown reason. |
| C02 | P1 | Generic text/JSON helpers selected `GITHUB_TOKEN` / `GH_TOKEN` by a substring anywhere in the URL. A non-GitHub URL containing `github` or `api.github.com` received the synthetic bearer header. The helpers also inherited registry authentication, cookies, query parameters, custom headers and client certificates when fetching public release information. Current release-building code constructs canonical GitHub URLs, so the substring reproducer establishes a generic helper defect, not an asserted remote exploit through current registry metadata. | GitHub bearer headers require an exact allowed HTTPS hostname on the default port without user information. Public evidence uses an independent session. Configured proxy routing and CA verification remain available; registry identity, client certificates and implicit netrc authentication do not transfer to public sources. Responses and temporary sessions are closed. |
| C03 | P2 | `refine_transition_safe_groups` reported `safe=True` for an unchanged target forbidden by `USER_BASELINE_REQUIRED_UPDATE` or `USER_EXACT_TARGET`. Normal planner callers use solver-validated targets, so this is a public transition API boundary defect. | Validate the complete final assignment before applying exceptions that permit the recorded baseline to predate a required change. Existing out-of-domain diagnostics and the explicit unsupported-cardinality result remain intact. |
| C04 | P3 | The test guide listed only three of the six configured general CI profiles. | List all current profiles and the separate ownership jobs. |

The public evidence policy covers `DEPLOOM_DRAFT_PRIVATE_SCOPES`,
`DEPLOOM_MCP_PRIVATE_SCOPES`, `DEPLOOM_DRAFT_DISABLE_EXTERNAL_EVIDENCE`,
`DEPLOOM_MCP_DISABLE_EXTERNAL_EVIDENCE`, `DEPLOOM_MCP_LOCAL_CACHE_ONLY`, and
`DEPLOOM_MCP_RECORDS_MIRROR_ONLY`. A public-research option selects a lookup; it
cannot override host restrictions. As in the previous audit, migration-only
and knowledge-only flags retain their separate meanings.

## Verification

Environment: Linux, CPython **3.13.5**, Node **24.22.3**. Dependencies were
installed with hash enforcement from the unchanged npm POSIX runtime lock,
SHA-256 `8d8bc412c46bf89d30af602e9664530f754e4558b7dddfee2600c4732d60accd`.

The new policy, credential-origin and unchanged-target tests were exercised
against the baseline before implementing their fixes. They reproduced the
described failures using intercepted transports and synthetic credentials.
The final tests also use a real loopback HTTP receiver to confirm that a URL
whose path contains GitHub's name receives neither a GitHub token nor registry
identity. Allowed GitHub origins, unrestricted explicit public research,
approved private metadata routes, proxy/CA transport settings, valid solved
targets and current versions outside the final domain remain covered.

The final focused command covers **42 passing tests**:

```bash
python -m unittest tests.test_required_transition tests.test_peer_solver_transition tests.test_public_evidence_policy tests.test_manual_audit_host_policy tests.test_registry_privacy tests.test_private_metadata_routing -v
```

The complete suite was run before and after the changes without filtering:

| Checkout | Tests executed | Failures | Errors | Skips |
| --- | ---: | ---: | ---: | ---: |
| Baseline | 849 | 6 | 11 | 95 |
| Corrected source | 858 | 6 | 11 | 95 |

The failing test/subtest identities are identical. Their native preparation,
semver and process-lifecycle operations remain blocked by
`PROCESS_TREE_OWNERSHIP_UNAVAILABLE` because this host does not expose the
required `/proc/self/task/<pid>/children` interface. A separate 97-test
integration selection covering OSV evidence, registry identity/context,
explicit targets and process supervision likewise had only the six known
native ownership errors, with one platform skip.

This is **not a green full-suite result**. No process guard, dependency hash,
test or CI profile was weakened. Native CI must verify the eventual commit on
its configured platforms, followed by any required consumer pin and release
acceptance.

## Further improvements

1. Centralize optional evidence transport and host-policy admission across
standalone helpers so a new helper cannot accidentally omit the boundary.
2. Keep public evidence and private registry credentials in separate transport
objects by construction; add cross-component transport-admission checks to
installed consumer qualification.
3. Break the large planning module into separately testable metadata,
evidence, model-extraction and publication components while preserving the
current exported API and exact acceptance fixtures.
4. Continue recording source, consumer pin, signed package publication and
ordinary installed acceptance as different states; a merged Core fix is
not proof that the published CLI contains it.
5 changes: 5 additions & 0 deletions migration_research.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

import argparse
import json
import os
import re
import queue
import threading
from urllib.parse import urlsplit, quote
import requests

from planning_cache import cached_query
from registry_privacy import public_evidence_block_reason

MAX_RESPONSE = 2 * 1024 * 1024

Expand Down Expand Up @@ -62,6 +64,9 @@ def github_repository(value):
def collect(package, before, after, *, repository="", include_osv=False, fetch=_public_json, root=None):
result = {"schemaVersion": 1, "package": package, "from": before, "to": after,
"authority": "guidance-only", "unknown": [], "releases": []}
if reason := public_evidence_block_reason(os.environ, package):
result["unknown"].append(reason)
return result
repo = github_repository(repository)
if repo:
url = f"https://api.github.com/repos/{repo}/releases?per_page=30"
Expand Down
5 changes: 5 additions & 0 deletions peer_solver_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ def refine_transition_safe_groups(
unresolved=("UNSUPPORTED_TRANSITION_CARDINALITY",),
)

# Final-only obligations may be relaxed for the recorded baseline below,
# but never for the target itself, including an unchanged target.
if issue := model.assignment_issue(target_assignment):
return TransitionSafetyResult(groups=(), unresolved=(f"INVALID_TARGET_ENDPOINT: {issue}",))

union_find = _UnionFind(names)
for group in initial_groups or ():
members = sorted(set(group) & expected)
Expand Down
28 changes: 24 additions & 4 deletions registry_privacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import re

_SCOPE_NAME = re.compile(r"[a-zA-Z0-9][a-zA-Z0-9_.~-]{0,213}")
_NETWORK_POLICY_FLAGS = (
"DEPLOOM_DRAFT_DISABLE_EXTERNAL_EVIDENCE", "DEPLOOM_MCP_DISABLE_EXTERNAL_EVIDENCE",
"DEPLOOM_MCP_LOCAL_CACHE_ONLY", "DEPLOOM_MCP_RECORDS_MIRROR_ONLY",
)


@lru_cache(maxsize=16)
Expand Down Expand Up @@ -33,6 +37,25 @@ def private_package(package: str, private_scopes: str) -> bool:
return True


def public_evidence_block_reason(host_environment, package: str | None = None) -> str:
"""Admit optional public evidence only within the host's network policy.

CLI options can select a public lookup; they cannot override private scopes
or a restricted host. Both Core and MCP spellings remain restrictions.
"""
scopes = set()
for key in ("DEPLOOM_DRAFT_PRIVATE_SCOPES", "DEPLOOM_MCP_PRIVATE_SCOPES"):
try:
scopes.update(normalize_private_scopes(host_environment.get(key, "")))
except (ValueError, TypeError, AttributeError):
return "INVALID_PRIVATE_SCOPES"
if any(host_environment.get(key) == "1" for key in _NETWORK_POLICY_FLAGS):
return "EXTERNAL_EVIDENCE_DISABLED_BY_HOST_POLICY"
if package is not None and package.partition("/")[0].lower() in scopes:
return "PRIVATE_SCOPE_EXCLUDED"
return ""


def standalone_audit_block_reason(host_environment, runtime_environment=None) -> str:
"""The standalone helper cannot enforce a guarded native audit route.

Expand All @@ -47,9 +70,6 @@ def standalone_audit_block_reason(host_environment, runtime_environment=None) ->
has_private_scopes = bool(normalize_private_scopes(environment.get(key, ""))) or has_private_scopes
except (ValueError, TypeError, AttributeError):
return "INVALID_PRIVATE_SCOPES"
if any(environment.get(key) == "1" for environment in environments for key in (
"DEPLOOM_DRAFT_DISABLE_EXTERNAL_EVIDENCE", "DEPLOOM_MCP_DISABLE_EXTERNAL_EVIDENCE",
"DEPLOOM_MCP_LOCAL_CACHE_ONLY", "DEPLOOM_MCP_RECORDS_MIRROR_ONLY",
)):
if any(environment.get(key) == "1" for environment in environments for key in _NETWORK_POLICY_FLAGS):
return "NETWORK_POLICY_REQUIRES_GUARDED_AUDIT"
return "PRIVATE_SCOPE_POLICY_REQUIRES_GUARDED_AUDIT" if has_private_scopes else ""
Loading
Loading