qwed-infra provides four guards to verify different aspects of your infrastructure. Every guard’s to_diagnostic() method converts its result into a unified InfraDiagnosticResult with an audit trace and proof reference.
1. IamGuard
Engine: Z3 Theorem Prover IamGuard converts AWS IAM Policies into first-order logic formulas to prove or disprove access. This is superior to regex-based policy checks because it reasons about logic (AND, OR, NOT, Conditions) using an SMT solver.Capabilities
- Wildcard Logic: Correctly handles
s3:*,bucket/*expansion using Z3 regex (InRe). - Conditions: Supports context keys like
aws:SourceIp(CIDR blocks),aws:CurrentTime(Date comparisons),StringEquals, andStringLike. - Deny Overrides: Mathematically proves that an explicit
Denyalways overrides anAllow, regardless of statement order. - Least Privilege Analysis:
verify_least_privilege(policy)proves whether a policy allows full admin access (*on*). - Unknown Operator Fail-Closed: An unrecognized condition operator causes a
BLOCKEDresult — never a silent pass.
API
Diagnostic Mapping
2. NetworkGuard
Engine: NetworkX (Graph Theory) NetworkGuard builds a directed graph of your network topology (VPCs, Subnets, Route Tables, Security Groups, NACLs, Internet Gateways). It uses graph traversal algorithms to verify reachability.Capabilities
- Public Access Check: Validates if a path exists from
Internetto a specificInstance.- Path:
Internet -> IGW -> Route Table -> Subnet -> Security Group -> Instance.
- Path:
- Port Verification: Ensures critical management ports (22 SSH, 3389 RDP) are not exposed to
0.0.0.0/0. - Segmentation Verification: Proves that sensitive subnets (e.g., Database) are isolated from public subnets.
- Fail-Closed Topologies: Returns
UNVERIFIABLEwhen the topology contains NAT Gateways, VPC Peering, NACLs, or Transit Gateway — constructs the guard cannot model deterministically.
API
Diagnostic Mapping
3. CostGuard
Engine: Deterministic Arithmetic & Pricing Catalog CostGuard estimates the monthly cost of your infrastructure definition before deployment using an embedded, static pricing catalog with Decimal arithmetic (no floating-point rounding errors).Capabilities
- Budget enforcement: Blocks deployment if
estimated_cost > budget. - Anomaly detection: Flags expensive instance types (e.g.,
p4d.24xlargeGPU instances) as suspected hallucinations. - Granular breakdown: Provides cost breakdown by resource type (Compute, Storage, Database).
- Fail-Closed Unknown Types: Unknown instance or volume types produce a
BLOCKEDresult — never a silent zero-cost estimate.
API
Diagnostic Mapping
4. ArtifactBoundaryGuard
Engine: File system scanning + TOML build config validation ArtifactBoundaryGuard is a release gate that verifies a Python package’s source tree andpyproject.toml build configuration before publishing. It ensures that no secrets, debug artifacts, or unintended files leak into the distribution.
Capabilities
- Secret Detection: Scans for
.pem,.key,.env, credential files, and other sensitive patterns in the package surface. - Debug Artifact Detection: Flags test files (
test_*.py), notebooks (*.ipynb), and debug directories (__pycache__,.git) included in the package. - Build Config Validation: Parses
[tool.hatch.build.targets.wheel]to confirm the package boundary is explicit. Blocks if the config is missing, invalid, or doesn’t reference the expected package name. - Disclosure Risk Detection: Flags project-structure files (
.gitignore,.dockerignore) that could leak internal conventions. - Fail-Closed on Missing TOML Parser: If neither
tomllibnortomliis available, every package isBLOCKED.