Palo Alto Networks Certified Security Automation Engineer (PCSAE)IntegrationsEasy
A security analyst is developing a custom integration for Cortex XSOAR that interacts with a proprietary logging system. The logging system's API requires a specific `X-API-Version` header to be present in all requests, with a value of `2.1`. How should the analyst ensure this header is consistently included in all HTTP requests made by the integration?
- AModify the `_http_request` method in the integration to inject the header before making the request.
- BConfigure the `BaseClient` class within the integration to include the `X-API-Version` header in its default headers.
- CAdd the header directly to each `demisto.requests.get()` or `demisto.requests.post()` call within the integration code.
- DDefine the `X-API-Version` header as an integration instance parameter and pass it to each HTTP request.
Show answer & explanationAnswer & explanation
Correct answer: B. Configure the `BaseClient` class within the integration to include the `X-API-Version` header in its default headers.
To ensure a specific header is consistently included in all HTTP requests made by an integration, it should be configured in the BaseClient's default headers. This approach centralizes header management and prevents redundancy.
Why the other options are wrong
- A. Modifying `_http_request` is an option for more complex, dynamic header injection, but for a static, consistently required header, `BaseClient` default headers is the more direct and idiomatic solution.
- C. This approach is inefficient and prone to errors, as the header would need to be added manually to every single request function call.
- D. While parameters can be used, directly adding it to each request from a parameter is less efficient than configuring it globally in the `BaseClient` for consistent inclusion.
BaseClient Headers
The `BaseClient` class in Cortex XSOAR integrations allows for the configuration of default HTTP headers that will be automatically included in all requests made through that client instance.
- Ensures consistent header inclusion across all requests.
- Centralizes header management for easier maintenance.
- Configured during the `BaseClient` initialization.
Memory trick: BaseClient Builds Better Headers.