Documentation
¶
Overview ¶
Copyright (C) 2025 timbastin
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Copyright (C) 2026 l3montree GmbH ¶
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func AddSlashCommandsToDependencyVuln(str *strings.Builder) *strings.Builder
- func AddSlashCommandsToFirstPartyVuln(str *strings.Builder) *strings.Builder
- func AddToWhitespaceSeparatedStringList(s string, item string) string
- func All[T any](s []T, f func(T) bool) bool
- func Any[T any](s []T, f func(T) bool) bool
- func CheckForValidLanguageCode(languageCode string) bool
- func CheckIfDeleted(name string) bool
- func CollectSeq2[T any](seq iter.Seq2[[]T, error]) ([]T, error)
- func CompareFirstTwoDecimals(a, b float64) bool
- func Concurrently(fns ...func() (any, error)) concurrentResultSlice
- func Contains[T comparable](s []T, el T) bool
- func ContainsAll[T comparable](s []T, needed []T) bool
- func ContainsAny[T comparable](s []T, needed []T) bool
- func DeduplicateSlice[T any](slice []T, idFunc func(t T) string) []T
- func DereferenceSlice[T any](s []*T) []T
- func DoGetRequestWithContext(ctx context.Context, url string, client *http.Client) (io.ReadCloser, error)
- func EmptyThenNil(s string) *string
- func EndSpanWithError(span trace.Span, err error) error
- func ErrGroup[T any](limit int) *errGroup[T]
- func ExtractAttestationPayload(content string) (any, error)
- func Filter[T any](s []T, f func(T) bool) []T
- func Find[T any](s []T, f func(T) bool) (T, bool)
- func Flat[T any](s [][]T) []T
- func GetDirFromPath(path string) string
- func HashBytes(b []byte) string
- func HashString(s string) string
- func HashToInt64(s string) int64
- func HashToUUID(s string) uuid.UUID
- func IsCVE(str string) bool
- func IsEmail(str string) bool
- func Keys[K comparable, T any](m map[K]T) []K
- func Map[T, U any](s []T, f func(T) U) []U
- func MapType[New any, Old any](s []Old) []New
- func NewEgressClient(timeout time.Duration) *http.Client
- func OrDefault[T any](val *T, def T) T
- func ParallelBatches[T any, R any](items []T, fn func(batch []T) (R, error)) ([]R, error)
- func Ptr[T any](t T) *T
- func PtrMap[T any, U any](t *T, f func(T) U) *U
- func PublicKeyID(publicKey crypto.PublicKey) (string, error)
- func ReadFileFromGitRef(path string, commitSha string, fileName string) ([]byte, error)
- func RecordSpanError(span trace.Span, err error)
- func Reduce[T, U any](s []T, f func(U, T) U, init U) U
- func RemoveFromWhitespaceSeparatedStringList(s string, item string) string
- func RemovePrefixInsensitive(input string, prefix string) string
- func RunsInCI() bool
- func SafeDereference(s *string) string
- func ScoreToSeverity(score float64) cdx.Severity
- func ShannonEntropy(str string) float64
- func SlicePtr[T any](t []T) []*T
- func TeeChannel[T any](input <-chan T) (<-chan T, <-chan T)
- func ToLowerSlice(s []string) []string
- func UniqBy[T any, K comparable](s []T, f func(T) K) []T
- func ValidatePurlFields(purl packageurl.PackageURL) error
- func Values[K comparable, T any](m map[K]T) []T
- func VectorToCVSSScoringMethod(vector string) cdx.ScoringMethod
- func WaitForChannelDrain[T any](ch <-chan T)
- func WrapHTTPClient(client *http.Client, ...)
- func ZipReaderFromResponse(resp *http.Response) (*zip.Reader, error)
- type BatchModelWriter
- type CacheTransport
- type CompareResult
- type Date
- type EgressRoundTripper
- type FireAndForgetSynchronizer
- type GitVersionInfo
- type GoroutineFireAndForgetSynchronizer
- type ModelReader
- type ModelWriter
- type Repository
- type SyncFireAndForgetSynchronizer
- type TTLCache
- type Tabler
- type Transactioner
Constants ¶
const ISO8601Format = "2006-01-02T15:04:05.000"
Variables ¶
var EgressClient = *NewEgressClient(30 * time.Second)
var EgressTransport http.RoundTripper = otelhttp.NewTransport(EgressRoundTripper{ R: http.DefaultTransport, })
EgressTransport is the shared RoundTripper for all outgoing HTTP calls. It adds User-Agent and OpenTelemetry trace propagation headers.
var GitLister gitLister = commandLineGitLister{}
Functions ¶
func CheckForValidLanguageCode ¶
supported languages are declared in `supportedLanguageCodes` at the start of this file
func CheckIfDeleted ¶
func CollectSeq2 ¶ added in v1.12.4
CollectSeq2 drains a paged iter.Seq2[[]T, error] (as produced by batched repository queries) into a single slice, stopping at the first error.
func CompareFirstTwoDecimals ¶
func Concurrently ¶
func Contains ¶
func Contains[T comparable](s []T, el T) bool
func ContainsAll ¶
func ContainsAll[T comparable](s []T, needed []T) bool
func ContainsAny ¶ added in v1.4.0
func ContainsAny[T comparable](s []T, needed []T) bool
func DeduplicateSlice ¶
DeduplicateSlice deduplicates a slice in O(n) out of place.
func DereferenceSlice ¶
func DereferenceSlice[T any](s []*T) []T
func DoGetRequestWithContext ¶ added in v1.11.0
func DoGetRequestWithContext(ctx context.Context, url string, client *http.Client) (io.ReadCloser, error)
executes a GET request with an empty body to the specified url if no client is passed, the function uses the default http client returns the io.ReadCloser of the body of the response, callers are responsible for closing it
func EmptyThenNil ¶
func GetDirFromPath ¶
func HashString ¶
func HashToInt64 ¶ added in v1.12.5
func HashToUUID ¶ added in v1.3.0
HashToUUID hashes the input string with SHA-256 and returns the first 128 bits as a UUID.
func Keys ¶ added in v1.12.5
func Keys[K comparable, T any](m map[K]T) []K
func ParallelBatches ¶ added in v1.12.3
func PublicKeyID ¶ added in v1.17.2
PublicKeyID is the hex sha256 of the DER (PKIX) encoded public key - the key id of signatures devguard creates. Verifiers can compute it from the published PEM.
func ReadFileFromGitRef ¶
func RecordSpanError ¶ added in v1.12.3
func RemovePrefixInsensitive ¶
func SafeDereference ¶
func ScoreToSeverity ¶ added in v1.17.0
func ShannonEntropy ¶
func TeeChannel ¶
func TeeChannel[T any](input <-chan T) (<-chan T, <-chan T)
func ToLowerSlice ¶ added in v1.4.0
func UniqBy ¶
func UniqBy[T any, K comparable](s []T, f func(T) K) []T
func ValidatePurlFields ¶ added in v1.6.1
func ValidatePurlFields(purl packageurl.PackageURL) error
validate individual fields of purl for any incorrect characters
func Values ¶
func Values[K comparable, T any](m map[K]T) []T
func VectorToCVSSScoringMethod ¶ added in v1.17.0
func VectorToCVSSScoringMethod(vector string) cdx.ScoringMethod
func WaitForChannelDrain ¶
func WaitForChannelDrain[T any](ch <-chan T)
func WrapHTTPClient ¶
Types ¶
type BatchModelWriter ¶
type CacheTransport ¶
type CacheTransport struct {
// contains filtered or unexported fields
}
func NewCacheTransport ¶
func NewCacheTransport(cacheSize int, expiration time.Duration) *CacheTransport
func (*CacheTransport) Handler ¶
func (c *CacheTransport) Handler() func(req *http.Request, next http.RoundTripper) (*http.Response, error)
type CompareResult ¶
type CompareResult[T any] struct { OnlyInA []T OnlyInB []T InBoth []T // returns the elements in A InBothB []T }
func CompareSlices ¶
func CompareSlices[T any, K comparable](a, b []T, serializer func(T) K) CompareResult[T]
type EgressRoundTripper ¶
type EgressRoundTripper struct {
R http.RoundTripper
}
type FireAndForgetSynchronizer ¶
type FireAndForgetSynchronizer interface {
FireAndForget(fn func())
}
useful for integration testing - use in production to just fire and forget a function "go func()" during testing, this can be used to synchronize the execution of multiple goroutines - and wait for them to finish
type GitVersionInfo ¶
func GetAssetVersionInfo ¶
func GetAssetVersionInfo(path string) (GitVersionInfo, error)
type GoroutineFireAndForgetSynchronizer ¶
type GoroutineFireAndForgetSynchronizer struct{}
func NewFireAndForgetSynchronizer ¶
func NewFireAndForgetSynchronizer() *GoroutineFireAndForgetSynchronizer
func (*GoroutineFireAndForgetSynchronizer) FireAndForget ¶
func (f *GoroutineFireAndForgetSynchronizer) FireAndForget(fn func())
super simple: create a goroutine and call the function in it
type ModelReader ¶
type ModelReader[ID any, T Tabler, Tx any] interface { Read(ctx context.Context, tx Tx, id ID) (T, error) List(ctx context.Context, tx Tx, ids []ID) ([]T, error) All(ctx context.Context, tx Tx) ([]T, error) InBatches(ctx context.Context, tx Tx, batchSize int) iter.Seq2[[]T, error] Upsert(ctx context.Context, tx Tx, t *[]*T, conflictingColumns []clause.Column, updateOnly []string) error }
type ModelWriter ¶
type Repository ¶
type Repository[ID any, T Tabler, Tx any] interface { ModelWriter[ID, T, Tx] ModelReader[ID, T, Tx] BatchModelWriter[T, Tx] Transactioner[Tx] }
type SyncFireAndForgetSynchronizer ¶
type SyncFireAndForgetSynchronizer struct{}
SyncFireAndForgetSynchronizer calls functions synchronously. Useful for tests that want predictable execution ordering instead of spawning goroutines.
func NewSyncFireAndForgetSynchronizer ¶
func NewSyncFireAndForgetSynchronizer() *SyncFireAndForgetSynchronizer
func (*SyncFireAndForgetSynchronizer) FireAndForget ¶
func (f *SyncFireAndForgetSynchronizer) FireAndForget(fn func())
type TTLCache ¶ added in v1.15.0
type TTLCache[K comparable, V any] struct { // contains filtered or unexported fields }
TTLCache is a concurrency-safe in-memory cache whose entries expire after a fixed TTL and whose total size is bounded. Because every entry lives for the same TTL, insertion order equals expiry order: the oldest entry is both the first to expire and the one evicted when the size bound is exceeded.
func NewTTLCache ¶ added in v1.15.0
func NewTTLCache[K comparable, V any](ttl time.Duration, maxSize int, sizeOf func(V) int) *TTLCache[K, V]
NewTTLCache creates a cache holding entries for ttl, with the summed sizeOf of all entries bounded by maxSize. A nil sizeOf counts every entry as 1, bounding the number of entries instead.
func (*TTLCache[K, V]) Delete ¶ added in v1.15.0
func (c *TTLCache[K, V]) Delete(key K)
Delete removes key from the cache.
func (*TTLCache[K, V]) Get ¶ added in v1.15.0
Get returns the value stored for key if it exists and has not expired.