Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7649a775de | ||
|
|
a60a33012b |
@@ -105,6 +105,9 @@ class CommandRunner:
|
||||
stdout=staged,
|
||||
stderr=subprocess.DEVNULL,
|
||||
shell=False,
|
||||
# Resolve bare executables via the OS default path and
|
||||
# exclude ambient credentials and runtime overrides.
|
||||
env={"PATH": os.defpath, "LC_ALL": "C"},
|
||||
start_new_session=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# ABSDEV-CI command environment and credential rotation
|
||||
|
||||
ABSDEV-CI qualified commit `a60a33012be7f5cfb7062c47f8706f9216f3405a`. All 16 qualification checks and 898 framework tests passed.
|
||||
|
||||
The command runner excludes ambient credentials and runtime overrides. Disposable MySQL and PostgreSQL clients authenticated using owner-only files. Missing, world-writable and retired credential files failed authentication. Atomic replacement restored authentication after server-side rotation. The qualification removed both containers and their disposable volumes.
|
||||
|
||||
Production execution remained disabled. This evidence covers the disposable credential-file workflow. Production secret delivery remains unqualified.
|
||||
@@ -0,0 +1,8 @@
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-after.json
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-before.json
|
||||
13929b9643b7138f61b0944e2a6cb18b3f19208e53c2f279dd63b2a06893d752 ./checks.jsonl
|
||||
25c26158a66f1f284b83ec26de1a554fb10a7d8ee4e57a351e211a8313d484ed ./framework-ci.txt
|
||||
9e5008fb18bbbe95a2c54b0dbb327bb57804ce2faf34863105ce8ab326f3a437 ./scope.txt
|
||||
36e510bef6e2627c790206650688dc8148ecd486340a8a75e1aff439c22bd7cf probe.py
|
||||
4ad1a4783d14024047ff7638ae1cba27a1aeec2bcf971d7387aa1728fc25548c run.sh
|
||||
6c44598e7812f4bd454814cc863c20e676f5195bf1bd5347088255996fa4f0c7 README.md
|
||||
@@ -0,0 +1,16 @@
|
||||
{"engine": "framework", "result": "PASS", "check": "approved child receives fixed PATH and locale only"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "disposable container has no external network, host mounts or published ports"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "missing credential file rejects authentication without publishing output"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "adapter authenticates with mode 0600 credential file and unrelated UID cannot read it"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "database client rejects world-writable credential file"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "old credential file is rejected after server-side rotation"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "atomic credential replacement restores authentication"}
|
||||
{"engine": "mysql", "result": "PASS", "check": "rolling file back to retired credential does not restore access"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "disposable container has no external network, host mounts or published ports"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "missing credential file rejects authentication without publishing output"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "adapter authenticates with mode 0600 credential file and unrelated UID cannot read it"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "database client rejects world-writable credential file"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "old credential file is rejected after server-side rotation"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "atomic credential replacement restores authentication"}
|
||||
{"engine": "pgsql", "result": "PASS", "check": "rolling file back to retired credential does not restore access"}
|
||||
{"engine": "framework", "result": "PASS", "check": "all disposable containers and their anonymous volumes removed"}
|
||||
@@ -0,0 +1,108 @@
|
||||
=== ABSDEV FRAMEWORK CI ===
|
||||
Python 3.14.4
|
||||
|
||||
=== PYTHON SYNTAX VALIDATION ===
|
||||
PASS: 86 Python sources compiled
|
||||
|
||||
=== COMPLETE UNIT REGRESSION SUITE ===
|
||||
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
|
||||
----------------------------------------------------------------------
|
||||
Ran 898 tests in 18.400s
|
||||
|
||||
OK
|
||||
|
||||
=== VERIFY PRODUCTION CAPABILITY RESTRICTIONS ===
|
||||
PASS: production_ready=false
|
||||
PASS: deployment_execution_enabled=false
|
||||
PASS: migration_execution_enabled=false
|
||||
PASS: provisioning_execution_enabled=false
|
||||
PASS: database_restore_enabled=false
|
||||
PASS: permanent_deletion_enabled=false
|
||||
PASS: Unsupported command rejected: deploy
|
||||
PASS: Unsupported command rejected: migrate
|
||||
PASS: Unsupported command rejected: rollback
|
||||
PASS: Unsupported command rejected: restore
|
||||
PASS: Unsupported command rejected: provision
|
||||
PASS: Unsupported command rejected: delete
|
||||
|
||||
=== EXAMPLE CONFIGURATION ===
|
||||
PASS: Configuration valid
|
||||
Site: example-absdev-net
|
||||
Domain: example.absdev.net
|
||||
Database: mysql
|
||||
Schema: 1
|
||||
No deployment performed
|
||||
{
|
||||
"configuration_fingerprint": "8067fa8477a7d50cbcc42b585961bcd4dbce5407fc7e4bffcfb3e07af529e483",
|
||||
"execution_permitted": false,
|
||||
"fingerprint": "d271a3a3ed2cbda032f905558fe9ada653c380c74306fc714ebc594483a63042",
|
||||
"format_version": 1,
|
||||
"runtime_verified": false,
|
||||
"site": "example-absdev-net",
|
||||
"static_policy_verified": true,
|
||||
"status": "VALID"
|
||||
}
|
||||
{
|
||||
"configuration_fingerprint": "8067fa8477a7d50cbcc42b585961bcd4dbce5407fc7e4bffcfb3e07af529e483",
|
||||
"database": {
|
||||
"container": "platform-mysql",
|
||||
"driver": "mysql",
|
||||
"name": "example_db",
|
||||
"username": "example_app"
|
||||
},
|
||||
"database_creation_permitted": false,
|
||||
"directories": [
|
||||
"/opt/laravel-sites/example-absdev-net",
|
||||
"/opt/laravel-sites/example-absdev-net/app",
|
||||
"/opt/laravel-sites/example-absdev-net/app/releases",
|
||||
"/opt/laravel-sites/example-absdev-net/app/shared",
|
||||
"/opt/laravel-sites/example-absdev-net/deployment",
|
||||
"/opt/laravel-sites/example-absdev-net/backups",
|
||||
"/opt/laravel-sites/example-absdev-net/deployment/state",
|
||||
"/opt/laravel-sites/example-absdev-net/deployment/approvals",
|
||||
"/opt/laravel-sites/example-absdev-net/deployment/archives"
|
||||
],
|
||||
"docker": {
|
||||
"networks": [
|
||||
"laravel_backend",
|
||||
"laravel_proxy"
|
||||
],
|
||||
"project": "site-example-absdev-net",
|
||||
"services": [
|
||||
"php",
|
||||
"web",
|
||||
"queue",
|
||||
"scheduler"
|
||||
]
|
||||
},
|
||||
"domain": "example.absdev.net",
|
||||
"execution_permitted": false,
|
||||
"filesystem_permissions_verified": false,
|
||||
"fingerprint": "d8432e17dc1b91ce4712ab656c14c0b5a0957c54700b027b22444dc3a4c19feb",
|
||||
"format_version": 1,
|
||||
"origin_port": 8199,
|
||||
"repository": {
|
||||
"branch": "main",
|
||||
"url": "[email protected]:example/application.git"
|
||||
},
|
||||
"resource_conflicts_checked": false,
|
||||
"retention": {
|
||||
"automatic_deletion": false,
|
||||
"keep_releases": 5
|
||||
},
|
||||
"root": "/opt/laravel-sites/example-absdev-net",
|
||||
"secrets_required": true,
|
||||
"site": "example-absdev-net",
|
||||
"site_policy_fingerprint": "d271a3a3ed2cbda032f905558fe9ada653c380c74306fc714ebc594483a63042",
|
||||
"static_policy_verified": true,
|
||||
"status": "PLAN_ONLY"
|
||||
}
|
||||
|
||||
=== REFERENCE INTEGRITY ===
|
||||
SKIP: Private reference excluded from checkout
|
||||
|
||||
========================================
|
||||
PASS: FRAMEWORK CI
|
||||
UNIT TESTS AND STATIC VALIDATION ONLY
|
||||
DATABASE INTEGRATION NOT EXECUTED
|
||||
========================================
|
||||
@@ -0,0 +1,167 @@
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import secrets
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from core.database import get_adapter
|
||||
from core.execution import CommandRunner, ExecutionError
|
||||
|
||||
IMAGES = {
|
||||
"mysql": "sha256:8c233bad33d520a7aae1c1e619c3a9775f4a1ba2d463d692fada04ec7f40be00",
|
||||
"pgsql": "sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35",
|
||||
}
|
||||
KEY_PATHS = {"mysql": "/run/secrets/absdev-client.cnf", "pgsql": "/run/secrets/absdev-pgpass"}
|
||||
containers = []
|
||||
event_count = 0
|
||||
|
||||
def docker(*args, input_data=None):
|
||||
return subprocess.run(("docker", *args), input=input_data, capture_output=True,
|
||||
text=True, timeout=120)
|
||||
|
||||
def good(*args, input_data=None):
|
||||
result = docker(*args, input_data=input_data)
|
||||
if result.returncode:
|
||||
raise RuntimeError(f"Docker {args[0]} failed with status {result.returncode}")
|
||||
return result.stdout.strip()
|
||||
|
||||
def record(engine, check):
|
||||
global event_count
|
||||
event_count += 1
|
||||
print(json.dumps(dict(engine=engine, result="PASS", check=check)), flush=True)
|
||||
|
||||
def start(engine):
|
||||
name = "absdev-secret-" + engine + "-" + secrets.token_hex(5)
|
||||
variable = "MYSQL_ROOT_PASSWORD" if engine == "mysql" else "POSTGRES_PASSWORD"
|
||||
environment = Path.cwd().parent / (name + ".env")
|
||||
environment.write_text(variable + "=" + secrets.token_hex(24) + "\n")
|
||||
environment.chmod(0o600)
|
||||
with environment.open("a") as handle:
|
||||
if engine == "pgsql":
|
||||
handle.write("POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256\n")
|
||||
try:
|
||||
cid = good("create", "--pull", "never", "--name", name, "--network", "none",
|
||||
"--security-opt", "no-new-privileges", "--cap-drop", "NET_RAW",
|
||||
"--memory", "1g", "--pids-limit", "256", "--env-file", str(environment),
|
||||
IMAGES[engine])
|
||||
finally:
|
||||
environment.unlink()
|
||||
containers.append(cid)
|
||||
good("start", cid)
|
||||
details = json.loads(good("inspect", "--format", "{{json .HostConfig}}", cid))
|
||||
assert details["NetworkMode"] == "none" and not details["Privileged"]
|
||||
assert not details["PortBindings"] and not details["Binds"]
|
||||
record(engine, "disposable container has no external network, host mounts or published ports")
|
||||
return name, cid
|
||||
|
||||
def admin(engine, cid, sql):
|
||||
if engine == "mysql":
|
||||
return docker("exec", "-i", cid, "sh", "-c",
|
||||
'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" exec mysql --no-defaults -uroot --batch',
|
||||
input_data=sql)
|
||||
return docker("exec", "-i", "--user", "postgres", cid, "psql", "-X", "-U", "postgres",
|
||||
"-d", "postgres", "-v", "ON_ERROR_STOP=1", input_data=sql)
|
||||
|
||||
def ready(engine, cid):
|
||||
for _ in range(90):
|
||||
if engine == "pgsql":
|
||||
status = docker("exec", cid, "pg_isready", "-h", "127.0.0.1", "-U", "postgres")
|
||||
if status.returncode:
|
||||
time.sleep(1)
|
||||
continue
|
||||
else:
|
||||
status = docker("exec", cid, "sh", "-c",
|
||||
'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" mysql --no-defaults --protocol=TCP -h127.0.0.1 -uroot -e "SELECT 1"')
|
||||
if status.returncode:
|
||||
time.sleep(1)
|
||||
continue
|
||||
if admin(engine, cid, "SELECT 1;").returncode == 0:
|
||||
return
|
||||
time.sleep(1)
|
||||
raise RuntimeError(f"{engine} did not become ready")
|
||||
|
||||
def write_key(engine, cid, password):
|
||||
path = KEY_PATHS[engine]
|
||||
data = ("[client]\npassword=" + password + "\n" if engine == "mysql"
|
||||
else "127.0.0.1:5432:fixture:fixture:" + password + "\n")
|
||||
good("exec", "-i", cid, "sh", "-ceu",
|
||||
'mkdir -p /run/secrets; umask 077; tmp=$(mktemp "$1.XXXXXX"); cat > "$tmp"; mv -f "$tmp" "$1"',
|
||||
"sh", path, input_data=data)
|
||||
assert good("exec", cid, "stat", "-c", "%a:%u", path) == "600:0"
|
||||
|
||||
def check_command(runner, command, success):
|
||||
output = io.BytesIO()
|
||||
try:
|
||||
runner(command, output)
|
||||
except ExecutionError:
|
||||
assert not success and not output.getvalue()
|
||||
else:
|
||||
assert success and output.getvalue().strip() == b"1"
|
||||
|
||||
def qualify(engine):
|
||||
name, cid = start(engine)
|
||||
ready(engine, cid)
|
||||
original, rotated = secrets.token_hex(24), secrets.token_hex(24)
|
||||
if engine == "mysql":
|
||||
setup = ("CREATE DATABASE fixture; "
|
||||
f"CREATE USER 'fixture'@'127.0.0.1' IDENTIFIED BY '{original}'; "
|
||||
"GRANT SELECT ON fixture.* TO 'fixture'@'127.0.0.1';")
|
||||
change = f"ALTER USER 'fixture'@'127.0.0.1' IDENTIFIED BY '{rotated}';"
|
||||
else:
|
||||
setup = f"CREATE ROLE fixture LOGIN PASSWORD '{original}';\nCREATE DATABASE fixture OWNER fixture;"
|
||||
change = f"ALTER ROLE fixture PASSWORD '{rotated}';"
|
||||
assert admin(engine, cid, setup).returncode == 0, f"{engine} fixture setup failed"
|
||||
config = json.loads(Path("config/site.example.json").read_text())
|
||||
config["database"].update(driver=engine, container=name, host="127.0.0.1",
|
||||
port=3306 if engine == "mysql" else 5432,
|
||||
name="fixture", username="fixture")
|
||||
command = get_adapter(config).ping_command()
|
||||
assert not any(value in arg for arg in command for value in (original, rotated))
|
||||
runner = CommandRunner([command], timeout=15)
|
||||
check_command(runner, command, False)
|
||||
record(engine, "missing credential file rejects authentication without publishing output")
|
||||
write_key(engine, cid, original)
|
||||
path = KEY_PATHS[engine]
|
||||
assert docker("exec", "--user", "65534:65534", cid, "cat", path).returncode != 0
|
||||
check_command(runner, command, True)
|
||||
record(engine, "adapter authenticates with mode 0600 credential file and unrelated UID cannot read it")
|
||||
good("exec", cid, "chmod", "0666", path)
|
||||
check_command(runner, command, False)
|
||||
record(engine, "database client rejects world-writable credential file")
|
||||
good("exec", cid, "chmod", "0600", path)
|
||||
assert admin(engine, cid, change).returncode == 0, f"{engine} password rotation failed"
|
||||
check_command(runner, command, False)
|
||||
record(engine, "old credential file is rejected after server-side rotation")
|
||||
write_key(engine, cid, rotated)
|
||||
check_command(runner, command, True)
|
||||
record(engine, "atomic credential replacement restores authentication")
|
||||
write_key(engine, cid, original)
|
||||
check_command(runner, command, False)
|
||||
record(engine, "rolling file back to retired credential does not restore access")
|
||||
|
||||
try:
|
||||
os.environ.update(PATH="/untrusted", ABSDEV_TEST_SECRET="synthetic", DOCKER_HOST="synthetic",
|
||||
PGPASSWORD="synthetic", MYSQL_PWD="synthetic")
|
||||
argv = [sys.executable, "-I", "-c", "import json, os; print(json.dumps(dict(os.environ)))"]
|
||||
output = io.BytesIO()
|
||||
CommandRunner([argv])(argv, output)
|
||||
assert json.loads(output.getvalue()) == {"PATH": os.defpath, "LC_ALL": "C"}
|
||||
record("framework", "approved child receives fixed PATH and locale only")
|
||||
# The qualification controller needs its own trusted Docker environment.
|
||||
for name in ("ABSDEV_TEST_SECRET", "DOCKER_HOST", "PGPASSWORD", "MYSQL_PWD"):
|
||||
os.environ.pop(name)
|
||||
os.environ["PATH"] = os.defpath
|
||||
for engine in IMAGES:
|
||||
qualify(engine)
|
||||
finally:
|
||||
cleanup_failed = False
|
||||
for cid in reversed(containers):
|
||||
command = docker("rm", "-fv", cid)
|
||||
if command.returncode:
|
||||
cleanup_failed = True
|
||||
if cleanup_failed:
|
||||
raise RuntimeError("Disposable container cleanup failed")
|
||||
record("framework", "all disposable containers and their anonymous volumes removed")
|
||||
@@ -0,0 +1,19 @@
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
test "$(hostname -s | tr A-Z a-z)" = absdev-ci
|
||||
stage=$(mktemp -d /var/tmp/absdev-secret-fix.XXXXXX)
|
||||
trap 'rm -rf -- "$stage"' EXIT
|
||||
mkdir "$stage/source" "$stage/evidence" "$stage/tmp"
|
||||
tar -xm -f - -C "$stage/source"
|
||||
cd "$stage/source"
|
||||
export TMPDIR="$stage/tmp"
|
||||
out="$stage/evidence"
|
||||
printf 'host=%s\nrevision=a60a33012be7f5cfb7062c47f8706f9216f3405a\n' "$(hostname -s)" > "$out/scope.txt"
|
||||
python3 -B bin/absdev-deploy capabilities > "$out/capabilities-before.json"
|
||||
python3 -B -c 'import json,sys; d=json.load(open(sys.argv[1])); f=[v for k,v in d.items() if k.endswith("_enabled") or k=="production_ready"]; assert len(f)==6 and all(v is False for v in f)' "$out/capabilities-before.json"
|
||||
python3 -B probe.py > "$out/checks.jsonl" || { cat "$out/checks.jsonl" >&2; exit 1; }
|
||||
bash scripts/ci-check.sh > "$out/framework-ci.txt" 2>&1 || { tail -80 "$out/framework-ci.txt" >&2; exit 1; }
|
||||
python3 -B bin/absdev-deploy capabilities > "$out/capabilities-after.json"
|
||||
cmp "$out/capabilities-before.json" "$out/capabilities-after.json"
|
||||
(cd "$out" && sha256sum ./* > SHA256SUMS)
|
||||
tar -czf - -C "$out" .
|
||||
@@ -0,0 +1,2 @@
|
||||
host=absdev-ci
|
||||
revision=a60a33012be7f5cfb7062c47f8706f9216f3405a
|
||||
@@ -1,2 +0,0 @@
|
||||
ABSDEV-CI operator account and migration approval signing key qualification, 28 November 2026.
|
||||
Two disposable locked OS accounts were exercised through a privileged test launcher under their actual non-root identities. The signing key is the framework's HMAC sealing key. The root-owned key permits read access only to the authorised account's group. Approval and rehearsal data were synthetic. No database or deployment operation ran. The tests checked revocation in fresh processes after policy reload and key rotation. They did not exercise live revocation of processes already holding the old policy or key, or production secret delivery. The archive contains neither key bytes nor approval confirmation values.
|
||||
@@ -1,6 +0,0 @@
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-after.json
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-before.json
|
||||
729138832cef705a2b885b30eeaa1710329416c576a3633681a1e37d5e59c1ac ./probe.py
|
||||
ec94a71ab10f42256c9c7230501a9f8861f1283803842f2fe9b9e28ce1a5fef7 ./qualification-log.txt
|
||||
42bb47558db3396d43ce6c306da22f882fcc687d35d8cf4772b311bd2d428c4a qualification.sh
|
||||
3227a1380c102c0467ccf75f81ddf2111828684d3f9be82d636afb1881b7ff2f SCOPE.txt
|
||||
@@ -1,73 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from core.approval import issue_approval
|
||||
from core.approval_store import ApprovalStore, ApprovalStoreError
|
||||
from core.operator_approval import OperatorApprovalPolicy, OperatorGrant
|
||||
from core.rehearsal import approval_context, create_rehearsal
|
||||
|
||||
root = Path(sys.argv[1])
|
||||
action = sys.argv[2]
|
||||
config = json.loads((root / "policy.json").read_text())
|
||||
now = datetime(2026, 11, 28, 12, tzinfo=timezone.utc)
|
||||
base = dict(site="operator-lab", release="2", revision="a"*40, provenance="b"*64,
|
||||
compatibility="c"*64, database_identity="d"*64, backup_sha256="e"*64,
|
||||
pending_migrations=["2026_11_28_000000_create_fixture"])
|
||||
execution = dict(driver="postgresql", source_database="source", target_database="isolated_restore_fixture",
|
||||
target_identity="f"*64, applied_migrations=base["pending_migrations"],
|
||||
checks=dict.fromkeys(("isolation_verified", "backup_restored", "migration_succeeded",
|
||||
"migration_history_verified", "application_verified",
|
||||
"cleanup_verified"), True))
|
||||
rehearsal = create_rehearsal(base, execution, completed_at=now)
|
||||
rehearsal_path = root / "state" / "rehearsal.json"
|
||||
if action not in ("issue", "wrong-principal"):
|
||||
rehearsal = json.loads(rehearsal_path.read_text())
|
||||
context = approval_context(rehearsal, base, now=now)
|
||||
policy = OperatorApprovalPolicy([
|
||||
OperatorGrant(config["uid"], "fixture-operator", op, base["site"], base["revision"],
|
||||
now + timedelta(hours=1))
|
||||
for op in config["operations"]
|
||||
], sealing_key=(root / "operator.key").read_bytes())
|
||||
store = ApprovalStore(root / "state", operator_policy=policy)
|
||||
if action in ("issue", "wrong-principal"):
|
||||
draft = issue_approval(context, approver=("other-principal" if action == "wrong-principal"
|
||||
else "fixture-operator"), now=now)
|
||||
try:
|
||||
saved = store.save(draft, context, confirmation=draft["confirmation"], now=now)
|
||||
except ApprovalStoreError as error:
|
||||
assert action == "wrong-principal" and "not authorised" in str(error)
|
||||
assert not store.approval_path(draft["approval_id"]).exists()
|
||||
print("PASS: actual operator UID cannot issue for another principal")
|
||||
else:
|
||||
assert action == "issue" and saved["format_version"] == 2
|
||||
rehearsal_path.write_text(json.dumps(rehearsal))
|
||||
(root / "state" / "current").write_text(saved["approval_id"])
|
||||
print("PASS: dedicated OS account issued sealed approval")
|
||||
else:
|
||||
identifier = (root / "state" / "current").read_text()
|
||||
approval = store.load(identifier)
|
||||
marker = store.consumed_path(identifier)
|
||||
before = marker.read_bytes() if marker.exists() else None
|
||||
try:
|
||||
result = store.consume(identifier, base, rehearsal, confirmation=approval["confirmation"], now=now)
|
||||
except ApprovalStoreError as error:
|
||||
assert action in ("replay", "grant-revoked", "key-revoked")
|
||||
assert (marker.read_bytes() if marker.exists() else None) == before
|
||||
if action == "replay":
|
||||
assert before and "already consumed" in str(error)
|
||||
else:
|
||||
assert before is None
|
||||
try:
|
||||
store.verify_execution(approval, context, confirmation=approval["confirmation"], now=now)
|
||||
except ApprovalStoreError as cause:
|
||||
expected = "not authorised" if action == "grant-revoked" else "invalid operator approval seal"
|
||||
assert expected in str(cause)
|
||||
else:
|
||||
raise AssertionError("Preflight accepted revoked authority")
|
||||
print("PASS:", action, "rejected without changing consumption state")
|
||||
else:
|
||||
assert action == "consume" and result["migration_executed"] is False
|
||||
print("PASS: fresh process consumed an authorised approval without executing migrations")
|
||||
@@ -1,20 +0,0 @@
|
||||
host=absdev-ci
|
||||
revision=b0dda75809a7efa2dd8ae3dc910dab23db9cfb61
|
||||
uid=1001(aboprxay27) gid=1001(aboprxay27) groups=1001(aboprxay27)
|
||||
uid=1002(abnorxay27) gid=1002(abnorxay27) groups=1002(abnorxay27)
|
||||
PASS: both accounts have locked passwords and no login shell
|
||||
640 root aboprxay27 /var/tmp/absdev-op-provision.rxay27/lab/operator.key
|
||||
644 root root /var/tmp/absdev-op-provision.rxay27/lab/policy.json
|
||||
700 aboprxay27 aboprxay27 /var/tmp/absdev-op-provision.rxay27/lab/state
|
||||
PASS: operator can read the key; neither operator account can modify key or policy; ungranted account cannot read key or enter state
|
||||
PASS: actual operator UID cannot issue for another principal
|
||||
PASS: dedicated OS account issued sealed approval
|
||||
PASS: fresh process consumed an authorised approval without executing migrations
|
||||
PASS: replay rejected without changing consumption state
|
||||
PASS: dedicated OS account issued sealed approval
|
||||
PASS: grant-revoked rejected without changing consumption state
|
||||
PASS: key-revoked rejected without changing consumption state
|
||||
PASS: dedicated OS account issued sealed approval
|
||||
PASS: fresh process consumed an authorised approval without executing migrations
|
||||
PASS: replay rejected without changing consumption state
|
||||
PASS: temporary accounts and key/state removed
|
||||
@@ -1,90 +0,0 @@
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
test "$(hostname -s | tr A-Z a-z)" = absdev-ci
|
||||
stage=$(mktemp -d /var/tmp/absdev-op-provision.XXXXXX)
|
||||
suffix=$(tr '[:upper:]' '[:lower:]' <<< "${stage##*.}")
|
||||
op="abop$suffix"
|
||||
other="abno$suffix"
|
||||
created_op=0
|
||||
created_other=0
|
||||
cleanup() {
|
||||
rc=$?
|
||||
if ((created_other)); then userdel "$other" || rc=1; fi
|
||||
if ((created_op)); then userdel "$op" || rc=1; fi
|
||||
rm -rf -- "$stage" || rc=1
|
||||
exit "$rc"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
mkdir "$stage/source" "$stage/evidence"
|
||||
tar -xf - -C "$stage/source"
|
||||
chmod 0755 "$stage"
|
||||
chmod -R a+rX "$stage/source"
|
||||
useradd -U -M -d /nonexistent -s /usr/sbin/nologin "$op"
|
||||
created_op=1
|
||||
useradd -U -M -d /nonexistent -s /usr/sbin/nologin "$other"
|
||||
created_other=1
|
||||
lab="$stage/lab"
|
||||
install -d -m 0755 "$lab"
|
||||
install -d -m 0700 -o "$op" -g "$op" "$lab/state"
|
||||
policy() {
|
||||
printf '{"uid":%s,"operations":%s}\n' "$(id -u "$op")" "$1" > "$lab/policy.json"
|
||||
chmod 0644 "$lab/policy.json"
|
||||
}
|
||||
rotate() {
|
||||
python3 -c 'import secrets,sys; sys.stdout.buffer.write(secrets.token_bytes(32))' > "$lab/key.new"
|
||||
chgrp "$op" "$lab/key.new"
|
||||
chmod 0640 "$lab/key.new"
|
||||
mv -f "$lab/key.new" "$lab/operator.key"
|
||||
}
|
||||
cd "$stage/source"
|
||||
out="$stage/evidence"
|
||||
python3 -B bin/absdev-deploy capabilities > "$out/capabilities-before.json"
|
||||
python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); f=[v for k,v in d.items() if k.endswith("_enabled") or k=="production_ready"]; assert len(f)==6 and all(v is False for v in f)' "$out/capabilities-before.json"
|
||||
policy '["issue","execute"]'
|
||||
rotate
|
||||
deny() { if "$@"; then echo "Unexpected access: $*" >&2; exit 1; fi; }
|
||||
probe() { runuser -u "$op" -- python3 -B probe.py "$lab" "$1"; }
|
||||
{
|
||||
printf 'host=%s\nrevision=b0dda75809a7efa2dd8ae3dc910dab23db9cfb61\n' "$(hostname -s)"
|
||||
id "$op"
|
||||
id "$other"
|
||||
test "$(getent passwd "$op" | cut -d: -f7)" = /usr/sbin/nologin
|
||||
test "$(getent passwd "$other" | cut -d: -f7)" = /usr/sbin/nologin
|
||||
test "$(passwd -S "$op" | awk '{print $2}')" = L
|
||||
test "$(passwd -S "$other" | awk '{print $2}')" = L
|
||||
echo 'PASS: both accounts have locked passwords and no login shell'
|
||||
stat -c '%a %U %G %n' "$lab/operator.key" "$lab/policy.json" "$lab/state"
|
||||
runuser -u "$op" -- test -r "$lab/operator.key"
|
||||
deny runuser -u "$op" -- test -w "$lab/operator.key"
|
||||
deny runuser -u "$op" -- test -w "$lab/policy.json"
|
||||
deny runuser -u "$other" -- test -r "$lab/operator.key"
|
||||
deny runuser -u "$other" -- test -x "$lab/state"
|
||||
echo 'PASS: operator can read the key; neither operator account can modify key or policy; ungranted account cannot read key or enter state'
|
||||
probe wrong-principal
|
||||
probe issue
|
||||
probe consume
|
||||
probe replay
|
||||
probe issue
|
||||
policy '[]'
|
||||
probe grant-revoked
|
||||
policy '["issue","execute"]'
|
||||
rotate
|
||||
probe key-revoked
|
||||
probe issue
|
||||
probe consume
|
||||
probe replay
|
||||
userdel "$other"
|
||||
created_other=0
|
||||
userdel "$op"
|
||||
created_op=0
|
||||
deny getent passwd "$op"
|
||||
deny getent passwd "$other"
|
||||
rm -rf -- "$lab"
|
||||
test ! -e "$lab"
|
||||
echo 'PASS: temporary accounts and key/state removed'
|
||||
} > "$out/qualification.log"
|
||||
python3 -B bin/absdev-deploy capabilities > "$out/capabilities-after.json"
|
||||
cmp "$out/capabilities-before.json" "$out/capabilities-after.json"
|
||||
cp probe.py "$out/"
|
||||
(cd "$out" && sha256sum ./* > SHA256SUMS)
|
||||
tar -czf - -C "$out" .
|
||||
@@ -1,8 +1,11 @@
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from core.execution import (
|
||||
ExecutionError,
|
||||
@@ -43,6 +46,23 @@ class ExecutionTests(unittest.TestCase):
|
||||
b"SUCCESS\n",
|
||||
)
|
||||
|
||||
def test_subprocess_environment_excludes_parent_credentials(self):
|
||||
|
||||
command = self.command(
|
||||
"import json, os; print(json.dumps(dict(os.environ), sort_keys=True))"
|
||||
)
|
||||
output = io.BytesIO()
|
||||
with patch.dict(os.environ, {
|
||||
"PATH": "/untrusted",
|
||||
"LC_ALL": "untrusted",
|
||||
"ABSDEV_TEST_SECRET": "synthetic",
|
||||
"DOCKER_HOST": "synthetic",
|
||||
"PGPASSWORD": "synthetic",
|
||||
}):
|
||||
self.runner(command)(command, output)
|
||||
|
||||
self.assertEqual(json.loads(output.getvalue()), {"PATH": os.defpath, "LC_ALL": "C"})
|
||||
|
||||
def test_binary_output_preserved(self):
|
||||
|
||||
command = self.command(
|
||||
|
||||
Reference in New Issue
Block a user