scanner

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset   = "\033[0m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	Gray    = "\033[37m"
	White   = "\033[97m"
)

Color codes

Variables

This section is empty.

Functions

func AutoFixRepository

func AutoFixRepository(isDryRun bool) error

AutoFixRepository tries to match and replace third-party action references with SHA It uses SHA resolution to find accurate SHA

func ReadFile added in v1.1.3

func ReadFile(loc FilePath) ([]byte, error)

ReadFile reads content of file in a given filepath

func ScanContent added in v1.1.3

func ScanContent(content []byte, regex *regexp.Regexp) ([]string, error)

ScanContent finds matches in given content

Types

type FilePath added in v1.1.3

type FilePath string

Relative or Absolute path of a file

func ListFiles added in v1.1.3

func ListFiles(loc FilePath) ([]*FilePath, error)

type GitRepository

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

GitRepository implements Repository interface

func ListRepositoriesAtRoot added in v1.1.3

func ListRepositoriesAtRoot(root FilePath) ([]*GitRepository, error)

func (GitRepository) ListBranches

func (g GitRepository) ListBranches(fp FilePath) ([]string, error)

func (GitRepository) Name

func (g GitRepository) Name() string

type Inventory

type Inventory struct {
	Records []*InventoryRecord `json:"findings"`
}

Inventory aggregates multiple inventory records.

func AuditRepository

func AuditRepository() (*Inventory, error)

AuditRepository collects inventory details from current Git repository.

func Find added in v1.1.3

func Find(root string, headOnly bool) (*Inventory, error)

func ScanBranch added in v1.1.3

func ScanBranch(branch string, repo GitRepository, regex *regexp.Regexp, dirPath string) *Inventory

ScanBranch scans a given branch for mutable references

func ScanRepos added in v1.1.3

func ScanRepos(repos []*GitRepository, regex *regexp.Regexp, ho bool) (*Inventory, error)

ScanRepos traverses all repositories found under the root directory, checks each branch, enumerates over files in the given workflow directory path, and scans each file's content for regex matches. ho - HEAD only

type InventoryRecord

type InventoryRecord struct {
	Repository string   `json:"repository_name"` // Repository name or path
	Branch     string   `json:"branch_name"`     // Branch name
	FilePath   string   `json:"actions_file"`    // File path where the match was found
	Matches    []string `json:"matches"`         // Regex match results from the file content
}

InventoryRecord holds details for a regex match in a file.

Jump to

Keyboard shortcuts

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