util

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package util holds small helpers shared across packages so a single implementation is imported everywhere rather than duplicated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(cluster, scanner, rule string) string

Fingerprint returns a stable hex identifier for a finding, derived from the cluster, scanner, and rule separated by null bytes. The rule names the check rather than its wording, so a finding keeps its fingerprint when a count in its title changes. Acknowledgements key on the same value, so a finding can be matched to its ack and tracked across scans by fingerprint.

func Plural added in v0.10.0

func Plural(n int) string

Plural returns "s" when n is not 1 and the empty string otherwise.

func SanitizeName added in v0.10.0

func SanitizeName(name string) string

SanitizeName returns a DNS-1123-safe rendering of name suitable for use as a Kubernetes metadata.name value. It lowercases, replaces runs of invalid characters with a dash, collapses adjacent dashes, caps the result at 253 characters, and trims dashes and dots from both ends so the name starts and ends alphanumeric. Pass any fixed prefix as part of name so the cap covers it.

func SeverityAtLeast added in v0.10.0

func SeverityAtLeast(got, want string) bool

SeverityAtLeast reports whether got meets the want threshold. An empty want always passes.

func SeverityRank added in v0.10.0

func SeverityRank(s string) int

SeverityRank assigns a numeric weight to a severity string for comparison. Unknown values rank 0.

func Truncate added in v0.10.0

func Truncate(s string, n int) string

Truncate shortens s to at most n runes, appending an ellipsis when cut.

Types

This section is empty.

Jump to

Keyboard shortcuts

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