---
inputType: "CA10__CaAwsUser__c"
testData:
  - file: test-data.json
importExtracts:
  - file: /types/CA10__CaAwsUser__c/credReport.extracts.yaml
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "Requirements of this policy are applicable only to users with enabled console password or access keys."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportPasswordEnabled__c
              right:
                BOOLEAN: false
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey1Active__c
              right:
                BOOLEAN: false
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey2Active__c
              right:
                BOOLEAN: false
  - status: "INCOMPLIANT"
    currentStateMessage: "Password hasn't been used for over 45 days."
    remediationMessage: "Consider disabling the Console Access for the user."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportPasswordEnabled__c
              right:
                BOOLEAN: true
          - NOT_EMPTY:
              arg:
                EXTRACT: CA10__credReportPasswordLastUsed__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportPasswordLastUsed__c
  - status: "INCOMPLIANT"
    currentStateMessage: "Password hasn't been changed over 45 days."
    remediationMessage: "Consider disabling the Console Access for the user."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportPasswordEnabled__c
              right:
                BOOLEAN: true
          - IS_EMPTY:
              arg:
                EXTRACT: CA10__credReportPasswordLastUsed__c
          - NOT_EMPTY:
              arg: 
                EXTRACT: CA10__credReportPasswordLastChanged__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportPasswordLastChanged__c
  - status: "INCOMPLIANT"
    currentStateMessage: "Access Key 1 hasn't been used for over 45 days."
    remediationMessage: "Consider deactivating the Access Key 1."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey1Active__c
              right:
                BOOLEAN: true
          - NOT_EMPTY:
              arg:
                EXTRACT: CA10__credReportAccessKey1LastUsed__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportAccessKey1LastUsed__c
  - status: "INCOMPLIANT"
    currentStateMessage: "Access key 1 hasn't been rotated for over 45 days."
    remediationMessage: "Consider deleting the Access Key 1."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey1Active__c
              right:
                BOOLEAN: true
          - IS_EMPTY:
              arg:
                EXTRACT: CA10__credReportAccessKey1LastUsed__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportAccessKey1LastRotated__c
  - status: "INCOMPLIANT"
    currentStateMessage: "Access Key 2 hasn't been used for over 45 days."
    remediationMessage: "Consider deactivating the Access Key 2."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey2Active__c
              right:
                BOOLEAN: true
          - NOT_EMPTY:
              arg:
                EXTRACT: CA10__credReportAccessKey2LastUsed__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportAccessKey2LastUsed__c
  - status: "INCOMPLIANT"
    currentStateMessage: "Access key 2 hasn't been rotated for over 45 days."
    remediationMessage: "Consider deleting the Access Key 2."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: CA10__credReportAccessKey2Active__c
              right:
                BOOLEAN: true
          - IS_EMPTY:
              arg:
                EXTRACT: CA10__credReportAccessKey2LastUsed__c
          - IS_BEYOND_LAST_DAYS:
              offsetDays: 45
              arg:
                EXTRACT: CA10__credReportAccessKey2LastRotated__c
otherwise:
  status: "COMPLIANT"
  currentStateMessage: "All credentials unused for 45 days or longer were removed or deactivated"