filter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package filter предоставляет функциональность для фильтрации компонентов SBOM на основе шаблонов игнорирования и правил исключения.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	PURL    string `json:"purl"`
	Name    string `json:"name"`
	Version string `json:"version"`
}

Component представляет минимальную структуру компонента для фильтрации.

type IgnoreFilter

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

IgnoreFilter обрабатывает фильтрацию компонентов на основе шаблонов игнорирования.

func NewIgnoreFilter

func NewIgnoreFilter() *IgnoreFilter

NewIgnoreFilter создает новый фильтр игнорирования.

func (*IgnoreFilter) AddPattern

func (f *IgnoreFilter) AddPattern(pattern string)

AddPattern добавляет один шаблон в фильтр.

func (*IgnoreFilter) Clear

func (f *IgnoreFilter) Clear()

Clear удаляет все шаблоны и сбрасывает список удаленных.

func (*IgnoreFilter) ClearRemoved

func (f *IgnoreFilter) ClearRemoved()

ClearRemoved очищает только список удаленных компонентов.

func (*IgnoreFilter) FilterComponents

func (f *IgnoreFilter) FilterComponents(components []Component) []Component

FilterComponents фильтрует список компонентов на основе шаблонов игнорирования Возвращает отфильтрованный список и обновляет отслеживание удаленных компонентов.

func (*IgnoreFilter) GetPatterns

func (f *IgnoreFilter) GetPatterns() []string

GetPatterns возвращает текущий список шаблонов.

func (*IgnoreFilter) GetRemovedComponents

func (f *IgnoreFilter) GetRemovedComponents() []RemovedComponent

GetRemovedComponents возвращает список всех удаленных компонентов.

func (*IgnoreFilter) GetRemovedCount

func (f *IgnoreFilter) GetRemovedCount() int

GetRemovedCount возвращает количество удаленных компонентов.

func (*IgnoreFilter) GetStatistics

func (f *IgnoreFilter) GetStatistics() map[string]any

GetStatistics возвращает статистику о фильтре.

func (*IgnoreFilter) IsEnabled

func (f *IgnoreFilter) IsEnabled() bool

IsEnabled возвращает, включен ли фильтр.

func (*IgnoreFilter) LoadFromFile

func (f *IgnoreFilter) LoadFromFile(filename string) error

LoadFromFile загружает шаблоны игнорирования из файла (например, .sbomignore).

func (*IgnoreFilter) LoadPatterns

func (f *IgnoreFilter) LoadPatterns(patterns []string)

LoadPatterns загружает шаблоны из среза строк.

func (*IgnoreFilter) SaveRemovedPURLs

func (f *IgnoreFilter) SaveRemovedPURLs(filename string) error

SaveRemovedPURLs сохраняет только PURL удаленных компонентов (простой формат).

func (*IgnoreFilter) SaveRemovedReport

func (f *IgnoreFilter) SaveRemovedReport(filename string) error

SaveRemovedReport сохраняет отчет об удаленных компонентах в файл.

func (*IgnoreFilter) SetEnabled

func (f *IgnoreFilter) SetEnabled(enabled bool)

SetEnabled включает или отключает фильтр.

func (*IgnoreFilter) ShouldIgnore

func (f *IgnoreFilter) ShouldIgnore(purl string) bool

ShouldIgnore проверяет, следует ли игнорировать компонент на основе его PURL Использует точное совпадение подстроки, как указано техническим руководителем.

func (*IgnoreFilter) ShouldIgnoreComponent

func (f *IgnoreFilter) ShouldIgnoreComponent(purl, name, version string) bool

ShouldIgnoreComponent проверяет, следует ли игнорировать компонент и отслеживает его.

func (*IgnoreFilter) ShouldIgnoreCycloneDXComponent added in v0.3.0

func (f *IgnoreFilter) ShouldIgnoreCycloneDXComponent(component *cyclonedx.Component) bool

ShouldIgnoreCycloneDXComponent проверяет, следует ли игнорировать компонент CycloneDX на основе фильтра. Получатель может быть nil — в этом случае компонент не игнорируется.

type RemovedComponent

type RemovedComponent struct {
	PURL      string    `json:"purl"`
	Name      string    `json:"name"`
	Version   string    `json:"version"`
	Pattern   string    `json:"matched_pattern"`
	RemovedAt time.Time `json:"removed_at"`
}

RemovedComponent представляет компонент, который был отфильтрован.

Source Files

  • ignore_filter.go

Jump to

Keyboard shortcuts

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