Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7a642b23c |
@@ -0,0 +1,8 @@
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-after.json
|
||||
934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 ./capabilities-before.json
|
||||
b2d5eb9eb65eae107efd1e7afdebef051e24f85e71ed9a556c35721a1df911d7 ./checks.jsonl
|
||||
563b698c0d99294765669c84c96869f92dcae9f87df8f8e62de69dc8fa946d83 ./framework-ci.txt
|
||||
eebbff2c0505a4e3e80a676500191b4d9b41fb8a18a39a235cc717d36aeb81ab ./scope.txt
|
||||
8c89cb04d6f12405a9e0fcd5e0d3519d7511329699c0f27eeecd4df0f537a27e controller.py
|
||||
afda0afc490c108f7e1ce1a1774185fe566e7d38f43918a426e11144425ce6e6 worker.py
|
||||
3cea8a8d312caf532497e79d2d8aaa9dd29acf1008342be9862eefc8ea7efdb6 run.sh
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"commands": [
|
||||
"validate",
|
||||
"capabilities",
|
||||
"inventory",
|
||||
"retention-plan",
|
||||
"provision-plan",
|
||||
"site-policy",
|
||||
"registry-validate",
|
||||
"preflight"
|
||||
],
|
||||
"database_restore_enabled": false,
|
||||
"deployment_execution_enabled": false,
|
||||
"format_version": 1,
|
||||
"migration_execution_enabled": false,
|
||||
"permanent_deletion_enabled": false,
|
||||
"production_ready": false,
|
||||
"provisioning_execution_enabled": false
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"commands": [
|
||||
"validate",
|
||||
"capabilities",
|
||||
"inventory",
|
||||
"retention-plan",
|
||||
"provision-plan",
|
||||
"site-policy",
|
||||
"registry-validate",
|
||||
"preflight"
|
||||
],
|
||||
"database_restore_enabled": false,
|
||||
"deployment_execution_enabled": false,
|
||||
"format_version": 1,
|
||||
"migration_execution_enabled": false,
|
||||
"permanent_deletion_enabled": false,
|
||||
"production_ready": false,
|
||||
"provisioning_execution_enabled": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{"check": "authorised approval consumed once and replay rejected", "result": "PASS"}
|
||||
{"check": "same running process rejected unconsumed approval after execute grant removal", "result": "PASS"}
|
||||
{"check": "same running process rejected an approval sealed by the retired key", "result": "PASS"}
|
||||
{"check": "missing authority failed closed without a consumption marker", "result": "PASS"}
|
||||
{"check": "unsafe authority permissions failed closed without a consumption marker", "result": "PASS"}
|
||||
{"check": "replacement key restored authorised consumption in the original process", "result": "PASS"}
|
||||
{"check":"disposable operator and authority files removed","result":"PASS"}
|
||||
@@ -0,0 +1,62 @@
|
||||
import json
|
||||
import os
|
||||
import secrets
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
account, uid, gid, root = sys.argv[1:]
|
||||
uid, gid, root = int(uid), int(gid), Path(root)
|
||||
path = root / "authority.json"
|
||||
key = secrets.token_hex(32)
|
||||
|
||||
def publish(actions, signing_key):
|
||||
grants = [dict(uid=uid, principal="operator", operation=op, site="example-absdev-net",
|
||||
revision="a"*40, expires_at="2026-12-01T10:00:00+00:00") for op in actions]
|
||||
with tempfile.NamedTemporaryFile(mode="w", dir=root, delete=False) as stream:
|
||||
json.dump({"grants": grants, "sealing_key": signing_key}, stream)
|
||||
stream.flush()
|
||||
os.fchown(stream.fileno(), 0, gid)
|
||||
os.fchmod(stream.fileno(), 0o440)
|
||||
os.fsync(stream.fileno())
|
||||
os.replace(stream.name, path)
|
||||
|
||||
def report(check):
|
||||
print(json.dumps({"check": check, "result": "PASS"}), flush=True)
|
||||
|
||||
publish(("issue", "execute"), key)
|
||||
with subprocess.Popen(("runuser", "-u", account, "--", "env", "TMPDIR=" + str(root.parent / "operator-tmp"), "python3", "-B", "worker.py", str(path)),
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) as process:
|
||||
def send(action, expected):
|
||||
process.stdin.write(action + "\n")
|
||||
process.stdin.flush()
|
||||
assert process.stdout.readline().strip() == expected, action
|
||||
|
||||
send("issue", "issued")
|
||||
send("consume", "consumed")
|
||||
send("replay", "rejected")
|
||||
report("authorised approval consumed once and replay rejected")
|
||||
send("issue", "issued")
|
||||
publish(("issue",), key)
|
||||
send("reject", "rejected")
|
||||
report("same running process rejected unconsumed approval after execute grant removal")
|
||||
publish(("issue", "execute"), key)
|
||||
rotated = secrets.token_hex(32)
|
||||
publish(("issue", "execute"), rotated)
|
||||
send("reject", "rejected")
|
||||
report("same running process rejected an approval sealed by the retired key")
|
||||
send("issue", "issued")
|
||||
path.unlink()
|
||||
send("reject", "rejected")
|
||||
report("missing authority failed closed without a consumption marker")
|
||||
publish(("issue", "execute"), rotated)
|
||||
path.chmod(0o444)
|
||||
send("reject", "rejected")
|
||||
report("unsafe authority permissions failed closed without a consumption marker")
|
||||
publish(("issue", "execute"), rotated)
|
||||
send("consume", "consumed")
|
||||
send("replay", "rejected")
|
||||
report("replacement key restored authorised consumption in the original process")
|
||||
process.stdin.close()
|
||||
assert process.wait(timeout=10) == 0
|
||||
@@ -0,0 +1,108 @@
|
||||
=== ABSDEV FRAMEWORK CI ===
|
||||
Python 3.14.4
|
||||
|
||||
=== PYTHON SYNTAX VALIDATION ===
|
||||
PASS: 88 Python sources compiled
|
||||
|
||||
=== COMPLETE UNIT REGRESSION SUITE ===
|
||||
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
|
||||
----------------------------------------------------------------------
|
||||
Ran 901 tests in 18.524s
|
||||
|
||||
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,38 @@
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
test "$(hostname -s | tr A-Z a-z)" = absdev-ci
|
||||
stage=$(mktemp -d /var/tmp/absdev-revocation-fix.XXXXXX)
|
||||
suffix=$(tr '[:upper:]' '[:lower:]' <<< "${stage##*.}")
|
||||
account="abrev$suffix"
|
||||
created=0
|
||||
cleanup() {
|
||||
rc=$?
|
||||
if ((created)); then userdel "$account" || rc=1; fi
|
||||
rm -rf -- "$stage" || rc=1
|
||||
exit "$rc"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
mkdir "$stage/source" "$stage/evidence" "$stage/tmp"
|
||||
tar -xm -f - -C "$stage/source"
|
||||
chmod 0711 "$stage"
|
||||
chmod -R a+rX "$stage/source"
|
||||
useradd -U -M -d /nonexistent -s /usr/sbin/nologin "$account"
|
||||
created=1
|
||||
install -d -m 0750 -o root -g "$account" "$stage/authority"
|
||||
install -d -m 0700 -o "$account" -g "$account" "$stage/operator-tmp"
|
||||
export TMPDIR="$stage/tmp"
|
||||
out="$stage/evidence"
|
||||
cd "$stage/source"
|
||||
printf 'host=%s\nrevision=2719378f67da153f0210b886d66e8e2b68cf6c01\noperator_uid=%s\n' "$(hostname -s)" "$(id -u "$account")" > "$out/scope.txt"
|
||||
python3 -B bin/absdev-deploy capabilities > "$out/capabilities-before.json"
|
||||
python3 -B controller.py "$account" "$(id -u "$account")" "$(id -g "$account")" "$stage/authority" > "$out/checks.jsonl"
|
||||
userdel "$account"
|
||||
created=0
|
||||
rm -rf -- "$stage/authority" "$stage/operator-tmp"
|
||||
if getent passwd "$account"; then exit 1; fi
|
||||
printf '%s\n' '{"check":"disposable operator and authority files removed","result":"PASS"}' >> "$out/checks.jsonl"
|
||||
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,3 @@
|
||||
host=absdev-ci
|
||||
revision=2719378f67da153f0210b886d66e8e2b68cf6c01
|
||||
operator_uid=1001
|
||||
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path("tests/unit").resolve()))
|
||||
from test_approval_store import ApprovalStoreTests
|
||||
from core.approval_store import ApprovalStore, ApprovalStoreError
|
||||
from core.operator_approval import FileOperatorAuthority
|
||||
|
||||
fixture = ApprovalStoreTests()
|
||||
try:
|
||||
fixture.setUp()
|
||||
assert os.geteuid() > 0
|
||||
fixture.store = ApprovalStore(
|
||||
fixture.root, operator_policy=FileOperatorAuthority(sys.argv[1], group=os.getegid())
|
||||
)
|
||||
original_draft = fixture.approval
|
||||
for action in sys.stdin:
|
||||
action = action.strip()
|
||||
if action == "issue":
|
||||
from core.approval import issue_approval
|
||||
fixture.approval = issue_approval(fixture.context, approver=original_draft["approver"],
|
||||
now=fixture.now)
|
||||
fixture.identifier = fixture.approval["approval_id"]
|
||||
fixture.save()
|
||||
print("issued", flush=True)
|
||||
elif action == "consume":
|
||||
result = fixture.consume()
|
||||
assert result["migration_executed"] is False
|
||||
print("consumed", flush=True)
|
||||
else:
|
||||
try:
|
||||
fixture.consume()
|
||||
except ApprovalStoreError as error:
|
||||
marker = fixture.store.consumed_path(fixture.identifier)
|
||||
if action == "replay":
|
||||
assert "already consumed" in str(error) and marker.exists()
|
||||
else:
|
||||
assert not marker.exists()
|
||||
print("rejected", flush=True)
|
||||
else:
|
||||
raise AssertionError("Expected rejection")
|
||||
finally:
|
||||
fixture.doCleanups()
|
||||
Reference in New Issue
Block a user