Documentation
¶
Overview ¶
Package proto provides bidirectional conversion between Deputy's internal domain types and their protobuf representations.
This package serves as the boundary between the internal Go types used throughout Deputy's codebase and the generated protobuf types in gen/deputy/*/v1. All conversions maintain fidelity and are designed to be zero-allocation where possible.
Usage ¶
Convert internal scan results to proto for transmission:
result := scan.Result{...}
protoResult := proto.ScanResponseFromInternal(&result)
Convert incoming proto requests to internal types:
req := &scanv1.ScanRequest{...}
target, opts := proto.ScanRequestToInternal(req)
Design Principles ¶
- Converters are pure functions with no side effects
- Nil inputs produce nil outputs (safe for optional fields)
- Proto types are always fully populated (no nil embedded messages)
- Internal types use pointers for optional fields
Package proto provides helpers for working with Deputy's proto types.
Proto types defined in api/deputy/*/*.proto are the source of truth for API contracts. This package provides:
- Validation via protovalidate (see validate.go)
- Helper functions for common proto operations
- Conversion functions for internal types (see types.go, scan.go, remediation.go)
Guidelines:
- Use proto types at API boundaries (server handlers, client interfaces)
- Use protovalidate for input validation instead of manual checks
- Use helper functions in this package for common operations
Index ¶
- func AdvisoriesFromProto(advisories map[string]*vulnerabilityv1.Advisory) map[string]*vulnerabilityv1.Advisory
- func AdvisoriesToProto(advisories map[string]*vulnerabilityv1.Advisory) map[string]*vulnerabilityv1.Advisory
- func AffectedImportsFromProto(imports []*vulnerabilityv1.AffectedImport) []vulnerabilityv1.AffectedImport
- func AffectedImportsToProto(imports []vulnerabilityv1.AffectedImport) []*vulnerabilityv1.AffectedImport
- func AgentInfoToProto(p ai.Provider) *remediationv1.AgentInfo
- func AgentInfosToProto(providers []ai.Provider) []*remediationv1.AgentInfo
- func ApprovalModeFromProto(m remediationv1.ApprovalMode) string
- func BuildContainerDiffResponseFromScanning(baseResult, targetResult *scanning.Result) *diffv1.DiffContainerImagesResponse
- func BuildFixResponse(displayPath, ref, commit string, stdlibUpgrade string, ...) *fixv1.FixResponse
- func BuildTriageResponse(displayPath string, stats *vulnerabilityv1.Stats, ...) *triagev1.TriageResponse
- func ChangeKindFromProto(ck diffv1.ChangeKind) compare.ChangeType
- func ChangeKindToProto(ct compare.ChangeType) diffv1.ChangeKind
- func ContainerDiffResponseToReport(resp *diffv1.DiffContainerImagesResponse) *compare.ImageDiffReport
- func DependencyGraphFromScanProto(dg *scanv1.DependencyGraph) *graph.Graph
- func DependencyGraphToScanProto(g *graph.Graph) *scanv1.DependencyGraph
- func DiffStatsToProto(changes []compare.Change) *diffv1.DiffStats
- func DockerfileAnalysisFromProto(a *inventoryv1.DockerfileAnalysis) *dockerfile.Analysis
- func DockerfileAnalysisFromProtoNested(info *inventoryv1.DockerfileInfo) *dockerfile.Analysis
- func DockerfileAnalysisToProto(a *dockerfile.Analysis) *inventoryv1.DockerfileAnalysis
- func DockerfileInfoFromProto(info *inventoryv1.DockerfileInfo) *dockerfile.Info
- func DockerfileInfoToProto(info *dockerfile.Info) *inventoryv1.DockerfileInfo
- func DockerfileInfoWithAnalysisToProto(info *dockerfile.Info, analysis *dockerfile.Analysis) *inventoryv1.DockerfileInfo
- func DockerfileStageFromProto(s *inventoryv1.DockerfileStage) *dockerfile.Stage
- func DockerfileStageToProto(s *dockerfile.Stage) *inventoryv1.DockerfileStage
- func DurationFromProto(d *durationpb.Duration) time.Duration
- func DurationToProto(d time.Duration) *durationpb.Duration
- func ExtractorPackageToProto(pkg *extractor.Package, direct map[string]bool) *dependencyv1.Package
- func ExtractorPackagesFromProto(pkgs []*dependencyv1.Package) ([]*extractor.Package, map[string]bool)
- func ExtractorPackagesToProto(pkgs []*extractor.Package, direct map[string]bool) []*dependencyv1.Package
- func FilterPackages(pkgs []*extractor.Package, opts FilterOptions) []*extractor.Package
- func FindingFromProto(f *vulnerabilityv1.Finding) vulnerability.Finding
- func FindingHasFix(f *vulnerabilityv1.Finding) bool
- func FindingIsDirect(f *vulnerabilityv1.Finding) bool
- func FindingSeverity(f *vulnerabilityv1.Finding) vulnerabilityv1.SeverityLevel
- func FindingToProto(f vulnerability.Finding, advisory *vulnerabilityv1.Advisory) *vulnerabilityv1.Finding
- func FindingsFromProto(findings []*vulnerabilityv1.Finding) []vulnerability.Finding
- func FindingsToProto(findings []vulnerability.Finding, ...) []*vulnerabilityv1.Finding
- func GitDiffReportToProto(repo, baseRef, targetRef string, changes []compare.Change, ...) *diffv1.DiffVulnerabilitiesResponse
- func HasCritical(s *vulnerabilityv1.Stats) bool
- func HasCriticalOrHigh(s *vulnerabilityv1.Stats) bool
- func HealthcheckFromScanProto(h *scanv1.Healthcheck) *image.HealthcheckConfig
- func HealthcheckToContainerProto(h *image.HealthcheckConfig) *containerv1.HealthcheckConfig
- func HealthcheckToScanProto(h *image.HealthcheckConfig) *scanv1.Healthcheck
- func HistoryEntriesFromScanProto(entries []*scanv1.HistoryEntry) []image.HistoryEntry
- func HistoryEntriesToContainerProto(entries []image.HistoryEntry) []*containerv1.HistoryEntry
- func HistoryEntriesToScanProto(entries []image.HistoryEntry) []*scanv1.HistoryEntry
- func HistoryEntryFromScanProto(h *scanv1.HistoryEntry) image.HistoryEntry
- func HistoryEntryToScanProto(h image.HistoryEntry) *scanv1.HistoryEntry
- func ImageConfigFromScanProto(c *scanv1.ImageConfig) image.Config
- func ImageConfigToContainerProto(c *image.Config) *containerv1.ImageConfig
- func ImageConfigToScanProto(c *image.Config) *scanv1.ImageConfig
- func ImageDiffReportToProto(report *compare.ImageDiffReport) *diffv1.DiffContainerImagesResponse
- func ImageInfoFromScanProto(info *scanv1.ImageInfo) *image.Info
- func ImageInfoToContainerProto(info *image.Info) *containerv1.ImageInfo
- func ImageInfoToProto(info *image.Info) *containerv1.ImageInfo
- func ImageInfoToScanProto(info *image.Info) *scanv1.ImageInfo
- func ImageMetadataFromScanProto(m *scanv1.ImageMetadata) image.Metadata
- func ImageMetadataToContainerProto(m *image.Metadata) *containerv1.ImageMetadata
- func ImageMetadataToScanProto(m *image.Metadata) *scanv1.ImageMetadata
- func InventoryResultToProto(r *inventory.Result) *inventoryv1.CollectInventoryResponse
- func InventoryTargetFromProto(t *targetv1.Target) inventory.Target
- func InventoryTargetToProto(t inventory.Target) *targetv1.Target
- func IsAgentComplete(phase remediationv1.AgentPhase) bool
- func IsAgentFailed(phase remediationv1.AgentPhase) bool
- func IsAgentTerminal(phase remediationv1.AgentPhase) bool
- func IsComplete(phase scanv1.ScanPhase) bool
- func IsCriticalOrHigh(l vulnerabilityv1.SeverityLevel) bool
- func IsFailed(phase scanv1.ScanPhase) bool
- func IsTerminal(phase scanv1.ScanPhase) bool
- func IsValid(msg proto.Message) bool
- func LayerDetailsFromProto(ld *containerv1.LayerDetails) *containerv1.LayerDetails
- func LayerDetailsToProto(ld *containerv1.LayerDetails) *containerv1.LayerDetails
- func ManifestRefsFromProto(refs []*dependencyv1.ManifestRef) []dependencyv1.ManifestRef
- func ManifestRefsToProto(refs []dependencyv1.ManifestRef) []*dependencyv1.ManifestRef
- func MustValidate(msg proto.Message)
- func NewStats(findings []*vulnerabilityv1.Finding) *vulnerabilityv1.Stats
- func PackageChangeFromProto(pc *diffv1.PackageChange) compare.Change
- func PackageChangeToProto(c compare.Change) *diffv1.PackageChange
- func PackageChangesFromProto(changes []*diffv1.PackageChange) []compare.Change
- func PackageChangesToProto(changes []compare.Change) []*diffv1.PackageChange
- func PackageDisplayName(p *dependencyv1.Package) string
- func PackageKey(p *dependencyv1.Package) string
- func PackageToProto(f vulnerability.Finding) *dependencyv1.Package
- func ParseSeverityLevel(s string) vulnerabilityv1.SeverityLevel
- func ParseTargetKind(s string) targetv1.TargetKind
- func PolicyActionsToProto(actions []policy.Action) []*policyv1.Action
- func RemediationCommandFromProto(pc *fixv1.RemediationCommand) remediation.Command
- func RemediationCommandToProto(c remediation.Command) *fixv1.RemediationCommand
- func RemediationCommandToStep(c remediation.Command, id string) *remediationv1.Step
- func RemediationCommandsFromProto(commands []*fixv1.RemediationCommand) []remediation.Command
- func RemediationCommandsToProto(commands []remediation.Command) []*fixv1.RemediationCommand
- func RemediationCommandsToSteps(commands []remediation.Command) []*remediationv1.Step
- func RemediationStepFromProto(s *remediationv1.Step) remediation.Command
- func RemediationStepsFromProto(steps []*remediationv1.Step) []remediation.Command
- func RiskLevelFromProto(r remediationv1.RiskLevel) string
- func RiskLevelToProto(risk string) remediationv1.RiskLevel
- func SandboxFromProto(s string) ai.Sandbox
- func SandboxToProto(s ai.Sandbox) string
- func ScanningResultFromProto(r *scanv1.ScanResponse) *scanning.Result
- func ScanningResultToProto(r *scanning.Result) *scanv1.ScanResponse
- func SecretTypeFromProto(t secretsv1.SecretType) secrets.SecretType
- func SecretTypeToProto(t secrets.SecretType) secretsv1.SecretType
- func SecretsFindingFromProto(f *secretsv1.Finding) secrets.Finding
- func SecretsFindingToProto(f secrets.Finding) *secretsv1.Finding
- func SecretsFindingWithVerificationToProto(f secrets.Finding, v *secrets.VerificationResult) *secretsv1.Finding
- func SecretsFindingsFromProto(findings []*secretsv1.Finding) []secrets.Finding
- func SecretsFindingsToProto(findings []secrets.Finding) []*secretsv1.Finding
- func SecretsScanOptionsFromProto(o *secretsv1.ScanOptions) secrets.EngineConfig
- func SecretsScanOptionsToProto(c secrets.EngineConfig) *secretsv1.ScanOptions
- func SecretsScanResultToProto(target inventory.Target, findings []secrets.Finding, ...) *secretsv1.ScanResponse
- func SecretsStatsFromProto(s *secretsv1.Stats) map[string]int32
- func SecretsStatsToProto(findings []secrets.Finding) *secretsv1.Stats
- func SecretsTargetHintFromProto(h *secretsv1.TargetHint) inventory.TargetHint
- func SecretsVerificationResultToProto(v secrets.VerificationResult) *secretsv1.VerificationStatus
- func SeverityLevelString(l vulnerabilityv1.SeverityLevel) string
- func StatsFromProto(s *vulnerabilityv1.Stats) vulnerabilityv1.Stats
- func StatsToProto(s vulnerabilityv1.Stats) *vulnerabilityv1.Stats
- func StreamEventToAgentEvent(e ai.StreamEvent, sessionID string, phase remediationv1.AgentPhase) *remediationv1.AgentEvent
- func TargetKindString(k targetv1.TargetKind) string
- func UsageToTokensEvent(u ai.Usage, runningTotal int) *remediationv1.AgentTokensEvent
- func Validate(msg proto.Message) error
- type ContainerDiffResponseContext
- type FilterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvisoriesFromProto ¶
func AdvisoriesFromProto(advisories map[string]*vulnerabilityv1.Advisory) map[string]*vulnerabilityv1.Advisory
AdvisoriesFromProto converts a map of proto advisories to internal. Since internal advisories are now pointers, this is essentially a pass-through.
func AdvisoriesToProto ¶
func AdvisoriesToProto(advisories map[string]*vulnerabilityv1.Advisory) map[string]*vulnerabilityv1.Advisory
AdvisoriesToProto converts a map of internal advisories to proto. Since internal advisories are now pointers, this is essentially a pass-through.
func AffectedImportsFromProto ¶
func AffectedImportsFromProto(imports []*vulnerabilityv1.AffectedImport) []vulnerabilityv1.AffectedImport
AffectedImportsFromProto converts proto AffectedImports to value slice.
func AffectedImportsToProto ¶
func AffectedImportsToProto(imports []vulnerabilityv1.AffectedImport) []*vulnerabilityv1.AffectedImport
AffectedImportsToProto converts internal AffectedImports to proto pointers.
func AgentInfoToProto ¶
func AgentInfoToProto(p ai.Provider) *remediationv1.AgentInfo
AgentInfoToProto converts internal ai.Provider to proto AgentInfo.
func AgentInfosToProto ¶
func AgentInfosToProto(providers []ai.Provider) []*remediationv1.AgentInfo
AgentInfosToProto converts a slice of providers to proto AgentInfo slice.
func ApprovalModeFromProto ¶
func ApprovalModeFromProto(m remediationv1.ApprovalMode) string
ApprovalModeFromProto converts proto ApprovalMode to a descriptive setting.
func BuildContainerDiffResponseFromScanning ¶
func BuildContainerDiffResponseFromScanning(baseResult, targetResult *scanning.Result) *diffv1.DiffContainerImagesResponse
BuildContainerDiffResponseFromScanning constructs the proto response from scanning.Result. This is used by the DiffHandler which uses the scanning package directly.
func BuildFixResponse ¶
func BuildFixResponse( displayPath, ref, commit string, stdlibUpgrade string, commands []remediation.Command, ) *fixv1.FixResponse
BuildFixResponse creates a FixResponse from internal types.
func BuildTriageResponse ¶
func BuildTriageResponse( displayPath string, stats *vulnerabilityv1.Stats, cons []vulnerability.Consolidated, maxPackages int, ) *triagev1.TriageResponse
BuildTriageResponse constructs a TriageResponse from consolidated vulnerabilities.
func ChangeKindFromProto ¶
func ChangeKindFromProto(ck diffv1.ChangeKind) compare.ChangeType
ChangeKindFromProto converts proto diffv1.ChangeKind to internal compare.ChangeType.
func ChangeKindToProto ¶
func ChangeKindToProto(ct compare.ChangeType) diffv1.ChangeKind
ChangeKindToProto converts internal compare.ChangeType to proto diffv1.ChangeKind.
func ContainerDiffResponseToReport ¶
func ContainerDiffResponseToReport(resp *diffv1.DiffContainerImagesResponse) *compare.ImageDiffReport
ContainerDiffResponseToReport converts a proto response to the internal ImageDiffReport format. This allows reusing existing rendering functions.
func DependencyGraphFromScanProto ¶
func DependencyGraphFromScanProto(dg *scanv1.DependencyGraph) *graph.Graph
DependencyGraphFromScanProto converts scanv1.DependencyGraph to graph.Graph.
func DependencyGraphToScanProto ¶
func DependencyGraphToScanProto(g *graph.Graph) *scanv1.DependencyGraph
DependencyGraphToScanProto converts a graph.Graph to scanv1.DependencyGraph. This is used when embedding the graph in ScanResponse.
func DiffStatsToProto ¶
DiffStatsToProto converts internal change counts to proto DiffStats.
func DockerfileAnalysisFromProto ¶
func DockerfileAnalysisFromProto(a *inventoryv1.DockerfileAnalysis) *dockerfile.Analysis
DockerfileAnalysisFromProto converts proto DockerfileAnalysis to internal dockerfile.Analysis.
func DockerfileAnalysisFromProtoNested ¶
func DockerfileAnalysisFromProtoNested(info *inventoryv1.DockerfileInfo) *dockerfile.Analysis
DockerfileAnalysisFromProtoNested extracts analysis from nested DockerfileInfo proto.
func DockerfileAnalysisToProto ¶
func DockerfileAnalysisToProto(a *dockerfile.Analysis) *inventoryv1.DockerfileAnalysis
DockerfileAnalysisToProto converts internal dockerfile.Analysis to proto.
func DockerfileInfoFromProto ¶
func DockerfileInfoFromProto(info *inventoryv1.DockerfileInfo) *dockerfile.Info
DockerfileInfoFromProto converts proto DockerfileInfo to internal dockerfile.Info.
func DockerfileInfoToProto ¶
func DockerfileInfoToProto(info *dockerfile.Info) *inventoryv1.DockerfileInfo
DockerfileInfoToProto converts internal dockerfile.Info to proto.
func DockerfileInfoWithAnalysisToProto ¶
func DockerfileInfoWithAnalysisToProto(info *dockerfile.Info, analysis *dockerfile.Analysis) *inventoryv1.DockerfileInfo
DockerfileInfoWithAnalysisToProto converts internal dockerfile.Info and Analysis to proto.
func DockerfileStageFromProto ¶
func DockerfileStageFromProto(s *inventoryv1.DockerfileStage) *dockerfile.Stage
DockerfileStageFromProto converts proto DockerfileStage to internal dockerfile.Stage.
func DockerfileStageToProto ¶
func DockerfileStageToProto(s *dockerfile.Stage) *inventoryv1.DockerfileStage
DockerfileStageToProto converts internal dockerfile.Stage to proto.
func DurationFromProto ¶
func DurationFromProto(d *durationpb.Duration) time.Duration
DurationFromProto converts proto Duration to time.Duration.
func DurationToProto ¶
func DurationToProto(d time.Duration) *durationpb.Duration
DurationToProto converts a time.Duration to proto Duration.
func ExtractorPackageToProto ¶
ExtractorPackageToProto converts an OSV-SCALIBR extractor.Package to proto Package. The direct map indicates which packages are direct dependencies. For Go packages, the map keys are module roots (e.g., "github.com/google/osv-scalibr"). For other ecosystems, keys are PURL strings.
func ExtractorPackagesFromProto ¶
func ExtractorPackagesFromProto(pkgs []*dependencyv1.Package) ([]*extractor.Package, map[string]bool)
ExtractorPackagesFromProto converts proto Packages back to a simplified representation. Note: This is a lossy conversion as extractor.Package contains fields that aren't stored in the proto (e.g., Metadata, SourceCode, Plugins). This is primarily useful for testing or when you only need the basic package identity fields.
For full fidelity, store the original extractor.Package or re-extract from source.
func ExtractorPackagesToProto ¶
func ExtractorPackagesToProto(pkgs []*extractor.Package, direct map[string]bool) []*dependencyv1.Package
ExtractorPackagesToProto converts a slice of OSV-SCALIBR packages to proto Packages. The direct map indicates which packages are direct dependencies. For Go packages, the map keys are module roots (e.g., "github.com/google/osv-scalibr"). For other ecosystems, keys are PURL strings.
func FilterPackages ¶
func FilterPackages(pkgs []*extractor.Package, opts FilterOptions) []*extractor.Package
FilterPackages applies filtering rules to exclude unwanted packages from output. This filters out:
- Main modules (the project itself appearing as a dependency)
- Duplicate Go stdlib entries (go vs stdlib, multiple versions)
The original slice is not modified; a new filtered slice is returned.
func FindingFromProto ¶
func FindingFromProto(f *vulnerabilityv1.Finding) vulnerability.Finding
FindingFromProto converts proto Finding to internal vulnerability.Finding.
func FindingHasFix ¶
func FindingHasFix(f *vulnerabilityv1.Finding) bool
FindingHasFix returns true if the finding has at least one fixed version.
func FindingIsDirect ¶
func FindingIsDirect(f *vulnerabilityv1.Finding) bool
FindingIsDirect returns true if the finding is in a direct dependency.
func FindingSeverity ¶
func FindingSeverity(f *vulnerabilityv1.Finding) vulnerabilityv1.SeverityLevel
FindingSeverity returns the severity level of a finding. Returns UNSPECIFIED if the finding has no advisory or severity.
func FindingToProto ¶
func FindingToProto(f vulnerability.Finding, advisory *vulnerabilityv1.Advisory) *vulnerabilityv1.Finding
FindingToProto converts internal vulnerability.Finding to proto Finding.
func FindingsFromProto ¶
func FindingsFromProto(findings []*vulnerabilityv1.Finding) []vulnerability.Finding
FindingsFromProto converts a slice of proto Finding to internal.
func FindingsToProto ¶
func FindingsToProto(findings []vulnerability.Finding, advisories map[string]*vulnerabilityv1.Advisory) []*vulnerabilityv1.Finding
FindingsToProto converts a slice of internal Findings to proto.
func GitDiffReportToProto ¶
func GitDiffReportToProto( repo, baseRef, targetRef string, changes []compare.Change, findings []vulnerability.Finding, advisories map[string]*vulnerabilityv1.Advisory, ) *diffv1.DiffVulnerabilitiesResponse
GitDiffReportToProto creates a DiffVulnerabilitiesResponse from git diff data.
func HasCritical ¶
func HasCritical(s *vulnerabilityv1.Stats) bool
HasCritical returns true if there are any critical vulnerabilities.
func HasCriticalOrHigh ¶
func HasCriticalOrHigh(s *vulnerabilityv1.Stats) bool
HasCriticalOrHigh returns true if there are any critical or high vulnerabilities.
func HealthcheckFromScanProto ¶
func HealthcheckFromScanProto(h *scanv1.Healthcheck) *image.HealthcheckConfig
HealthcheckFromScanProto converts scanv1.Healthcheck to internal HealthcheckConfig.
func HealthcheckToContainerProto ¶
func HealthcheckToContainerProto(h *image.HealthcheckConfig) *containerv1.HealthcheckConfig
HealthcheckToContainerProto converts internal HealthcheckConfig to container proto.
func HealthcheckToScanProto ¶
func HealthcheckToScanProto(h *image.HealthcheckConfig) *scanv1.Healthcheck
HealthcheckToScanProto converts internal HealthcheckConfig to scanv1.Healthcheck.
func HistoryEntriesFromScanProto ¶
func HistoryEntriesFromScanProto(entries []*scanv1.HistoryEntry) []image.HistoryEntry
HistoryEntriesFromScanProto converts a slice of scanv1 HistoryEntry to internal.
func HistoryEntriesToContainerProto ¶
func HistoryEntriesToContainerProto(entries []image.HistoryEntry) []*containerv1.HistoryEntry
HistoryEntriesToContainerProto converts internal history entries to container proto.
func HistoryEntriesToScanProto ¶
func HistoryEntriesToScanProto(entries []image.HistoryEntry) []*scanv1.HistoryEntry
HistoryEntriesToScanProto converts a slice of internal HistoryEntry to scanv1 proto.
func HistoryEntryFromScanProto ¶
func HistoryEntryFromScanProto(h *scanv1.HistoryEntry) image.HistoryEntry
HistoryEntryFromScanProto converts scanv1.HistoryEntry to internal HistoryEntry.
func HistoryEntryToScanProto ¶
func HistoryEntryToScanProto(h image.HistoryEntry) *scanv1.HistoryEntry
HistoryEntryToScanProto converts internal HistoryEntry to scanv1.HistoryEntry.
func ImageConfigFromScanProto ¶
func ImageConfigFromScanProto(c *scanv1.ImageConfig) image.Config
ImageConfigFromScanProto converts scanv1.ImageConfig to internal image.Config.
func ImageConfigToContainerProto ¶
func ImageConfigToContainerProto(c *image.Config) *containerv1.ImageConfig
ImageConfigToContainerProto converts internal image.Config to container proto.
func ImageConfigToScanProto ¶
func ImageConfigToScanProto(c *image.Config) *scanv1.ImageConfig
ImageConfigToScanProto converts internal image.Config to scanv1.ImageConfig.
func ImageDiffReportToProto ¶
func ImageDiffReportToProto(report *compare.ImageDiffReport) *diffv1.DiffContainerImagesResponse
ImageDiffReportToProto converts an internal ImageDiffReport to proto DiffContainerImagesResponse.
func ImageInfoFromScanProto ¶
ImageInfoFromScanProto converts scanv1.ImageInfo to internal image.Info.
func ImageInfoToContainerProto ¶
func ImageInfoToContainerProto(info *image.Info) *containerv1.ImageInfo
ImageInfoToContainerProto converts internal image.Info to container proto.
func ImageInfoToProto ¶
func ImageInfoToProto(info *image.Info) *containerv1.ImageInfo
ImageInfoToProto is an alias for ImageInfoToContainerProto for convenience.
func ImageInfoToScanProto ¶
ImageInfoToScanProto converts internal image.Info to scanv1.ImageInfo.
func ImageMetadataFromScanProto ¶
func ImageMetadataFromScanProto(m *scanv1.ImageMetadata) image.Metadata
ImageMetadataFromScanProto converts scanv1.ImageMetadata to internal image.Metadata.
func ImageMetadataToContainerProto ¶
func ImageMetadataToContainerProto(m *image.Metadata) *containerv1.ImageMetadata
ImageMetadataToContainerProto converts internal image.Metadata to container proto.
func ImageMetadataToScanProto ¶
func ImageMetadataToScanProto(m *image.Metadata) *scanv1.ImageMetadata
ImageMetadataToScanProto converts internal image.Metadata to scanv1.ImageMetadata.
func InventoryResultToProto ¶
func InventoryResultToProto(r *inventory.Result) *inventoryv1.CollectInventoryResponse
InventoryResultToProto converts an inventory.Result to CollectInventoryResponse.
func InventoryTargetFromProto ¶
InventoryTargetFromProto converts proto Target to internal inventory.Target.
func InventoryTargetToProto ¶
InventoryTargetToProto converts internal inventory.Target to proto Target.
func IsAgentComplete ¶
func IsAgentComplete(phase remediationv1.AgentPhase) bool
IsAgentComplete returns true if the agent phase indicates completion.
func IsAgentFailed ¶
func IsAgentFailed(phase remediationv1.AgentPhase) bool
IsAgentFailed returns true if the agent phase indicates failure.
func IsAgentTerminal ¶
func IsAgentTerminal(phase remediationv1.AgentPhase) bool
IsAgentTerminal returns true if the agent phase is a terminal state.
func IsComplete ¶
IsComplete returns true if the scan phase indicates completion.
func IsCriticalOrHigh ¶
func IsCriticalOrHigh(l vulnerabilityv1.SeverityLevel) bool
IsCriticalOrHigh returns true if the severity is CRITICAL or HIGH.
func IsTerminal ¶
IsTerminal returns true if the scan phase is a terminal state.
func LayerDetailsFromProto ¶
func LayerDetailsFromProto(ld *containerv1.LayerDetails) *containerv1.LayerDetails
LayerDetailsFromProto returns the LayerDetails as-is since it's already a domain proto type.
func LayerDetailsToProto ¶
func LayerDetailsToProto(ld *containerv1.LayerDetails) *containerv1.LayerDetails
LayerDetailsToProto returns the LayerDetails as-is since it's already a domain proto type. This is a pass-through for consistency with the conversion API.
func ManifestRefsFromProto ¶
func ManifestRefsFromProto(refs []*dependencyv1.ManifestRef) []dependencyv1.ManifestRef
ManifestRefsFromProto converts proto ManifestRefs to internal ManifestRefs.
func ManifestRefsToProto ¶
func ManifestRefsToProto(refs []dependencyv1.ManifestRef) []*dependencyv1.ManifestRef
ManifestRefsToProto converts internal ManifestRefs to proto ManifestRefs. Since the domain protos use pointers, we convert value slices to pointer slices.
func MustValidate ¶
MustValidate validates a proto message and panics if validation fails. Use only in tests or initialization code where validation failures indicate programming errors.
func NewStats ¶
func NewStats(findings []*vulnerabilityv1.Finding) *vulnerabilityv1.Stats
NewStats creates a Stats from findings.
func PackageChangeFromProto ¶
func PackageChangeFromProto(pc *diffv1.PackageChange) compare.Change
PackageChangeFromProto converts a proto diffv1.PackageChange to internal compare.Change.
func PackageChangeToProto ¶
func PackageChangeToProto(c compare.Change) *diffv1.PackageChange
PackageChangeToProto converts an internal compare.Change to proto diffv1.PackageChange.
func PackageChangesFromProto ¶
func PackageChangesFromProto(changes []*diffv1.PackageChange) []compare.Change
PackageChangesFromProto converts proto PackageChanges to internal changes.
func PackageChangesToProto ¶
func PackageChangesToProto(changes []compare.Change) []*diffv1.PackageChange
PackageChangesToProto converts a slice of internal changes to proto.
func PackageDisplayName ¶
func PackageDisplayName(p *dependencyv1.Package) string
PackageDisplayName returns a human-readable display name for a package.
func PackageKey ¶
func PackageKey(p *dependencyv1.Package) string
PackageKey returns a unique key for a package (ecosystem:name@version).
func PackageToProto ¶
func PackageToProto(f vulnerability.Finding) *dependencyv1.Package
PackageToProto converts internal finding data to proto Package.
func ParseSeverityLevel ¶
func ParseSeverityLevel(s string) vulnerabilityv1.SeverityLevel
ParseSeverityLevel converts a string severity to proto SeverityLevel.
func ParseTargetKind ¶
func ParseTargetKind(s string) targetv1.TargetKind
ParseTargetKind converts a string target kind to proto TargetKind. Returns TARGET_KIND_UNSPECIFIED for unknown values.
func PolicyActionsToProto ¶
PolicyActionsToProto converts internal policy.Action slice to proto Action slice.
func RemediationCommandFromProto ¶
func RemediationCommandFromProto(pc *fixv1.RemediationCommand) remediation.Command
RemediationCommandFromProto converts a proto RemediationCommand to internal type.
func RemediationCommandToProto ¶
func RemediationCommandToProto(c remediation.Command) *fixv1.RemediationCommand
RemediationCommandToProto converts an internal remediation.Command to proto.
func RemediationCommandToStep ¶
func RemediationCommandToStep(c remediation.Command, id string) *remediationv1.Step
RemediationCommandToStep converts internal remediation.Command to proto Step.
func RemediationCommandsFromProto ¶
func RemediationCommandsFromProto(commands []*fixv1.RemediationCommand) []remediation.Command
RemediationCommandsFromProto converts proto commands to internal types.
func RemediationCommandsToProto ¶
func RemediationCommandsToProto(commands []remediation.Command) []*fixv1.RemediationCommand
RemediationCommandsToProto converts a slice of internal commands to proto.
func RemediationCommandsToSteps ¶
func RemediationCommandsToSteps(commands []remediation.Command) []*remediationv1.Step
RemediationCommandsToSteps converts a slice of internal Commands to proto Steps.
func RemediationStepFromProto ¶
func RemediationStepFromProto(s *remediationv1.Step) remediation.Command
RemediationStepFromProto converts proto Step to internal remediation.Command. Note: Some proto fields don't map back to Command (they're for execution tracking).
func RemediationStepsFromProto ¶
func RemediationStepsFromProto(steps []*remediationv1.Step) []remediation.Command
RemediationStepsFromProto converts a slice of proto Steps to internal Commands.
func RiskLevelFromProto ¶
func RiskLevelFromProto(r remediationv1.RiskLevel) string
RiskLevelFromProto converts proto RiskLevel to an internal risk string.
func RiskLevelToProto ¶
func RiskLevelToProto(risk string) remediationv1.RiskLevel
RiskLevelToProto converts an internal risk string to proto RiskLevel.
func SandboxFromProto ¶
SandboxFromProto converts proto sandbox string to internal ai.Sandbox.
func SandboxToProto ¶
SandboxToProto converts internal ai.Sandbox to proto sandbox string.
func ScanningResultFromProto ¶
func ScanningResultFromProto(r *scanv1.ScanResponse) *scanning.Result
ScanningResultFromProto converts proto ScanResponse to scanning.Result. This enables CLI commands to work directly with the scanning package.
func ScanningResultToProto ¶
func ScanningResultToProto(r *scanning.Result) *scanv1.ScanResponse
ScanningResultToProto converts scanning.Result to proto ScanResponse. This is used by handlers that use the scanning package directly.
func SecretTypeFromProto ¶
func SecretTypeFromProto(t secretsv1.SecretType) secrets.SecretType
SecretTypeFromProto converts proto SecretType to internal SecretType.
func SecretTypeToProto ¶
func SecretTypeToProto(t secrets.SecretType) secretsv1.SecretType
SecretTypeToProto converts internal SecretType to proto SecretType.
func SecretsFindingFromProto ¶
SecretsFindingFromProto converts proto Finding to internal secrets.Finding.
func SecretsFindingToProto ¶
SecretsFindingToProto converts internal secrets.Finding to proto Finding.
func SecretsFindingWithVerificationToProto ¶
func SecretsFindingWithVerificationToProto(f secrets.Finding, v *secrets.VerificationResult) *secretsv1.Finding
SecretsFindingWithVerificationToProto converts internal secrets.Finding with optional VerificationResult to proto.
func SecretsFindingsFromProto ¶
SecretsFindingsFromProto converts a slice of proto Finding to internal.
func SecretsFindingsToProto ¶
SecretsFindingsToProto converts a slice of internal Findings to proto.
func SecretsScanOptionsFromProto ¶
func SecretsScanOptionsFromProto(o *secretsv1.ScanOptions) secrets.EngineConfig
SecretsScanOptionsFromProto converts proto ScanOptions to internal engine config.
func SecretsScanOptionsToProto ¶
func SecretsScanOptionsToProto(c secrets.EngineConfig) *secretsv1.ScanOptions
SecretsScanOptionsToProto converts internal engine config to proto ScanOptions.
func SecretsScanResultToProto ¶
func SecretsScanResultToProto(target inventory.Target, findings []secrets.Finding, policyActions []policyv1.Action, warnings []string) *secretsv1.ScanResponse
SecretsScanResultToProto converts internal scan results to proto ScanResponse.
func SecretsStatsFromProto ¶
SecretsStatsFromProto converts proto Stats to a simple stats struct. Note: internal secrets doesn't have a Stats type, so this returns a map.
func SecretsStatsToProto ¶
SecretsStatsToProto converts secret findings to proto Stats.
func SecretsTargetHintFromProto ¶
func SecretsTargetHintFromProto(h *secretsv1.TargetHint) inventory.TargetHint
SecretsTargetHintFromProto converts proto TargetHint to internal inventory.TargetHint.
func SecretsVerificationResultToProto ¶
func SecretsVerificationResultToProto(v secrets.VerificationResult) *secretsv1.VerificationStatus
SecretsVerificationResultToProto converts internal secrets.VerificationResult to proto VerificationStatus.
func SeverityLevelString ¶
func SeverityLevelString(l vulnerabilityv1.SeverityLevel) string
SeverityLevelString returns a human-readable string for a SeverityLevel.
func StatsFromProto ¶
func StatsFromProto(s *vulnerabilityv1.Stats) vulnerabilityv1.Stats
StatsFromProto converts proto Stats to domain Stats.
func StatsToProto ¶
func StatsToProto(s vulnerabilityv1.Stats) *vulnerabilityv1.Stats
StatsToProto converts domain Stats (vulnerabilityv1) to proto Stats.
func StreamEventToAgentEvent ¶
func StreamEventToAgentEvent(e ai.StreamEvent, sessionID string, phase remediationv1.AgentPhase) *remediationv1.AgentEvent
StreamEventToAgentEvent converts internal ai.StreamEvent to proto AgentEvent.
func TargetKindString ¶
func TargetKindString(k targetv1.TargetKind) string
TargetKindString returns a human-readable string for a TargetKind.
func UsageToTokensEvent ¶
func UsageToTokensEvent(u ai.Usage, runningTotal int) *remediationv1.AgentTokensEvent
UsageToTokensEvent converts internal ai.Usage to proto AgentTokensEvent.
func Validate ¶
Validate validates a proto message using protovalidate rules defined in the proto schema. Returns nil if validation passes, or a validation error describing the failures.
This uses the package-level Validate function from protovalidate, which is safe for concurrent use and caches compiled validators for efficient repeated validation.
Example usage:
req := &remediationv1.ExecuteWithAgentRequest{Agent: ""}
if err := proto.Validate(req); err != nil {
return connect.NewError(connect.CodeInvalidArgument, err)
}
Types ¶
type ContainerDiffResponseContext ¶
type ContainerDiffResponseContext struct {
BaseDistro string
BasePackageCount int
BaseSize int64
BaseArch string
TargetDistro string
TargetPackageCount int
TargetSize int64
TargetArch string
}
ContainerDiffResponseContext provides additional context for rendering.
func ExtractContainerDiffContext ¶
func ExtractContainerDiffContext(resp *diffv1.DiffContainerImagesResponse) ContainerDiffResponseContext
ExtractContainerDiffContext extracts display context from a proto response.
type FilterOptions ¶
type FilterOptions struct {
// ExcludeMainModules is a set of Go module paths that represent the project
// being analyzed. Packages matching these modules are excluded from output
// to avoid showing the project as its own dependency.
ExcludeMainModules map[string]bool
// DeduplicateStdlib removes duplicate Go stdlib entries (go vs stdlib,
// multiple versions) keeping only a single "stdlib" entry with the highest
// version found.
DeduplicateStdlib bool
}
FilterOptions configures which packages to exclude from output.