strategy

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package strategy provides scan strategy determination for security scanning. It supports AllFiles (full scan) and ChangedFileOnly (differential scan) modes.

Index

Constants

View Source
const MaxChangedFiles = 512

MaxChangedFiles is the threshold for switching from ChangedFileOnly to AllFiles. If more files have changed, a full scan is more efficient.

Variables

This section is empty.

Functions

func ContainsPath

func ContainsPath(files []ChangedFile, path string) bool

ContainsPath checks if a path is in the changed files list.

func DetermineStrategy

func DetermineStrategy(ctx *ScanContext) (ScanStrategy, []ChangedFile)

DetermineStrategy determines the scan strategy based on context.

func GetPaths

func GetPaths(files []ChangedFile) []string

GetPaths extracts file paths from changed files.

Types

type ChangeStatus

type ChangeStatus string

ChangeStatus represents the type of file change.

const (
	ChangeAdded    ChangeStatus = "added"
	ChangeModified ChangeStatus = "modified"
	ChangeDeleted  ChangeStatus = "deleted"
	ChangeRenamed  ChangeStatus = "renamed"
)

type ChangedFile

type ChangedFile struct {
	Path    string       // File path relative to repo root
	Status  ChangeStatus // Type of change
	OldPath string       // Previous path (for renames)
}

ChangedFile represents a file that was changed between commits.

func FilterByExtensions

func FilterByExtensions(files []ChangedFile, extensions []string) []ChangedFile

FilterByExtensions filters changed files by file extensions.

func GetChangedFiles

func GetChangedFiles(repoPath, currentSha, baselineSha string) ([]ChangedFile, error)

GetChangedFiles returns the list of changed files between two commits.

type ScanContext

type ScanContext struct {
	GitEnv            gitenv.GitEnv
	BaselineCommitSha string
	RepoPath          string
	MaxChangedFiles   int
	Verbose           bool
}

ScanContext holds the context for determining scan strategy.

type ScanStrategy

type ScanStrategy int

ScanStrategy represents how files should be scanned.

const (
	// AllFiles scans all files in the repository
	AllFiles ScanStrategy = iota
	// ChangedFileOnly scans only files that changed between commits
	ChangedFileOnly
)

func (ScanStrategy) String

func (s ScanStrategy) String() string

String returns the string representation of the strategy.

Jump to

Keyboard shortcuts

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