Pipelines
Pipelines allows you to gather data across multiple audit classes in a single policy.
While the policy structure and format remains the same, pipelines can contain a complex
amount of configuration in the parameters section.
Pipelines are achieved by using the Drutiny\Audit\AuditAnalysisPipeline class.
Pipeline example
title: Domain verficiation errors
class: Drutiny\Audit\AuditAnalysisPipeline
description: When your domain is unverified, our system will error.
build_parameters:
verification_code: target.verification_code
parameters:
pipeline:
- name: logs
class: Drutiny\SumoLogic\Audit\QueryAnalysis
parameters:
^query: _sourceCategory=syslog "[ERROR] domain {target.domain} is unverified."
continueIf: logs.records|length > 0
- name: dns
class: Drutiny\Audit\DNS\DnsAnalysis
parameters:
type: TXT
$zone: target.domain
variables:
verified: dns !== false and verification_code in dns.txt
failIf: logs.records|length > 0
success: No errors found.
failure: |
Found {{ logs.records|length }} errors in the log file.
{% if not dns.verified %}
Your DNS is not verified. It requires the following DNS record:
```
{{ target.domain }} 3600 IN TXT {{ verification_code }}
```
{% endif %}
Lets walk through the example above:
- The policy defines
build_parameterswith a single parameters calledverification_code. This is just to make it easier to reference later. - There is a parameter called
pipelinewhich contains an array of sequential audits to gather data from. - Each stage in the pipeline contains three mandatory keys: name, class and parameters.
- The
namekey specifies the name of the pipeline and is also a prefix for referencing variables/tokens built in the audit. - The
classkey specifies which class to use in the stage. - The
parameterskey defines the parameters to pass into the class. - There is an optional key called
continueIfwhich allows you to stop the pipeline at a given point if the evaluated expression returnsfalse. - By using the caret (
^) infront of a parameter name, the value will have have token replacement processing conducted over it. This will translate the value{target.domain}into the actual domain of the target. See Dynamic parameters. - By using the dollars sign (
$) infront of a parameter name, the value will by evaluated by twig. This allows the$zoneparameter value to be the actual domain of the target. See Dynamic parameters. - The
failIfparameter refers to data gathered by thelogsstage of the pipeline. Therecordsvariable from that part of the pipeline is accessible vialogs.records. - The
failuremessage uses the pipeline nameslogsanddnsto access tokens gathered by those respective audits in the pipeline.
Pipelines do not have build_parameters. You can use the policy's build_parameters to evaluate
parameters before the pipeline starts. You can also use the variables parameter within each pipeline
to process outputs inbetween pipeline stages ready for the next stage. Finally parameters can use
process markers on their keys to allow for dynamic processing of parameters.
See Dynamic parameters.