platform

package
v1.8.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

  • Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. *

  • This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

  • Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. *

  • This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

Package platform provides a central registry of IaC scan platform definitions. Shared Rego libraries (common, datadog) and the cross-platform rule platform live in libraries.go — they are not scan targets.

Index

Constants

View Source
const (
	// LibraryCommon is generic.common — cross-platform Rego utilities.
	LibraryCommon = "common"
	// LibraryDatadog is package datadog — scanner contract helpers (finding, scopes).
	LibraryDatadog = "datadog"
)

Shared Rego libraries bundled with rules. These are not IaC scan targets.

View Source
const RulePlatformCommon = "common"

RulePlatformCommon is the metadata.json platform for rules that evaluate all payloads.

Variables

This section is empty.

Functions

func CompareKey

func CompareKey(name string) string

CompareKey returns a stable lowercase key for comparing scan-platform names across aliases.

func IsCrossPlatformRule

func IsCrossPlatformRule(name string) bool

IsCrossPlatformRule reports whether name is the cross-platform rule metadata platform.

func IsRequested

func IsRequested(id ID, requested []string) bool

IsRequested reports whether a platform is allowed by a requested platform filter.

func IsSharedLibrary

func IsSharedLibrary(name string) bool

IsSharedLibrary reports whether name identifies a bundled shared Rego library.

func LibraryIdentity

func LibraryIdentity(name string) (string, bool)

LibraryIdentity returns the library file key for any accepted scan-platform or shared-library name.

func LibraryIdentityOrUnknown

func LibraryIdentityOrUnknown(name string) string

LibraryIdentityOrUnknown returns the library identity or "unknown" when the name is not recognized.

func LibraryName

func LibraryName(name string) string

LibraryName maps a user-facing platform name to the embedded library file name. Unrecognized names fall back to the lower-cased input.

func Matches

func Matches(a, b string) bool

Matches reports whether two platform names refer to the same registered platform.

func RuleIdentity

func RuleIdentity(name string) (string, bool)

RuleIdentity returns the rule/query identity string for any accepted scan-platform or cross-platform name.

func StructuralClassificationRequiresContent

func StructuralClassificationRequiresContent(extension string) bool

StructuralClassificationRequiresContent reports whether an extension needs content for classification.

func StructuralExtensions

func StructuralExtensions() []string

StructuralExtensions returns extensions admitted by structural classifiers.

func SupportsResourceIndex

func SupportsResourceIndex(name string) bool

SupportsResourceIndex reports whether the named platform has a migrated adapter.

Types

type Definition

type Definition struct {
	// Canonical is the all-lowercase identity stored in FileMetadata.Platform after lowercasing.
	Canonical ID
	// Aliases are all names accepted case-insensitively (includes the canonical value).
	Aliases []string
	// RuleIdentity is the platform string used in QueryMetadata.Platform (may differ in casing).
	RuleIdentity string
	// LibraryIdentity is the key passed to GetQueryLibrary (may differ in casing, e.g. "k8s", "cloudFormation").
	LibraryIdentity string
	// PayloadTargets lists the canonical payloads that receive documents classified as this platform.
	// Usually just {Canonical}; Knative documents also enter the Kubernetes payload.
	PayloadTargets []ID
	// IndexCapability reports whether this platform has a migrated resource-index adapter.
	IndexCapability IndexCapability
}

Definition holds all metadata for a registered platform.

func All

func All() []Definition

All returns a copy of all registered scan-platform definitions in registration order.

func Lookup

func Lookup(name string) (Definition, bool)

Lookup returns the Definition for any accepted name (case-insensitive).

type ID

type ID string

ID is the canonical all-lowercase identifier for an IaC scan platform.

const (
	Terraform               ID = "terraform"
	CloudFormation          ID = "cloudformation"
	Kubernetes              ID = "kubernetes"
	Ansible                 ID = "ansible"
	CICD                    ID = "cicd"
	Dockerfile              ID = "dockerfile"
	Knative                 ID = "knative"
	Crossplane              ID = "crossplane"
	ServerlessFW            ID = "serverlessfw"
	AzureResourceManager    ID = "azureresourcemanager"
	OpenAPI                 ID = "openapi"
	GoogleDeploymentManager ID = "googledeploymentmanager"
	DockerCompose           ID = "dockercompose"
	Pulumi                  ID = "pulumi"
	GRPC                    ID = "grpc"
	Buildah                 ID = "buildah"
)

Canonical scan-platform IDs.

func CanonicalID

func CanonicalID(name string) (ID, bool)

CanonicalID returns the canonical ID for any accepted name (case-insensitive).

func ClassifyDocument

func ClassifyDocument(document map[string]interface{}) (ID, bool)

ClassifyDocument classifies an already parsed document.

func ClassifyStructuredContent

func ClassifyStructuredContent(extension string, content []byte) (ID, bool)

ClassifyStructuredContent classifies a supported structured file.

func ClassifyStructuredDocument

func ClassifyStructuredDocument(extension string, document map[string]interface{}) (ID, bool)

ClassifyStructuredDocument classifies an already parsed analyzer document.

func PayloadTargets

func PayloadTargets(name string) []ID

PayloadTargets returns the canonical payload IDs for any accepted name. Returns nil if the name is not recognized.

type IndexCapability

type IndexCapability uint8

IndexCapability describes whether a platform has a migrated resource-index adapter.

const (
	// IndexUnsupported means the platform does not yet have a resourceindex adapter.
	IndexUnsupported IndexCapability = iota
	// IndexMigrated means the platform has a fully migrated adapter in pkg/engine/resourceindex.
	IndexMigrated
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL