connector

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package connector is the interface every connector satisfies, the shared base holding the guarded client, and the registry.

Index

Constants

This section is empty.

Variables

View Source
var AWSActions = map[string]bool{
	"iam:GetAccountAuthorizationDetails": true,
	"iam:GetAccessKeyLastUsed":           true,
	"iam:ListAccessKeys":                 true,
	"iam:GenerateCredentialReport":       true,
	"iam:GetCredentialReport":            true,
}

AWSActions is the fixed list of AWS actions Firedrill may call. Broad reads such as secretsmanager:GetSecretValue or s3:GetObject are refused even if the credential allows them.

View Source
var ErrBlocked = errors.New("blocked by the read-only guard")

ErrBlocked marks a call the guard refused. It stops the run.

View Source
var Version = "0.0.1"

Version is the Firedrill version sent in the user agent. It is set at build time.

Functions

func CheckAWS

func CheckAWS(log *CallLog, action string) error

CheckAWS refuses an AWS action outside the list, and records it.

func Client

func Client(name string, p Policy, log *CallLog, next http.RoundTripper) *http.Client

Client returns an HTTP client behind the guard. Redirects pass through the guard too, since each hop is a new round trip.

func Register

func Register(c Connector)

Register adds a connector, the same pattern as database/sql drivers.

func UnderDomain

func UnderDomain(host, domain string) bool

UnderDomain reports whether host is a domain or one of its subdomains.

Types

type Base

type Base struct {
	ConnectorName string
	Policy        Policy
	Limit         rate.Limit
	Burst         int
	Next          http.RoundTripper // set in tests to reach a fake server
	// contains filtered or unexported fields
}

Base holds what every connector shares.

func (*Base) HTTP

func (b *Base) HTTP(log *CallLog) *http.Client

HTTP returns the guarded, rate-limited client. A connector never builds its own, so every call passes the guard and the log.

func (*Base) Name

func (b *Base) Name() string

Name returns the connector's name.

type Call

type Call struct {
	Time      time.Time `json:"time"`
	Connector string    `json:"connector"`
	Method    string    `json:"method"`
	Endpoint  string    `json:"endpoint"`
	Blocked   bool      `json:"blocked,omitempty"`
}

Call is one outbound call as logged.

type CallLog

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

CallLog records every outbound call and every call the guard refused. It stores the endpoint with no query string, so no value in a URL reaches disk.

func (*CallLog) Add

func (l *CallLog) Add(c Call)

Add records one call.

func (*CallLog) Calls

func (l *CallLog) Calls() []Call

Calls returns every call so far.

func (*CallLog) Violations

func (l *CallLog) Violations() []string

Violations returns every refused call so far.

func (*CallLog) WriteFile

func (l *CallLog) WriteFile(path string) error

WriteTo appends the log as JSON Lines to a file.

type Collection

type Collection struct {
	Name       string
	Nodes      []string // node kinds it writes
	Permission string   // the access it needs
	Calls      []string // the calls it makes, printed by --dry-run
}

Collection is one thing a connector can fetch.

type Connector

type Connector interface {
	Name() string
	Collections() []Collection
	// Available says whether the system is connected. The reason says how to
	// connect it.
	Available(s Scope) (bool, string)
	Collect(ctx context.Context, c Collection, s Scope, out graph.Writer) error
}

Connector is one system Firedrill can read.

func All

func All() []Connector

All returns every registered connector sorted by name.

func Lookup

func Lookup(name string) (Connector, bool)

Lookup returns a registered connector.

type Policy

type Policy struct {
	// Hosts may receive GET and HEAD. An empty map with HostAllowed set defers
	// to that function.
	Hosts map[string]bool
	// HostAllowed, when set, decides GET and HEAD hosts at call time.
	HostAllowed func(host string) bool
	// PostURLs are the exact scheme, host and path allowed to receive POST.
	PostURLs map[string]bool
}

Policy says which calls a connector may make.

func GitHubPolicy

func GitHubPolicy() Policy

GitHubPolicy allows reads of the GitHub API and its tarball redirect host.

func GooglePolicy

func GooglePolicy() Policy

GooglePolicy allows reads of the Admin SDK and the OAuth token exchange.

type RepoTarget

type RepoTarget struct {
	Name string // org/repo, or the folder name for a local checkout not in config
	Path string // local checkout, empty for remote only
}

RepoTarget is one repo a run covers.

func RepoTargets

func RepoTargets(s Scope) []RepoTarget

RepoTargets merges repos in config with local checkouts from --path. A repo in config can only be read remotely when a GitHub token is present.

type Scope

type Scope struct {
	Project         *config.Project
	Hasher          graph.Hasher
	Now             time.Time
	Log             *CallLog
	Paths           []string // local checkouts from --path
	IncludeHome     bool     // read user-level agent files
	HomeDir         string   // where user-level files live
	Token           string   // GitHub token, in memory only
	Getenv          func(string) string
	Tarball         func(ctx context.Context, repo string) (io.ReadCloser, error)
	FilePaths       []string    // paths named through files.json and files.yaml
	DNSHosts        []string    // hosts named through dns.records
	WebGets         [][2]string // host and path named through web.get
	VerifiedDomains []string
	RepoTargets     []string // every repo name in scope
}

Scope is what a run asks a connector to cover.

type Transport

type Transport struct {
	Next      http.RoundTripper
	Policy    Policy
	Log       *CallLog
	Connector string
}

Transport is the guarded HTTP client every connector gets from Base.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip refuses anything outside the policy and logs every call.

Jump to

Keyboard shortcuts

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