HTTP Collector
Fetches an HTTP endpoint and evaluates the configured policies against the response, for health monitoring and compliance validation.
This plugin is intended to be run as part of an agent to validate HTTP endpoints against defined compliance policies.
This page is for operators who run the plugin-http-collector plugin with the CCF Agent, and for developers who write policies for it. It documents v0.2.2 and is generated from the plugin's README at v0.2.2.
Configuration
The plugin supports the following configuration options:
url(required): The HTTP endpoint URL to testmethod: HTTP method to use (default: "GET")timeout: Request timeout in milliseconds (default: 5000)basic_auth: Enable basic authentication (default: false)basic_auth_username: Username for basic authbasic_auth_password: Password for basic authadditional_headers: Additional headers in format "Key1: Value1;Key2: Value2"check_certificate: Validate SSL certificates (default: true)body_regex_pattern: Regex pattern to match against response body
Policy input
One run makes one request to the configured url and evaluates every policy package against the response, so a policy receives one document per run as input: the response, as JSON. When no response was received (the request could not be built or sent, or its body could not be read) the plugin still evaluates the policies, with success false and error set, so a policy can record the failure as evidence. Fields are listed by their name in the document. A field marked as left out is missing from the document, not null, so test for it with object.get or a default. Your own policy data from the agent configuration is in data.<key>, not in input.
| Field | Type | Description |
|---|---|---|
status_code | integer | HTTP status code of the response. 0 when no response was received. |
status | string | Status line as Go reports it, such as 200 OK. Empty when no response was received. |
headers | object (string to array of strings) | Response headers, with Go's canonical names (Content-Type) and the list of values for each. Can be null when no response was received. |
body | string | Response body as text. Empty when no response was received. |
response_time_ms | integer | Time the request took, in milliseconds. |
success | boolean | True for a 2xx status, false for any other status and when no response was received. |
error | string | Why no response was received. Left out when a response was received, whatever its status. |
matched_regex | boolean | True when the body matches body_regex_pattern. Left out when the pattern is not configured, does not compile, or does not match. |
body_regex_pattern | string | The configured body_regex_pattern. Left out when it is not configured or does not compile. |
An example input:
{
"status_code": 200,
"status": "200 OK",
"headers": {
"Content-Type": [
"application/json"
],
"Content-Length": [
"27"
]
},
"body": "{\"status\":\"ok\",\"version\":\"1\"}",
"response_time_ms": 150,
"success": true,
"matched_regex": true,
"body_regex_pattern": "\"status\":\"ok\""
}
Subject templates
The subject templates this plugin registers. Each example is built from sample data.
http-endpoint
One endpoint per URL and HTTP method, registered when the agent calls Init with protocol v2. Title: HTTP Endpoint: {{ .method }} {{ .url }}. Every evidence carries both identity keys as labels, next to the provider label (http), so the API links it to one subject per endpoint and method. Agents that don't call Init (protocol v1) get the same evidence.
| Identity key | Description |
|---|---|
url | The URL requested, the url setting as written. |
method | The HTTP method used, in upper case (GET unless method is set). |
Example:
{
"name": "http-endpoint",
"type": "component",
"title": "HTTP Endpoint: GET https://status.example.com/health",
"description": "HTTP endpoint https://status.example.com/health checked with GET",
"purpose": "Represents an HTTP endpoint whose availability and response are checked",
"identityLabels": {
"url": "https://status.example.com/health",
"method": "GET"
}
}
Policies
The policy bundles that work with this plugin, at their newest releases. The controls are the ones the bundle's policies list in their metadata.
| Bundle | Latest version | Controls covered | Compatible plugin lines |
|---|---|---|---|
plugin-http-collector-policies | v0.2.1 | none listed | latest |
The plugin evaluates the policy bundles listed under policies in the agent's plugin config, usually the
plugin-http-collector-policies bundle:
plugins:
health-checker:
source: ghcr.io/compliance-framework/plugin-http-collector:<version>
policies:
- ghcr.io/compliance-framework/plugin-http-collector-policies:<version>
config:
url: https://example.com/health
Each run makes one request and evaluates every policy package in every bundle against it, producing one evidence
per package. Without policies the plugin makes the request but produces no evidence.
Policies are Rego v1 and live under the compliance_framework.http_collector package. They report failures with
a violation set, and set title, description and optionally labels (merged into the evidence labels):
package compliance_framework.http_collector.ensure_success_status
import rego.v1
violation contains {} if {
not input.success
}
title := "HTTP endpoint should return successful status codes"
description := "HTTP endpoints should return 2xx status codes to ensure proper service functionality"
labels := {"severity": "high"}
Policy data
policy_data from the agent config is passed to the policies as data.
Evidence
Each evidence carries:
- labels
provider: http,urlandmethod(with the policy's_policyand its ownlabels). Together with the policy they derive the evidence UUID, so the same endpoint and policy keep one evidence history across runs; - props
http_url,http_method,status_code,response_time_msandsuccess, pluserrorwhen the request failed andregex_patternandregex_matchedwhenbody_regex_patternis configured; - the
HTTP Health Checkactivity (client settings, request, response size and time), followed by the policy manager's activities; - the endpoint URL as a component subject, and start and end times of the request.
The response itself (the policy input above) is recorded with the evidence's policy evaluation.