49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""
|
|
CIS Debian Linux 13 Benchmark v1.0.0.
|
|
|
|
The benchmark object is built lazily — call debian.load(xlsx_path) before
|
|
running any checks. This avoids requiring the XLSX on systems that only
|
|
run (not build) the auditor.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from ..base import BenchmarkInfo
|
|
|
|
_benchmark: Optional[BenchmarkInfo] = None
|
|
_loaded_from: Optional[Path] = None
|
|
|
|
|
|
def load(xlsx_path: str | Path) -> BenchmarkInfo:
|
|
"""Parse the Debian benchmark XLSX and return (and cache) the BenchmarkInfo."""
|
|
global _benchmark, _loaded_from
|
|
xlsx_path = Path(xlsx_path)
|
|
|
|
if _benchmark is not None and _loaded_from == xlsx_path:
|
|
return _benchmark
|
|
|
|
from .loader import load_benchmark
|
|
registry, by_profile, profiles = load_benchmark(xlsx_path)
|
|
|
|
_benchmark = BenchmarkInfo(
|
|
name="CIS Debian Linux 13 Benchmark",
|
|
version="v1.0.0",
|
|
profiles=profiles,
|
|
checks_by_profile=by_profile,
|
|
check_registry=registry,
|
|
)
|
|
_loaded_from = xlsx_path
|
|
return _benchmark
|
|
|
|
|
|
# Expose as module-level 'benchmark' only after load() is called
|
|
def __getattr__(name: str):
|
|
if name == "benchmark":
|
|
if _benchmark is None:
|
|
raise RuntimeError(
|
|
"Debian benchmark not loaded yet. Call debian.load(xlsx_path) first."
|
|
)
|
|
return _benchmark
|
|
raise AttributeError(name)
|