---
policy: /ce/ca/aws/acm/certificate-validity
logic: /ce/ca/aws/acm/certificate-validity/prod.logic.yaml
executionTime: 2025-12-27T12:01:37.863347375Z
generationMs: 108
executionMs: 657
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__status__c') == 'PENDING_VALIDATION'
      actual: extract('CA10__status__c') == 'PENDING_VALIDATION'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__status__c') == 'FAILED'
      actual: extract('CA10__status__c') == 'FAILED'
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__status__c') == 'VALIDATION_TIMED_OUT'
      actual: extract('CA10__status__c') == 'VALIDATION_TIMED_OUT'
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/acm/certificate-validity/policy.yaml
    md5Hash: 6DE0DCE7DD1EEA029C8C4D52B6C39777
    content: "---\nnames:\n  full: AWS ACM Certificate validation has failed\n  contextual:\
      \ Certificate validation has failed\ndescription: >\n  Ensure that AWS ACM Certificates\
      \ are successfully validated. Certificates with \n  a status of FAILED or VALIDATION_TIMED_OUT\
      \ cannot be used to secure traffic \n  and indicate an issue with the domain\
      \ ownership verification process.\ncategories:\n  - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\
      \nframeworkMappings:\n  - \"/frameworks/cloudaware/secret-and-certificate-governance/cryptographic-configuration\"\
      \n  - \"/frameworks/aws-well-architected/sec/09/01\"\nsimilarPolicies:\n  cloudConformity:\n\
      \    - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/ACM/certificate-validity.html\n\
      \      name: AWS ACM Certificates Validity\n"
  - path: /ce/ca/aws/acm/certificate-validity/prod.logic.yaml
    md5Hash: A528DB62554B6B096E2DC24C7689C236
    content: |
      ---
      inputType: "CA10__CaAwsAcmCertificate__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAwsAcmCertificate__c/object.extracts.yaml"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "This certificate validation is pending."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__status__c"
              right:
                TEXT: "PENDING_VALIDATION"
        - status: "INCOMPLIANT"
          currentStateMessage: "The certificate validation has failed."
          remediationMessage: "Review the failure reason and re-initiate validation."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__status__c"
              right:
                TEXT: "FAILED"
        - status: "INCOMPLIANT"
          currentStateMessage: "The certificate validation has timed out."
          remediationMessage: "Ensure that the validation requirements are met and re-initiate validation."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__status__c"
              right:
                TEXT: "VALIDATION_TIMED_OUT"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The certificate is issued."
  - path: /ce/ca/aws/acm/certificate-validity/test-data.json
    md5Hash: 60FFF86A0F3A483E7FB5AFBD2EFDF78C
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-21T23:51:55Z" },
          "CA10__disappearanceTime__c": "2025-12-12T21:19:09Z",
          "CA10__status__c": "VALIDATION_TIMED_OUT",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__status__c') == 'PENDING_VALIDATION'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-21T23:51:55Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__status__c": "PENDING_VALIDATION",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__status__c') == 'FAILED'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-21T23:51:55Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__status__c": "FAILED",
          "Id": "003"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__status__c') == 'VALIDATION_TIMED_OUT'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-21T23:51:55Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__status__c": "VALIDATION_TIMED_OUT",
          "Id": "004"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "400",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-21T23:51:55Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__status__c": "ISSUED",
          "Id": "005"
        }
      ]
  - path: /types/CA10__CaAwsAcmCertificate__c/object.extracts.yaml
    md5Hash: D20EE095842A506CDEF3AC47E90A5A3B
    content: "---\nextracts:\n# Values: PENDING_VALIDATION | ISSUED | INACTIVE | EXPIRED\
      \ | REVOKED | FAILED | VALIDATION_TIMED_OUT\n# Not Nullable can't have no access\n\
      \  - name: CA10__status__c\n    value: \n      FIELD:\n        path: CA10__status__c\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: CA10__status__c\n\
      \            currentStateMessage: Unable to determine certificate status. Possible\
      \ permission issue with acm:DescribeCertificate\n          isEmpty: Status is\
      \ not populated yet\n# Nullable\n  - name: CA10__notAfter__c\n    value: \n\
      \      FIELD:\n        path: CA10__notAfter__c\n        undeterminedIf:\n  \
      \        noAccessDelegate:\n            path: CA10__notAfter__c\n          \
      \  currentStateMessage: Unable to determine certificate 'NotAfter'. Possible\
      \ permission issue with acm:DescribeCertificate\n# Not Nullable\n  - name: CA10__domainName__c\n\
      \    value: \n      FIELD:\n        path: CA10__domainName__c\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: CA10__domainName__c\n      \
      \      currentStateMessage: Unable to determine certificate domain name. Possible\
      \ permission issue with acm:DescribeCertificate\n          isEmpty: Domain name\
      \ is not populated yet\n# Values: ELIGIBLE | INELIGIBLE, Not Nullable\n  - name:\
      \ CA10__renewalEligibility__c\n    value: \n      FIELD:\n        path: CA10__renewalEligibility__c\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: CA10__renewalEligibility__c\n\
      \            currentStateMessage: Unable to determine certificate renewal eligibility.\
      \ Possible permission issue with acm:DescribeCertificate\n          isEmpty:\
      \ Renewal eligibility is not populated yet\n# Values: RSA-1024 | RSA-2048 |\
      \ RSA-3072 | RSA-4096 | EC-prime256v1 | EC-secp384r1 | EC-secp521r1\n# Not Nullable\n\
      \  - name: CA10__keyAlgorithm__c\n    value: \n      FIELD:\n        path: CA10__keyAlgorithm__c\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: CA10__keyAlgorithm__c\n\
      \            currentStateMessage: Unable to determine certificate status. Possible\
      \ permission issue with acm:DescribeCertificate\n          isEmpty: Key Algorithm\
      \ is not populated yet\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__status__c') == 'PENDING_VALIDATION'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__status__c') == 'FAILED'",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__status__c') == 'VALIDATION_TIMED_OUT'",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAcmCertificate__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__status__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-21T23:51:55Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-12-12T21:19:09Z"),
    "CA10__status__c" : "VALIDATION_TIMED_OUT",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-21T23:51:55Z")
    },
    "CA10__status__c" : "PENDING_VALIDATION",
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-21T23:51:55Z")
    },
    "CA10__status__c" : "FAILED",
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-21T23:51:55Z")
    },
    "CA10__status__c" : "VALIDATION_TIMED_OUT",
    "Id" : "004"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-21T23:51:55Z")
    },
    "CA10__status__c" : "ISSUED",
    "Id" : "005"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsAcmCertificate__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__status__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
  var TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__status__c.delegatedTo(CA10__status__c).isEmpty()", currentStateMessage: "Unable to determine certificate status. Possible permission issue with acm:DescribeCertificate", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Status is not populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'PENDING_VALIDATION')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') == 'PENDING_VALIDATION'", currentStateMessage: "This certificate validation is pending.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__status__c.delegatedTo(CA10__status__c).isEmpty()", currentStateMessage: "Unable to determine certificate status. Possible permission issue with acm:DescribeCertificate", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Status is not populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      try {
          if (TextLib.equal(extract6.call(extract6), 'FAILED')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__status__c') == 'FAILED'", currentStateMessage: "The certificate validation has failed.", currentStateReferences: references1.join('\n'), remediation: "Review the failure reason and re-initiate validation.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__status__c.delegatedTo(CA10__status__c).isEmpty()", currentStateMessage: "Unable to determine certificate status. Possible permission issue with acm:DescribeCertificate", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Status is not populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      try {
          if (TextLib.equal(extract9.call(extract9), 'VALIDATION_TIMED_OUT')) {
              return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__status__c') == 'VALIDATION_TIMED_OUT'", currentStateMessage: "The certificate validation has timed out.", currentStateReferences: references1.join('\n'), remediation: "Ensure that the validation requirements are met and re-initiate validation.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "The certificate is issued.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__status__c AS CA10__status__c,
          sObject.Id AS Id,
          process_CA10__CaAwsAcmCertificate__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__status__c AS CA10__status__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsAcmCertificate__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
