|
| 1 | +package api |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/base64" |
| 5 | + "net/http" |
| 6 | + "net/url" |
| 7 | + |
| 8 | + "github.com/jetstack/preflight/pkg/version" |
| 9 | +) |
| 10 | + |
| 11 | +// Integrations working with the Identity Security Platform, should add metadata |
| 12 | +// in their API calls, to provide insights into how customers utilize each API. |
| 13 | +// |
| 14 | +// - IntegrationName (in): The vendor integration name (required) |
| 15 | +// - IntegrationType (it): Integration Type (required) |
| 16 | +// - IntegrationVersion (iv): The plugin version being used (required) |
| 17 | +// - VendorName (vn): Vendor name (required) |
| 18 | +// - VendorVersion (vv): Version of the vendor product in which the plugin is used (if applicable) |
| 19 | + |
| 20 | +const ( |
| 21 | + // TelemetryHeaderKey is the name of the HTTP header to use for telemetry |
| 22 | + TelemetryHeaderKey = "X-Cybr-Telemetry" |
| 23 | +) |
| 24 | + |
| 25 | +var ( |
| 26 | + telemetryValues url.Values |
| 27 | + telemetryValueEncoded string |
| 28 | +) |
| 29 | + |
| 30 | +func init() { |
| 31 | + telemetryValues = url.Values{} |
| 32 | + telemetryValues.Set("in", "cyberark-disco-agent") |
| 33 | + telemetryValues.Set("vn", "CyberArk") |
| 34 | + telemetryValues.Set("it", "KubernetesAgent") |
| 35 | + telemetryValues.Set("iv", version.PreflightVersion) |
| 36 | + telemetryValueEncoded = base64.URLEncoding.EncodeToString([]byte(telemetryValues.Encode())) |
| 37 | +} |
| 38 | + |
| 39 | +// SetTelemetryRequestHeader adds the x-cybr-telemetry header to the given HTTP |
| 40 | +// request, with information about this integration. |
| 41 | +func SetTelemetryRequestHeader(req *http.Request) { |
| 42 | + req.Header.Set(TelemetryHeaderKey, telemetryValueEncoded) |
| 43 | +} |
0 commit comments