---
inputType: "CA10__CaAwsGuardDutyDetector__c"
testData:
  - file: "test-data.json"
importExtracts:
  - file: "/types/CA10__CaAwsGuardDutyDetector__c/object.extracts.yaml"
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "This GuardDuty Detector is not enabled."
    check:
      NOT_EQUAL:
        left:
          EXTRACT: "CA10__status__c"
        right:
          TEXT: "ENABLED"
  - status: "INCOMPLIANT"
    currentStateMessage: "EKS Runtime Monitoring is enabled for this detector."
    remediationMessage: "Consider migrating from EKS Runtime Monitoring to Runtime Monitoring."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
            expression: "[?name=='EKS_RUNTIME_MONITORING'].status | [0]" 
            arg:
              EXTRACT: "caJsonFrom__featuresJson__c"
            undeterminedIf:
              evaluationError: "Json query text has failed."
              resultTypeMismatch: "Json query text did not return text type."
        right:
          TEXT: "ENABLED"
  - status: "INCOMPLIANT"
    currentStateMessage: "Runtime Monitoring is not enabled for this detector."
    remediationMessage: "Enable Runtime Monitoring to monitor runtime events."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
            expression: "[?name=='RUNTIME_MONITORING'].status | [0]" 
            arg:
              EXTRACT: "caJsonFrom__featuresJson__c"
            undeterminedIf:
              evaluationError: "Json query text has failed."
              resultTypeMismatch: "Json query text did not return text type."
        right:
          TEXT: "DISABLED"
  - status: "COMPLIANT"
    currentStateMessage: "Runtime Monitoring is enabled for this detector."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
            expression: "[?name=='RUNTIME_MONITORING'].status | [0]" 
            arg:
              EXTRACT: "caJsonFrom__featuresJson__c"
            undeterminedIf:
              evaluationError: "Json query text has failed."
              resultTypeMismatch: "Json query text did not return text type."
        right:
          TEXT: "ENABLED"
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected values in the field."