นโยบายที่ใช้กับเอาต์พุตที่เรนเดอร์: กฎประจำองค์กรหนึ่งข้อ ทุกเป้าหมาย สองเอนจิน
กฎrender-verdict ตัดสิน
อิมเมจ
คอนเทนเนอร์ ทุก รายการ ระบุ เวอร์ชัน ที่ แน่นอน — แท็ก ที่ ไม่ใช่ latestหรือ ไดเจสต์ อินสแตนซ์ฐาน ข้อมูล ทุก รายการ จัด เก็บ ข้อมูล แบบ เข้า รหัส
พื้นที่arm) บทบาท render-verdict ตัดสิน
กฎ
aggrega buildนโยบาย
เสียบ
ผ่าน
ไฟล์
พร้อม
ไม่
การ
นโยบาย
สิ่งที่ตัวอย่างนี้บิลด์
| อินสแตนซ์ | Component ของ | สิ่ง |
|---|---|---|
db | core/datastore/postgres | ฐาน |
report | core/compute/task | งานdb และcore/manual-trigger จึง |
การaggregate-arm.yaml ซึ่งreport ชนิด core/compute/worker ที่arm รองรับcore/manual-trigger ที่orders-db ใน
report อ่านdatabase ของDB_HOST, DB_PORT และ DB_NAME Aggregate เป็น
| Manifest | db | report |
|---|---|---|
manifest-helm.yaml | helm/postgres ซึ่ง | helm/task ซึ่ง |
manifest-compose.yaml | compose/postgres ซึ่ง | compose/task ซึ่ง |
manifest-terraform.yaml | terraform/postgres-rds ซึ่ง | terraform/task-ecs ซึ่ง |
manifest-cloudformation.yaml | cloudformation/postgres-rds ซึ่ง | cloudformation/task-ecs ซึ่ง |
manifest-arm.yaml | arm/postgres-flexible-server ซึ่ง | arm/worker-container-apps ซึ่ง |
Recipes ของ Kubernetes, Compose, Terraform และ CloudFormation เรนเดอร์arm ห่อ
Releases
| Release | เป้า | สิ่ง | การ |
|---|---|---|---|
release-helm.yaml | Kubernetes | report รัน registry.example.com/orders-report:1.4.2 | เสร็จ |
release-helm-unpinned.yaml | Kubernetes | report รันlatest | หยุด |
release-compose.yaml | Docker Compose | report รัน registry.example.com/orders-report:1.4.2 | เสร็จ |
release-compose-unpinned.yaml | Docker Compose | report รัน | หยุด |
release-terraform.yaml | Terraform | อินสแตนซ์ | เสร็จ |
release-terraform-unencrypted.yaml | Terraform | Release ไม่ | หยุด |
release-cloudformation.yaml | CloudFormation | Release เปิด StorageEncrypted | เสร็จ |
release-cloudformation-unencrypted.yaml | CloudFormation | Release ปล่อย | หยุด |
release-arm.yaml | Azure Resource Manager | report รัน registry.example.com/orders-report:1.4.2 | เสร็จ |
release-arm-unpinned.yaml | Azure Resource Manager | report รัน | หยุด |
อิมเมจcore/compute/task และ core/compute/worker ไม่infra.image โดยinfra.overrides.kms_key_id และstorage_encrypted = true ข้างinfra.overrides.StorageEncrypted และ KmsKeyId ภาย
เป้า
ฐานpostgres:16 ซึ่ง
การแนบกฎ
.aggrega-config.yaml ระบุ hub เป็น--config ได้แก่ governance-rego.yaml สำหรับgovernance-cel.yaml สำหรับ
plugins: governance: - uri: governance/rego:0.9.0 role: render-verdict with: sources: - policies/house-rule.rego--config ระบุ.aggrega-config.yaml ของplugins.governance ใน0.9.0 คือaggrega plugin list แสดง governance/rego และ governance/cel ใน
สิ่งที่นโยบาย render-verdict อ่าน
นโยบายrender-verdict อ่านinput.artifacts ซึ่ง
path— เส้นทาง ของ ไฟล์ ใต้ dist/เช่นterraform/modules/db/main.tfcontent— ข้อความของ ไฟล์ ตาม ที่ เขียน format— รูปแบบ ที่ ผู้ ให้ บริการ ของ เป้า หมาย ประกาศ สำหรับ ไฟล์: yamlสำหรับไฟล์ Compose jsonสำหรับเทมเพลต CloudFormation และ hclสำหรับทุก ไฟล์ Terraform รวม ถึง เนื้อหา ฐาน ข้อมูล ที่ Recipe ของ ฐาน ข้อมูล นั้น เขียน หาก ไม่มี สิ่ง ใด ประกาศ ไว้ จะ เป็น สตริง ว่าง ดัง เช่น ไฟล์ Kubernetes ที่ นี่ documents— เนื้อหาของ ไฟล์ ที่ แยก วิเคราะห์ เป็น โครงสร้าง ใน รูป รายการ ของ เอกสาร ซึ่ง ที่ นี่ แต่ละ ไฟล์ มี หนึ่ง รายการ parse_error— มีเฉพาะ ใน ไฟล์ ที่ แยก วิเคราะห์ ไม่ ได้ แทน documents
นอกจากinput.sources ยังinput.settings เก็บ
aggrega build --release <release> --dry-run --policy-input <dir> เขียน<dir> และrender-verdict ไฟล์path และ content รวมformat ที่documents จากrelease-terraform.yaml เติม
aggrega build --release release-terraform.yaml --config governance-rego.yaml --dry-run --policy-input payloadsjq -c '[.artifacts[].path]' payloads/render-verdict.json# ["terraform/aggrega.modules.tf","terraform/modules/db/main.tf","terraform/modules/report/aggrega.provenance.tf","terraform/modules/report/main.tf","terraform/modules/report/variables.tf"]เส้นdocuments ถูกparse_error ข้อdocuments ไฟล์parse_error
วิธีที่แต่ละข้อย่อยอ่านรูปทรงของเป้าหมาย
แต่ละ
Compose เขียนservices:
deny contains msg if { some artifact in input.artifacts some doc in artifact.documents some name, service in doc.services unpinned(service.image) msg := sprintf("%v: service %v runs %v, an image with no tag or the tag latest", [artifact.path, name, service.image])}ออบเจ็กต์ Kubernetes มีspec.jobTemplate.spec:
pod_template(doc) := doc.spec.jobTemplate.spec.template if doc.kind == "CronJob"
pod_template(doc) := doc.spec.template if doc.kind != "CronJob"Terraform ใน HCL แบบ
deny contains msg if { some artifact in input.artifacts native_hcl(artifact) some doc in artifact.documents some name, blocks in doc.resource.aws_db_instance some block in blocks not block.storage_encrypted == true msg := sprintf("%v: the RDS instance %v stores its data unencrypted", [artifact.path, name])}รายการsome name, block in doc.resource.aws_db_instance — block คือblock.storage_encrypted ไม่not เป็นrelease-terraform.yaml ด้วย ทั้ง
ไฟล์ .tf.json อ่านformat ก่อน native_hcl รับhcl หรือ.tf — ไฟล์hcl จึง.tf.json กฎ
CloudFormation เขียนResources โดยType และ Properties:
deny contains msg if { some artifact in input.artifacts some doc in artifact.documents some id, resource in doc.Resources resource.Type == "AWS::RDS::DBInstance" not resource.Properties.StorageEncrypted == true msg := sprintf("%v: the RDS instance %v stores its data unencrypted", [artifact.path, id])}อินสแตนซ์StorageEncrypted หรือtrue จะnot … == true เป็น
Azure Resource Manager เขียนresources เป็นMicrosoft.App/containerApps ที่properties.template ส่วน Recipe ที่Microsoft.Resources/deployments ที่containers เอาต์พุต worker-container-apps ที่
deny contains msg if { some artifact in input.artifacts some doc in artifact.documents is_object(doc.resources) some resource in doc.resources resource.type == "Microsoft.Resources/deployments" some container in resource.properties.parameters.containers.value unpinned(container.image) msg := sprintf("%v: container %v runs %v, an image with no tag or the tag latest", [artifact.path, container.name, container.image])}ผู้arm เขียน resources เป็นis_object กันresources ระดับ
เหตุใดกฎ CEL จึงเขียนต่างออกไป
policies/house-rule.cel ระบุ
ทดสอบservices ไฟล์ Compose ไม่มี kind — ดังhas() ก่อน:
// Docker Compose: a service whose image names no fixed version.input.artifacts .filter(a, has(a.documents) && a.documents.exists(d, has(d.services) && d.services.exists(s, has(d.services[s].image) [… omitted: the image test, and the rest of the clause]หากhas(d.services) แล้ว aggrega build --release release-helm.yaml --config governance-cel.yaml --auto-pull จะ1 และdist/ เลย และ
render-verdict: plugin "governance/cel:0.9.0": call "verdict_render": wasm: plugin "cel" call to verdict_render: policy source "house-rule.cel" could not be evaluated: No such key: servicesรายงาน
เขียนunpinned ของ Rego
ไฟล์
คำตัดสินไม่เปลี่ยนเอาต์พุตเลย
นโยบายrender-verdict ยอมรับcheck.sh เปรียบdist/ เลย ทาง
ร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example policy-render-verdictจาก
cd policy-render-verdictบิลด์
aggrega build --release release-terraform.yaml --config governance-rego.yaml --auto-pullaggrega build --release release-terraform-unencrypted.yaml --config governance-rego.yaml --auto-pull # halts; exits 1สลับ governance-rego.yaml เป็น governance-cel.yaml เพื่อterraform ในhelm, compose, cloudformation หรือ arm พร้อม Releases ที่release-helm-unpinned.yaml, release-compose-unpinned.yaml, release-cloudformation-unencrypted.yaml และ release-arm-unpinned.yaml
แค็ตตาล็อกhub.aggrega.ai ซึ่ง.aggrega-config.yaml ระบุ เมื่อ--catalog จะ--auto-pull เติม
กรณี
[… omitted: the lines printed while the lockfile is resolved, which carry the refusal below once more and say the render that discovers external inputs could not finish][POLICY_ERROR E0005] policy plugin "rego" rejected the build: terraform/modules/db/main.tf: the RDS instance db stores its data unencrypted caused by: policy violationแต่ละdist/ และ
policy plugin "rego" rejected the build: helm/report-cronjob.yaml: container main runs registry.example.com/orders-report:latest, an image with no tag or the tag latestpolicy plugin "cel" rejected the build: compose/docker-compose.yaml: service report runs registry.example.com/orders-report, an image with no tag or the tag latestpolicy plugin "cel" rejected the build: cloudformation/cloudformation-stack.json: the RDS instance Db stores its data unencryptedpolicy plugin "rego" rejected the build: arm/arm-template.json: container main runs registry.example.com/orders-report, an image with no tag or the tag latestแต่ละ[POLICY_ERROR E0005] ใน
กับผู้ช่วย AI
ผู้
ใช้เครื่องมือของ Aggrega เท่านั้น และอย่าสร้างโฟลเดอร์เอง หากโฟลเดอร์พื้นที่ทำงานยังไม่มีโฟลเดอร์ `policy-render-verdict` ให้เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `policy-render-verdict` และไม่ระบุ `dir` เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `policy-render-verdict` ใหม่ จากนั้นเรียกเครื่องมือ `cli-build` ซึ่งรัน `aggrega build` และรับแฟล็ก `--config` ของคำสั่งนั้น หนึ่งครั้งต่อ Release ตามลำดับนี้ — `release-terraform.yaml` และ `release-terraform-unencrypted.yaml` — โดยทุกครั้งตั้ง `workspace_root` เป็น `policy-render-verdict` ตั้ง `release` เป็นไฟล์นั้น ตั้ง `auto_pull` เป็น true และตั้ง `config` เป็น `governance-rego.yaml` ครั้งที่สองตั้งใจให้ถูกปฏิเสธ ดังนั้นแจ้งข้อความการปฏิเสธนั้นให้ฉันทราบ บอกฉันว่าการบิลด์ครั้งแรกเขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใน `policy-render-verdict/dist/`การตรวจสอบทุกบิลด์
การaggrega draft --example เขียน
./check.shcheck.sh บิลด์E0005 และdist/ เลย ทั้ง
ENGINE RELEASE EXIT EXPECTED VERDICT--------------------------------------------------------------------------------------------------------------none release-helm.yaml 0 reference OKnone release-compose.yaml 0 reference OKnone release-terraform.yaml 0 reference OKnone release-cloudformation.yaml 0 reference OKnone release-arm.yaml 0 reference OKrego release-helm.yaml 0 pass OK: completed, byte-identical to the build with no policyrego release-helm-unpinned.yaml 1 halt OK: E0005, the expected sentencerego release-compose.yaml 0 pass OK: completed, byte-identical to the build with no policyrego release-compose-unpinned.yaml 1 halt OK: E0005, the expected sentencerego release-terraform.yaml 0 pass OK: completed, byte-identical to the build with no policyrego release-terraform-unencrypted.yaml 1 halt OK: E0005, the expected sentencerego release-cloudformation.yaml 0 pass OK: completed, byte-identical to the build with no policyrego release-cloudformation-unencrypted.yaml 1 halt OK: E0005, the expected sentencerego release-arm.yaml 0 pass OK: completed, byte-identical to the build with no policyrego release-arm-unpinned.yaml 1 halt OK: E0005, the expected sentencecel release-helm.yaml 0 pass OK: completed, byte-identical to the build with no policycel release-helm-unpinned.yaml 1 halt OK: E0005, the expected sentencecel release-compose.yaml 0 pass OK: completed, byte-identical to the build with no policycel release-compose-unpinned.yaml 1 halt OK: E0005, the expected sentencecel release-terraform.yaml 0 pass OK: completed, byte-identical to the build with no policycel release-terraform-unencrypted.yaml 1 halt OK: E0005, the expected sentencecel release-cloudformation.yaml 0 pass OK: completed, byte-identical to the build with no policycel release-cloudformation-unencrypted.yaml 1 halt OK: E0005, the expected sentencecel release-arm.yaml 0 pass OK: completed, byte-identical to the build with no policycel release-arm-unpinned.yaml 1 halt OK: E0005, the expected sentence
check: every build ended as expected.ใช้./build-release.sh หาAGGREGA_BIN จึง-- ถูกdist/ อยู่
ตำแหน่งที่คอมไพเลอร์ไม่ตีความ
คอมไพเลอร์latest เปลี่ยน
ไฟล์
aggregate.yaml— ฐานข้อมูล และ งาน รายงาน ที่ เชื่อม โยง กับ ฐาน ข้อมูล นั้น aggregate-arm.yaml— ฐานข้อมูล เดียวกัน และ เวิร์กเกอร์ รายงาน สำหรับ การ บิลด์ Azure Resource Manager manifest-helm.yaml,manifest-compose.yaml,manifest-terraform.yaml,manifest-cloudformation.yaml,manifest-arm.yaml— ผูกชนิด ของ ส่วน ประกอบ แต่ละ ชนิด และ Features กับ Recipes ของ เป้า หมาย หนึ่ง เป้า หมาย release-<target>.yaml,release-<target>-unpinned.yaml,release-<target>-unencrypted.yaml— กรณีควบคุม หนึ่ง รายการ และ การ ละเมิด ที่ ฝัง ไว้ หนึ่ง รายการ ต่อ เป้า หมาย .aggrega-config.yaml— รีจิสทรีเริ่ม ต้น ไม่มี การ แนบ ด้าน การ กำกับ ดูแล governance-rego.yaml,governance-cel.yaml— กฎที่ แนบ ที่ render-verdictผ่านแต่ละ เอนจิน โดย แต่ละ ไฟล์ ระบุ ด้วย --configpolicies/house-rule.rego,policies/house-rule.cel— กฎ หนึ่งไฟล์ ต่อ เอนจิน build-release.sh— บิลด์ Release หนึ่งรายการ พร้อม พิมพ์ คำ สั่ง aggrega buildที่เทียบ เท่า ออก มา check.sh— บิลด์ทุก Release ภาย ใต้ แต่ละ เอนจิน และ ตรวจ สอบ ผลลัพธ์ แต่ละ รายการ