sources

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sources provides a modular framework for fetching metrics from external systems.

Index

Constants

This section is empty.

Variables

View Source
var Registry = make(map[string]Source)

Registry holds available sources by name.

Functions

func DeriveTitleFromPath added in v1.1.2

func DeriveTitleFromPath(path, explicitTitle string) string

DeriveTitleFromPath returns a friendly title from a file path. If an explicit title is provided, it returns that. Otherwise, resolves the path to an absolute path and returns the base name.

func GetExtra added in v1.1.2

func GetExtra(opts Options, key, defaultValue string) string

GetExtra retrieves a value from opts.Extra, returning defaultValue if not found or empty.

func Names

func Names() []string

Names returns a sorted list of registered source names.

func Register

func Register(s Source)

Register adds a source to the registry. Panics if a source with the same name already exists.

func ResolveCommand added in v1.1.1

func ResolveCommand(opts Options, extraKey, envVar string) string

ResolveCommand resolves a command path from Extra options or an environment variable.

func ResolveTitle added in v1.1.2

func ResolveTitle(values ...string) string

ResolveTitle returns the first non-empty string from the provided values. Typically used as ResolveTitle(opts.Title, derivedTitle, fallback).

Types

type ConfigResolver

type ConfigResolver struct {
	SourceName     string
	TokenEnvVar    string
	URLEnvVar      string
	TokenRequired  bool
	URLRequired    bool
	DefaultTimeout time.Duration
}

ConfigResolver provides methods for resolving source configuration.

func (*ConfigResolver) Resolve

func (r *ConfigResolver) Resolve(opts Options) (*ResolvedConfig, error)

Resolve resolves token and URL from options or environment variables.

type Options

type Options struct {
	// Common options
	URL       string
	Project   string
	Token     string
	Branch    string
	Title     string
	Threshold int
	Timeout   int // seconds

	// Source-specific options stored by key
	Extra map[string]string
}

Options holds configuration for fetching from a source.

type ResolvedConfig

type ResolvedConfig struct {
	Token   string
	URL     string
	Timeout time.Duration
}

ResolvedConfig holds resolved configuration for a source.

type Source

type Source interface {
	// Name returns the unique identifier for this source (e.g., "sonarqube").
	Name() string

	// Fetch retrieves metrics and converts them to a confidence report.
	// The opts map contains source-specific configuration (URL, project, token, etc.).
	Fetch(ctx context.Context, opts Options) (*confidence.Report, error)
}

Source fetches metrics from an external system and produces a confidence report.

func Get

func Get(name string) Source

Get returns a source by name, or nil if not found.

Directories

Path Synopsis
Package cmdrun provides utilities for running CLI commands.
Package cmdrun provides utilities for running CLI commands.
Package codecov provides a source for fetching coverage metrics from Codecov.
Package codecov provides a source for fetching coverage metrics from Codecov.
Package codeql provides a source for fetching code scanning alerts from GitHub CodeQL.
Package codeql provides a source for fetching code scanning alerts from GitHub CodeQL.
Package coverage provides shared infrastructure for coverage source providers.
Package coverage provides shared infrastructure for coverage source providers.
Package coveralls provides a source for fetching coverage metrics from Coveralls.
Package coveralls provides a source for fetching coverage metrics from Coveralls.
Package dependabot provides a source for fetching vulnerability alerts from GitHub Dependabot.
Package dependabot provides a source for fetching vulnerability alerts from GitHub Dependabot.
Package ghactions provides a source for fetching CI/CD metrics from GitHub Actions.
Package ghactions provides a source for fetching CI/CD metrics from GitHub Actions.
Package githubalerts provides shared infrastructure for GitHub security alerts sources.
Package githubalerts provides shared infrastructure for GitHub security alerts sources.
Package gitleaks provides a source for detecting secrets using GitLeaks.
Package gitleaks provides a source for detecting secrets using GitLeaks.
Package gosec provides a source for fetching security findings from Gosec.
Package gosec provides a source for fetching security findings from Gosec.
Package grype provides a source for fetching vulnerability metrics from Grype.
Package grype provides a source for fetching vulnerability metrics from Grype.
Package httpclient provides a common HTTP client for API sources.
Package httpclient provides a common HTTP client for API sources.
Package repoparse provides utilities for parsing repository identifiers.
Package repoparse provides utilities for parsing repository identifiers.
Package scoring provides shared scoring utilities for vulnerability sources.
Package scoring provides shared scoring utilities for vulnerability sources.
Package semgrep provides a source for fetching security findings from Semgrep.
Package semgrep provides a source for fetching security findings from Semgrep.
Package snyk provides a source for fetching vulnerability metrics from Snyk.
Package snyk provides a source for fetching vulnerability metrics from Snyk.
Package sonarqube provides a source for fetching metrics from SonarQube.
Package sonarqube provides a source for fetching metrics from SonarQube.
Package trivy provides a source for fetching vulnerability metrics from Trivy.
Package trivy provides a source for fetching vulnerability metrics from Trivy.
Package trufflehog provides a source for detecting secrets using TruffleHog.
Package trufflehog provides a source for detecting secrets using TruffleHog.

Jump to

Keyboard shortcuts

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