Documentation
¶
Overview ¶
Package source defines what a collector is and holds the registry of them.
A source declares itself, emits claims, and returns a checkpoint. It does not decide scope, allocate IDs, write files or construct network clients: those arrive with the request or belong to the pipeline. Adding a source therefore touches this package's registry and nothing else.
Index ¶
Constants ¶
const UserAgent = "canopy/0 (+https://github.com/anytool-sh/canopy)"
UserAgent identifies Canopy to providers. Several of them reject an empty one, and an operator reading their logs should be able to tell who called.
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
func Fetch(ctx context.Context, c *http.Client, url string) (body []byte, sha256sum string, err error)
Fetch performs one GET with the client the pipeline issued, and returns the body with its SHA-256 so a claim can cite the exact bytes it came from. The client is gate-issued: passing anything else is how a source escapes scope enforcement, so callers must use req.HTTP.
Types ¶
type Checkpoint ¶
Checkpoint is where a source stopped, so a later call can resume.
func Backoff ¶
func Backoff(err error) Checkpoint
Backoff converts an error into the checkpoint to report with it, carrying the provider's retry delay so a later call can wait rather than guess.
type Claim ¶
type Claim struct {
Kind core.Kind
Hostname string
Value string
Query string
RawSHA256 string
ObservedAt time.Time
}
Claim is one thing a source observed. The pipeline turns it into a core.Observation, assigning the ID and run ID so a source cannot forge them.
ObservedAt is the provider's date for the claim, such as a certificate's issuance time. A zero value means the source has no date of its own and the pipeline stamps the observation with the run clock.
type Collector ¶
type Collector struct {
Emit Emitter
Root string
Query string
// SHA is the hash of the response the names came from.
SHA string
// contains filtered or unexported fields
}
Collector turns raw provider strings into claims. Every source needs the same four things — normalize, reject malformed names, keep only names under the requested root, and emit each name once — so they live here rather than being re-derived per provider with slightly different bugs.
type Descriptor ¶
type Descriptor struct {
ID string `json:"id"`
Activity netgate.Class `json:"activity"`
Capabilities []string `json:"capabilities"`
// Credential names the secret this source needs, empty when it needs none.
// A source with a credential and no value is skipped, not failed.
Credential string `json:"credential,omitempty"`
// Endpoints are the provider hosts the source may reach.
Endpoints []string `json:"endpoints,omitempty"`
// RPS caps request rate against the provider. Zero means unlimited.
RPS float64 `json:"rps,omitempty"`
}
Descriptor is a source's self-description, read before it runs so the pipeline can grant it the narrowest clients that let it work.
func (Descriptor) Grant ¶
func (d Descriptor) Grant() netgate.Grant
Grant converts a descriptor into the authorization the gate enforces.
type Emitter ¶
Emitter is the only way to produce observations. It returns an error when the run is over budget or the ledger cannot be written, and a source must stop rather than retry.
type RateLimited ¶
RateLimited is a provider asking us to back off. It is separate from a generic failure because the run summary reports when a source may be retried rather than treating it as broken.
func AsRateLimited ¶
func AsRateLimited(err error) (*RateLimited, bool)
AsRateLimited reports whether err was a provider backoff request.
func (*RateLimited) Error ¶
func (e *RateLimited) Error() string
type Request ¶
type Request struct {
Root string
Cursor string
// Limit caps hostnames per call, zero for the source's own default.
Limit int
// Credential is the secret for Descriptor.Credential, empty when none.
Credential string
HTTP *http.Client
DNS *netgate.Resolver
}
Request is one call to a source. The clients are gate-issued: a source has no other way to reach the network, which is what makes the activity class it declares enforceable rather than advisory.
type Source ¶
type Source interface {
Describe() Descriptor
Discover(ctx context.Context, req Request, emit Emitter) (Checkpoint, error)
}
Source collects hostnames from one provider.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all registers the built-in sources.
|
Package all registers the built-in sources. |
|
Package argosdns collects passive DNS hostnames from ArgosDNS.
|
Package argosdns collects passive DNS hostnames from ArgosDNS. |
|
Package certspotter collects hostnames from SSLMate's Cert Spotter API, a second view of the certificate transparency logs.
|
Package certspotter collects hostnames from SSLMate's Cert Spotter API, a second view of the certificate transparency logs. |
|
Package crtname collects hostnames from crt.name, an index of subdomains built from the certificate transparency firehose plus historical backfills and active probing.
|
Package crtname collects hostnames from crt.name, an index of subdomains built from the certificate transparency firehose plus historical backfills and active probing. |
|
Package crtsh collects hostnames from crt.sh, a search interface over the public certificate transparency logs.
|
Package crtsh collects hostnames from crt.sh, a search interface over the public certificate transparency logs. |
|
Package fixture provides sources that touch no network, so the pipeline and the run directory can be exercised end to end before a real provider exists.
|
Package fixture provides sources that touch no network, so the pipeline and the run directory can be exercised end to end before a real provider exists. |
|
Package hackertarget collects hostnames from HackerTarget's hostsearch API, a passive DNS view built from its own scanning.
|
Package hackertarget collects hostnames from HackerTarget's hostsearch API, a passive DNS view built from its own scanning. |
|
Package otx collects hostnames from AlienVault OTX passive DNS.
|
Package otx collects hostnames from AlienVault OTX passive DNS. |
|
Package rapiddns collects hostnames from rapiddns.io, a searchable archive of DNS records.
|
Package rapiddns collects hostnames from rapiddns.io, a searchable archive of DNS records. |
|
Package sourcetest is the conformance suite every collector must pass.
|
Package sourcetest is the conformance suite every collector must pass. |
|
Package subdomaincenter collects hostnames from subdomain.center, an aggregator that answers with a plain list of names.
|
Package subdomaincenter collects hostnames from subdomain.center, an aggregator that answers with a plain list of names. |
|
Package urlscan collects hostnames from urlscan.io's search over public scans.
|
Package urlscan collects hostnames from urlscan.io's search over public scans. |
|
Package wayback collects hostnames from the Internet Archive's CDX index.
|
Package wayback collects hostnames from the Internet Archive's CDX index. |