Table of contents
Topics on this page

Configure the PHP agent with the API

In most cases, the Application Security agent automatically detects all supported threat types. The Application Security agent also provides an API that the application can integrate with and that provides advanced functionality.

Tag setting API

Security events tags that have been set during the agent configuration are included in the security events. You can also integrate with the API to dynamically set tags from the application code.

trend_app_protect_set_tag($key, $value)

where:

  • $key: string up to 128 bytes, containing numbers, letters, spaces, and special characters + - = . _ : / @

  • $value: string up to 1024 bytes, containing any UTF-8 characters, except NUL (null byte). Note that the setting of tag from the API has precedence over the tags with same key, being set in the agent configuration.

If the tag setting is set from the API, it has precedence over the tags with the same key that have been set in the agent configuration.

If setting the tag is successful, "True" is returned. If it isn't, "False" is returned.

Dynamically set the tags using API calls:

<?php
trend_app_protect_set_tag("tenant_id", "some-tenant-id");
// Rest of page script
?>

Malicious Payload and Malicious File Upload detection can block an HTTP request early, before the execution of PHP scripts. However, the script specified in trend_app_protect.prepend_php_file is always executed. For more information, see Security events tags. To make sure tags are added even when requests are blocked early, trend_app_protect_set_tag can be called from the prepended script. In the agent configuration, set the php file into prepend_php_file setting, for example:

trend_app_protect.prepend_php_file = /path/to/prepend.php