processors

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCtyValueToGo added in v0.8.0

func ConvertCtyValueToGo(val cty.Value) interface{}

func InitializeProcessors

func InitializeProcessors() []core.FileProcessor

InitializeProcessors creates and returns a slice of FileProcessor implementations.

func ParseReferenceInclude

func ParseReferenceInclude(include string) (string, string)

Types

type AWSResourceBlockProcessor added in v0.8.0

type AWSResourceBlockProcessor struct{}

-- New AWS Resource Block Processor --

func (AWSResourceBlockProcessor) Process added in v0.8.0

func (a AWSResourceBlockProcessor) Process(block *TerraformBlock, path string, repoName string) ([]core.Finding, error)

type AzureResourceBlockProcessor added in v0.8.0

type AzureResourceBlockProcessor struct{}

-- New Azure Resource Block Processor --

func (AzureResourceBlockProcessor) Process added in v0.8.0

func (a AzureResourceBlockProcessor) Process(block *TerraformBlock, path string, repoName string) ([]core.Finding, error)

type CDMImport added in v0.8.0

type CDMImport struct {
	Path string `yaml:"path,omitempty"`
	Name string `yaml:"name,omitempty"`
}

type CDMResource added in v0.8.0

type CDMResource struct {
	Name       string                 `yaml:"name,omitempty"`
	Type       string                 `yaml:"type,omitempty"`
	Properties map[string]interface{} `yaml:"properties,omitempty"`
}

type CloudDeploymentManagerProcessor added in v0.8.0

type CloudDeploymentManagerProcessor struct{}

CloudDeploymentManagerProcessor attempts to detect and parse GCP Cloud Deployment Manager templates.

func (CloudDeploymentManagerProcessor) Process added in v0.8.0

func (p CloudDeploymentManagerProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

Process tries to parse the file as YAML (common for Deployment Manager). If "resources" is present and non-empty, we produce a Finding for each resource.

func (CloudDeploymentManagerProcessor) Supports added in v0.8.0

func (p CloudDeploymentManagerProcessor) Supports(filePath string) bool

Supports checks file extensions that are commonly used for Deployment Manager templates.

type CloudDeploymentManagerTemplate added in v0.8.0

type CloudDeploymentManagerTemplate struct {
	Imports   []CDMImport   `yaml:"imports,omitempty"`
	Resources []CDMResource `yaml:"resources,omitempty"`
}

CloudDeploymentManagerTemplate is a simplified representation of a Cloud Deployment Manager template. Typically, you’ll see keys: "imports", "resources", etc.

type CloudFormationProcessor added in v0.8.0

type CloudFormationProcessor struct {
}

CloudFormationProcessor parses files with .yml, .yaml, or .json and checks if they appear to be AWS CloudFormation templates. It then emits a Finding for each resource.

func (CloudFormationProcessor) Process added in v0.8.0

func (c CloudFormationProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (CloudFormationProcessor) Supports added in v0.8.0

func (c CloudFormationProcessor) Supports(filePath string) bool

type CloudFormationResource added in v0.8.0

type CloudFormationResource struct {
	Type       string                 `yaml:"Type,omitempty" json:"Type,omitempty"`
	Properties map[string]interface{} `yaml:"Properties,omitempty" json:"Properties,omitempty"`
}

CloudFormationResource is a partial representation of a CloudFormation resource.

type CloudFormationTemplate added in v0.8.0

type CloudFormationTemplate struct {
	AWSTemplateFormatVersion string                            `yaml:"AWSTemplateFormatVersion,omitempty" json:"AWSTemplateFormatVersion,omitempty"`
	Resources                map[string]CloudFormationResource `yaml:"Resources,omitempty" json:"Resources,omitempty"`
}

CloudFormationTemplate is a partial representation of a CloudFormation template.

type DockerComposeFile added in v0.8.0

type DockerComposeFile struct {
	Services map[string]DockerComposeService `yaml:"services,omitempty"`
}

DockerComposeFile represents the top-level structure of a docker-compose.yml file.

type DockerComposeProcessor added in v0.8.0

type DockerComposeProcessor struct {
}

DockerComposeProcessor scans Docker Compose files (docker-compose.yml / .yaml) and reports the discovered services/images.

func (DockerComposeProcessor) Process added in v0.8.0

func (d DockerComposeProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (DockerComposeProcessor) Supports added in v0.8.0

func (d DockerComposeProcessor) Supports(filePath string) bool

Supports checks if the file is named (or symlinked) as a docker-compose file.

type DockerComposeService added in v0.8.0

type DockerComposeService struct {
	Image string `yaml:"image,omitempty"`
}

DockerComposeService is a minimal struct to parse just enough from a docker-compose file.

type DockerInstruction

type DockerInstruction struct {
	Directive string
	Arguments string
}

func ParseDockerfile

func ParseDockerfile(reader io.Reader) ([]DockerInstruction, error)

type DockerProcessor

type DockerProcessor struct {
}

func (DockerProcessor) Process

func (d DockerProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (DockerProcessor) Supports

func (d DockerProcessor) Supports(filePath string) bool

type FilePatternsProcessor

type FilePatternsProcessor struct {
	Patterns []Pattern
}

func NewFilePatternsProcessor

func NewFilePatternsProcessor(fs fs.FS) *FilePatternsProcessor

func (*FilePatternsProcessor) CompilePatterns

func (s *FilePatternsProcessor) CompilePatterns()

func (*FilePatternsProcessor) Process

func (s *FilePatternsProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (*FilePatternsProcessor) Supports

func (s *FilePatternsProcessor) Supports(path string) bool

type FilenameProcessor added in v0.8.0

type FilenameProcessor struct {
}

func (FilenameProcessor) Process added in v0.8.0

func (f FilenameProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (FilenameProcessor) Supports added in v0.8.0

func (f FilenameProcessor) Supports(filePath string) bool

type GCPResourceBlockProcessor added in v0.8.0

type GCPResourceBlockProcessor struct{}

-- New GCP Resource Block Processor --

func (GCPResourceBlockProcessor) Process added in v0.8.0

func (g GCPResourceBlockProcessor) Process(block *TerraformBlock, path string, repoName string) ([]core.Finding, error)

type LanguageProcessor added in v0.8.0

type LanguageProcessor struct {
}

func (LanguageProcessor) Process added in v0.8.0

func (l LanguageProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (LanguageProcessor) Supports added in v0.8.0

func (l LanguageProcessor) Supports(filePath string) bool

type LibrariesProcessor

type LibrariesProcessor struct {
	// contains filtered or unexported fields
}

func NewLibrariesProcessor

func NewLibrariesProcessor() *LibrariesProcessor

func (*LibrariesProcessor) Process

func (mp *LibrariesProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (*LibrariesProcessor) Supports

func (mp *LibrariesProcessor) Supports(filePath string) bool

type Library

type Library struct {
	Name     string `json:"library_name"`
	Language string `json:"language"`
	Version  string `json:"version"`
}

type ModuleBlockProcessor added in v0.8.0

type ModuleBlockProcessor struct{}

func (ModuleBlockProcessor) Process added in v0.8.0

func (m ModuleBlockProcessor) Process(block *TerraformBlock, path string, repoName string) ([]core.Finding, error)

type Pattern

type Pattern struct {
	Name                 string   `json:"name,omitempty"`
	Type                 string   `json:"type,omitempty"`
	Category             string   `json:"category,omitempty"`
	Filenames            []string `json:"file_names,omitempty"`
	PathPatterns         []string `json:"path_patterns,omitempty"`
	FileExtensions       []string `json:"file_extensions,omitempty"`
	ContentPatterns      []string `json:"content_patterns,omitempty"`
	FilenameRegexs       []*regexp.Regexp
	ContentPatternRegexs []*regexp.Regexp
	PathPatternGlobs     []glob.Glob
	Properties           map[string]interface{} `json:"properties,omitempty"`
}

func LoadAllPatterns

func LoadAllPatterns(f fs.FS) ([]Pattern, error)

type TerraformBlock added in v0.8.0

type TerraformBlock struct {
	Type       string
	Labels     []string
	Attributes map[string]interface{}
	Blocks     []*TerraformBlock
}

func ParseBody added in v0.8.0

func ParseBody(body *hclsyntax.Body, src []byte) []*TerraformBlock

type TerraformBlockProcessor added in v0.8.0

type TerraformBlockProcessor interface {
	Process(block *TerraformBlock, path string, repoName string) ([]core.Finding, error)
}

type TerraformProcessor added in v0.8.0

type TerraformProcessor struct {
	// contains filtered or unexported fields
}

func NewTerraformProcessor added in v0.8.0

func NewTerraformProcessor() *TerraformProcessor

func (TerraformProcessor) Process added in v0.8.0

func (t TerraformProcessor) Process(path string, repoName string, content string) ([]core.Finding, error)

func (TerraformProcessor) Supports added in v0.8.0

func (t TerraformProcessor) Supports(filePath string) bool

Jump to

Keyboard shortcuts

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