Perform harvest validation before trying to manifest from it
This commit is contained in:
parent
706604df74
commit
5ffd4ee755
2 changed files with 10 additions and 5 deletions
|
|
@ -12,6 +12,7 @@
|
|||
* Support for detecting Docker and Podman images and enforcing their presence (by SHA256 hash).
|
||||
* Add support for detecting Flatpaks and Snaps.
|
||||
* Stricter validation of harvests to ensure that they meet the schema and don't contain unsafe artifacts (e.g symlinks pointing outside the artifact tree)
|
||||
* Perform harvest validation before trying to manifest from it.
|
||||
|
||||
# 0.6.0
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from .sopsutil import (
|
|||
encrypt_file_binary,
|
||||
require_sops_cmd,
|
||||
)
|
||||
from .validate import validate_harvest
|
||||
|
||||
|
||||
def _prepare_bundle_dir(
|
||||
|
|
@ -203,6 +204,14 @@ def manifest(
|
|||
|
||||
td_out: Optional[tempfile.TemporaryDirectory] = None
|
||||
try:
|
||||
validation = validate_harvest(resolved_bundle_dir)
|
||||
if not validation.ok:
|
||||
raise RuntimeError(
|
||||
"harvest state does not match this Enroll version's schema; "
|
||||
"please re-harvest the host with this version of Enroll.\n"
|
||||
+ validation.to_text().strip()
|
||||
)
|
||||
|
||||
if not sops_mode:
|
||||
if target == "puppet":
|
||||
manifest_puppet_from_bundle_dir(
|
||||
|
|
@ -235,11 +244,6 @@ def manifest(
|
|||
|
||||
td_out = tempfile.TemporaryDirectory(prefix="enroll-manifest-")
|
||||
tmp_out = Path(td_out.name) / "out"
|
||||
tmp_out.mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
os.chmod(tmp_out, 0o700)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if target == "puppet":
|
||||
manifest_puppet_from_bundle_dir(
|
||||
|
|
|
|||
Reference in a new issue