---

inputType: "CA10__CaGoogleProject__c"
testData:
  - file: test-data.json
importExtracts:
  - file: /types/CA10__CaGoogleProject__c/object.extracts.yaml
conditions:
  - status: "COMPLIANT"
    currentStateMessage: "Cloud Audit Logging is configured to track all admin activities and read, write access to user data."
    check:
      RELATED_LIST_HAS:
        status: "COMPLIANT"
        relationshipName: "CA10__Google_Resource_Manager_Projects__r"
otherwise:
  status: "INCOMPLIANT"
  currentStateMessage: "Cloud Audit Logging is not configured to track all admin activities and read, write access to user data."
  remediationMessage: "Configure Cloud Audit Logging to track all admin activities and read, write access to user data."
relatedLists:
  - relationshipName: "CA10__Google_Resource_Manager_Projects__r"
    importExtracts:
      - file: /types/CA10__CaGoogleIamPolicyAuditConfig__c/object.extracts.yaml
      - file: /types/CA10__CaGoogleIamPolicyAuditLogConfig__c/object.extracts.yaml
    conditions:
      - status: "COMPLIANT"
        currentStateMessage: "Cloud Audit Logging is configured to track all admin activities and read, write access to user data."
        check:
          OR:
            args:
              - RELATED_LIST_HAS:
                  status: "COMPLIANT"
                  relationshipName: "CA10__Google_IAM_Policy_Audit_Configs__r"
              - RELATED_LIST_HAS:
                  status: "COMPLIANT"
                  relationshipName: "CA10__resourceManagerFolder__r.CA10__Google_IAM_Policy_Audit_Configs__r"
              - RELATED_LIST_HAS:
                  status: "COMPLIANT"
                  relationshipName: "CA10__resourceManagerOrganization__r.CA10__Google_IAM_Policy_Audit_Configs__r"
    otherwise:
      status: "INCOMPLIANT"
      currentStateMessage: "Resource Manager Project is not configured to track all admin activities and read, write access to user data."
    relatedLists:
    # PROJECT level
      - relationshipName: "CA10__Google_IAM_Policy_Audit_Configs__r"
        recordTypes:
        - "caGoogleIamPolicyAuditConfigProject"
        conditions:
          - status: "COMPLIANT"
            currentStateMessage: "Project Audit Config is configured to track all admin activities and read, write access to user data." 
            check:
              AND:
                args:
                  - IS_EQUAL:
                      left:
                        RELATED_LIST_COUNT:
                          status: "COMPLIANT"
                          relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
                      right:
                        NUMBER: 2.0
                  - IS_EMPTY:
                      arg:
                        EXTRACT: "CA10__exemptedMembers__c" # Audit_Configs
                  - IS_EQUAL:
                      left:
                        EXTRACT: "CA10__service__c"
                      right:
                        TEXT: "allServices"
        otherwise:
          status: "INCOMPLIANT"
          currentStateMessage: "Project Audit Config is not configured to track all admin activities and read, write access to user data."
        relatedLists:
          - relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
            conditions:
              - status: "COMPLIANT"
                currentStateMessage: "COMPLIANT Audit Log Configs"
                check:
                 AND:
                   args:
                    - OR:
                       args:
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right:
                              TEXT: "DATA_WRITE"
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right: 
                              TEXT: "DATA_READ"
                    - IS_EMPTY:
                        arg:
                          EXTRACT: "CA10__exemptedMembers__c" # Audit_Log_Config
            otherwise:
              status: "INCOMPLIANT"
              currentStateMessage: "INCOMPLIANT Audit Log Configs"
# FOLDER level
      - relationshipName: "CA10__resourceManagerFolder__r.CA10__Google_IAM_Policy_Audit_Configs__r"
        recordTypes:
        - "caGoogleIamPolicyAuditConfigFolder"
        conditions:
          - status: "COMPLIANT"
            currentStateMessage: "Folder Audit Config is configured to track all admin activities and read, write access to user data." 
            check:
              AND:
                args:
                  - IS_EQUAL:
                      left:
                        RELATED_LIST_COUNT:
                          status: "COMPLIANT"
                          relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
                      right:
                        NUMBER: 2.0
                  - IS_EMPTY:
                      arg:
                        EXTRACT: "CA10__exemptedMembers__c" # Audit_Configs
                  - IS_EQUAL:
                      left:
                        EXTRACT: "CA10__service__c"
                      right:
                        TEXT: "allServices"
        otherwise:
          status: "INCOMPLIANT"
          currentStateMessage: "Folder Audit Config is not configured to track all admin activities and read, write access to user data."
        relatedLists:
          - relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
            conditions:
              - status: "COMPLIANT"
                currentStateMessage: "COMPLIANT Audit Log Configs"
                check:
                 AND:
                   args:
                    - OR:
                       args:
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right:
                              TEXT: "DATA_WRITE"
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right: 
                              TEXT: "DATA_READ"
                    - IS_EMPTY:
                        arg:
                          EXTRACT: "CA10__exemptedMembers__c" # Audit_Log_Config
            otherwise:
              status: "INCOMPLIANT"
              currentStateMessage: "INCOMPLIANT Audit Log Configs"
# ORG level
      - relationshipName: "CA10__resourceManagerOrganization__r.CA10__Google_IAM_Policy_Audit_Configs__r"
        recordTypes:
        - "caGoogleIamPolicyAuditConfigOrganization"
        conditions:
          - status: "COMPLIANT"
            currentStateMessage: "Organization Audit Config is configured to track all admin activities and read, write access to user data." 
            check:
              AND:
                args:
                  - IS_EQUAL:
                      left:
                        RELATED_LIST_COUNT:
                          status: "COMPLIANT"
                          relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
                      right:
                        NUMBER: 2.0
                  - IS_EMPTY:
                      arg:
                        EXTRACT: "CA10__exemptedMembers__c" # Audit_Configs
                  - IS_EQUAL:
                      left:
                        EXTRACT: "CA10__service__c"
                      right:
                        TEXT: "allServices"
        otherwise:
          status: "INCOMPLIANT"
          currentStateMessage: "Organization Audit Config is not configured to track all admin activities and read, write access to user data."
        relatedLists:
          - relationshipName: "CA10__Google_IAM_Policy_Audit_Log_Config1__r"
            conditions:
              - status: "COMPLIANT"
                currentStateMessage: "COMPLIANT Audit Log Configs"
                check:
                 AND:
                   args:
                    - OR:
                       args:
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right:
                              TEXT: "DATA_WRITE"
                        - IS_EQUAL:
                            left:
                              EXTRACT: "CA10__logType__c"
                            right: 
                              TEXT: "DATA_READ"
                    - IS_EMPTY:
                        arg:
                          EXTRACT: "CA10__exemptedMembers__c" # Audit_Log_Config
            otherwise:
              status: "INCOMPLIANT"
              currentStateMessage: "INCOMPLIANT Audit Log Configs"