Documentation
¶
Overview ¶
Package cloudflare provides the Cloudflare integration definition for integrations
Index ¶
- Constants
- Variables
- func Builder(runtime *RuntimeConfig) registry.Builder
- func DomainScanPollBackoff(attempt int) time.Duration
- type AssetSync
- type Client
- type ClientConfig
- type CredentialSchema
- type DirectorySync
- type DomainScanBuildReport
- type DomainScanBuildReportResult
- type DomainScanGatherEnrichment
- type DomainScanGatherEnrichmentResult
- type DomainScanImport
- type DomainScanImportAsset
- type DomainScanImportFinding
- type DomainScanImportPlatform
- type DomainScanImportSystem
- type DomainScanImportVendor
- type DomainScanPoll
- type DomainScanPollEnvelope
- type DomainScanPollResult
- type DomainScanRequest
- type DomainScanRequestResult
- type DomainScanSubmit
- type DomainScanSubmitResult
- type FindingsSync
- type InstallationMetadata
- type RuntimeConfig
- type ScanTaskError
- type ScanTaskErrors
Constants ¶
const ( // DomainScanPollMinInterval is the wait before the first retry, and the starting point the backoff doubles from DomainScanPollMinInterval = 10 * time.Second // DomainScanPollMaxInterval caps how long the backoff is allowed to grow to between poll cycles DomainScanPollMaxInterval = 60 * time.Second // DomainScanMaxAttempts bounds how many poll cycles are attempted before giving up on a scan DomainScanMaxAttempts = 30 )
const ( // DomainScanPerformedBy marks a Scan record for submission to the cloudflare domain scan job DomainScanPerformedBy = "openlane_domain_scan" // DomainScanBrandDesignOnlyMetadataKey selects the brand-design-only scan path DomainScanBrandDesignOnlyMetadataKey = "brandDesignOnly" // DomainScanApplyBrandDesignToPreviewMetadataKey applies extracted brand design to preview only DomainScanApplyBrandDesignToPreviewMetadataKey = "applyBrandDesignToPreview" // DomainScanApplyBrandDesignToLiveMetadataKey applies extracted brand design to live only DomainScanApplyBrandDesignToLiveMetadataKey = "applyBrandDesignToLive" // DomainScanGroupMetadataKey is the Scan.Metadata key carrying the shared group id for scans DomainScanGroupMetadataKey = "scan_group_id" )
Variables ¶
var ( // ErrAPITokenMissing indicates the Cloudflare API token is missing from the credential ErrAPITokenMissing = errors.New("cloudflare: api token missing") // ErrTokenVerificationFailed indicates the Cloudflare token verification failed ErrTokenVerificationFailed = errors.New("cloudflare: token verification failed") // ErrTokenNotActive indicates the Cloudflare token is not in an active state ErrTokenNotActive = errors.New("cloudflare: token is not active") // ErrResultEncode indicates an operation result could not be serialized ErrResultEncode = errors.New("cloudflare: result encode failed") // ErrMembersFetchFailed indicates the account members list request failed ErrMembersFetchFailed = errors.New("cloudflare: members fetch failed") // ErrGroupsFetchFailed indicates the account groups list request failed ErrGroupsFetchFailed = errors.New("cloudflare: groups fetch failed") // ErrPayloadEncode indicates a collected Cloudflare payload could not be serialized for ingest ErrPayloadEncode = errors.New("cloudflare: ingest payload encode failed") // ErrAccountIDMissing indicates the account ID is missing from user input ErrAccountIDMissing = errors.New("cloudflare: account id missing") // ErrFindingsFetchFailed indicates the Security Center insights list request failed ErrFindingsFetchFailed = errors.New("cloudflare: findings fetch failed") // ErrAssetsFetchFailed indicates the Registrar registrations list request failed ErrAssetsFetchFailed = errors.New("cloudflare: assets fetch failed") // ErrRuntimeConfigDecode indicates the runtime Cloudflare config could not be decoded ErrRuntimeConfigDecode = errors.New("cloudflare: runtime config decode failed") // ErrRuntimeConfigInvalid indicates the runtime Cloudflare config is missing required fields ErrRuntimeConfigInvalid = errors.New("cloudflare: runtime config invalid") // ErrDomainScanSubmitFailed indicates a URL Scanner submission request failed ErrDomainScanSubmitFailed = errors.New("cloudflare: domain scan submit failed") // ErrDomainScanResultFailed indicates the URL Scanner result retrieval request failed ErrDomainScanResultFailed = errors.New("cloudflare: domain scan result fetch failed") // ErrDomainScanTaskFailed indicates Cloudflare reported the scan task itself failed ErrDomainScanTaskFailed = errors.New("cloudflare: domain scan task failed") // ErrDomainScanMaxAttemptsReached indicates a scan never completed within the poll budget ErrDomainScanMaxAttemptsReached = errors.New("cloudflare: domain scan max poll attempts reached") // ErrInstallationRequired indicates the operation requires a resolved installation ErrInstallationRequired = errors.New("cloudflare: installation required") )
var ( // DefinitionID is the stable identifier for the Cloudflare integration definition DefinitionID = types.NewDefinitionRef("def_01K0CFLARE00000000000000001") )
var DomainScanBuildReportOp = types.OperationPayloadOf[DomainScanBuildReport](). Handles(runDomainScanBuildReport). Policy(types.ExecutionPolicy{SkipRunRecord: true}). CustomerSelectable(false). Internal()
DomainScanBuildReportOp is the operation ref for building the scan report
var DomainScanEnrichmentOp = types.OperationPayloadOf[DomainScanGatherEnrichment](). Handles(runDomainScanGatherEnrichment). Policy(types.ExecutionPolicy{SkipRunRecord: true}). CustomerSelectable(false). Internal()
DomainScanEnrichmentOp is the operation ref for gathering enrichment data for a domain
var DomainScanImportOp = types.OperationPayloadOf[DomainScanImport](). Policy(domainScanImportPolicy). CustomerSelectable(false). Internal()
DomainScanImportOp is the operation ref for importing an accepted domain scan review it declares no ingest contracts so it runs as the reviewer who dispatched it, not as the integration
var DomainScanPollOp = types.OperationPayloadOf[DomainScanPoll](). Handles(runDomainScanPoll). Policy(types.ExecutionPolicy{SkipRunRecord: true}). CustomerSelectable(false). Internal()
DomainScanPollOp is the operation ref for polling a submitted URL Scanner result
var DomainScanRequestOp = types.OperationPayloadOf[DomainScanRequest](). HandlesRequest(runDomainScanRequest). Policy(types.ExecutionPolicy{Inline: true, SkipRunRecord: true}). RateLimit(types.RateLimitPolicy{Window: time.Hour}). CustomerSelectable(false). RequiresPaymentMethod()
DomainScanRequestOp is the operation ref for requesting a domain scan
var DomainScanSubmitOp = types.OperationPayloadOf[DomainScanSubmit](). Handles(runDomainScanSubmit). Policy(types.ExecutionPolicy{SkipRunRecord: true}). CustomerSelectable(false). Internal()
DomainScanSubmitOp is the operation ref for submitting domains to the URL Scanner
Functions ¶
func Builder ¶
func Builder(runtime *RuntimeConfig) registry.Builder
Builder returns the Cloudflare definition builder with the supplied runtime config applied
func DomainScanPollBackoff ¶
DomainScanPollBackoff returns the wait before the next poll cycle for a scan that's still processing. The interval doubles from DomainScanPollMinInterval up to DomainScanPollMaxInterval as attempt grows, so slow scans are checked less often instead of exhausting the attempt budget at a flat cadence. Jitter is added on top to desynchronize scans that were submitted together and would otherwise poll Cloudflare in lockstep
Types ¶
type AssetSync ¶
type AssetSync struct {
types.OperationSettings
}
AssetSync holds installation-specific configuration for Cloudflare domain assets
type Client ¶
type Client struct {
*cf.Client
// Config holds the account scope and domain scan settings this client was built with
Config ClientConfig
}
Client wraps the Cloudflare SDK client with the account it's scoped to
type ClientConfig ¶
type ClientConfig struct {
// AccountID is the Cloudflare account this client is scoped to
AccountID string
// APIToken is the raw Cloudflare API token, needed by calls made outside the SDK client
APIToken string
// DomainScan configures vendor/technology classification for domain scan reports; runtime only
DomainScan domainscan.ReportConfig
}
ClientConfig holds the account and domain scan settings a CloudflareClient is built from
type CredentialSchema ¶
type CredentialSchema struct {
// APIToken is the Cloudflare API token with permissions to read account and zone metadata
APIToken string `json:"apiToken" jsonschema:"required,title=API Token"`
// AccountID is the Cloudflare account identifier used for account-scoped API calls
AccountID string `` /* 137-byte string literal not displayed */
}
CredentialSchema holds the Cloudflare API credentials for one installation
type DirectorySync ¶
type DirectorySync struct {
types.OperationSettings
}
DirectorySync holds installation-specific configuration for Cloudflare account members
type DomainScanBuildReport ¶
type DomainScanBuildReport struct {
// InternalScanID is the openlane Scan record id the built report belongs to
InternalScanID string `json:"internalScanId"`
// Result is the completed URL Scanner task result to build the report from, may be empty
Result json.RawMessage `json:"result,omitempty"`
// Enrichment is the data gathered via DomainScanGatherEnrichment
Enrichment domainscan.Enrichment `json:"enrichment"`
}
DomainScanBuildReport builds the structured domain scan report from a result and enrichment
func (DomainScanBuildReport) Run ¶
func (DomainScanBuildReport) Run(ctx context.Context, client *Client, cfg DomainScanBuildReport) (DomainScanBuildReportResult, error)
Run builds the structured scan report from the URL Scanner result plus gathered enrichment
type DomainScanBuildReportResult ¶
type DomainScanBuildReportResult struct {
// Data is the structured scan report, ready to persist on the Scan record
Data map[string]any `json:"data"`
}
DomainScanBuildReportResult carries the structured report built from the result and enrichment
type DomainScanGatherEnrichment ¶
type DomainScanGatherEnrichment struct {
// Domain is the domain to gather enrichment for
Domain string `json:"domain"`
// ForceRefresh bypasses Cloudflare's Browser Rendering cache, forcing a fresh render
ForceRefresh bool `json:"forceRefresh,omitempty"`
// BrandDesignOnly instructs the scanning process to only extract the brand design
BrandDesignOnly bool `json:"brandDesignOnly,omitempty"`
}
DomainScanGatherEnrichment gathers enrichment data for a domain
func (DomainScanGatherEnrichment) Run ¶
func (DomainScanGatherEnrichment) Run(ctx context.Context, client *Client, cfg DomainScanGatherEnrichment) (DomainScanGatherEnrichmentResult, error)
Run gathers company profile, branding, compliance, and DNS vendor data for the domain
type DomainScanGatherEnrichmentResult ¶
type DomainScanGatherEnrichmentResult struct {
// Enrichment is the gathered company profile, branding, compliance, and DNS vendor data
Enrichment domainscan.Enrichment `json:"enrichment"`
}
DomainScanGatherEnrichmentResult carries the gathered enrichment data
type DomainScanImport ¶
type DomainScanImport struct {
// OrganizationID is the organization the created records belong to
OrganizationID string `json:"organizationId"`
// ScanIDs are the Scan records the created records should link back to
ScanIDs []string `json:"scanIds"`
// Platforms are the accepted platforms, if any
Platforms []DomainScanImportPlatform `json:"platforms,omitempty"`
// Systems are the accepted system details
Systems []DomainScanImportSystem `json:"systems,omitempty"`
// Vendors are the accepted vendors
Vendors []DomainScanImportVendor `json:"vendors"`
// Assets are the accepted assets
Assets []DomainScanImportAsset `json:"assets"`
// Findings are the accepted findings
Findings []DomainScanImportFinding `json:"findings,omitempty"`
// Branding is the brand design config for a trust center environment
Branding *domainscan.BrandDesignProfile `json:"branding,omitempty"`
}
DomainScanImport imports a reviewer-accepted domain scan report into real records
type DomainScanImportAsset ¶
type DomainScanImportAsset struct {
// Ref is a client-assigned identifier for this asset, referenced by AssetRefs elsewhere
Ref string `json:"ref"`
// Name is the asset's display name
Name string `json:"name"`
// Identifier is the asset's domain, IP, or other unique identifier
Identifier string `json:"identifier,omitempty"`
// Website is the asset's URL, if known
Website string `json:"website,omitempty"`
// Categories are the asset's detected categories
Categories []string `json:"categories,omitempty"`
}
DomainScanImportAsset is one reviewer-accepted asset, keyed by a client-assigned Ref
type DomainScanImportFinding ¶
type DomainScanImportFinding struct {
// Category is the finding's category
Category string `json:"category,omitempty"`
// Description is the finding's description
Description string `json:"description,omitempty"`
// Severity is the finding's severity
Severity string `json:"severity,omitempty"`
// Domain is the domain this finding was raised against, if known
Domain string `json:"domain,omitempty"`
}
DomainScanImportFinding is one accepted finding
type DomainScanImportPlatform ¶
type DomainScanImportPlatform struct {
// Ref is a client-assigned identifier for this platform, referenced by PlatformRefs elsewhere
Ref string `json:"ref"`
// Name is the platform's name
Name string `json:"name"`
// Description is the platform's description
Description string `json:"description,omitempty"`
// EntityRefs are the Refs of accepted vendors linked to this platform
EntityRefs []string `json:"entityRefs,omitempty"`
// AssetRefs are the Refs of accepted assets linked to this platform
AssetRefs []string `json:"assetRefs,omitempty"`
}
DomainScanImportPlatform is one accepted platform, keyed by a client-assigned Ref
type DomainScanImportSystem ¶
type DomainScanImportSystem struct {
// Name is the system's name
Name string `json:"name"`
// Description is the system's description
Description string `json:"description,omitempty"`
// EntityRefs are the Refs of accepted vendors linked to this system
EntityRefs []string `json:"entityRefs,omitempty"`
// AssetRefs are the Refs of accepted assets linked to this system
AssetRefs []string `json:"assetRefs,omitempty"`
// PlatformRefs are the Refs of accepted platforms this system belongs to
PlatformRefs []string `json:"platformRefs,omitempty"`
}
DomainScanImportSystem is one accepted system detail, linked to its own vendors/assets/platforms
type DomainScanImportVendor ¶
type DomainScanImportVendor struct {
// Ref is a client-assigned identifier for this vendor, referenced by EntityRefs elsewhere
Ref string `json:"ref"`
// Name is the vendor's name
Name string `json:"name"`
// LegalName is the vendor's raw legal entity name, if known and different from Name
LegalName string `json:"legalName,omitempty"`
// Domain is the vendor's domain, if known
Domain string `json:"domain,omitempty"`
// Categories are the vendor's detected categories
Categories []string `json:"categories,omitempty"`
}
DomainScanImportVendor is one reviewer-accepted vendor, keyed by a client-assigned Ref
type DomainScanPoll ¶
type DomainScanPoll struct {
// ScanResultID is the scan ID returned by DomainScanSubmit
ScanResultID string `json:"scanResultId"`
}
DomainScanPoll retrieves a previously submitted URL Scanner result by scan ID
func (DomainScanPoll) Run ¶
func (DomainScanPoll) Run(ctx context.Context, client *Client, cfg DomainScanPoll) (DomainScanPollResult, error)
Run retrieves a URL Scanner result by scan ID
type DomainScanPollEnvelope ¶
type DomainScanPollEnvelope struct {
// OrganizationID is the organization that owns the scan
OrganizationID string `json:"organizationId"`
// ScanResultID is the scan ID returned by Cloudflare's URL Scanner on submission
ScanResultID string `json:"scanResultId"`
// InternalScanID is the id of the Scan record created when the scan was submitted;
// the poll cycle updates this same record rather than creating a new one on completion
InternalScanID string `json:"internalScanId"`
// Attempt is the number of poll cycles already attempted for this scan
Attempt int `json:"attempt"`
// SiblingScanIDs lists every internal Scan ID submitted together with this one
// so the last one to finish can gather and combine every sibling's report into a single notification
SiblingScanIDs []string `json:"siblingScanIds"`
}
DomainScanPollEnvelope carries one submitted scan through poll cycles until it's ready or the attempt budget is exhausted. This stays on raw Gala pub/sub rather than a Dispatch-able Operation because the poll cycle self-reschedules via Gala's ScheduledAt header, which Dispatch has no equivalent for
type DomainScanPollResult ¶
type DomainScanPollResult struct {
// Result is the raw URL Scanner result payload
Result *url_scanner.ScanGetResponse `json:"result"`
// TaskErrors lists task-level errors reported alongside the result, if any
TaskErrors ScanTaskErrors `json:"taskErrors,omitempty"`
// NotReady is true when Cloudflare reported the scan isn't available yet
NotReady bool `json:"notReady,omitempty"`
}
DomainScanPollResult carries the raw URL Scanner result plus any task-level errors
type DomainScanRequest ¶
type DomainScanRequest struct {
// ScanID identifies the Scan record that triggered an internally dispatched request
ScanID string `json:"scanId,omitempty"`
// OrganizationID is the organization the scan belongs to, used only without an Integration
OrganizationID string `json:"organizationId,omitempty"`
// Domain is the domain to scan
Domain string `json:"domain" jsonschema:"required,title=Domain,description=Domain to scan"`
// ForceRefresh bypasses Cloudflare's Browser Rendering cache, forcing a fresh render
ForceRefresh bool `json:"forceRefresh,omitempty" jsonschema:"title=Force Refresh,description=Bypass the render cache and force a fresh scan"`
// BrandDesignOnly extracts the brand design without running the full domain scan
BrandDesignOnly bool `` /* 159-byte string literal not displayed */
// ApplyBrandDesignToPreview applies the extracted brand design to the preview trustcenter
ApplyBrandDesignToPreview bool `` /* 165-byte string literal not displayed */
// ApplyBrandDesignToLive applies the extracted brand design to the live trustcenter
ApplyBrandDesignToLive bool `` /* 156-byte string literal not displayed */
// GroupID links this scan to sibling scans requested together for a combined notification
GroupID string `json:"groupId,omitempty"`
}
DomainScanRequest queues a domain scan by creating a pending Scan record
type DomainScanRequestResult ¶
type DomainScanRequestResult struct {
// Message describes what happened
Message string `json:"message"`
// ScanID is the id of the Scan record for this request
ScanID string `json:"scanId"`
}
DomainScanRequestResult acknowledges that a domain scan was queued or run
type DomainScanSubmit ¶
type DomainScanSubmit struct {
// Domains is the list of domains to submit for scanning
Domains []string `json:"domains"`
}
DomainScanSubmit submits domains to Cloudflare's URL Scanner for scanning
func (DomainScanSubmit) Run ¶
func (DomainScanSubmit) Run(ctx context.Context, client *Client, cfg DomainScanSubmit) (DomainScanSubmitResult, error)
Run submits the domains to Cloudflare's URL Scanner, with a max of 10 domains in any scan request
type DomainScanSubmitResult ¶
type DomainScanSubmitResult struct {
// Scans is the list of scan tasks created by Cloudflare's URL Scanner
Scans []url_scanner.ScanBulkNewResponse `json:"scans"`
}
DomainScanSubmitResult is the set of scan tasks created by a submission
type FindingsSync ¶
type FindingsSync struct {
types.OperationSettings
}
FindingsSync holds installation-specific configuration for Cloudflare Security Center insights
type InstallationMetadata ¶
type InstallationMetadata struct {
// AccountID is the Cloudflare account identifier used for account-scoped collection
AccountID string `json:"accountId,omitempty" jsonschema:"title=Account ID"`
}
InstallationMetadata holds the stable Cloudflare account identity for one installation
func (InstallationMetadata) InstallationIdentity ¶
func (m InstallationMetadata) InstallationIdentity() types.IntegrationInstallationIdentity
InstallationIdentity implements types.InstallationIdentifiable
type RuntimeConfig ¶
type RuntimeConfig struct {
// APIToken is the Cloudflare API token for the operator-owned account
APIToken string `` /* 126-byte string literal not displayed */
// AccountID is the Cloudflare account identifier for the operator-owned account
AccountID string `json:"accountid" koanf:"accountid" jsonschema:"description=Cloudflare account ID for the operator-owned account"`
// DomainScan configures vendor/technology classification for onboarding domain scan reports
DomainScan domainscan.ReportConfig `` /* 153-byte string literal not displayed */
}
RuntimeConfig is the runtime-provisioned configuration for the operator-owned Cloudflare account
func (RuntimeConfig) Provisioned ¶
func (c RuntimeConfig) Provisioned() bool
Provisioned reports whether the runtime config has the fields required for Cloudflare API calls
type ScanTaskError ¶
type ScanTaskError struct {
Name string `json:"name"`
Message string `json:"message"`
Detail string `json:"detail"`
Code int `json:"code"`
}
ScanTaskError is a single error reported in a URL Scanner task's error list
func (ScanTaskError) Error ¶
func (e ScanTaskError) Error() string
Error returns a human-readable representation of the scan task error
type ScanTaskErrors ¶
type ScanTaskErrors []ScanTaskError
ScanTaskErrors is a list of ScanTaskError, satisfying the error interface when non-empty
func (ScanTaskErrors) Error ¶
func (e ScanTaskErrors) Error() string
Error joins every task error's message with "; "
Source Files
¶
- builder.go
- client.go
- doc.go
- domain_scan_import.go
- domain_scan_listeners.go
- domain_scan_poll.go
- errors.go
- mappings.go
- operation_asset_sync.go
- operation_directory_sync.go
- operation_domain_scan_enrich.go
- operation_domain_scan_gather_enrichment.go
- operation_domain_scan_import.go
- operation_domain_scan_poll.go
- operation_domain_scan_request.go
- operation_domain_scan_submit.go
- operation_findings.go
- types.go
- verify.go