Documentation
¶
Index ¶
- Constants
- Variables
- type Owners
- type Requester
- type Rule
- type Rules
- type T
- func (t *T) Check(rawURL string) (ip net.IP, port string, err error)
- func (t *T) CheckAddresses(use string, ips []net.IP) (net.IP, error)
- func (t *T) CheckNamespaceEndpoint(use string, ips []net.IP, req Requester) (net.IP, error)
- func (t *T) CheckRedirect(rawURL string) (ip net.IP, port string, err error)
- func (t *T) CheckSource(rawURL string) (ip net.IP, port string, follow bool, err error)
Constants ¶
const ( // LiveCluster is the addresses of the cluster nodes. LiveCluster = "cluster" // LiveNamespace is the addresses of the objects of a namespace, // "namespace ." the one of the object the endpoint is checked for. LiveNamespace = "namespace" // share of the object the endpoint is checked for names, * left out: // the consent already given between those namespaces. LiveShare = "share" // LiveObjects is the addresses of every object of the cluster. LiveObjects = "objects" )
The nouns of the endpoint rules naming addresses the cluster knows of.
const ( // UseFetch is a download of a url a configuration names, as the // source of a key or the image of a virtual machine. UseFetch = "fetch" UseSFTP = "sftp" UseS3 = "s3" UseISCSI = "iscsi" UseNVMeT = "nvmet" UseCeph = "ceph" UseRegistry = "registry" )
The uses an endpoint rule is for, what a connection of the node is made for.
const ( // SourcesKeyword is the keyword of the source rules. SourcesKeyword = "node.source_rules" // EndpointsKeyword is the keyword of the endpoint rules. EndpointsKeyword = "node.endpoint_rules" )
Variables ¶
var DefaultEndpoints = mustParse(listEndpoints, `
deny address 127.0.0.0/8
deny address 10.0.0.0/8
deny address 172.16.0.0/12
deny address 192.168.0.0/16
deny address 169.254.0.0/16
deny address 100.64.0.0/10
deny address 192.0.2.0/24
deny address 198.51.100.0/24
deny address 203.0.113.0/24
deny address ::1/128
deny address fe80::/10
deny address fc00::/7
deny address ff00::/8
allow any
`)
DefaultEndpoints is the endpoint rules ending every list: the loopback, private, link-local, shared and documentation ranges are refused, any other address allowed.
var DefaultNamespaceEndpoints = mustParse(listEndpoints, `
deny address 127.0.0.0/8
deny address 0.0.0.0/8
deny address 169.254.0.0/16
deny address 224.0.0.0/4
deny address ::1/128
deny address ::/128
deny address fe80::/10
deny address ff00::/8
deny cluster
allow namespace .
allow share
deny objects
allow any
`)
DefaultNamespaceEndpoints is the endpoint rules ending the list of an endpoint a namespace chose, a store or a registry of a namespace: the loopback, unspecified, link-local and multicast addresses, the cluster nodes and the objects of the other namespaces are refused, the objects of the namespace and of the namespaces its share names allowed, and any address the cluster does not know of allowed, a server of another site or cluster included.
var DefaultSources = mustParse(listSources, `
allow url https://raw.githubusercontent.com/opensvc/*
allow url https://github.com/opensvc/*/releases/*
deny any
`)
DefaultSources is the source rules ending every list: what the opensvc organization publishes, the files of its repositories and the assets of their releases, as a template seeds its keys from, then no other url.
var Uses = []string{UseFetch, UseSFTP, UseS3, UseISCSI, UseNVMeT, UseCeph, UseRegistry}
Uses is the uses an endpoint rule may be for, in the order an error lists them.
Functions ¶
This section is empty.
Types ¶
type Owners ¶
type Owners interface {
// IsNode says whether the address is one of a cluster node.
IsNode(addr netip.Addr) (bool, error)
// IsObjectOf says whether the address is one an object of the
// namespace publishes, one of any object when namespace is empty.
IsObjectOf(addr netip.Addr, namespace string) (bool, error)
}
Owners tells the addresses the cluster knows of, which the live nouns of the endpoint rules name. It is the object layer's to answer, from the view of the daemon: a util knows nothing of a cluster. It is asked only when the evaluation reaches a rule naming them, so the rules deciding first need nothing of the daemon, and an owner that can not be told is an error, which refuses the endpoint.
type Requester ¶
type Requester struct {
Namespace string
Owners Owners
// Rules are the endpoint rules of the namespace, which its
// configuration says, read before the ones of the node.
Rules Rules
}
Requester is what an endpoint a namespace chose is checked for: the namespace of the object naming it, a store or a registry, the namespaces its share names, and the owners of the addresses of the cluster.
type Rule ¶
type Rule struct {
// Allow is the verb: allow, or deny.
Allow bool
// Any is a rule matching everything, as "deny any".
Any bool
// URL is the pattern of a source rule, as "allow url
// https://mirror.example.com/*".
URL string
// NoRedirect is a source rule allowing the url, and no redirect
// it answers with: "allow url https://mirror.example.com/*
// noredirect".
NoRedirect bool
// Prefix is the address range of an endpoint rule, as "allow
// address 10.0.5.0/24".
Prefix netip.Prefix
// Live is the noun of an endpoint rule naming addresses the
// cluster knows of, resolved at each check: LiveCluster,
// LiveNamespace, LiveShare or LiveObjects. See Owners.
Live string
// Namespace is the namespace of a LiveNamespace rule, "." for
// the one of the object the endpoint is checked for.
Namespace string
// For is the uses an endpoint rule is for, all of them when
// empty: "allow address 10.20.0.0/24 for iscsi nvmet".
For []string
// Text is the rule as written, words separated by a space.
Text string
// Line is the line of the keyword value the rule is written on,
// 0 for a rule ending every list, which no keyword writes.
Line int
// Keyword is the keyword the rule is written in.
Keyword string
}
Rule is a rule of a list: its verb, what it names, and for an endpoint rule, the uses it is for.
The first rule of a list matching what is judged decides it.
type Rules ¶
type Rules []Rule
Rules is an ordered list of rules.
func ParseEndpoints ¶
ParseEndpoints returns the endpoint rules of the value of a keyword: a rule per line, "allow address <address or range>", "deny address <address or range>", "allow any" or "deny any", each with an optional "for <use>...", as ParseSources reads its value.
func ParseSources ¶
ParseSources returns the source rules of the value of a keyword: a rule per line, "allow url <pattern>", "deny url <pattern>", "allow any" or "deny any", an allow optionally followed by "noredirect", for the url to be fetched without following a redirect.
A value written on one line, as a command sets it, holds several rules: a verb starts a rule, so "allow url https://a/* deny any" is two. An error names the keyword and the line.
type T ¶
type T struct {
// contains filtered or unexported fields
}
T is the policy of the connections a node makes to the hosts a configuration names, against server side request forgery: two ordered lists, each read to its first rule matching.
The source rules judge the url a configuration names, once: which content the node trusts. The endpoint rules judge the address of every connection, each redirect followed included: where the node connects. Each list ends with the rules of the package, DefaultSources and DefaultEndpoints, which a rule written before them overrides.
func (*T) Check ¶
Check validates the url a configuration names, for a download: the source rules judge the url, and the endpoint rules for UseFetch each address its host resolves to. It returns the address to connect to, and the port, for the connection to go nowhere else than where it was checked to.
func (*T) CheckAddresses ¶
CheckAddresses validates the addresses of a connection made for use, and returns the one to connect to. Every address has to be allowed: a host resolving to an address refused is refused, whatever else it resolves to.
func (*T) CheckNamespaceEndpoint ¶
CheckNamespaceEndpoint validates the addresses of an endpoint a namespace chose, as the server of a registry or the url of a store of a namespace, connected to for use: by the rules of the namespace, then the endpoint rules written for the node, then DefaultNamespaceEndpoints, which refuse the nodes and the objects of the other namespaces, and allow what the cluster does not know of.
func (*T) CheckRedirect ¶
CheckRedirect validates the target of a redirect served by a url Check accepted: its addresses are held to the endpoint rules, as every connection is, and its url is not held to the source rules. The source rules say which content the node trusts, by the url a configuration names; where that source keeps its content, as the storage a release download redirects to, is the source's to say. An address refused is refused whatever redirects to it.