Documentation
¶
Overview ¶
Package connector is the interface every connector satisfies, the shared base holding the guarded client, and the registry.
Index ¶
- Variables
- func CheckAWS(log *CallLog, action string) error
- func Client(name string, p Policy, log *CallLog, next http.RoundTripper) *http.Client
- func Register(c Connector)
- func UnderDomain(host, domain string) bool
- type Base
- type Call
- type CallLog
- type Collection
- type Connector
- type Policy
- type RepoTarget
- type Scope
- type Transport
Constants ¶
This section is empty.
Variables ¶
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.
var ErrBlocked = errors.New("blocked by the read-only guard")
ErrBlocked marks a call the guard refused. It stops the run.
var Version = "0.0.1"
Version is the Firedrill version sent in the user agent. It is set at build time.
Functions ¶
func 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 ¶
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.
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) Violations ¶
Violations returns every refused call so far.
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.
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.