diff --git a/api/v1/common.go b/api/v1/common.go index 4a3dc209..13419ccd 100644 --- a/api/v1/common.go +++ b/api/v1/common.go @@ -4,11 +4,14 @@ import ( "fmt" "net/url" "regexp" + "sort" "strings" + "github.com/flanksource/commons/hash" "github.com/flanksource/duty/models" "github.com/flanksource/duty/types" "github.com/flanksource/gomplate/v3" + "github.com/samber/lo" ) // ConfigFieldExclusion defines fields with JSONPath that needs to @@ -100,6 +103,139 @@ func (t *TransformChange) IsEmpty() bool { return len(t.Exclude) == 0 } +// RelationshipLookup offers different ways to specify a lookup value +type RelationshipLookup struct { + Expr string `json:"expr,omitempty"` + Value string `json:"value,omitempty"` + Label string `json:"label,omitempty"` +} + +func (t *RelationshipLookup) Eval(labels map[string]string, envVar map[string]any) (string, error) { + if t.Value != "" { + return t.Value, nil + } + + if t.Label != "" { + return labels[t.Label], nil + } + + if t.Expr != "" { + res, err := gomplate.RunTemplate(envVar, gomplate.Template{Expression: t.Expr}) + if err != nil { + return "", err + } + + return res, nil + } + + return "", nil +} + +func (t RelationshipLookup) IsEmpty() bool { + if t.Value == "" && t.Label == "" && t.Expr == "" { + return true + } + + return false +} + +// RelationshipSelector is the evaluated output of RelationshipSelector. +// +// NOTE: The fields are pointers because we need to differentiate between +// empty filter (null value) and empty result (output of the filter). +type RelationshipSelector struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Agent *string `json:"agent,omitempty"` + Labels map[string]string `json:"labels,omitempty"` +} + +func (t *RelationshipSelector) Hash() string { + items := []string{ + lo.FromPtr(t.ID), + lo.FromPtr(t.Name), + lo.FromPtr(t.Type), + lo.FromPtr(t.Agent), + } + + labelkeys := lo.Keys(t.Labels) + sort.Slice(labelkeys, func(i, j int) bool { return labelkeys[i] < labelkeys[j] }) + for _, k := range labelkeys { + items = append(items, fmt.Sprintf("%s=%s", k, t.Labels[k])) + } + + return hash.Sha256Hex(strings.Join(items, "|")) +} + +func (t *RelationshipSelector) IsEmpty() bool { + return t.ID == nil && t.Name == nil && t.Type == nil && t.Agent == nil && len(t.Labels) == 0 +} + +type RelationshipSelectorTemplate struct { + ID RelationshipLookup `json:"id,omitempty"` + Name RelationshipLookup `json:"name,omitempty"` + Type RelationshipLookup `json:"type,omitempty"` + // Agent can be one of + // - agent id + // - agent name + // - 'self' (no agent) + Agent RelationshipLookup `json:"agent,omitempty"` + Labels map[string]string `json:"labels,omitempty"` +} + +func (t *RelationshipSelectorTemplate) IsEmpty() bool { + return t.ID.IsEmpty() && t.Name.IsEmpty() && t.Type.IsEmpty() && t.Agent.IsEmpty() && len(t.Labels) == 0 +} + +func (t *RelationshipSelectorTemplate) Eval(labels map[string]string, env map[string]any) (*RelationshipSelector, error) { + var output RelationshipSelector + + if !t.ID.IsEmpty() { + if res, err := t.ID.Eval(labels, env); err != nil { + return nil, fmt.Errorf("failed to evaluate id: %v for config relationship: %w", t.ID, err) + } else { + output.ID = &res + } + } + + if !t.Name.IsEmpty() { + if res, err := t.Name.Eval(labels, env); err != nil { + return nil, fmt.Errorf("failed to evaluate name: %v for config relationship: %w", t.Name, err) + } else { + output.Name = &res + } + } + + if !t.Type.IsEmpty() { + if res, err := t.Type.Eval(labels, env); err != nil { + return nil, fmt.Errorf("failed to evaluate type: %v for config relationship: %w", t.Type, err) + } else { + output.Type = &res + } + } + + if !t.Agent.IsEmpty() { + if res, err := t.Agent.Eval(labels, env); err != nil { + return nil, fmt.Errorf("failed to evaluate agent_id: %v for config relationship: %w", t.Agent, err) + } else { + output.Agent = &res + } + } + + return &output, nil +} + +type RelationshipConfig struct { + RelationshipSelectorTemplate `json:",inline"` + // Alternately, a single cel-expression can be used + // that returns a list of relationship selector. + Expr string `json:"expr,omitempty"` + // Filter is a CEL expression that selects on what config items + // the relationship needs to be applied + Filter string `json:"filter,omitempty"` +} + type Transform struct { Script Script `yaml:",inline" json:",inline"` // Fields to remove from the config, useful for removing sensitive data and fields @@ -107,12 +243,14 @@ type Transform struct { Exclude []ConfigFieldExclusion `json:"exclude,omitempty"` // Masks consist of configurations to replace sensitive fields // with hash functions or static string. - Masks MaskList `json:"mask,omitempty"` - Change TransformChange `json:"changes,omitempty"` + Masks MaskList `json:"mask,omitempty"` + // Relationship allows you to form relationships between config items using selectors. + Relationship []RelationshipConfig `json:"relationship,omitempty"` + Change TransformChange `json:"changes,omitempty"` } func (t Transform) IsEmpty() bool { - return t.Script.IsEmpty() && t.Change.IsEmpty() && len(t.Exclude) == 0 && t.Masks.IsEmpty() + return t.Script.IsEmpty() && t.Change.IsEmpty() && len(t.Exclude) == 0 && t.Masks.IsEmpty() && len(t.Relationship) == 0 } func (t Transform) String() string { @@ -133,6 +271,7 @@ func (t Transform) String() string { s += fmt.Sprintf(" change=%s", t.Change) } + s += fmt.Sprintf(" relationships=%d", len(t.Relationship)) return s } diff --git a/api/v1/kubernetes.go b/api/v1/kubernetes.go index 238664f8..119f0440 100644 --- a/api/v1/kubernetes.go +++ b/api/v1/kubernetes.go @@ -2,13 +2,11 @@ package v1 import ( "encoding/json" - "errors" "fmt" "strings" "github.com/flanksource/commons/collections" "github.com/flanksource/duty/types" - "github.com/flanksource/gomplate/v3" "github.com/flanksource/mapstructure" coreV1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -105,47 +103,13 @@ func (t *KubernetesExclusionConfig) Filter(name, namespace, kind string, labels return false } -type KubernetesRelationshipLookup struct { - Expr string `json:"expr,omitempty"` - Value string `json:"value,omitempty"` - Label string `json:"label,omitempty"` -} - -func (t *KubernetesRelationshipLookup) Eval(labels map[string]string, envVar map[string]any) (string, error) { - if t.Value != "" { - return t.Value, nil - } - - if t.Label != "" { - return labels[t.Label], nil - } - - if t.Expr != "" { - res, err := gomplate.RunTemplate(envVar, gomplate.Template{Expression: t.Expr}) - if err != nil { - return "", err - } - - return res, nil - } - - return "", errors.New("unknown kubernetes relationship lookup type") -} - -func (t KubernetesRelationshipLookup) IsEmpty() bool { - if t.Value == "" && t.Label == "" && t.Expr == "" { - return true - } - return false -} - type KubernetesRelationship struct { // Kind defines which field to use for the kind lookup - Kind KubernetesRelationshipLookup `json:"kind" yaml:"kind"` + Kind RelationshipLookup `json:"kind" yaml:"kind"` // Name defines which field to use for the name lookup - Name KubernetesRelationshipLookup `json:"name" yaml:"name"` + Name RelationshipLookup `json:"name" yaml:"name"` // Namespace defines which field to use for the namespace lookup - Namespace KubernetesRelationshipLookup `json:"namespace" yaml:"namespace"` + Namespace RelationshipLookup `json:"namespace" yaml:"namespace"` } type Kubernetes struct { diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index ad9f88ad..4f15cffc 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -651,21 +651,6 @@ func (in *KubernetesRelationship) DeepCopy() *KubernetesRelationship { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubernetesRelationshipLookup) DeepCopyInto(out *KubernetesRelationshipLookup) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesRelationshipLookup. -func (in *KubernetesRelationshipLookup) DeepCopy() *KubernetesRelationshipLookup { - if in == nil { - return nil - } - out := new(KubernetesRelationshipLookup) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Mask) DeepCopyInto(out *Mask) { *out = *in @@ -816,6 +801,37 @@ func (in *QueryRequest) DeepCopy() *QueryRequest { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelationshipConfig) DeepCopyInto(out *RelationshipConfig) { + *out = *in + in.RelationshipSelectorTemplate.DeepCopyInto(&out.RelationshipSelectorTemplate) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelationshipConfig. +func (in *RelationshipConfig) DeepCopy() *RelationshipConfig { + if in == nil { + return nil + } + out := new(RelationshipConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelationshipLookup) DeepCopyInto(out *RelationshipLookup) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelationshipLookup. +func (in *RelationshipLookup) DeepCopy() *RelationshipLookup { + if in == nil { + return nil + } + out := new(RelationshipLookup) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RelationshipResult) DeepCopyInto(out *RelationshipResult) { *out = *in @@ -854,6 +870,74 @@ func (in RelationshipResults) DeepCopy() RelationshipResults { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelationshipSelector) DeepCopyInto(out *RelationshipSelector) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } + if in.Agent != nil { + in, out := &in.Agent, &out.Agent + *out = new(string) + **out = **in + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelationshipSelector. +func (in *RelationshipSelector) DeepCopy() *RelationshipSelector { + if in == nil { + return nil + } + out := new(RelationshipSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelationshipSelectorTemplate) DeepCopyInto(out *RelationshipSelectorTemplate) { + *out = *in + out.ID = in.ID + out.Name = in.Name + out.Type = in.Type + out.Agent = in.Agent + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelationshipSelectorTemplate. +func (in *RelationshipSelectorTemplate) DeepCopy() *RelationshipSelectorTemplate { + if in == nil { + return nil + } + out := new(RelationshipSelectorTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceSelector) DeepCopyInto(out *ResourceSelector) { *out = *in @@ -1155,6 +1239,13 @@ func (in *Transform) DeepCopyInto(out *Transform) { *out = make(MaskList, len(*in)) copy(*out, *in) } + if in.Relationship != nil { + in, out := &in.Relationship, &out.Relationship + *out = make([]RelationshipConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } in.Change.DeepCopyInto(&out.Change) } diff --git a/chart/crds/configs.flanksource.com_scrapeconfigs.yaml b/chart/crds/configs.flanksource.com_scrapeconfigs.yaml index 5abda241..d035dcbf 100644 --- a/chart/crds/configs.flanksource.com_scrapeconfigs.yaml +++ b/chart/crds/configs.flanksource.com_scrapeconfigs.yaml @@ -345,6 +345,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object trusted_advisor_check: type: boolean @@ -633,6 +698,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -872,6 +1002,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -1069,6 +1264,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -1306,6 +1566,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -1653,6 +1978,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -1861,6 +2251,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -2175,6 +2630,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as @@ -2395,6 +2915,71 @@ spec: type: string type: object type: array + relationship: + description: Relationship allows you to form relationships + between config items using selectors. + items: + properties: + agent: + description: Agent can be one of - agent id - agent + name - 'self' (no agent) + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + expr: + description: Alternately, a single cel-expression + can be used that returns a list of relationship + selector. + type: string + filter: + description: Filter is a CEL expression that selects + on what config items the relationship needs to be + applied + type: string + id: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + name: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: + description: RelationshipLookup offers different ways + to specify a lookup value + properties: + expr: + type: string + label: + type: string + value: + type: string + type: object + type: object + type: array type: object type: description: A static value or JSONPath expression to use as diff --git a/config/schemas/config_aws.schema.json b/config/schemas/config_aws.schema.json index cb3707a6..dfe1d3be 100644 --- a/config/schemas/config_aws.schema.json +++ b/config/schemas/config_aws.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWS","definitions":{"AWS":{"required":["BaseScraper","AWSConnection"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"AWSConnection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWSConnection"},"patch_states":{"type":"boolean"},"patch_details":{"type":"boolean"},"inventory":{"type":"boolean"},"compliance":{"type":"boolean"},"cloudtrail":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CloudTrail"},"trusted_advisor_check":{"type":"boolean"},"include":{"items":{"type":"string"},"type":"array"},"exclude":{"items":{"type":"string"},"type":"array"},"cost_reporting":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CostReporting"}},"additionalProperties":false,"type":"object"},"AWSConnection":{"required":["region"],"properties":{"connection":{"type":"string"},"accessKey":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"secretKey":{"$ref":"#/definitions/EnvVar"},"region":{"items":{"type":"string"},"type":"array"},"endpoint":{"type":"string"},"skipTLSVerify":{"type":"boolean"},"assumeRole":{"type":"string"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"CloudTrail":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"},"max_age":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"CostReporting":{"properties":{"s3_bucket_path":{"type":"string"},"table":{"type":"string"},"database":{"type":"string"},"region":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWS","definitions":{"AWS":{"required":["BaseScraper","AWSConnection"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"AWSConnection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWSConnection"},"patch_states":{"type":"boolean"},"patch_details":{"type":"boolean"},"inventory":{"type":"boolean"},"compliance":{"type":"boolean"},"cloudtrail":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CloudTrail"},"trusted_advisor_check":{"type":"boolean"},"include":{"items":{"type":"string"},"type":"array"},"exclude":{"items":{"type":"string"},"type":"array"},"cost_reporting":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CostReporting"}},"additionalProperties":false,"type":"object"},"AWSConnection":{"required":["region"],"properties":{"connection":{"type":"string"},"accessKey":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"secretKey":{"$ref":"#/definitions/EnvVar"},"region":{"items":{"type":"string"},"type":"array"},"endpoint":{"type":"string"},"skipTLSVerify":{"type":"boolean"},"assumeRole":{"type":"string"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"CloudTrail":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"},"max_age":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"CostReporting":{"properties":{"s3_bucket_path":{"type":"string"},"table":{"type":"string"},"database":{"type":"string"},"region":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_azure.schema.json b/config/schemas/config_azure.schema.json index f1d19b42..ce2dce84 100644 --- a/config/schemas/config_azure.schema.json +++ b/config/schemas/config_azure.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Azure","definitions":{"Azure":{"required":["BaseScraper","subscriptionID","organisation","tenantID"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"subscriptionID":{"type":"string"},"organisation":{"type":"string"},"clientID":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"clientSecret":{"$ref":"#/definitions/EnvVar"},"tenantID":{"type":"string"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureExclusions"}},"additionalProperties":false,"type":"object"},"AzureExclusions":{"properties":{"activityLogs":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Azure","definitions":{"Azure":{"required":["BaseScraper","subscriptionID","organisation","tenantID"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"subscriptionID":{"type":"string"},"organisation":{"type":"string"},"clientID":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"clientSecret":{"$ref":"#/definitions/EnvVar"},"tenantID":{"type":"string"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureExclusions"}},"additionalProperties":false,"type":"object"},"AzureExclusions":{"properties":{"activityLogs":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_azuredevops.schema.json b/config/schemas/config_azuredevops.schema.json index 895a3edd..040f2bba 100644 --- a/config/schemas/config_azuredevops.schema.json +++ b/config/schemas/config_azuredevops.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureDevops","definitions":{"AzureDevops":{"required":["BaseScraper","projects","pipelines"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"organization":{"type":"string"},"personalAccessToken":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"projects":{"items":{"type":"string"},"type":"array"},"pipelines":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureDevops","definitions":{"AzureDevops":{"required":["BaseScraper","projects","pipelines"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"organization":{"type":"string"},"personalAccessToken":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"projects":{"items":{"type":"string"},"type":"array"},"pipelines":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_file.schema.json b/config/schemas/config_file.schema.json index 536a195c..54341713 100644 --- a/config/schemas/config_file.schema.json +++ b/config/schemas/config_file.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/File","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"File":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"url":{"type":"string"},"paths":{"items":{"type":"string"},"type":"array"},"ignore":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"},"icon":{"type":"string"},"connection":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/File","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"File":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"url":{"type":"string"},"paths":{"items":{"type":"string"},"type":"array"},"ignore":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"},"icon":{"type":"string"},"connection":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_githubactions.schema.json b/config/schemas/config_githubactions.schema.json index 351698c2..4aa80070 100644 --- a/config/schemas/config_githubactions.schema.json +++ b/config/schemas/config_githubactions.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/GitHubActions","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"GitHubActions":{"required":["BaseScraper","owner","repository","personalAccessToken","workflows"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"owner":{"type":"string"},"repository":{"type":"string"},"personalAccessToken":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"connection":{"type":"string"},"workflows":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/GitHubActions","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"GitHubActions":{"required":["BaseScraper","owner","repository","personalAccessToken","workflows"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"owner":{"type":"string"},"repository":{"type":"string"},"personalAccessToken":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"connection":{"type":"string"},"workflows":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_kubernetes.schema.json b/config/schemas/config_kubernetes.schema.json index dc99e0e1..00201690 100644 --- a/config/schemas/config_kubernetes.schema.json +++ b/config/schemas/config_kubernetes.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Kubernetes","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Kubernetes":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"clusterName":{"type":"string"},"namespace":{"type":"string"},"useCache":{"type":"boolean"},"allowIncomplete":{"type":"boolean"},"scope":{"type":"string"},"since":{"type":"string"},"selector":{"type":"string"},"fieldSelector":{"type":"string"},"maxInflight":{"type":"integer"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesExclusionConfig"},"kubeconfig":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"event":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventConfig"},"relationships":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationship"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesEventConfig":{"properties":{"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventExclusions"},"severityKeywords":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SeverityKeywords"}},"additionalProperties":false,"type":"object"},"KubernetesEventExclusions":{"properties":{"name":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"reason":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesExclusionConfig":{"required":["name","kind","namespace"],"properties":{"name":{"items":{"type":"string"},"type":"array"},"kind":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"KubernetesRelationship":{"required":["kind","name","namespace"],"properties":{"kind":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationshipLookup"},"name":{"$ref":"#/definitions/KubernetesRelationshipLookup"},"namespace":{"$ref":"#/definitions/KubernetesRelationshipLookup"}},"additionalProperties":false,"type":"object"},"KubernetesRelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"SeverityKeywords":{"properties":{"warn":{"items":{"type":"string"},"type":"array"},"error":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Kubernetes","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Kubernetes":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"clusterName":{"type":"string"},"namespace":{"type":"string"},"useCache":{"type":"boolean"},"allowIncomplete":{"type":"boolean"},"scope":{"type":"string"},"since":{"type":"string"},"selector":{"type":"string"},"fieldSelector":{"type":"string"},"maxInflight":{"type":"integer"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesExclusionConfig"},"kubeconfig":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"event":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventConfig"},"relationships":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationship"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesEventConfig":{"properties":{"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventExclusions"},"severityKeywords":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SeverityKeywords"}},"additionalProperties":false,"type":"object"},"KubernetesEventExclusions":{"properties":{"name":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"reason":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesExclusionConfig":{"required":["name","kind","namespace"],"properties":{"name":{"items":{"type":"string"},"type":"array"},"kind":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"KubernetesRelationship":{"required":["kind","name","namespace"],"properties":{"kind":{"$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"namespace":{"$ref":"#/definitions/RelationshipLookup"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"SeverityKeywords":{"properties":{"warn":{"items":{"type":"string"},"type":"array"},"error":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_kubernetesfile.schema.json b/config/schemas/config_kubernetesfile.schema.json index 24b96fe4..bff5a0db 100644 --- a/config/schemas/config_kubernetesfile.schema.json +++ b/config/schemas/config_kubernetesfile.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesFile","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"KubernetesFile":{"required":["BaseScraper","selector"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"selector":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ResourceSelector"},"container":{"type":"string"},"files":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/PodFile"},"type":"array"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"PodFile":{"properties":{"path":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"}},"additionalProperties":false,"type":"object"},"ResourceSelector":{"properties":{"namespace":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"labelSelector":{"type":"string"},"fieldSelector":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesFile","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"KubernetesFile":{"required":["BaseScraper","selector"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"selector":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ResourceSelector"},"container":{"type":"string"},"files":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/PodFile"},"type":"array"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"PodFile":{"properties":{"path":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"ResourceSelector":{"properties":{"namespace":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"labelSelector":{"type":"string"},"fieldSelector":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_sql.schema.json b/config/schemas/config_sql.schema.json index db6d7faf..1c078e24 100644 --- a/config/schemas/config_sql.schema.json +++ b/config/schemas/config_sql.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SQL","definitions":{"Authentication":{"required":["username","password"],"properties":{"username":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"password":{"$ref":"#/definitions/EnvVar"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Connection":{"required":["connection"],"properties":{"connection":{"type":"string"},"auth":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Authentication"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"SQL":{"required":["BaseScraper","Connection","query"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"Connection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Connection"},"driver":{"type":"string"},"query":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SQL","definitions":{"Authentication":{"required":["username","password"],"properties":{"username":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"password":{"$ref":"#/definitions/EnvVar"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Connection":{"required":["connection"],"properties":{"connection":{"type":"string"},"auth":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Authentication"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"SQL":{"required":["BaseScraper","Connection","query"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"Connection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Connection"},"driver":{"type":"string"},"query":{"type":"string"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/config_trivy.schema.json b/config/schemas/config_trivy.schema.json index cab31979..c62b20c3 100644 --- a/config/schemas/config_trivy.schema.json +++ b/config/schemas/config_trivy.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Trivy","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Trivy":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"version":{"type":"string"},"compliance":{"items":{"type":"string"},"type":"array"},"ignoredLicenses":{"items":{"type":"string"},"type":"array"},"ignoreUnfixed":{"type":"boolean"},"licenseFull":{"type":"boolean"},"severity":{"items":{"type":"string"},"type":"array"},"vulnType":{"items":{"type":"string"},"type":"array"},"scanners":{"items":{"type":"string"},"type":"array"},"timeout":{"type":"string"},"kubernetes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TrivyK8sOptions"}},"additionalProperties":false,"type":"object"},"TrivyK8sOptions":{"properties":{"components":{"items":{"type":"string"},"type":"array"},"context":{"type":"string"},"kubeconfig":{"type":"string"},"namespace":{"type":"string"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Trivy","definitions":{"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Trivy":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"version":{"type":"string"},"compliance":{"items":{"type":"string"},"type":"array"},"ignoredLicenses":{"items":{"type":"string"},"type":"array"},"ignoreUnfixed":{"type":"boolean"},"licenseFull":{"type":"boolean"},"severity":{"items":{"type":"string"},"type":"array"},"vulnType":{"items":{"type":"string"},"type":"array"},"scanners":{"items":{"type":"string"},"type":"array"},"timeout":{"type":"string"},"kubernetes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TrivyK8sOptions"}},"additionalProperties":false,"type":"object"},"TrivyK8sOptions":{"properties":{"components":{"items":{"type":"string"},"type":"array"},"context":{"type":"string"},"kubeconfig":{"type":"string"},"namespace":{"type":"string"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/config/schemas/scrape_config.schema.json b/config/schemas/scrape_config.schema.json index 5790aacf..3bfacc51 100644 --- a/config/schemas/scrape_config.schema.json +++ b/config/schemas/scrape_config.schema.json @@ -1 +1 @@ -{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScrapeConfig","definitions":{"AWS":{"required":["BaseScraper","AWSConnection"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"AWSConnection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWSConnection"},"patch_states":{"type":"boolean"},"patch_details":{"type":"boolean"},"inventory":{"type":"boolean"},"compliance":{"type":"boolean"},"cloudtrail":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CloudTrail"},"trusted_advisor_check":{"type":"boolean"},"include":{"items":{"type":"string"},"type":"array"},"exclude":{"items":{"type":"string"},"type":"array"},"cost_reporting":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CostReporting"}},"additionalProperties":false,"type":"object"},"AWSConnection":{"required":["region"],"properties":{"connection":{"type":"string"},"accessKey":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"secretKey":{"$ref":"#/definitions/EnvVar"},"region":{"items":{"type":"string"},"type":"array"},"endpoint":{"type":"string"},"skipTLSVerify":{"type":"boolean"},"assumeRole":{"type":"string"}},"additionalProperties":false,"type":"object"},"Authentication":{"required":["username","password"],"properties":{"username":{"$ref":"#/definitions/EnvVar"},"password":{"$ref":"#/definitions/EnvVar"}},"additionalProperties":false,"type":"object"},"Azure":{"required":["BaseScraper","subscriptionID","organisation","tenantID"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"subscriptionID":{"type":"string"},"organisation":{"type":"string"},"clientID":{"$ref":"#/definitions/EnvVar"},"clientSecret":{"$ref":"#/definitions/EnvVar"},"tenantID":{"type":"string"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureExclusions"}},"additionalProperties":false,"type":"object"},"AzureDevops":{"required":["BaseScraper","projects","pipelines"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"organization":{"type":"string"},"personalAccessToken":{"$ref":"#/definitions/EnvVar"},"projects":{"items":{"type":"string"},"type":"array"},"pipelines":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"AzureExclusions":{"properties":{"activityLogs":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ChangeRetentionSpec":{"properties":{"name":{"type":"string"},"age":{"type":"string"},"count":{"type":"integer"}},"additionalProperties":false,"type":"object"},"CloudTrail":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"},"max_age":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Connection":{"required":["connection"],"properties":{"connection":{"type":"string"},"auth":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Authentication"}},"additionalProperties":false,"type":"object"},"CostReporting":{"properties":{"s3_bucket_path":{"type":"string"},"table":{"type":"string"},"database":{"type":"string"},"region":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"FieldsV1":{"properties":{},"additionalProperties":false,"type":"object"},"File":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"url":{"type":"string"},"paths":{"items":{"type":"string"},"type":"array"},"ignore":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"},"icon":{"type":"string"},"connection":{"type":"string"}},"additionalProperties":false,"type":"object"},"GitHubActions":{"required":["BaseScraper","owner","repository","personalAccessToken","workflows"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"owner":{"type":"string"},"repository":{"type":"string"},"personalAccessToken":{"$ref":"#/definitions/EnvVar"},"connection":{"type":"string"},"workflows":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Kubernetes":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"clusterName":{"type":"string"},"namespace":{"type":"string"},"useCache":{"type":"boolean"},"allowIncomplete":{"type":"boolean"},"scope":{"type":"string"},"since":{"type":"string"},"selector":{"type":"string"},"fieldSelector":{"type":"string"},"maxInflight":{"type":"integer"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesExclusionConfig"},"kubeconfig":{"$ref":"#/definitions/EnvVar"},"event":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventConfig"},"relationships":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationship"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesEventConfig":{"properties":{"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventExclusions"},"severityKeywords":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SeverityKeywords"}},"additionalProperties":false,"type":"object"},"KubernetesEventExclusions":{"properties":{"name":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"reason":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesExclusionConfig":{"required":["name","kind","namespace"],"properties":{"name":{"items":{"type":"string"},"type":"array"},"kind":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"KubernetesFile":{"required":["BaseScraper","selector"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"selector":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ResourceSelector"},"container":{"type":"string"},"files":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/PodFile"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesRelationship":{"required":["kind","name","namespace"],"properties":{"kind":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationshipLookup"},"name":{"$ref":"#/definitions/KubernetesRelationshipLookup"},"namespace":{"$ref":"#/definitions/KubernetesRelationshipLookup"}},"additionalProperties":false,"type":"object"},"KubernetesRelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"ManagedFieldsEntry":{"properties":{"manager":{"type":"string"},"operation":{"type":"string"},"apiVersion":{"type":"string"},"time":{"$ref":"#/definitions/Time"},"fieldsType":{"type":"string"},"fieldsV1":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/FieldsV1"},"subresource":{"type":"string"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"ObjectMeta":{"properties":{"name":{"type":"string"},"generateName":{"type":"string"},"namespace":{"type":"string"},"selfLink":{"type":"string"},"uid":{"type":"string"},"resourceVersion":{"type":"string"},"generation":{"type":"integer"},"creationTimestamp":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Time"},"deletionTimestamp":{"$ref":"#/definitions/Time"},"deletionGracePeriodSeconds":{"type":"integer"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"annotations":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"ownerReferences":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/OwnerReference"},"type":"array"},"finalizers":{"items":{"type":"string"},"type":"array"},"managedFields":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ManagedFieldsEntry"},"type":"array"}},"additionalProperties":false,"type":"object"},"OwnerReference":{"required":["apiVersion","kind","name","uid"],"properties":{"apiVersion":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"uid":{"type":"string"},"controller":{"type":"boolean"},"blockOwnerDeletion":{"type":"boolean"}},"additionalProperties":false,"type":"object"},"PodFile":{"properties":{"path":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"}},"additionalProperties":false,"type":"object"},"ResourceSelector":{"properties":{"namespace":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"labelSelector":{"type":"string"},"fieldSelector":{"type":"string"}},"additionalProperties":false,"type":"object"},"RetentionSpec":{"properties":{"changes":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ChangeRetentionSpec"},"type":"array"},"types":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TypeRetentionSpec"},"type":"array"}},"additionalProperties":false,"type":"object"},"SQL":{"required":["BaseScraper","Connection","query"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"Connection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Connection"},"driver":{"type":"string"},"query":{"type":"string"}},"additionalProperties":false,"type":"object"},"ScrapeConfig":{"required":["TypeMeta"],"properties":{"TypeMeta":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TypeMeta"},"metadata":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ObjectMeta"},"spec":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScraperSpec"},"status":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScrapeConfigStatus"}},"additionalProperties":false,"type":"object"},"ScrapeConfigStatus":{"properties":{"observedGeneration":{"type":"integer"}},"additionalProperties":false,"type":"object"},"ScraperSpec":{"properties":{"logLevel":{"type":"string"},"schedule":{"type":"string"},"aws":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWS"},"type":"array"},"file":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/File"},"type":"array"},"kubernetes":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Kubernetes"},"type":"array"},"kubernetesFile":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesFile"},"type":"array"},"azureDevops":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureDevops"},"type":"array"},"githubActions":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/GitHubActions"},"type":"array"},"azure":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Azure"},"type":"array"},"sql":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SQL"},"type":"array"},"trivy":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Trivy"},"type":"array"},"retention":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RetentionSpec"},"full":{"type":"boolean"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"SeverityKeywords":{"properties":{"warn":{"items":{"type":"string"},"type":"array"},"error":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Time":{"properties":{},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Trivy":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"version":{"type":"string"},"compliance":{"items":{"type":"string"},"type":"array"},"ignoredLicenses":{"items":{"type":"string"},"type":"array"},"ignoreUnfixed":{"type":"boolean"},"licenseFull":{"type":"boolean"},"severity":{"items":{"type":"string"},"type":"array"},"vulnType":{"items":{"type":"string"},"type":"array"},"scanners":{"items":{"type":"string"},"type":"array"},"timeout":{"type":"string"},"kubernetes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TrivyK8sOptions"}},"additionalProperties":false,"type":"object"},"TrivyK8sOptions":{"properties":{"components":{"items":{"type":"string"},"type":"array"},"context":{"type":"string"},"kubeconfig":{"type":"string"},"namespace":{"type":"string"}},"additionalProperties":false,"type":"object"},"TypeMeta":{"properties":{"kind":{"type":"string"},"apiVersion":{"type":"string"}},"additionalProperties":false,"type":"object"},"TypeRetentionSpec":{"properties":{"name":{"type":"string"},"createdAge":{"type":"string"},"updatedAge":{"type":"string"},"deletedAge":{"type":"string"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file +{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScrapeConfig","definitions":{"AWS":{"required":["BaseScraper","AWSConnection"],"properties":{"BaseScraper":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/BaseScraper"},"AWSConnection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWSConnection"},"patch_states":{"type":"boolean"},"patch_details":{"type":"boolean"},"inventory":{"type":"boolean"},"compliance":{"type":"boolean"},"cloudtrail":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CloudTrail"},"trusted_advisor_check":{"type":"boolean"},"include":{"items":{"type":"string"},"type":"array"},"exclude":{"items":{"type":"string"},"type":"array"},"cost_reporting":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/CostReporting"}},"additionalProperties":false,"type":"object"},"AWSConnection":{"required":["region"],"properties":{"connection":{"type":"string"},"accessKey":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVar"},"secretKey":{"$ref":"#/definitions/EnvVar"},"region":{"items":{"type":"string"},"type":"array"},"endpoint":{"type":"string"},"skipTLSVerify":{"type":"boolean"},"assumeRole":{"type":"string"}},"additionalProperties":false,"type":"object"},"Authentication":{"required":["username","password"],"properties":{"username":{"$ref":"#/definitions/EnvVar"},"password":{"$ref":"#/definitions/EnvVar"}},"additionalProperties":false,"type":"object"},"Azure":{"required":["BaseScraper","subscriptionID","organisation","tenantID"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"subscriptionID":{"type":"string"},"organisation":{"type":"string"},"clientID":{"$ref":"#/definitions/EnvVar"},"clientSecret":{"$ref":"#/definitions/EnvVar"},"tenantID":{"type":"string"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureExclusions"}},"additionalProperties":false,"type":"object"},"AzureDevops":{"required":["BaseScraper","projects","pipelines"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"connection":{"type":"string"},"organization":{"type":"string"},"personalAccessToken":{"$ref":"#/definitions/EnvVar"},"projects":{"items":{"type":"string"},"type":"array"},"pipelines":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"AzureExclusions":{"properties":{"activityLogs":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"BaseScraper":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"items":{"type":"string"},"type":{"type":"string"},"class":{"type":"string"},"transform":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Transform"},"format":{"type":"string"},"timestampFormat":{"type":"string"},"createFields":{"items":{"type":"string"},"type":"array"},"deleteFields":{"items":{"type":"string"},"type":"array"},"tags":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"properties":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigProperties"},"type":"array"}},"additionalProperties":false,"type":"object"},"ChangeRetentionSpec":{"properties":{"name":{"type":"string"},"age":{"type":"string"},"count":{"type":"integer"}},"additionalProperties":false,"type":"object"},"CloudTrail":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"},"max_age":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigFieldExclusion":{"required":["jsonpath"],"properties":{"types":{"items":{"type":"string"},"type":"array"},"jsonpath":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigMapKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"ConfigProperties":{"properties":{"label":{"type":"string"},"name":{"type":"string"},"tooltip":{"type":"string"},"icon":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"order":{"type":"integer"},"headline":{"type":"boolean"},"text":{"type":"string"},"value":{"type":"integer"},"unit":{"type":"string"},"max":{"type":"integer"},"min":{"type":"integer"},"status":{"type":"string"},"lastTransition":{"type":"string"},"links":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Link"},"type":"array"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"Connection":{"required":["connection"],"properties":{"connection":{"type":"string"},"auth":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Authentication"}},"additionalProperties":false,"type":"object"},"CostReporting":{"properties":{"s3_bucket_path":{"type":"string"},"table":{"type":"string"},"database":{"type":"string"},"region":{"type":"string"}},"additionalProperties":false,"type":"object"},"EnvVar":{"properties":{"name":{"type":"string"},"value":{"type":"string"},"valueFrom":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/EnvVarSource"}},"additionalProperties":false,"type":"object"},"EnvVarSource":{"properties":{"serviceAccount":{"type":"string"},"helmRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/HelmRefKeySelector"},"configMapKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigMapKeySelector"},"secretKeyRef":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SecretKeySelector"}},"additionalProperties":false,"type":"object"},"FieldsV1":{"properties":{},"additionalProperties":false,"type":"object"},"File":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"url":{"type":"string"},"paths":{"items":{"type":"string"},"type":"array"},"ignore":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"},"icon":{"type":"string"},"connection":{"type":"string"}},"additionalProperties":false,"type":"object"},"GitHubActions":{"required":["BaseScraper","owner","repository","personalAccessToken","workflows"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"owner":{"type":"string"},"repository":{"type":"string"},"personalAccessToken":{"$ref":"#/definitions/EnvVar"},"connection":{"type":"string"},"workflows":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"HelmRefKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"Kubernetes":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"clusterName":{"type":"string"},"namespace":{"type":"string"},"useCache":{"type":"boolean"},"allowIncomplete":{"type":"boolean"},"scope":{"type":"string"},"since":{"type":"string"},"selector":{"type":"string"},"fieldSelector":{"type":"string"},"maxInflight":{"type":"integer"},"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesExclusionConfig"},"kubeconfig":{"$ref":"#/definitions/EnvVar"},"event":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventConfig"},"relationships":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesRelationship"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesEventConfig":{"properties":{"exclusions":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesEventExclusions"},"severityKeywords":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SeverityKeywords"}},"additionalProperties":false,"type":"object"},"KubernetesEventExclusions":{"properties":{"name":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"reason":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesExclusionConfig":{"required":["name","kind","namespace"],"properties":{"name":{"items":{"type":"string"},"type":"array"},"kind":{"items":{"type":"string"},"type":"array"},"namespace":{"items":{"type":"string"},"type":"array"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"KubernetesFile":{"required":["BaseScraper","selector"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"selector":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ResourceSelector"},"container":{"type":"string"},"files":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/PodFile"},"type":"array"}},"additionalProperties":false,"type":"object"},"KubernetesRelationship":{"required":["kind","name","namespace"],"properties":{"kind":{"$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"namespace":{"$ref":"#/definitions/RelationshipLookup"}},"additionalProperties":false,"type":"object"},"Link":{"required":["Text"],"properties":{"type":{"type":"string"},"url":{"type":"string"},"Text":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Text"}},"additionalProperties":false,"type":"object"},"ManagedFieldsEntry":{"properties":{"manager":{"type":"string"},"operation":{"type":"string"},"apiVersion":{"type":"string"},"time":{"$ref":"#/definitions/Time"},"fieldsType":{"type":"string"},"fieldsV1":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/FieldsV1"},"subresource":{"type":"string"}},"additionalProperties":false,"type":"object"},"Mask":{"properties":{"selector":{"type":"string"},"jsonpath":{"type":"string"},"value":{"type":"string"}},"additionalProperties":false,"type":"object"},"ObjectMeta":{"properties":{"name":{"type":"string"},"generateName":{"type":"string"},"namespace":{"type":"string"},"selfLink":{"type":"string"},"uid":{"type":"string"},"resourceVersion":{"type":"string"},"generation":{"type":"integer"},"creationTimestamp":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Time"},"deletionTimestamp":{"$ref":"#/definitions/Time"},"deletionGracePeriodSeconds":{"type":"integer"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"annotations":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"ownerReferences":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/OwnerReference"},"type":"array"},"finalizers":{"items":{"type":"string"},"type":"array"},"managedFields":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ManagedFieldsEntry"},"type":"array"}},"additionalProperties":false,"type":"object"},"OwnerReference":{"required":["apiVersion","kind","name","uid"],"properties":{"apiVersion":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"uid":{"type":"string"},"controller":{"type":"boolean"},"blockOwnerDeletion":{"type":"boolean"}},"additionalProperties":false,"type":"object"},"PodFile":{"properties":{"path":{"items":{"type":"string"},"type":"array"},"format":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipConfig":{"required":["RelationshipSelectorTemplate"],"properties":{"RelationshipSelectorTemplate":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipSelectorTemplate"},"expr":{"type":"string"},"filter":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipLookup":{"properties":{"expr":{"type":"string"},"value":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"RelationshipSelectorTemplate":{"properties":{"id":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipLookup"},"name":{"$ref":"#/definitions/RelationshipLookup"},"type":{"$ref":"#/definitions/RelationshipLookup"},"agent":{"$ref":"#/definitions/RelationshipLookup"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"ResourceSelector":{"properties":{"namespace":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"labelSelector":{"type":"string"},"fieldSelector":{"type":"string"}},"additionalProperties":false,"type":"object"},"RetentionSpec":{"properties":{"changes":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ChangeRetentionSpec"},"type":"array"},"types":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TypeRetentionSpec"},"type":"array"}},"additionalProperties":false,"type":"object"},"SQL":{"required":["BaseScraper","Connection","query"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"Connection":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Connection"},"driver":{"type":"string"},"query":{"type":"string"}},"additionalProperties":false,"type":"object"},"ScrapeConfig":{"required":["TypeMeta"],"properties":{"TypeMeta":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TypeMeta"},"metadata":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ObjectMeta"},"spec":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScraperSpec"},"status":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ScrapeConfigStatus"}},"additionalProperties":false,"type":"object"},"ScrapeConfigStatus":{"properties":{"observedGeneration":{"type":"integer"}},"additionalProperties":false,"type":"object"},"ScraperSpec":{"properties":{"logLevel":{"type":"string"},"schedule":{"type":"string"},"aws":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AWS"},"type":"array"},"file":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/File"},"type":"array"},"kubernetes":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Kubernetes"},"type":"array"},"kubernetesFile":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/KubernetesFile"},"type":"array"},"azureDevops":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/AzureDevops"},"type":"array"},"githubActions":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/GitHubActions"},"type":"array"},"azure":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Azure"},"type":"array"},"sql":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/SQL"},"type":"array"},"trivy":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Trivy"},"type":"array"},"retention":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RetentionSpec"},"full":{"type":"boolean"}},"additionalProperties":false,"type":"object"},"SecretKeySelector":{"required":["key"],"properties":{"name":{"type":"string"},"key":{"type":"string"}},"additionalProperties":false,"type":"object"},"SeverityKeywords":{"properties":{"warn":{"items":{"type":"string"},"type":"array"},"error":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Text":{"properties":{"tooltip":{"type":"string"},"icon":{"type":"string"},"text":{"type":"string"},"label":{"type":"string"}},"additionalProperties":false,"type":"object"},"Time":{"properties":{},"additionalProperties":false,"type":"object"},"Transform":{"properties":{"gotemplate":{"type":"string"},"jsonpath":{"type":"string"},"expr":{"type":"string"},"javascript":{"type":"string"},"exclude":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ConfigFieldExclusion"},"type":"array"},"mask":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Mask"},"type":"array"},"relationship":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/RelationshipConfig"},"type":"array"},"changes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TransformChange"}},"additionalProperties":false,"type":"object"},"TransformChange":{"properties":{"exclude":{"items":{"type":"string"},"type":"array"}},"additionalProperties":false,"type":"object"},"Trivy":{"required":["BaseScraper"],"properties":{"BaseScraper":{"$ref":"#/definitions/BaseScraper"},"version":{"type":"string"},"compliance":{"items":{"type":"string"},"type":"array"},"ignoredLicenses":{"items":{"type":"string"},"type":"array"},"ignoreUnfixed":{"type":"boolean"},"licenseFull":{"type":"boolean"},"severity":{"items":{"type":"string"},"type":"array"},"vulnType":{"items":{"type":"string"},"type":"array"},"scanners":{"items":{"type":"string"},"type":"array"},"timeout":{"type":"string"},"kubernetes":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/TrivyK8sOptions"}},"additionalProperties":false,"type":"object"},"TrivyK8sOptions":{"properties":{"components":{"items":{"type":"string"},"type":"array"},"context":{"type":"string"},"kubeconfig":{"type":"string"},"namespace":{"type":"string"}},"additionalProperties":false,"type":"object"},"TypeMeta":{"properties":{"kind":{"type":"string"},"apiVersion":{"type":"string"}},"additionalProperties":false,"type":"object"},"TypeRetentionSpec":{"properties":{"name":{"type":"string"},"createdAge":{"type":"string"},"updatedAge":{"type":"string"},"deletedAge":{"type":"string"}},"additionalProperties":false,"type":"object"}}} \ No newline at end of file diff --git a/db/config.go b/db/config.go index 8ed65af7..ecd62814 100644 --- a/db/config.go +++ b/db/config.go @@ -5,6 +5,7 @@ import ( "database/sql" "encoding/json" "fmt" + "time" "github.com/flanksource/commons/logger" "github.com/flanksource/commons/utils" @@ -19,6 +20,14 @@ import ( "gorm.io/gorm/clause" ) +var ( + configIDCache = cache.New(cache.NoExpiration, cache.NoExpiration) + + configRelationshipSelectorCache = cache.New(cache.NoExpiration, cache.NoExpiration) + + configRelationshipSelectorMutableCache = cache.New(time.Minute*5, time.Minute*5) +) + // GetConfigItem returns a single config item result func GetConfigItem(extType, extID string) (*models.ConfigItem, error) { ci := models.ConfigItem{} @@ -99,16 +108,88 @@ func UpdateConfigItem(ci *models.ConfigItem) error { return nil } +// ConfigRelationshipSelectorResult represents the a subset of columns in the config item database table. +type ConfigRelationshipSelectorResult struct { + ID string `json:"id"` + Type string `json:"type"` +} + +func (t *ConfigRelationshipSelectorResult) TableName() string { + return "config_items" +} + +func FindConfigsByRelationshipSelector(ctx context.Context, selector v1.RelationshipSelector) ([]ConfigRelationshipSelectorResult, error) { + if selector.IsEmpty() { + return nil, nil + } + + var cacheToUse = configRelationshipSelectorCache + if len(selector.Labels) != 0 { + cacheToUse = configRelationshipSelectorMutableCache + } + + if val, ok := cacheToUse.Get(selector.Hash()); ok { + return val.([]ConfigRelationshipSelectorResult), nil + } + + var items []ConfigRelationshipSelectorResult + query := ctx.DB().Select("config_items.id, config_items.type") + if selector.Name != nil { + query = query.Where("config_items.name = ?", *selector.Name) + } + + if selector.Type != nil { + query = query.Where("config_items.type = ?", *selector.Type) + } + + if selector.Agent != nil { + if *selector.Agent == "self" { + query = query.Where("config_items.agent_id = ?", uuid.Nil) + } else if uid, err := uuid.Parse(*selector.Agent); err == nil { + query = query.Where("config_items.agent_id = ?", uid) + } else { // assume it's an agent name + query = query.Joins("LEFT JOIN agents ON config_items.agent_id = agents.id").Where("agents.name = ?", *selector.Agent).Where("config_items.agent_id = ?", uid) + } + } + + if len(selector.Labels) > 0 { + query = query.Where("config_items.labels @> ?", selector.Labels) + } + + if err := query.Find(&items).Error; err != nil { + return nil, err + } + + if len(items) > 0 { + cacheToUse.SetDefault(selector.Hash(), items) + } else { + cacheToUse.Set(selector.Hash(), items, time.Minute*5) + } + + return items, nil +} + // FindConfigIDsByNamespaceNameClass returns the uuid of config items which matches the given type, name & namespace func FindConfigIDsByNamespaceNameClass(ctx context.Context, namespace, name, configClass string) ([]uuid.UUID, error) { + cacheKey := fmt.Sprintf("%s|%s|%s", namespace, name, configClass) + if val, ok := configIDCache.Get(cacheKey); ok { + return val.([]uuid.UUID), nil + } + var ids []uuid.UUID - err := ctx.DB(). - Model(&models.ConfigItem{}). - Select("id"). + err := ctx.DB().Model(&models.ConfigItem{}).Select("id"). Where("name = ?", name). Where("namespace = ?", namespace). Where("config_class = ?", configClass). Find(&ids).Error + if err != nil { + return nil, err + } + + if len(ids) > 0 { + configIDCache.SetDefault(cacheKey, ids) + } + return ids, err } diff --git a/fixtures/kubernetes.yaml b/fixtures/kubernetes.yaml index 5ee3c1ed..c04fb950 100644 --- a/fixtures/kubernetes.yaml +++ b/fixtures/kubernetes.yaml @@ -6,6 +6,21 @@ spec: kubernetes: - clusterName: local-kind-cluster transform: + relationship: + # Link a service to a deployment (adjust the label selector accordingly) + - filter: config_type == "Kubernetes::Service" + type: + value: 'Kubernetes::Deployment' + name: + expr: | + has(config.spec.selector) && has(config.spec.selector.name) ? config.spec.selector.name : '' + # Link Pods to PVCs + - filter: config_type == 'Kubernetes::Pod' + expr: | + config.spec.volumes. + filter(item, has(item.persistentVolumeClaim)). + map(item, {"type": "Kubernetes::PersistentVolumeClaim", "name": item.persistentVolumeClaim.claimName}). + toJSON() mask: - selector: | has(config.kind) ? config.kind == 'Certificate' : false diff --git a/scrapers/kubernetes/kubernetes.go b/scrapers/kubernetes/kubernetes.go index 27b95beb..6533448c 100644 --- a/scrapers/kubernetes/kubernetes.go +++ b/scrapers/kubernetes/kubernetes.go @@ -1,6 +1,7 @@ package kubernetes import ( + "encoding/json" "fmt" "regexp" "strconv" @@ -370,6 +371,11 @@ func extractResults(ctx context.Context, config v1.Kubernetes, objs []*unstructu } } + configObj, err := cleanKubernetesObject(obj.Object) + if err != nil { + return results.Errorf(err, "failed to clean kubernetes object") + } + parentType, parentExternalID := getKubernetesParent(obj, resourceIDMap) results = append(results, v1.ScrapeResult{ BaseScraper: config.BaseScraper, @@ -382,7 +388,7 @@ func extractResults(ctx context.Context, config v1.Kubernetes, objs []*unstructu CreatedAt: &createdAt, DeletedAt: deletedAt, DeleteReason: deleteReason, - Config: cleanKubernetesObject(obj.Object), + Config: configObj, ID: string(obj.GetUID()), Tags: stripLabels(tags, "-hash"), Aliases: getKubernetesAlias(obj), @@ -489,7 +495,7 @@ func getResourceIDsFromObjs(objs []*unstructured.Unstructured) map[string]map[st } //nolint:errcheck -func cleanKubernetesObject(obj map[string]any) string { +func cleanKubernetesObject(obj map[string]any) (map[string]any, error) { o := gabs.Wrap(obj) o.Delete("metadata", "generation") o.Delete("metadata", "resourceVersion") @@ -521,7 +527,8 @@ func cleanKubernetesObject(obj map[string]any) string { o.Delete("status", "checkStatus", k, "uptime1h") } - return o.String() + var output map[string]any + return output, json.Unmarshal(o.Bytes(), &output) } var arnRegexp = regexp.MustCompile(`arn:aws:iam::(\d+):role/`) diff --git a/scrapers/processors/json.go b/scrapers/processors/json.go index 9589a550..15c0ed73 100644 --- a/scrapers/processors/json.go +++ b/scrapers/processors/json.go @@ -3,6 +3,7 @@ package processors import ( "crypto/md5" "encoding/hex" + "encoding/json" "fmt" "strconv" "strings" @@ -11,6 +12,8 @@ import ( "github.com/flanksource/commons/collections" "github.com/flanksource/commons/logger" v1 "github.com/flanksource/config-db/api/v1" + "github.com/flanksource/config-db/db" + "github.com/flanksource/duty/context" "github.com/flanksource/duty/types" "github.com/flanksource/gomplate/v3" "github.com/magiconair/properties" @@ -41,8 +44,9 @@ func (t *Mask) Filter(in v1.ScrapeResult) (bool, error) { } type Transform struct { - Script v1.Script - Masks []Mask + Script v1.Script + Masks []Mask + Relationship []v1.RelationshipConfig } // ConfigFieldExclusion instructs what fields from the given config types should be removed. @@ -147,6 +151,7 @@ func NewExtractor(config v1.BaseScraper) (Extract, error) { } extract.Transform.Script = config.Transform.Script + extract.Transform.Relationship = config.Transform.Relationship for _, mask := range config.Transform.Masks { if mask.Selector == "" { @@ -191,7 +196,65 @@ func (e Extract) String() string { return s } -func (e Extract) Extract(inputs ...v1.ScrapeResult) ([]v1.ScrapeResult, error) { +func getRelationshipsFromRelationshipConfigs(ctx context.Context, input v1.ScrapeResult, relationshipConfigs []v1.RelationshipConfig) ([]v1.RelationshipResult, error) { + var relationships []v1.RelationshipResult + + for _, rc := range relationshipConfigs { + if rc.Filter != "" { + filterOutput, err := gomplate.RunTemplate(input.AsMap(), gomplate.Template{Expression: rc.Filter}) + if err != nil { + return nil, err + } + + if ok, err := strconv.ParseBool(filterOutput); err != nil { + return nil, err + } else if !ok { + continue + } + } + + var relationshipSelectors []v1.RelationshipSelector + if rc.Expr != "" { + celOutput, err := gomplate.RunTemplate(input.AsMap(), gomplate.Template{Expression: rc.Expr}) + if err != nil { + return nil, err + } + + var output []v1.RelationshipSelector + if err := json.Unmarshal([]byte(celOutput), &output); err != nil { + return nil, err + } + relationshipSelectors = append(relationshipSelectors, output...) + } else { + if compiled, err := rc.RelationshipSelectorTemplate.Eval(input.Tags, input.AsMap()); err != nil { + return nil, err + } else if compiled != nil { + relationshipSelectors = append(relationshipSelectors, *compiled) + } + } + + for _, selector := range relationshipSelectors { + linkedConfigItems, err := db.FindConfigsByRelationshipSelector(ctx, selector) + if err != nil { + return nil, fmt.Errorf("failed to find config items by relationship selector: %w", err) + } + + for _, itemToLink := range linkedConfigItems { + rel := v1.RelationshipResult{ + ConfigExternalID: v1.ExternalID{ExternalID: []string{input.ID}, ConfigType: input.Type}, + RelatedConfigID: itemToLink.ID, + Relationship: itemToLink.Type + input.Type, + } + + relationships = append(relationships, rel) + } + } + } + + return relationships, nil +} + +func (e Extract) Extract(ctx context.Context, inputs ...v1.ScrapeResult) ([]v1.ScrapeResult, error) { var results []v1.ScrapeResult var err error @@ -205,6 +268,13 @@ func (e Extract) Extract(inputs ...v1.ScrapeResult) ([]v1.ScrapeResult, error) { } } + // Form new relationships based on the transform configs + if newRelationships, err := getRelationshipsFromRelationshipConfigs(ctx, input, e.Transform.Relationship); err != nil { + return results, err + } else if len(newRelationships) > 0 { + input.RelationshipResults = append(input.RelationshipResults, newRelationships...) + } + for i, configProperty := range input.BaseScraper.Properties { if configProperty.Filter != "" { if response, err := gomplate.RunTemplate(input.AsMap(), gomplate.Template{Expression: configProperty.Filter}); err != nil { @@ -304,7 +374,7 @@ func (e Extract) Extract(inputs ...v1.ScrapeResult) ([]v1.ScrapeResult, error) { items := e.Items.Get(parsedConfig) logger.Debugf("extracted %d items with %s", len(items), *e.Items) for _, item := range items { - extracted, err := e.WithoutItems().Extract(input.Clone(item)) + extracted, err := e.WithoutItems().Extract(ctx, input.Clone(item)) if err != nil { return results, fmt.Errorf("failed to extract items: %v", err) } diff --git a/scrapers/runscrapers.go b/scrapers/runscrapers.go index 7c289f6f..bf927518 100644 --- a/scrapers/runscrapers.go +++ b/scrapers/runscrapers.go @@ -16,6 +16,7 @@ import ( "github.com/flanksource/config-db/scrapers/kubernetes" "github.com/flanksource/config-db/scrapers/processors" "github.com/flanksource/config-db/utils" + "github.com/flanksource/duty/context" "github.com/flanksource/duty/models" ) @@ -34,7 +35,7 @@ func runK8IncrementalScraper(ctx api.ScrapeContext, config v1.Kubernetes, ids [] var results v1.ScrapeResults var scraper kubernetes.KubernetesScraper for _, result := range scraper.IncrementalScrape(ctx, config, ids) { - scraped := processScrapeResult(ctx.ScrapeConfig().Spec, result) + scraped := processScrapeResult(ctx.DutyContext(), ctx.ScrapeConfig().Spec, result) for i := range scraped { if scraped[i].Error != nil { @@ -82,7 +83,7 @@ func Run(ctx api.ScrapeContext) ([]v1.ScrapeResult, error) { logger.Debugf("Starting to scrape [%s]", jobHistory.Name) for _, result := range scraper.Scrape(ctx) { - scraped := processScrapeResult(ctx.ScrapeConfig().Spec, result) + scraped := processScrapeResult(ctx.DutyContext(), ctx.ScrapeConfig().Spec, result) for i := range scraped { if scraped[i].Error != nil { @@ -133,7 +134,7 @@ func summarizeChanges(changes []v1.ChangeResult) []v1.ChangeResult { } // processScrapeResult extracts possibly more configs from the result -func processScrapeResult(config v1.ScraperSpec, result v1.ScrapeResult) v1.ScrapeResults { +func processScrapeResult(ctx context.Context, config v1.ScraperSpec, result v1.ScrapeResult) v1.ScrapeResults { if result.AnalysisResult != nil { if rule, ok := analysis.Rules[result.AnalysisResult.Analyzer]; ok { result.AnalysisResult.AnalysisType = models.AnalysisType(rule.Category) @@ -156,7 +157,7 @@ func processScrapeResult(config v1.ScraperSpec, result v1.ScrapeResult) v1.Scrap return []v1.ScrapeResult{result} } - scraped, err := extractor.Extract(result) + scraped, err := extractor.Extract(ctx, result) if err != nil { result.Error = err return []v1.ScrapeResult{result} diff --git a/scrapers/runscrapers_test.go b/scrapers/runscrapers_test.go index 24c475db..231a57dc 100644 --- a/scrapers/runscrapers_test.go +++ b/scrapers/runscrapers_test.go @@ -51,9 +51,9 @@ var _ = Describe("Scrapers test", Ordered, func() { ValueStatic: kubeConfigPath, } scrapeConfig.Spec.Kubernetes[0].Relationships = append(scrapeConfig.Spec.Kubernetes[0].Relationships, v1.KubernetesRelationship{ - Kind: v1.KubernetesRelationshipLookup{Value: "ConfigMap"}, - Name: v1.KubernetesRelationshipLookup{Label: "flanksource/name"}, - Namespace: v1.KubernetesRelationshipLookup{Label: "flanksource/namespace"}, + Kind: v1.RelationshipLookup{Value: "ConfigMap"}, + Name: v1.RelationshipLookup{Label: "flanksource/name"}, + Namespace: v1.RelationshipLookup{Label: "flanksource/namespace"}, }) })