Activar Application & API Protection para PHP

Este producto no es compatible con el sitio Datadog seleccionado. ().

Puedes monitorizar la seguridad de las aplicaciones PHP que se ejecutan en entornos basados ​​en host o en contenedores, como Docker, Kubernetes, AWS ECS y AWS EKS.

Prerequisites

Activar Application & API Protection

Para empezar

  1. Instala la última versión de la biblioteca PHP de Datadog descargando y ejecutando el instalador:

    wget https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php -O datadog-setup.php
    php datadog-setup.php --php-bin all --enable-appsec
    

    Para comprobar que las versiones del lenguaje y del marco de trabajo de tu servicio son compatibles con las funciones de Application & API Protection, consulta Compatibilidad.

  2. Habilita la biblioteca en tu código reiniciando PHP-FPM o Apache. En un entorno de contenedores, si previamente instalaste la biblioteca sin habilitar Application & API Protection, puedes habilitarla opcionalmente después al configurar las siguientes variables de entorno:

    Actualiza tu contenedor de configuración para APM añadiendo los siguientes argumentos en tu comando docker run:

    docker run [...] -e DD_APPSEC_ENABLED=true -e DD_APM_TRACING_ENABLED=false [...]
    

    Añade los siguientes valores de variable de entorno a tu archivo de contenedor de Docker:

    ENV DD_APPSEC_ENABLED=true
    ENV DD_APM_TRACING_ENABLED=false
    

    Actualiza el contenedor de tu archivo yaml de configuración para APM y añade las variables de entorno:

    spec:
      template:
        spec:
          containers:
            - name: <CONTAINER_NAME>
              image: <CONTAINER_IMAGE>/<TAG>
              env:
                - name: DD_APPSEC_ENABLED
                  value: "true"
                - name: DD_APM_TRACING_ENABLED
                  value: "false"
    

    Actualiza tu archivo JSON de definición de tareas de ECS, añadiendo esto en la sección de entorno:

    "environment": [
      ...,
      {
        "name": "DD_APPSEC_ENABLED",
        "value": "true"
      },
      {
        "name": "DD_APM_TRACING_ENABLED",
        "value": "false"
      }
    ]
    

    The library collects security data from your application and sends it to the Agent, which sends it to Datadog, where out-of-the-box detection rules flag attacker techniques and potential misconfigurations so you can take steps to remediate.

  3. To see App and API Protection threat detection in action, send known attack patterns to your application. For example, trigger the Security Scanner Detected rule by running a file that contains the following curl script:

    for ((i=1;i<=250;i++)); 
    do
    # Target existing service’s routes
    curl https://your-application-url/existing-route -A dd-test-scanner-log;
    # Target non existing service’s routes
    curl https://your-application-url/non-existing-route -A dd-test-scanner-log;
    done

    Note: The dd-test-scanner-log value is supported in the most recent releases.

    A few minutes after you enable your application and exercise it, threat information appears in the Application Trace and Signals Explorer in Datadog.

Referencias adicionales