Record Class ComplianceRule

java.lang.Object
java.lang.Record
com.cloudforgeci.api.core.rules.ComplianceRule
Record Components:
ruleId - Unique identifier for this compliance rule (e.g., "SOC2-CC6.1", "PCI-DSS-Req3.4")
description - Human-readable description of the requirement
configRuleId - Optional AWS Config rule ID that monitors this requirement
passed - Whether the validation check passed -- true for both a clean pass and an advisory
errorMessage - Optional error message if validation failed
recommendation - Optional recommendation for an ADVISORY-tier control that's off; present only on a passed=true result, distinguishing "clean pass" from "passed, but here's a recommendation" without a separate boolean. See advisory(String, String, String).

public record ComplianceRule(String ruleId, String description, Optional<String> configRuleId, boolean passed, Optional<String> errorMessage, Optional<String> recommendation) extends Record
Represents a compliance rule with its validation status and AWS Config rule mapping.

This structured approach links compliance validation to actual AWS Config rules, providing traceability between framework requirements and infrastructure monitoring.

  • Constructor Details

    • ComplianceRule

      public ComplianceRule(String ruleId, String description, Optional<String> configRuleId, boolean passed, Optional<String> errorMessage, Optional<String> recommendation)
      Creates an instance of a ComplianceRule record class.
      Parameters:
      ruleId - the value for the ruleId record component
      description - the value for the description record component
      configRuleId - the value for the configRuleId record component
      passed - the value for the passed record component
      errorMessage - the value for the errorMessage record component
      recommendation - the value for the recommendation record component
  • Method Details

    • pass

      public static ComplianceRule pass(String ruleId, String description, String configRuleId)
      Create a passing compliance rule.
    • pass

      public static ComplianceRule pass(String ruleId, String description)
      Create a passing compliance rule without Config rule mapping.
    • fail

      public static ComplianceRule fail(String ruleId, String description, String errorMessage)
      Create a failing compliance rule with error message.
    • fail

      public static ComplianceRule fail(String ruleId, String description, String configRuleId, String errorMessage)
      Create a failing compliance rule with Config rule mapping.
    • advisory

      public static ComplianceRule advisory(String ruleId, String description, String recommendation)
      Create an ADVISORY-tier finding: the control is off, but the framework doesn't require it, so this must never block synthesis. passed stays true; recommendation carries the specific, actionable text for the compliance report.
    • advisory

      public static ComplianceRule advisory(String ruleId, String description, String configRuleId, String recommendation)
      Create an ADVISORY-tier finding with Config rule mapping.
    • isAdvisory

      public boolean isAdvisory()
      True for a passed result that carries a recommendation -- distinguishes an advisory finding from a clean pass without a separate constructor flag.
    • toErrorString

      public Optional<String> toErrorString()
      Convert to legacy string error format for CDK validation.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • ruleId

      public String ruleId()
      Returns the value of the ruleId record component.
      Returns:
      the value of the ruleId record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • configRuleId

      public Optional<String> configRuleId()
      Returns the value of the configRuleId record component.
      Returns:
      the value of the configRuleId record component
    • passed

      public boolean passed()
      Returns the value of the passed record component.
      Returns:
      the value of the passed record component
    • errorMessage

      public Optional<String> errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • recommendation

      public Optional<String> recommendation()
      Returns the value of the recommendation record component.
      Returns:
      the value of the recommendation record component