---
policy: /ce/ca/aws/s3/access-point-block-public-access
logic: /ce/ca/aws/s3/access-point-block-public-access/prod.logic.yaml
executionTime: 2025-11-20T13:28:57.583051358Z
generationMs: 53
executionMs: 607
rows:
  - id: test1
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10A1__blockPublicAcls__c') != 'Yes' || extract('CA10A1__blockPublicPolicy__c')
        != 'Yes' || extract('CA10A1__ignorePublicAcls__c') != 'Yes' || extract('CA10A1__restrictPublicBuckets__c')
        != 'Yes'
      actual: extract('CA10A1__blockPublicAcls__c') != 'Yes' || extract('CA10A1__blockPublicPolicy__c')
        != 'Yes' || extract('CA10A1__ignorePublicAcls__c') != 'Yes' || extract('CA10A1__restrictPublicBuckets__c')
        != 'Yes'
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10A1__disappearanceTime__c)
      actual: isDisappeared(CA10A1__disappearanceTime__c)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/s3/access-point-block-public-access/policy.yaml
    md5Hash: 0B75BD4DDC8D0350CE5B49C5F28E1A64
    content: "---\nnames:\n  full: \"AWS S3 Access Point is not configured to block\
      \ public access\"\n  contextual: \"Access Point is not configured to block public\
      \ access\"\ndescription: >\n  S3 Access Points provide Block Public Access settings\
      \ to help you manage public \n  access to Amazon S3 data. By default, new access\
      \ points have these settings enabled. \n  It is recommended to keep these settings\
      \ enabled to prevent data from being exposed \n  publicly through the access\
      \ point.\ntype: COMPLIANCE_POLICY\ncategories:\n  - SECURITY\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/s3/19\"\n  - \"/frameworks/aws-well-architected/sec/08/04\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[S3.19] S3 access points\
      \ should have block public access settings enabled\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/s3-controls.html#s3-19\""
  - path: /ce/ca/aws/s3/access-point-block-public-access/prod.logic.yaml
    md5Hash: 8870285330D39B89E9AA3AD645D2533D
    content: |
      ---
      inputType: "CA10A1__CaAwsS3AccessPoint__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10A1__CaAwsS3AccessPoint__c/object.extracts.yaml"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "The S3 Access Point is not configured to block public access."
          remediationMessage: "Consider configuring the S3 Access Point to block all public access settings."
          check:
            OR:
              args:
                - NOT_EQUAL:
                    left:
                      EXTRACT: CA10A1__blockPublicAcls__c
                    right:
                      TEXT: "Yes"
                - NOT_EQUAL:
                    left:
                      EXTRACT: CA10A1__blockPublicPolicy__c
                    right:
                      TEXT: "Yes"
                - NOT_EQUAL:
                    left:
                      EXTRACT: CA10A1__ignorePublicAcls__c
                    right:
                      TEXT: "Yes"
                - NOT_EQUAL:
                    left:
                      EXTRACT: CA10A1__restrictPublicBuckets__c
                    right:
                      TEXT: "Yes"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The S3 Access Point is configured to block all public access."
  - path: /ce/ca/aws/s3/access-point-block-public-access/test-data.json
    md5Hash: 289C5F24723E2816138A0D18A459AA54
    content: |-
      [
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10A1__blockPublicAcls__c') != 'Yes' || extract('CA10A1__blockPublicPolicy__c') != 'Yes' || extract('CA10A1__ignorePublicAcls__c') != 'Yes' || extract('CA10A1__restrictPublicBuckets__c') != 'Yes'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-11-09T19:32:58Z"
              },
              "CA10A1__disappearanceTime__c": null,
              "CA10A1__blockPublicAcls__c": "No",
              "CA10A1__blockPublicPolicy__c": "No",
              "CA10A1__ignorePublicAcls__c": "No",
              "CA10A1__restrictPublicBuckets__c": "No",
              "Id": "test1"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-11-09T19:32:58Z"
              },
              "CA10A1__disappearanceTime__c": null,
              "CA10A1__blockPublicAcls__c": "Yes",
              "CA10A1__blockPublicPolicy__c": "Yes",
              "CA10A1__ignorePublicAcls__c": "Yes",
              "CA10A1__restrictPublicBuckets__c": "Yes",
              "Id": "test2"
          },
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-11-09T19:32:58Z"
              },
              "CA10A1__disappearanceTime__c": "2025-11-09T19:32:58Z",
              "CA10A1__blockPublicAcls__c": "Yes",
              "CA10A1__blockPublicPolicy__c": "Yes",
              "CA10A1__ignorePublicAcls__c": "Yes",
              "CA10A1__restrictPublicBuckets__c": "Yes",
              "Id": "test3"
          }
      ]
  - path: /types/CA10A1__CaAwsS3AccessPoint__c/object.extracts.yaml
    md5Hash: C4AE44407725A35D6C756B35066C74E1
    content: "---\nextracts:\n  - name: \"CA10A1__blockPublicAcls__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10A1__blockPublicAcls__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10A1__blockPublicAcls__c\"\
      \n            currentStateMessage: \"Unable to determine block public access\
      \ settings. Possible permission issue with s3:GetAccessPoint\"\n  - name: \"\
      CA10A1__blockPublicPolicy__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10A1__blockPublicPolicy__c\"\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10A1__blockPublicPolicy__c\"\n            currentStateMessage:\
      \ \"Unable to determine block public access settings. Possible permission issue\
      \ with s3:GetAccessPoint\"\n  - name: \"CA10A1__ignorePublicAcls__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10A1__ignorePublicAcls__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10A1__ignorePublicAcls__c\"\
      \n            currentStateMessage: \"Unable to determine block public access\
      \ settings. Possible permission issue with s3:GetAccessPoint\"\n  - name: \"\
      CA10A1__restrictPublicBuckets__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10A1__restrictPublicBuckets__c\"\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10A1__restrictPublicBuckets__c\"\n            currentStateMessage:\
      \ \"Unable to determine block public access settings. Possible permission issue\
      \ with s3:GetAccessPoint\"\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" : "test1",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10A1__blockPublicAcls__c') != 'Yes' || extract('CA10A1__blockPublicPolicy__c') != 'Yes' || extract('CA10A1__ignorePublicAcls__c') != 'Yes' || extract('CA10A1__restrictPublicBuckets__c') != 'Yes'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10A1__disappearanceTime__c)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A1__CaAwsS3AccessPoint__c()
  RETURNS ARRAY<STRUCT<
      CA10A1__disappearanceTime__c TIMESTAMP,
      CA10A1__blockPublicAcls__c STRING,
      CA10A1__blockPublicPolicy__c STRING,
      CA10A1__ignorePublicAcls__c STRING,
      CA10A1__restrictPublicBuckets__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-11-09T19:32:58Z")
    },
    "CA10A1__blockPublicAcls__c" : "No",
    "CA10A1__blockPublicPolicy__c" : "No",
    "CA10A1__ignorePublicAcls__c" : "No",
    "CA10A1__restrictPublicBuckets__c" : "No",
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-09T19:32:58Z")
    },
    "CA10A1__blockPublicAcls__c" : "Yes",
    "CA10A1__blockPublicPolicy__c" : "Yes",
    "CA10A1__ignorePublicAcls__c" : "Yes",
    "CA10A1__restrictPublicBuckets__c" : "Yes",
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-09T19:32:58Z")
    },
    "CA10A1__disappearanceTime__c" : new Date("2025-11-09T19:32:58Z"),
    "CA10A1__blockPublicAcls__c" : "Yes",
    "CA10A1__blockPublicPolicy__c" : "Yes",
    "CA10A1__ignorePublicAcls__c" : "Yes",
    "CA10A1__restrictPublicBuckets__c" : "Yes",
    "Id" : "test3"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10A1__CaAwsS3AccessPoint__c(
      obj STRUCT<
          CA10A1__disappearanceTime__c TIMESTAMP,
          CA10A1__blockPublicAcls__c STRING,
          CA10A1__blockPublicPolicy__c STRING,
          CA10A1__ignorePublicAcls__c STRING,
          CA10A1__restrictPublicBuckets__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 [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c);
      if (obj.CA10A1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__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.CA10A1__blockPublicAcls__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__blockPublicAcls__c.delegatedTo(CA10A1__blockPublicAcls__c).isEmpty()", currentStateMessage: "Unable to determine block public access settings. Possible permission issue with s3:GetAccessPoint", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A1__blockPublicAcls__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10A1__blockPublicPolicy__c)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "CA10A1__blockPublicPolicy__c.delegatedTo(CA10A1__blockPublicPolicy__c).isEmpty()", currentStateMessage: "Unable to determine block public access settings. Possible permission issue with s3:GetAccessPoint", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A1__blockPublicPolicy__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10A1__ignorePublicAcls__c)) {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "CA10A1__ignorePublicAcls__c.delegatedTo(CA10A1__ignorePublicAcls__c).isEmpty()", currentStateMessage: "Unable to determine block public access settings. Possible permission issue with s3:GetAccessPoint", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A1__ignorePublicAcls__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      function fieldChecked13() {
          if (TextLib.isEmpty(obj.CA10A1__restrictPublicBuckets__c)) {
              throw new Error("UNDETERMINED condition:104", {cause: {status: 'UNDETERMINED', conditionIndex: 104, conditionText: "CA10A1__restrictPublicBuckets__c.delegatedTo(CA10A1__restrictPublicBuckets__c).isEmpty()", currentStateMessage: "Unable to determine block public access settings. Possible permission issue with s3:GetAccessPoint", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A1__restrictPublicBuckets__c;
      }
      function extract12() { if (!this.out) { this.out = fieldChecked13(); } return this.out; };
      references1.push('Block Public ACLs [obj.CA10A1__blockPublicAcls__c]: ' + obj.CA10A1__blockPublicAcls__c);
      references1.push('Block Public Policy [obj.CA10A1__blockPublicPolicy__c]: ' + obj.CA10A1__blockPublicPolicy__c);
      references1.push('Ignore Public ACLs [obj.CA10A1__ignorePublicAcls__c]: ' + obj.CA10A1__ignorePublicAcls__c);
      references1.push('Restrict Public Buckets [obj.CA10A1__restrictPublicBuckets__c]: ' + obj.CA10A1__restrictPublicBuckets__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'Yes') || TextLib.notEqual(extract6.call(extract6), 'Yes') || TextLib.notEqual(extract9.call(extract9), 'Yes') || TextLib.notEqual(extract12.call(extract12), 'Yes')) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__blockPublicAcls__c') != 'Yes' || extract('CA10A1__blockPublicPolicy__c') != 'Yes' || extract('CA10A1__ignorePublicAcls__c') != 'Yes' || extract('CA10A1__restrictPublicBuckets__c') != 'Yes'", currentStateMessage: "The S3 Access Point is not configured to block public access.", currentStateReferences: references1.join('\n'), remediation: "Consider configuring the S3 Access Point to block all public access settings.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The S3 Access Point is configured to block all public access.", 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.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
          sObject.CA10A1__blockPublicAcls__c AS CA10A1__blockPublicAcls__c,
          sObject.CA10A1__blockPublicPolicy__c AS CA10A1__blockPublicPolicy__c,
          sObject.CA10A1__ignorePublicAcls__c AS CA10A1__ignorePublicAcls__c,
          sObject.CA10A1__restrictPublicBuckets__c AS CA10A1__restrictPublicBuckets__c,
          sObject.Id AS Id,
          process_CA10A1__CaAwsS3AccessPoint__c(
              STRUCT(
                  sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                  sObject.CA10A1__blockPublicAcls__c AS CA10A1__blockPublicAcls__c,
                  sObject.CA10A1__blockPublicPolicy__c AS CA10A1__blockPublicPolicy__c,
                  sObject.CA10A1__ignorePublicAcls__c AS CA10A1__ignorePublicAcls__c,
                  sObject.CA10A1__restrictPublicBuckets__c AS CA10A1__restrictPublicBuckets__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10A1__CaAwsS3AccessPoint__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
