Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome back to our course on architecting security products.
In our previous lesson, we designed a rule authoring subsystem and the foundational data model for mapping our internal CSPM rules to external technical benchmarks like the CIS Benchmarks. We established a link: a specific finding from our policy engine can now be traced back to a specific benchmark requirement (e.g., CIS AWS Foundations v2.0.0, Control 2.1.2).
While this is a crucial step, it provides only the raw data. An auditor or a CIO isn't interested in thousands of individual findings; they need to know, "Are we compliant with SOC 2?" Today, we will design the system that answers that question. We will build on our mapping foundation to aggregate low-level findings into high-level, business-relevant compliance reports.
Our learning outcome for this lesson is to: Design a compliance mapping system that links CSPM findings to regulatory frameworks such as SOC 2 and PCI-DSS.
We will architect the data models, processing logic, and visualization layers needed to transform technical security data into a clear and continuous view of your organization's compliance posture.
1. The Compliance Hierarchy: From Technical Checks to Strategic Objectives
The central challenge in compliance reporting is bridging the gap between different types of frameworks. They generally fall into two categories:
- Tactical/Prescriptive Benchmarks: These are technical and specific. Frameworks like the Center for Internet Security (CIS) Benchmarks give you concrete, testable instructions, such as "Ensure S3 bucket policy is configured to prevent public access." Our CSPM rules from the last lesson map directly to these requirements.
- Strategic/Control-Objective Frameworks: These are high-level and state goals. Frameworks like SOC 2 (Trust Services Criteria) or ISO 27001 state objectives like, "Controls are in place to prevent or detect and act upon the introduction of unauthorized and malicious software." They don't prescribe how to achieve this; that's up to the organization to define and prove.
Our system's primary job is to connect the results of our tactical checks to these strategic objectives, proving that our technical configurations satisfy the high-level compliance goals.

2. Architecting a Structured Governance Model
To connect these different layers, we can't just rely on manual processes. We need to treat compliance frameworks as structured data and build a "crosswalk" system that models their relationships.
A fantastic real-world example of this approach is detailed in a case study about a system built for Stacklet, the company behind the open-source Cloud Custodian project.
Scaling Cost and Compliance with Policy as Code - Six Feet Up
This article, 'Scaling Cost and Compliance with Policy as Code,' describes the exact problem we're trying to solve and presents a robust architectural solution.
Please read the 'Challenge' section, then continue to 'Implementation Details,' focusing on the 'Structured Governance Model' and 'Crosswalk from Benchmarks to Policies' sections. Pay attention to how they transformed vague requirements into a queryable data model.
As the article highlights, the key is to build a model that makes the overlap between frameworks explicit. A single technical check, like "ensure MFA is enabled for root," might satisfy requirements from SOC 2, PCI-DSS, and ISO 27001 simultaneously.
Let's evolve the data model from our previous lesson to support this:
-
Ingest All Frameworks: Our database must contain structured representations of both tactical benchmarks (CIS) and strategic frameworks (SOC 2, PCI-DSS). The
RequirementNodeentity from our last lesson is perfect for this, but we need an additional attribute:RequirementNode.type: An enum (strategic_objective,technical_benchmark).
-
Create a "Crosswalk" Mapping: We need a new join table to model the many-to-many relationship between strategic objectives and the technical benchmarks that implement them.
ObjectiveToBenchmarkMappingtable:strategic_req_node_urn(Foreign Key toRequirementNodewhere type isstrategic_objective)technical_req_node_urn(Foreign Key toRequirementNodewhere type istechnical_benchmark)rationale(Text field explaining why this benchmark satisfies the objective)
Now, we have a complete, queryable chain from a CSPM finding all the way up to a high-level compliance objective:
CSPM Finding -> CspmRule -> RuleToRequirementMapping -> RequirementNode (CIS) -> ObjectiveToBenchmarkMapping -> RequirementNode (SOC 2)
This multi-level mapping is the core of our compliance system's logic.
3. Standardizing the Model with NIST OSCAL
While our custom data model works, building and maintaining parsers and structures for every compliance framework is a significant engineering effort. A more robust, forward-looking approach is to adopt an industry standard for this very purpose: the Open Security Controls Assessment Language (OSCAL).
OSCAL is a set of standardized, machine-readable formats (in XML, JSON, and YAML) developed by NIST to represent security control catalogs, implementations, and assessment results.
[PDF] EUROSCAL - MEDINA project
The EUROSCAL whitepaper from the MEDINA project provides an excellent introduction to OSCAL and a practical example of its use.
Please read the following sections: Section 2.2 'OSCAL' (Pages 9-11): Focus on the goal of OSCAL and understand the purpose of its three main layers: Controls, Implementation, and Assessment. The table summarizing the layers and models is particularly helpful. Section 4.2 'OSCAL Format for...EUCS' (Pages 15-17): Skim this section to see a concrete JSON example of how a real-world framework (EUCS) is mapped into the OSCAL Catalog Model. This demonstrates how a complex document can be turned into structured, machine-readable data.
Adopting OSCAL as the foundation for our compliance system provides several architectural advantages:
- Interoperability: We can ingest any framework that has an OSCAL representation without writing a custom parser.
- Reduced Maintenance: As frameworks evolve, we only need to update the OSCAL data files, not our core application logic or database schema.
- Standardized Reporting: We can produce assessment results in the standard OSCAL
Assessment Resultformat, which can be consumed by other tools.
Architectural Redesign using OSCAL:
Instead of our custom Framework and RequirementNode tables, our system's data layer would be designed to handle OSCAL documents natively.
- Data Storage: We could use a document database (like MongoDB) or a JSONB column in a relational database (like PostgreSQL) to store OSCAL
Catalogdocuments directly. - Mapping Logic: Our
RuleToRequirementMappingtable would now link our internalCspmRule.idto a specific control within an OSCAL document (e.g., using the control's unique ID path). - Cross-Framework Linking: OSCAL profiles can inherit from and modify other catalogs, providing a standardized way to express the relationship we modeled with our
ObjectiveToBenchmarkMappingtable.
This approach aligns with your goal of understanding first principles by grounding our system in a robust, open standard.
4. Designing the Reporting and Aggregation Layer
With the data models in place, we need to build the services that aggregate findings and present them to users.
Aggregation Logic
A backend service (e.g., a scheduled job or a serverless function) will be responsible for calculating compliance scores. Here is the process:
- Fetch Findings: The service queries the database for all active CSPM findings from the latest scans.
- Traverse Mappings: For each finding, it follows the chain we established:
- Find the
CspmRulethat generated the finding.
- Use the mappings to identify all associated
RequirementNodes (both tactical and strategic).
- Find the
- Aggregate Status: The service builds an in-memory representation of each compliance framework's hierarchy (e.g., for SOC 2: all its Trust Services Criteria and their associated controls).
- Calculate Scores: It iterates through the hierarchy to determine the status of each node:
- A technical benchmark (
RequirementNodefrom CIS) isFAILif any of its associatedCspmRules have active findings. Otherwise, it isPASS. - A strategic objective (
RequirementNodefrom SOC 2) isFAILif any of its mapped technical benchmarks areFAIL. It is onlyPASSif all mapped benchmarks arePASS.
- A technical benchmark (
- Store Results: The calculated scores and pass/fail statuses for every control in every framework are stored in a dedicated
ComplianceReporttable, ready to be served by the API to the frontend.
Visualization and User Interface
The final piece is the UI that presents this aggregated data. A good compliance dashboard provides views for different personas.

A comprehensive UI would include:
- Executive Dashboard (The Heatmap): An overview showing percentage scores for each environment against each major framework. This is for CIOs and CISOs.
- Compliance Manager View: A deep-dive page for a single framework (e.g., PCI-DSS). It should display the framework's hierarchy of requirements, each with its calculated score and pass/fail status.
- Engineer/Operator View: Clicking on a failing control should drill down to a list of non-compliant resources. Each resource should link back to the raw CSPM finding, showing the evidence, the failing rule, and the resource metadata needed to fix the issue.
- Auditor View (Evidence Generation): A feature to export a compliance report for a selected framework. The report should list every control, its current status, and provide links to the underlying evidence (the pass/fail results of the individual CSPM checks). This is non-negotiable for any real-world audit.
Conclusion
In this lesson, we designed the complete system for transforming raw, low-level security findings into high-level, actionable compliance intelligence. We moved from simply knowing "what is broken" to understanding "what it means for our business."
Key Takeaways:
- Bridging the Hierarchy: The core of compliance mapping is architecting a "crosswalk" system that connects strategic control objectives (like those in SOC 2) to the tactical, technical checks performed by a CSPM.
- Model as Structured Data: Effective systems treat compliance frameworks as queryable data, not as static documents. This enables automation, aggregation, and analysis.
- Leverage Standards: Using a standard like NIST OSCAL provides a robust, interoperable foundation, saving significant engineering effort and making the system more future-proof.
- Multi-Layered Reporting: A successful compliance system must provide tailored visualizations for different stakeholders—from high-level heatmaps for executives to detailed evidence trails for auditors and engineers.
Preview of the Next Lesson
Our CSPM can now assess our cloud environment's configuration and report its compliance posture at a specific point in time. However, compliance is a continuous process, not a one-time snapshot. The moment after a scan finishes, a developer could make a change that brings a resource out of compliance.
In our next lesson, we will address this by tackling the learning outcome: Design a drift detection system to track configuration changes over time and trigger alerts on policy violations. We will architect the systems needed to move from periodic assessment to continuous monitoring, enabling us to detect and react to compliance-breaking changes in near real-time.