Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d694ba2e9 | |||
| 3d9dd06411 | |||
| b257846981 | |||
| 986171a165 |
@@ -37,14 +37,13 @@
|
||||
"escalate_high_severity": true,
|
||||
"bash_allowlist": {
|
||||
"allowed_commands": [
|
||||
"npm", "node", "npx", "pnpm", "yarn",
|
||||
"git", "ls", "cat", "head", "tail", "wc",
|
||||
"echo", "mkdir", "cp", "mv", "rm", "touch",
|
||||
"pwd", "which", "env", "printenv",
|
||||
"jest", "eslint", "tsc", "prettier",
|
||||
"python3", "pytest", "pip",
|
||||
"terraform", "checkov",
|
||||
"curl", "wget",
|
||||
"docker", "docker-compose",
|
||||
"ts-node", "tsx"
|
||||
"docker", "docker-compose"
|
||||
],
|
||||
"max_output_bytes": 1048576,
|
||||
"timeout_ms": 30000,
|
||||
|
||||
+11
-1
@@ -18,4 +18,14 @@ terraform/bootstrap/.bootstrap_state.json
|
||||
**/.terraform/
|
||||
**/.terraform.lock.hcl
|
||||
**/tfplan
|
||||
**/*.tfstate*
|
||||
**/*.tfstate*
|
||||
|
||||
# Credential patterns (v1.14, REQ-146)
|
||||
*.pem
|
||||
*.key
|
||||
*.p12
|
||||
*.pfx
|
||||
*.cer
|
||||
*.crt
|
||||
*.jks
|
||||
*.keystore
|
||||
@@ -8,13 +8,16 @@ v1.9 (REQ-111): the translator is fleshed out — full PolicyReport →
|
||||
PolicyCheckResult mapping with severity + skip-with-reason handling. It
|
||||
remains inactive for Terraform-only stacks (guard preserved — emits a
|
||||
single SKIPPED `KYVERNO_INACTIVE_TF_STACK` record when no K8s manifests).
|
||||
A `--kube-version` stub is parsed but not yet used (for future GitOps).
|
||||
A `--kube-version` flag was previously parsed but never used. It has been
|
||||
removed (v1.14, G-103) to resolve the stub. Version-aware policy selection
|
||||
will be added when the GitOps reconciler emits K8s manifests (D-053
|
||||
roadmap). The adapter is inactive for Terraform-only stacks today.
|
||||
|
||||
D-053: the platform emits Terraform, not K8s manifests. This adapter
|
||||
activates when the GitOps reconciler (roadmap) emits K8s manifests.
|
||||
Sample policies are included as documentation at adapters/kyverno/policies/.
|
||||
|
||||
CLI: kyverno_adapter.py <policyreport.json> <contract-id> [--kube-version <ver>]
|
||||
CLI: kyverno_adapter.py <policyreport.json> <contract-id>
|
||||
"""
|
||||
|
||||
import datetime
|
||||
@@ -100,7 +103,7 @@ def _emit_inactive_tf(contract_id):
|
||||
}
|
||||
|
||||
|
||||
def adapt(policyreport_json_path, contract_id, kube_version=None):
|
||||
def adapt(policyreport_json_path, contract_id):
|
||||
with open(policyreport_json_path, "r", encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
out = []
|
||||
@@ -112,8 +115,6 @@ def adapt(policyreport_json_path, contract_id, kube_version=None):
|
||||
out.append(_to_pcr(entry, contract_id))
|
||||
if not out:
|
||||
out.append(_emit_inactive_tf(contract_id))
|
||||
# kube_version is parsed but not yet used (future GitOps reconciler).
|
||||
_ = kube_version
|
||||
return out
|
||||
|
||||
|
||||
@@ -123,14 +124,8 @@ def adapt_inactive(contract_id):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
kube_ver = None
|
||||
args = sys.argv[1:]
|
||||
if "--kube-version" in args:
|
||||
idx = args.index("--kube-version")
|
||||
if idx + 1 < len(args):
|
||||
kube_ver = args[idx + 1]
|
||||
args = args[:idx] + args[idx + 2:]
|
||||
if len(args) != 2:
|
||||
print("usage: kyverno_adapter.py <policyreport.json> <contract-id> [--kube-version <ver>]", file=sys.stderr)
|
||||
print("usage: kyverno_adapter.py <policyreport.json> <contract-id>", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
print(json.dumps(adapt(args[0], args[1], kube_version=kube_ver), indent=2))
|
||||
print(json.dumps(adapt(args[0], args[1]), indent=2))
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "acdl"
|
||||
version = "1.3.0"
|
||||
version = "1.14.0"
|
||||
description = "Agentic Cloud Delivery Platform — consumers declare intent; the platform delivers safe production deployment."
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
@@ -28,7 +28,7 @@ filterwarnings = [
|
||||
]
|
||||
|
||||
[tool.coverage]
|
||||
run.source = ["acdl_platform", "adapters"]
|
||||
run.source = ["core", "adapters"]
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
|
||||
@@ -27,20 +27,23 @@
|
||||
"type": "object",
|
||||
"required": ["bucket", "lock_table"],
|
||||
"properties": {
|
||||
"bucket": {"type": "string", "description": "S3 state bucket name."},
|
||||
"bucket": {"type": "string", "pattern": "^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$", "description": "S3 state bucket name (lowercase, 3-63 chars, dots/hyphens)."},
|
||||
"lock_table": {"type": "string", "description": "DynamoDB lock table name."}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"network": {
|
||||
"type": "object",
|
||||
"required": ["vpc_cidr", "azs"],
|
||||
"properties": {
|
||||
"vpc_cidr": {"type": "string", "description": "VPC CIDR block."},
|
||||
"azs": {"type": "array", "items": {"type": "string"}, "description": "Availability zones."}
|
||||
}
|
||||
"vpc_cidr": {"type": "string", "pattern": "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/[0-9]{1,2}$", "description": "VPC CIDR block (e.g. 10.0.0.0/16)."},
|
||||
"azs": {"type": "array", "items": {"type": "string"}, "maxItems": 6, "description": "Availability zones (max 6)."}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"runner_role_arn": {
|
||||
"type": "string",
|
||||
"pattern": "^arn:aws:iam::[0-9]{12}:role/.+$",
|
||||
"description": "The IAM role ARN surfaced to the consumer's repo via ABAC."
|
||||
},
|
||||
"autonomy": {
|
||||
@@ -54,5 +57,6 @@
|
||||
"maximum": 1,
|
||||
"description": "The confidence gate threshold for this environment (dev 0.50, qa 0.75, prod 0.90, dr 0.95)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -96,4 +96,64 @@ def test_account_id_is_12_digits():
|
||||
for env_file in ENV_FILES:
|
||||
env = json.loads((ENV_DIR / env_file).read_text())
|
||||
assert len(env["account_id"]) == 12
|
||||
assert env["account_id"].isdigit()
|
||||
assert env["account_id"].isdigit()
|
||||
|
||||
|
||||
def test_v14_schema_rejects_undocumented_fields():
|
||||
"""v1.14 (REQ-145): additionalProperties: false rejects unknown fields."""
|
||||
schema = json.loads(SCHEMA.read_text())
|
||||
bad_env = {
|
||||
"name": "dev",
|
||||
"account_id": "123456789012",
|
||||
"region": "us-east-1",
|
||||
"state_backend": {"bucket": "test", "lock_table": "test"},
|
||||
"network": {"vpc_cidr": "10.0.0.0/16", "azs": ["us-east-1a"]},
|
||||
"runner_role_arn": "arn:aws:iam::123456789012:role/test",
|
||||
"autonomy": "full",
|
||||
"confidence_threshold": 0.5,
|
||||
"rogue_field": "should be rejected"
|
||||
}
|
||||
with pytest.raises(jsonschema.ValidationError, match="Additional properties are not allowed"):
|
||||
jsonschema.validate(bad_env, schema)
|
||||
|
||||
|
||||
def test_v14_schema_validates_bucket_name_format():
|
||||
"""v1.14 (REQ-145): state_backend.bucket must match S3 naming rules."""
|
||||
schema = json.loads(SCHEMA.read_text())
|
||||
bad_env = {
|
||||
"name": "dev", "account_id": "123456789012", "region": "us-east-1",
|
||||
"state_backend": {"bucket": "Invalid_Bucket!", "lock_table": "test"},
|
||||
"network": {"vpc_cidr": "10.0.0.0/16", "azs": ["us-east-1a"]},
|
||||
"runner_role_arn": "arn:aws:iam::123456789012:role/test",
|
||||
"autonomy": "full", "confidence_threshold": 0.5
|
||||
}
|
||||
with pytest.raises(jsonschema.ValidationError, match="does not match"):
|
||||
jsonschema.validate(bad_env, schema)
|
||||
|
||||
|
||||
def test_v14_schema_validates_arn_format():
|
||||
"""v1.14 (REQ-145): runner_role_arn must match ARN format."""
|
||||
schema = json.loads(SCHEMA.read_text())
|
||||
bad_env = {
|
||||
"name": "dev", "account_id": "123456789012", "region": "us-east-1",
|
||||
"state_backend": {"bucket": "test", "lock_table": "test"},
|
||||
"network": {"vpc_cidr": "10.0.0.0/16", "azs": ["us-east-1a"]},
|
||||
"runner_role_arn": "not-an-arn",
|
||||
"autonomy": "full", "confidence_threshold": 0.5
|
||||
}
|
||||
with pytest.raises(jsonschema.ValidationError, match="does not match"):
|
||||
jsonschema.validate(bad_env, schema)
|
||||
|
||||
|
||||
def test_v14_schema_validates_cidr_format():
|
||||
"""v1.14 (REQ-145): vpc_cidr must match CIDR format."""
|
||||
schema = json.loads(SCHEMA.read_text())
|
||||
bad_env = {
|
||||
"name": "dev", "account_id": "123456789012", "region": "us-east-1",
|
||||
"state_backend": {"bucket": "test", "lock_table": "test"},
|
||||
"network": {"vpc_cidr": "not-a-cidr", "azs": ["us-east-1a"]},
|
||||
"runner_role_arn": "arn:aws:iam::123456789012:role/test",
|
||||
"autonomy": "full", "confidence_threshold": 0.5
|
||||
}
|
||||
with pytest.raises(jsonschema.ValidationError, match="does not match"):
|
||||
jsonschema.validate(bad_env, schema)
|
||||
@@ -211,11 +211,13 @@ class TestFleshedOutTranslator:
|
||||
assert pcrs[0]["result"] == "skipped"
|
||||
assert "Terraform" in pcrs[0]["message"]
|
||||
|
||||
def test_kube_version_parsed(self, tmp_path):
|
||||
"""--kube-version is parsed but not yet used (future GitOps)."""
|
||||
def test_kube_version_removed(self, tmp_path):
|
||||
"""v1.14 (G-103): --kube-version flag removed; adapt() no longer
|
||||
accepts kube_version parameter. Version-aware policy selection
|
||||
deferred to GitOps reconciler (D-053)."""
|
||||
f = tmp_path / "k.json"
|
||||
f.write_text(json.dumps({"results": [
|
||||
{"policy": "p", "rule": "r", "severity": "low", "result": "pass", "resource": "x"},
|
||||
]}))
|
||||
results = adapt(str(f), "c8", kube_version="1.28")
|
||||
results = adapt(str(f), "c8")
|
||||
assert len(results) == 1
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""v1.14 (REQ-146): no credential-looking files are tracked by git."""
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
CREDENTIAL_EXTENSIONS = [".pem", ".key", ".p12", ".pfx", ".cer", ".crt", ".jks", ".keystore"]
|
||||
|
||||
|
||||
def test_no_credential_files_tracked():
|
||||
"""Assert no file with a credential extension is tracked by git."""
|
||||
result = subprocess.run(
|
||||
["git", "ls-files"],
|
||||
cwd=str(ROOT),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
pytest.skip("git not available or not a repo")
|
||||
tracked = result.stdout.strip().split("\n")
|
||||
cred_files = [
|
||||
f for f in tracked
|
||||
if any(f.endswith(ext) for ext in CREDENTIAL_EXTENSIONS)
|
||||
]
|
||||
assert cred_files == [], f"credential files tracked by git: {cred_files}"
|
||||
|
||||
|
||||
def test_gitignore_has_credential_patterns():
|
||||
"""Assert .gitignore contains the credential-pattern catch-all."""
|
||||
gitignore = (ROOT / ".gitignore").read_text()
|
||||
for ext in [".pem", ".key", ".p12", ".pfx"]:
|
||||
assert f"*{ext}" in gitignore, f".gitignore missing credential pattern *{ext}"
|
||||
Reference in New Issue
Block a user