clustermax 0.3.1.dev2026110271__tar.gz → 0.3.1.dev2026110372__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.
Files changed (88) hide show
  1. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/PKG-INFO +1 -1
  2. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/PKG-INFO +1 -1
  3. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/SOURCES.txt +2 -0
  4. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/obs_discovery.py +54 -1
  5. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/audit-common.sh +44 -0
  6. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/audit_findings.py +42 -2
  7. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/fabric/nic-topology-check.py +92 -1
  8. clustermax-0.3.1.dev2026110372/cmax/scripts/1-audit/checks/fabric/vf-interface-exposure.py +348 -0
  9. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-k8s.sh +45 -18
  10. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-slurm-security.sh +68 -7
  11. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-slurm.sh +1 -0
  12. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-standalone.sh +1 -0
  13. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/host-check.sh +82 -18
  14. clustermax-0.3.1.dev2026110372/cmax/scripts/1-audit/host_fleet.py +229 -0
  15. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/merge_audit.py +86 -0
  16. clustermax-0.3.1.dev2026110372/cmax/scripts/1-audit/pwnescape-host-facts.sh +219 -0
  17. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/pwnescape.py +97 -0
  18. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/run_checks.py +7 -0
  19. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/security.py +251 -30
  20. clustermax-0.3.1.dev2026110271/cmax/scripts/1-audit/pwnescape-host-facts.sh +0 -98
  21. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/LICENSE +0 -0
  22. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/README.md +0 -0
  23. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/dependency_links.txt +0 -0
  24. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/entry_points.txt +0 -0
  25. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/requires.txt +0 -0
  26. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/clustermax.egg-info/top_level.txt +0 -0
  27. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/__init__.py +0 -0
  28. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/_version.py +0 -0
  29. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/audit_profiles.py +0 -0
  30. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/audit_report.py +0 -0
  31. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/audit_review.py +0 -0
  32. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/audit_runner.py +0 -0
  33. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/banner.py +0 -0
  34. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/cli.py +0 -0
  35. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/cmax.yaml +0 -0
  36. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/criteria_links.py +0 -0
  37. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/host_role.py +0 -0
  38. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/logo.py +0 -0
  39. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/minimum_links.py +0 -0
  40. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/minimum_refresh.py +0 -0
  41. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/minimum_sync.py +0 -0
  42. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/obs_check.py +0 -0
  43. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/progress.py +0 -0
  44. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/report_style.py +0 -0
  45. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/runtime_paths.py +0 -0
  46. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/bad_epoll.py +0 -0
  47. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/_fanout.py +0 -0
  48. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/fabric/nccl-ib-qps-check.py +0 -0
  49. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/fabric/nccl-topology-file-check.py +0 -0
  50. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/fabric/virtio-net-check.py +0 -0
  51. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/gpu/vboost.py +0 -0
  52. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/platform_config.py +0 -0
  53. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/arm-smmu-virtualization-check.py +0 -0
  54. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/hbm_memory_exposure.py +0 -0
  55. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/hugepages.py +0 -0
  56. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/k8s_scheduling.py +0 -0
  57. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/kubernetes_nodes_proxy.py +0 -0
  58. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/storage_config.py +0 -0
  59. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/tenant_pod_defaults.py +0 -0
  60. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/checks/system/vm-iommu-check.py +0 -0
  61. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-k8s-security.sh +0 -0
  62. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/cluster-audit-standalone-security.sh +0 -0
  63. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/container-check.sh +0 -0
  64. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/criteria-checks.json +0 -0
  65. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/gpu_profiles.py +0 -0
  66. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/k8s-control.sh +0 -0
  67. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/k8s_runtime_software.py +0 -0
  68. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/kubernetes_quantities.py +0 -0
  69. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/minimum-versions.json +0 -0
  70. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/minimum_versions.py +0 -0
  71. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/monitoring-k8s.sh +0 -0
  72. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/plan_audit.py +0 -0
  73. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/run.sh +0 -0
  74. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/run_legacy_audit.py +0 -0
  75. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/security_fleet.py +0 -0
  76. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/security_version_audit.py +0 -0
  77. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/ubuntu_kernel_cves.py +0 -0
  78. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/scripts/1-audit/validate_audit.py +0 -0
  79. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/target_selection.py +0 -0
  80. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/cmax/yaml_support.py +0 -0
  81. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/pyproject.toml +0 -0
  82. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/setup.cfg +0 -0
  83. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/setup.py +0 -0
  84. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/tests/test_host_isolation.py +0 -0
  85. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/tests/test_minimum_pages.py +0 -0
  86. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/tests/test_nightly_version.py +0 -0
  87. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/tests/test_select_tests.py +0 -0
  88. {clustermax-0.3.1.dev2026110271 → clustermax-0.3.1.dev2026110372}/tests/test_stable_release.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clustermax
3
- Version: 0.3.1.dev2026110271
3
+ Version: 0.3.1.dev2026110372
4
4
  Summary: ClusterMAX GPU cluster audit and security CLI
5
5
  Author: SemiAnalysis
6
6
  Maintainer: SemiAnalysis
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clustermax
3
- Version: 0.3.1.dev2026110271
3
+ Version: 0.3.1.dev2026110372
4
4
  Summary: ClusterMAX GPU cluster audit and security CLI
5
5
  Author: SemiAnalysis
6
6
  Maintainer: SemiAnalysis
@@ -44,6 +44,7 @@ cmax/scripts/1-audit/container-check.sh
44
44
  cmax/scripts/1-audit/criteria-checks.json
45
45
  cmax/scripts/1-audit/gpu_profiles.py
46
46
  cmax/scripts/1-audit/host-check.sh
47
+ cmax/scripts/1-audit/host_fleet.py
47
48
  cmax/scripts/1-audit/k8s-control.sh
48
49
  cmax/scripts/1-audit/k8s_runtime_software.py
49
50
  cmax/scripts/1-audit/kubernetes_quantities.py
@@ -66,6 +67,7 @@ cmax/scripts/1-audit/checks/platform_config.py
66
67
  cmax/scripts/1-audit/checks/fabric/nccl-ib-qps-check.py
67
68
  cmax/scripts/1-audit/checks/fabric/nccl-topology-file-check.py
68
69
  cmax/scripts/1-audit/checks/fabric/nic-topology-check.py
70
+ cmax/scripts/1-audit/checks/fabric/vf-interface-exposure.py
69
71
  cmax/scripts/1-audit/checks/fabric/virtio-net-check.py
70
72
  cmax/scripts/1-audit/checks/gpu/vboost.py
71
73
  cmax/scripts/1-audit/checks/system/arm-smmu-virtualization-check.py
@@ -29,9 +29,10 @@ from __future__ import annotations
29
29
  import json
30
30
  import re
31
31
  import shutil
32
+ import socket
32
33
  import subprocess
33
34
  import urllib.parse
34
- from collections.abc import Iterable, Mapping, Sequence
35
+ from collections.abc import Callable, Iterable, Mapping, Sequence
35
36
  from typing import NamedTuple
36
37
 
37
38
  # Default query/user-interface ports of multi-tenant metrics backends. A port
@@ -145,6 +146,58 @@ class Endpoint(NamedTuple):
145
146
  url: str
146
147
  platform: str
147
148
  source: str
149
+ reason: str | None = None
150
+
151
+
152
+ def _host_resolves(host: str) -> bool:
153
+ """True when getaddrinfo can resolve the host from this vantage.
154
+
155
+ A Service name such as `dcgm-exporter.default.svc.cluster.local` resolves only
156
+ inside the cluster network. A short name or an operator-host vantage may
157
+ never resolve it. The question is reachability of the name, not the service.
158
+ """
159
+ try:
160
+ socket.getaddrinfo(host, None)
161
+ except (OSError, UnicodeError):
162
+ return False
163
+ return True
164
+
165
+
166
+ def split_unassessed(
167
+ endpoints: Iterable[Endpoint],
168
+ resolver: Callable[[str], bool] | None = None,
169
+ ) -> tuple[list[Endpoint], list[Endpoint]]:
170
+ """Split discovered endpoints into checkable and unassessable from here.
171
+
172
+ A Service name that the current host cannot resolve was never measured.
173
+ It is not a pass, and it is not unreachable, so it is reported separately.
174
+ Each distinct host is resolved at most once, because a failed lookup costs
175
+ seconds and the same Service can appear more than once.
176
+ """
177
+ if resolver is None:
178
+ resolver = _host_resolves
179
+ checkable: list[Endpoint] = []
180
+ unassessed: list[Endpoint] = []
181
+ resolved: dict[str, bool] = {}
182
+ for endpoint in endpoints:
183
+ if endpoint.source != "k8s-services":
184
+ checkable.append(endpoint)
185
+ continue
186
+ host = urllib.parse.urlsplit(endpoint.url).hostname or ""
187
+ if host not in resolved:
188
+ resolved[host] = bool(resolver(host))
189
+ if resolved[host]:
190
+ checkable.append(endpoint)
191
+ else:
192
+ unassessed.append(
193
+ endpoint._replace(
194
+ reason=(
195
+ "Kubernetes Service name did not resolve from the "
196
+ "operator host"
197
+ )
198
+ )
199
+ )
200
+ return checkable, unassessed
148
201
 
149
202
 
150
203
  class Discovery(NamedTuple):
@@ -133,6 +133,50 @@ minimum_version_grace() {
133
133
  fi
134
134
  }
135
135
 
136
+ # nvidia_driver_floors - print the NVIDIA driver branch floors that the
137
+ # minimum version table publishes, as "branch=floor" entries ordered by
138
+ # branch.
139
+ #
140
+ # The streamed host and pod checks cannot read the table, so the collector
141
+ # resolves the floors once and injects them into the check (the same delivery
142
+ # host_check_stdin uses for the kernel ABI minimums). An empty output means the
143
+ # policy could not be read, and the check must report an unknown verdict rather
144
+ # than grade against a guessed floor. Any malformed branch or floor fails the
145
+ # whole read: a partially valid table would grade its listed branches while
146
+ # silently dropping the rest, so the policy is all or nothing.
147
+ nvidia_driver_floors() {
148
+ local branches=""
149
+ if [[ -f "$MINIMUM_VERSIONS_READER" ]] && command -v python3 >/dev/null 2>&1; then
150
+ branches=$(python3 "$MINIMUM_VERSIONS_READER" --get components.nvidiaDriver.branches 2>/dev/null) || branches=""
151
+ fi
152
+ [[ -n "$branches" ]] || return 0
153
+ printf '%s\n' "$branches" | python3 -c '
154
+ import json
155
+ import sys
156
+
157
+ try:
158
+ doc = json.load(sys.stdin)
159
+ except ValueError:
160
+ sys.exit(1)
161
+ if not isinstance(doc, dict) or not doc:
162
+ sys.exit(1)
163
+ floors = {}
164
+ for branch, floor in doc.items():
165
+ text_branch = str(branch)
166
+ text_floor = str(floor)
167
+ parts = text_floor.split(".")
168
+ if (
169
+ not text_branch.isdigit()
170
+ or len(parts) < 2
171
+ or not all(part.isdigit() for part in parts)
172
+ or parts[0] != text_branch
173
+ ):
174
+ sys.exit(1)
175
+ floors[int(text_branch)] = text_floor
176
+ print(" ".join(f"{branch}={floors[branch]}" for branch in sorted(floors)))
177
+ ' 2>/dev/null || return 0
178
+ }
179
+
136
180
  # grade_ubuntu_kernel_cves - grade the running Ubuntu kernel against the exact
137
181
  # tracker state for each container-relevant CVE that the minimum table
138
182
  # publishes. ubuntu_kernel_cves.py selects the table row whose kernel family and
@@ -869,6 +869,13 @@ RULES: tuple[Rule, ...] = (
869
869
  harnesses=SCALE_OUT_HARNESSES,
870
870
  ),
871
871
  # --- Hypervisor security bulletins ----------------------------------
872
+ Rule(
873
+ "security.januscape.status",
874
+ "Nested virtualization exposes Januscape prerequisites on a fleet host",
875
+ VERSION,
876
+ _status_is("fail"),
877
+ cves=("CVE-2026-53359",),
878
+ ),
872
879
  Rule(
873
880
  "security.januscape.status",
874
881
  "Nested virtualization exposes Januscape prerequisites",
@@ -883,6 +890,13 @@ RULES: tuple[Rule, ...] = (
883
890
  _status_is("unknown"),
884
891
  cves=("CVE-2026-53359",),
885
892
  ),
893
+ Rule(
894
+ "security.januscape.status",
895
+ "Fleet coverage is incomplete for the Januscape exposure check",
896
+ CONFIG,
897
+ _status_is("coverage-incomplete"),
898
+ cves=("CVE-2026-53359",),
899
+ ),
886
900
  Rule(
887
901
  "security.guestKernel.newerInstalled",
888
902
  "Newer guest/worker kernel installed but not running; reboot required",
@@ -914,6 +928,13 @@ RULES: tuple[Rule, ...] = (
914
928
  _status_is("fail"),
915
929
  cves=("CVE-2026-46300", "CVE-2026-43284", "CVE-2026-43500"),
916
930
  ),
931
+ Rule(
932
+ "security.fragnesia.status",
933
+ "Fleet coverage is incomplete for the Fragnesia / Dirty Frag check",
934
+ CONFIG,
935
+ _status_is("coverage-incomplete"),
936
+ cves=("CVE-2026-46300", "CVE-2026-43284", "CVE-2026-43500"),
937
+ ),
917
938
  Rule(
918
939
  "security.badEpoll.status",
919
940
  "Running kernel is below the Bad Epoll fixed package minimum; update and reboot",
@@ -1845,9 +1866,15 @@ def _finding_guidance(
1845
1866
  component_name = _COMPONENT_NAMES.get(component, component)
1846
1867
  if (
1847
1868
  rule.key == "security.januscape.status"
1848
- and str(value).strip().lower() == "host-patch-required"
1869
+ and str(value).strip().lower() in {"host-patch-required", "fail"}
1849
1870
  ):
1850
- detected = "Nested virtualization prerequisites are exposed"
1871
+ payload = nested_get(audit, "security", "januscape", default={})
1872
+ reason = str(payload.get("reason") or "").strip()
1873
+ detected = (
1874
+ reason
1875
+ if str(value).strip().lower() == "fail" and reason
1876
+ else "Nested virtualization prerequisites are exposed"
1877
+ )
1851
1878
  recommendation = (
1852
1879
  "Disable nested virtualization and remove guest access to /dev/kvm "
1853
1880
  "until the provider confirms the physical-host patch."
@@ -2060,6 +2087,19 @@ def _finding_guidance(
2060
2087
  "host that the audit could not read, including managed "
2061
2088
  "control-plane hosts."
2062
2089
  )
2090
+ elif rule.key == "security.pwnescape.status":
2091
+ block = nested_get(audit, "security", "pwnescape", default={})
2092
+ reason = block.get("reason") if isinstance(block, dict) else None
2093
+ detected = str(value).replace("_", " ").capitalize()
2094
+ recommendation = str(reason) if reason else ""
2095
+ if "source package version" not in recommendation.lower():
2096
+ recommendation = (
2097
+ (recommendation + " " if recommendation else "")
2098
+ + "Ask the provider for the distribution, kernel flavor and "
2099
+ "ABI, the source package version that built the kernel, the "
2100
+ "CVE fix, and the livepatch state, because the upstream "
2101
+ "version alone does not settle a vendor kernel."
2102
+ )
2063
2103
  else:
2064
2104
  detected = str(value).replace("_", " ").capitalize()
2065
2105
  if "reboot required" in rule.title.lower():
@@ -488,6 +488,43 @@ def parse_lldp(text: str) -> dict:
488
488
  return fields
489
489
 
490
490
 
491
+ def parse_pkey_table(entries: list[str]) -> list[str]:
492
+ """Normalize non-empty sysfs PKey slots to lowercase 0xNNNN strings.
493
+
494
+ Only populated slots matter: 0x0000 marks an empty table row. A full
495
+ membership key has the high bit set (0x8000); a limited membership key
496
+ leaves it clear. The caller keeps the raw value so the partition policy
497
+ stays visible without a second read.
498
+ """
499
+ out: list[str] = []
500
+ for entry in entries:
501
+ value = (entry or "").strip().lower()
502
+ if not value or value in {"0x0000", "0x0"}:
503
+ continue
504
+ if not value.startswith("0x"):
505
+ try:
506
+ value = f"{int(value, 16):#06x}"
507
+ except ValueError:
508
+ continue
509
+ out.append(value)
510
+ return out
511
+
512
+
513
+ def parse_fabric_facts(lid: str, sm_lid: str, pkey_entries: list[str]) -> dict:
514
+ """SM and partition facts that a tenant can read from IB port sysfs."""
515
+ facts: dict[str, Any] = {}
516
+ lid = (lid or "").strip().lower()
517
+ sm_lid = (sm_lid or "").strip().lower()
518
+ if lid:
519
+ facts["lid"] = lid
520
+ if sm_lid:
521
+ facts["smLid"] = sm_lid
522
+ pkeys = parse_pkey_table(pkey_entries)
523
+ if pkeys:
524
+ facts["pkeys"] = pkeys
525
+ return facts
526
+
527
+
491
528
  def parse_ibnetdiscover(text: str, node_guid: str, host: str) -> dict:
492
529
  """Per-plane neighbor summary from `ibnetdiscover -C <dev> -p`.
493
530
 
@@ -528,6 +565,7 @@ def evidence_from_raw(
528
565
  *,
529
566
  node_guid: str = "",
530
567
  host: str = "",
568
+ fabric: dict[str, Any] | None = None,
531
569
  ) -> dict:
532
570
  """Assemble one HCA's tri-state evidence record from raw tool outputs.
533
571
 
@@ -536,6 +574,8 @@ def evidence_from_raw(
536
574
  orchestrator so both paths emit identical shapes.
537
575
  """
538
576
  record: dict[str, Any] = {"ibdev": dev, "port": parse_port_attrs(rate_raw)}
577
+ if fabric:
578
+ record["fabric"] = fabric
539
579
  record["mlxconfig"] = _tri(*raws.get("mlxconfig", ("", "not attempted")), parse_mlxconfig)
540
580
  record["mlxlink"] = _tri(*raws.get("mlxlink", ("", "not attempted")), parse_mlxlink)
541
581
 
@@ -577,6 +617,25 @@ def evidence_from_raw(
577
617
  return record
578
618
 
579
619
 
620
+ def _read_fabric_facts(sysfs_root: str, dev: str) -> dict | None:
621
+ """SM and partition facts from IB port sysfs, without touching UMAD.
622
+
623
+ ``sminfo``, ``perfquery`` and ``ibnetdiscover`` all need a UMAD
624
+ registration, which a tenant pod can be denied. The same SM LID and PKey
625
+ table are plain sysfs reads, so the evidence survives that boundary.
626
+ """
627
+ base = f"{sysfs_root}/{dev}/ports/1"
628
+ entries: list[str] = []
629
+ for path in sorted(glob.glob(f"{base}/pkeys/*")):
630
+ try:
631
+ entries.append(_read_sysfs(path))
632
+ except OSError:
633
+ continue
634
+ return parse_fabric_facts(
635
+ _read_sysfs(f"{base}/lid"), _read_sysfs(f"{base}/sm_lid"), entries
636
+ ) or None
637
+
638
+
580
639
  def _read_sysfs(path: str) -> str:
581
640
  try:
582
641
  return open(path).read().strip()
@@ -615,12 +674,14 @@ def collect_plane_evidence(
615
674
  continue
616
675
  dev = nic["name"]
617
676
  rate_raw = _read_sysfs(f"{sysfs_root}/{dev}/ports/1/rate")
677
+ fabric = _read_fabric_facts(sysfs_root, dev) if nic.get("layer") == "InfiniBand" else None
618
678
  if time_fn() - started > budget_s:
619
679
  record = evidence_from_raw(
620
680
  dev,
621
681
  nic.get("layer", "?"),
622
682
  rate_raw,
623
683
  {tool: ("", "budget exhausted") for tool in ("mlxconfig", "mlxlink", "ibnetdiscover", "lldp")},
684
+ fabric=fabric,
624
685
  )
625
686
  out.append(record)
626
687
  continue
@@ -646,7 +707,8 @@ def collect_plane_evidence(
646
707
  raws["lldp"] = ("", "no netdev exposed for this HCA")
647
708
  out.append(
648
709
  evidence_from_raw(
649
- dev, nic.get("layer", "?"), rate_raw, raws, node_guid=node_guid, host=host
710
+ dev, nic.get("layer", "?"), rate_raw, raws,
711
+ node_guid=node_guid, host=host, fabric=fabric,
650
712
  )
651
713
  )
652
714
  return out
@@ -1070,6 +1132,18 @@ for d in /sys/class/infiniband/*; do
1070
1132
  checked=$((checked+1))
1071
1133
  g=$(cat "$d/node_guid" 2>/dev/null)
1072
1134
  printf '@@PLANEGUID@@\t%s\t%s\n' "$n" "$g"
1135
+ # SM and PKey facts are plain sysfs reads, so they survive the UMAD denial
1136
+ # that makes sminfo / perfquery / ibnetdiscover unusable in a system pod.
1137
+ lid=$(cat "$d/ports/1/lid" 2>/dev/null)
1138
+ smlid=$(cat "$d/ports/1/sm_lid" 2>/dev/null)
1139
+ pk=""
1140
+ for pf in "$d"/ports/1/pkeys/*; do
1141
+ [ -e "$pf" ] || continue
1142
+ v=$(cat "$pf" 2>/dev/null)
1143
+ case "$v" in ""|0x0000|0X0000) continue;; esac
1144
+ pk="${pk:+$pk,}$v"
1145
+ done
1146
+ printf '@@PORT@@\t%s\t%s\t%s\t%s\n' "$n" "$lid" "$smlid" "$pk"
1073
1147
  l=$(cat "$d/ports/1/link_layer" 2>/dev/null)
1074
1148
  # Renamed ibdevs (for example rail0) do not resolve in the mlx tools; the
1075
1149
  # PCI function does.
@@ -1140,6 +1214,21 @@ def _k8s_rate_raws(text: str) -> dict[str, str]:
1140
1214
  return raws
1141
1215
 
1142
1216
 
1217
+ def _parse_k8s_ports(text: str) -> dict[str, dict]:
1218
+ """Parse @@PORT@@ lines (dev, LID, SM LID, populated PKeys) into facts."""
1219
+ ports: dict[str, dict] = {}
1220
+ for line in text.splitlines():
1221
+ if not line.startswith("@@PORT@@\t"):
1222
+ continue
1223
+ parts = line.split("\t")
1224
+ if len(parts) < 5:
1225
+ continue
1226
+ facts = parse_fabric_facts(parts[2], parts[3], parts[4].split(","))
1227
+ if facts:
1228
+ ports[parts[1]] = facts
1229
+ return ports
1230
+
1231
+
1143
1232
  def _parse_k8s_plane(text: str) -> tuple[dict[str, dict[str, tuple[str, str | None]]], dict[str, str]]:
1144
1233
  """Parse @@PLANE@@ / @@PLANEGUID@@ blocks from K8S_COLLECTOR_SH output.
1145
1234
 
@@ -1241,6 +1330,7 @@ def run_k8s_node_check(
1241
1330
  record["topo_error"] = "no output"
1242
1331
  plane_raws, plane_guids = _parse_k8s_plane(proc.stdout)
1243
1332
  rate_raws = _k8s_rate_raws(proc.stdout)
1333
+ ports = _parse_k8s_ports(proc.stdout)
1244
1334
  evidence = [
1245
1335
  evidence_from_raw(
1246
1336
  nic["name"],
@@ -1249,6 +1339,7 @@ def run_k8s_node_check(
1249
1339
  plane_raws.get(nic["name"], {}),
1250
1340
  node_guid=plane_guids.get(nic["name"], ""),
1251
1341
  host=node,
1342
+ fabric=ports.get(nic["name"]),
1252
1343
  )
1253
1344
  for nic in record["nics"]
1254
1345
  if plane_candidate(nic)