kics

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 20 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.

* 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCountTerraformResources

func GetCountTerraformResources(fileContent []byte) int

func PrepareScanDocument

func PrepareScanDocument(ctx context.Context, body map[string]interface{}, kind model.FileKind) map[string]interface{}

PrepareScanDocument removes _kics_lines from payload and parses json filters

Types

type Content

type Content struct {
	Content        *[]byte
	CountLines     int
	IsMinified     bool
	CountResources int
}

Content keeps the content of the file and the number of lines

type Service

type Service struct {
	SourceProvider provider.SourceProvider
	Storage        Storage
	Parser         *parser.Parser
	Inspector      *engine.Inspector
	Tracker        Tracker
	Resolver       *resolver.Resolver

	MaxFileSize int
	// contains filtered or unexported fields
}

Service is a struct that contains a SourceProvider to receive sources, a storage to save and retrieve scanning informations a parser to parse and provide files in format that KICS understand, a inspector that runs the scanning and a tracker to update scanning numbers

func (*Service) GetVulnerabilities

func (s *Service) GetVulnerabilities(ctx context.Context, scanID string) ([]model.Vulnerability, error)

GetVulnerabilities returns a list of scan detected vulnerabilities

func (*Service) PrepareSources

func (s *Service) PrepareSources(ctx context.Context,
	scanID string,
	openAPIResolveReferences bool,
	maxResolverDepth int,
	wg *sync.WaitGroup,
	errCh chan<- error, flagEvaluator featureflags.FlagEvaluator)

PrepareSources will prepare the sources to be scanned

func (*Service) StartScan

func (s *Service) StartScan(
	ctx context.Context,
	scanID string,
	errCh chan<- error,
	wg *sync.WaitGroup)

StartScan executes scan over the context, using the scanID as reference

type Storage

type Storage interface {
	SaveFile(ctx context.Context, metadata *model.FileMetadata) error
	SaveVulnerabilities(ctx context.Context, vulnerabilities []model.Vulnerability) error
	GetVulnerabilities(ctx context.Context, scanID string) ([]model.Vulnerability, error)
}

Storage is the interface that wraps following basic methods: SaveFile, SaveVulnerabilities, and GetVulnerabilities SaveFile should append metadata to a file SaveVulnerabilities should append vulnerabilities list to current storage GetVulnerabilities should returns all vulnerabilities associated to a scan ID

type Tracker

type Tracker interface {
	TrackFileFound(path string)
	TrackFileParse(path string)
	TrackFileFoundCountLines(countLines int)
	TrackFileParseCountLines(countLines int)
	TrackFileIgnoreCountLines(countLines int)
	TrackFileFoundCountResources(countResources int)
}

Tracker is the interface that wraps the basic methods: TrackFileFound and TrackFileParse TrackFileFound should increment the number of files to be scanned TrackFileParse should increment the number of files parsed successfully to be scanned TrackFileFoundCountResources should increment the number of resources to be scanned

Jump to

Keyboard shortcuts

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