Plugin Functions and Operators
Custom plugins support the mutation and assertion functions and a wide range of operators within each of them. These functions allow you to define how Traceable should inspect the APIs for vulnerabilities. The attributes in these functions refer to the specific elements in the request or response, such as headers, body, and query parameters, while the operators specify the comparison type to perform.
This document highlights details about attributes and operators, along with descriptions and examples of how to use them in the mutation and assertion functions.
Attributes and their Convention
Attributes are the elements in the API requests and responses. While writing custom plugins, you must refer to these attributes as part of the mutation and assertion functions.
As mentioned in the Working of a Plugin, Traceable creates a clone of the original request to create a mutated one. The attributes in these requests are represented in the following manner:
The attributes prefixed with
original.correspond to the traffic being received or generated in the original request.The attributes prefixed with
mutated.correspond to the modified request
For example, the authorization header is represented as original.header.request.header.authorization in the original request and mutated.header.request.header.authorization in the mutated request.
The following is the common list of attributes that you can use while writing a custom plugin:
Attribute Operators (Python Plugins only)
In Python-based custom plugins, attribute operators provide a way to interact with your API request and response. Using these operators, you can fetch, modify, or add attributes according to your requirements.
Whether you are retrieving a value for comparison or injecting a mutated field, these operators act as the building block for creating an accurate and adaptive plugin logic.
The following are the supported operators that you can use while writing a Custom Python Plugin:
Mutation Function
The mutation function adds, modifies, and deletes specific parameters within API requests. While Traceable specifies this function by default in test plugins, you can define it according to your requirements in custom plugins.
Mutation Parameters and Syntax
The parameters within a custom plugin mutation function vary depending on the plugin type you are configuring. To learn about these parameters, click the tabs below according to your requirements.
A mutation function in a YAML-based plugin contains the following parameters:
action (String)
The type of operation that Traceable should perform. For more information, see Mutation Operators.
description
A description of what the mutation does.
key (String)
The query parameter on which Traceable should perform the operation.
kind
The data type of the value being specified below.
value
The value you wish to mutate on the above key.
After combining the parameters within a plugin, the syntax is:
A mutation function in a Python-based plugin contains the following parameters:
operator (String)
The type of operation that Traceable should perform. For more information, see Mutation Operators.
key (String)
The key or attribute that Traceable should mutate. The attributes are updated in Traceable's mutated request in the Cloning step.
value (Any)
The new value to replace the existing value. This parameter can contain any value, for example, none or an empty string (““). This value is stored in the mutated request.
After combining the parameters within a plugin, the syntax is:
Mutation Operators
The following are the supported operators that you can use along with the mutation function while writing a custom plugin:
Assertion Function
The Assertion Function in custom plugins is used to evaluate API responses for vulnerabilities by comparing specific values in the response to expected outcomes, with various operators available to define the conditions for a successful match. The following sections explain the various subfunctions and operators.
Assertion Types
Assertion functions can be of two types:
IMMEDIATE
These assertions execute immediately after Traceable encounters them in the plugin definition. If the condition fails, Traceable stops further execution based on the logic. For example, verify whether the response code of the mutated request is 200.
LOGICAL
These assertions evaluate conditions at the end of the scan or execution rather than immediately. This allows for the aggregation of multiple results before making a final decision. For example, verify if at least one of the multiple mutated requests can access sensitive data.
For more information on this function, see the sections below.
Assertion Parameters and Syntax
The parameters within a custom plugin assertion function vary depending on the plugin type you are configuring. To know about these parameters, click the below tabs according to your requirements.
An assertion function in a YAML-based plugin contains the following parameters:
lhs (String)
The mutated value for comparison.
rhs (String)
The original value for comparison.
operator (String)
The match operator used for comparison.
key (String)
Used for display purposes as part of visualization on the UI. It is not used for any processing.
description
A description of what the assertion does.
assertionType
The type of assertion Traceable should execute on the above parameters.
After combining the parameters within a plugin, the syntax is:
An Assertion Function in a Python-based plugin contains the following parameters:
key (String)
Used for display purposes as part of visualization on the UI. It is not used for any processing.
operator (String)
The match operator used for comparison.
mutated (String)
The mutated value for comparison.
original (String)
The original value for comparison.
**kwargs (optional)
Additional parameters used to provide metadata for the assertion. These parameters can vary depending on the match operator used.
After combining the parameters within a plugin, the Assertion Function syntax is:
A Logical Assertion function in a Python-based plugin contains the following parameters:
operator (String)
The operator for evaluation between assertion functions.
Assertion function
The assertion functions for evaluation based on the above operator.
After combining the parameters within a plugin, the Logical Assertion Function syntax is:
Assertion Operators
Assertion operators are divided based on the assertion types. While the assertion operators can be used individually, the logical assertion operators are used in combination with the assertion functions and operators to write a custom plugin. The following sections explain these operators along with an example.
Logical Assertion Operators
The following are the supported logical operators that you can use in combination with the assertion functions while writing a custom plugin:
Assertion Operators
The following are the supported operators that you can use along with the assertion function while writing a custom plugin:
Last updated
Was this helpful?