diff --git a/.vscode/launch.json b/.vscode/launch.json index 3f02d20160..c591d8be22 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -44,9 +44,10 @@ "cwd": "${workspaceRoot}/", "args": [ "run", - // "local", "-c", - "asset.eol" + "vulnmgmt.advisories", + "--config", + "/home/christian/demo.agent.credentials.json" ], }, { diff --git a/Makefile b/Makefile index d52891127f..2df874ba1a 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,8 @@ prep/tools: prep/tools/protolint cnquery/generate: clean/proto llx/generate shared/generate providers explorer/generate +cnquery/generate/core: clean/proto llx/generate shared/generate providers/proto providers/build/mock providers/build/core explorer/generate + define buildProvider $(eval $@_HOME = $(1)) $(eval $@_NAME = $(shell basename ${$@_HOME})) diff --git a/explorer/cnquery_explorer.pb.go b/explorer/cnquery_explorer.pb.go index 6b4ffbd63c..5de2333323 100644 --- a/explorer/cnquery_explorer.pb.go +++ b/explorer/cnquery_explorer.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: cnquery_explorer.proto package explorer @@ -26,6 +26,8 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// protolint:disable ENUM_FIELD_NAMES_PREFIX +// protolint:disable ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH type Action int32 const ( @@ -81,6 +83,8 @@ func (Action) EnumDescriptor() ([]byte, []int) { return file_cnquery_explorer_proto_rawDescGZIP(), []int{0} } +// protolint:disable ENUM_FIELD_NAMES_PREFIX +// protolint:disable ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH type ScoringSystem int32 const ( @@ -139,6 +143,8 @@ func (ScoringSystem) EnumDescriptor() ([]byte, []int) { return file_cnquery_explorer_proto_rawDescGZIP(), []int{1} } +// protolint:disable ENUM_FIELD_NAMES_PREFIX +// protolint:disable ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH type AssignmentDelta_Action int32 const ( @@ -795,12 +801,13 @@ type Property struct { Mrn string `protobuf:"bytes,4,opt,name=mrn,proto3" json:"mrn,omitempty"` // UID is only needed on Mquery upload, when the MRN is computed. // It is not be persisted. - Uid string `protobuf:"bytes,5,opt,name=uid,proto3" json:"uid,omitempty"` - Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` - Context string `protobuf:"bytes,7,opt,name=context,proto3" json:"context,omitempty"` - For []*ObjectRef `protobuf:"bytes,8,rep,name=for,proto3" json:"for,omitempty"` - Title string `protobuf:"bytes,20,opt,name=title,proto3" json:"title,omitempty"` - Desc string `protobuf:"bytes,35,opt,name=desc,proto3" json:"desc,omitempty"` + Uid string `protobuf:"bytes,5,opt,name=uid,proto3" json:"uid,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` + Context string `protobuf:"bytes,7,opt,name=context,proto3" json:"context,omitempty"` + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED + For []*ObjectRef `protobuf:"bytes,8,rep,name=for,proto3" json:"for,omitempty"` + Title string `protobuf:"bytes,20,opt,name=title,proto3" json:"title,omitempty"` + Desc string `protobuf:"bytes,35,opt,name=desc,proto3" json:"desc,omitempty"` } func (x *Property) Reset() { @@ -1110,7 +1117,8 @@ type Impact struct { Scoring ScoringSystem `protobuf:"varint,2,opt,name=scoring,proto3,enum=cnquery.explorer.ScoringSystem" json:"scoring,omitempty"` // The weight of this query. Has to be > 0, otherwise counts as unset. Weight int32 `protobuf:"varint,3,opt,name=weight,proto3" json:"weight,omitempty"` - // Action is copied into the impact to correctly reconstruct the v7 ScoringSpec + // Action is copied into the impact to correctly reconstruct the v7 + // ScoringSpec Action Action `protobuf:"varint,4,opt,name=action,proto3,enum=cnquery.explorer.Action" json:"action,omitempty"` } @@ -2193,8 +2201,8 @@ func (x *ResolveReq) GetAssetFilters() []*Mquery { return nil } -// ResolvedPack is returned from a resolve request. It includes the execution job -// with all things that need to be run. +// ResolvedPack is returned from a resolve request. It includes the execution +// job with all things that need to be run. type ResolvedPack struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2434,8 +2442,9 @@ func (x *EntityDataRequest) GetDataMrn() string { return "" } -// The report of all the things collected for an entity (typically asset). -// The provided pack is used as the root to decide what data fields will be returned. +// The report of all the things collected for an entity (typically asset). The +// provided pack is used as the root to decide what data fields will be +// returned. type Report struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3051,12 +3060,12 @@ var File_cnquery_explorer_proto protoreflect.FileDescriptor var file_cnquery_explorer_proto_rawDesc = []byte{ 0x0a, 0x16, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x1a, 0x0d, 0x6c, 0x6c, 0x78, 0x2f, - 0x6c, 0x6c, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, - 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x79, 0x2e, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x6c, 0x6c, 0x78, 0x2f, 0x6c, 0x6c, 0x78, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, + 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x01, 0x0a, 0x06, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x6d, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x4d, 0x72, 0x6e, 0x12, 0x31, 0x0a, 0x05, 0x70, 0x61, 0x63, 0x6b, diff --git a/explorer/scan/cnquery_explorer_scan.pb.go b/explorer/scan/cnquery_explorer_scan.pb.go index bc17ba19f2..4e6b517443 100644 --- a/explorer/scan/cnquery_explorer_scan.pb.go +++ b/explorer/scan/cnquery_explorer_scan.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: cnquery_explorer_scan.proto package scan @@ -110,11 +110,11 @@ var file_cnquery_explorer_scan_proto_rawDesc = []byte{ 0x0a, 0x1b, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x5f, 0x73, 0x63, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2e, - 0x73, 0x63, 0x61, 0x6e, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2f, 0x63, 0x6e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x5f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x73, 0x63, 0x61, 0x6e, 0x1a, 0x1f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2f, 0x63, + 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x70, 0x6c, 0x6f, 0x72, 0x65, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, + 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, + 0x79, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb8, 0x02, 0x0a, 0x03, 0x4a, 0x6f, 0x62, 0x12, 0x3d, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, diff --git a/go.mod b/go.mod index b71d974564..141bb1a5ae 100644 --- a/go.mod +++ b/go.mod @@ -136,6 +136,7 @@ require ( github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect + github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect github.com/skeema/knownhosts v1.2.1 // indirect github.com/smarty/assertions v1.15.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -219,7 +220,7 @@ require ( github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.25.0 // indirect github.com/go-critic/go-critic v0.9.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -362,6 +363,7 @@ require ( github.com/yeya24/promlinter v0.2.0 // indirect github.com/ykadowak/zerologlint v0.1.3 // indirect gitlab.com/bosi/decorder v0.4.1 // indirect + go.mondoo.com/mondoo-go v0.0.0-20231115081401-e27ff48607b6 go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect go.tmz.dev/musttag v0.7.2 // indirect @@ -370,7 +372,7 @@ require ( golang.org/x/exp v0.0.0-20231006140011-7918f672742d golang.org/x/exp/typeparams v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 - golang.org/x/oauth2 v0.13.0 // indirect + golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.149.0 // indirect @@ -393,3 +395,5 @@ require ( sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect ) + +replace go.mondoo.com/mondoo-go => /home/christian/workspace/mondoo/github.com/mondoo-go diff --git a/go.sum b/go.sum index ce140b3f38..5e5b0ed4b6 100644 --- a/go.sum +++ b/go.sum @@ -333,8 +333,8 @@ github.com/go-git/go-git/v5 v5.10.0/go.mod h1:1FOZ/pQnqw24ghP2n7cunVl0ON55BsjPYv github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= -github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= +github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -857,6 +857,8 @@ github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqP github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= +github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0= +github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -1115,8 +1117,8 @@ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/llx/llx.pb.go b/llx/llx.pb.go index e54a8d3b1b..d6baf01424 100644 --- a/llx/llx.pb.go +++ b/llx/llx.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: llx.proto package llx @@ -23,9 +23,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX type Chunk_Call int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH Chunk_PRIMITIVE Chunk_Call = 0 Chunk_FUNCTION Chunk_Call = 1 Chunk_PROPERTY Chunk_Call = 2 @@ -83,6 +85,7 @@ type Primitive struct { // e.g. []int or map[string]string Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // In case of an array primitive, holds the data of the array + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED Array []*Primitive `protobuf:"bytes,3,rep,name=array,proto3" json:"array,omitempty"` // In case of a map primitive, holds the data of the map Map map[string]*Primitive `protobuf:"bytes,4,rep,name=map,proto3" json:"map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` @@ -368,13 +371,14 @@ type CodeV1 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Code []*Chunk `protobuf:"bytes,2,rep,name=code,proto3" json:"code,omitempty"` - Parameters int32 `protobuf:"varint,3,opt,name=parameters,proto3" json:"parameters,omitempty"` - Entrypoints []int32 `protobuf:"varint,4,rep,packed,name=entrypoints,proto3" json:"entrypoints,omitempty"` - Datapoints []int32 `protobuf:"varint,5,rep,packed,name=datapoints,proto3" json:"datapoints,omitempty"` - Checksums map[int32]string `protobuf:"bytes,6,rep,name=checksums,proto3" json:"checksums,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Functions []*CodeV1 `protobuf:"bytes,7,rep,name=functions,proto3" json:"functions,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Code []*Chunk `protobuf:"bytes,2,rep,name=code,proto3" json:"code,omitempty"` + Parameters int32 `protobuf:"varint,3,opt,name=parameters,proto3" json:"parameters,omitempty"` + Entrypoints []int32 `protobuf:"varint,4,rep,packed,name=entrypoints,proto3" json:"entrypoints,omitempty"` + Datapoints []int32 `protobuf:"varint,5,rep,packed,name=datapoints,proto3" json:"datapoints,omitempty"` + Checksums map[int32]string `protobuf:"bytes,6,rep,name=checksums,proto3" json:"checksums,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Functions []*CodeV1 `protobuf:"bytes,7,rep,name=functions,proto3" json:"functions,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE SingleValue bool `protobuf:"varint,8,opt,name=singleValue,proto3" json:"singleValue,omitempty"` Assertions map[int32]*AssertionMessage `protobuf:"bytes,20,rep,name=assertions,proto3" json:"assertions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -483,6 +487,7 @@ type Block struct { // Identifies if we return multiple or just a single value. // The difference is that blocks usually return the block type (a kind of map) // where this flag instructs it to just return the value instead. + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE SingleValue bool `protobuf:"varint,2,opt,name=singleValue,proto3" json:"singleValue,omitempty"` // Number of parameters that are directly provided to this block Parameters int32 `protobuf:"varint,3,opt,name=parameters,proto3" json:"parameters,omitempty"` @@ -751,8 +756,10 @@ type CodeBundle struct { Version string `protobuf:"bytes,20,opt,name=version,proto3" json:"version,omitempty"` MinMondooVersion string `protobuf:"bytes,22,opt,name=min_mondoo_version,json=minMondooVersion,proto3" json:"min_mondoo_version,omitempty"` Assertions map[string]*AssertionMessage `protobuf:"bytes,23,rep,name=assertions,proto3" json:"assertions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - AutoExpand map[string]uint64 `protobuf:"bytes,24,rep,name=auto_expand,json=autoExpand,proto3" json:"auto_expand,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // name + ref to the block of data - // ref + variable name; only used during label creation and discarded afterwards + // name + ref to the block of data + AutoExpand map[string]uint64 `protobuf:"bytes,24,rep,name=auto_expand,json=autoExpand,proto3" json:"auto_expand,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + // ref + variable name; only used during label creation and discarded + // afterwards Vars map[uint64]string `protobuf:"bytes,25,rep,name=vars,proto3" json:"vars,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } diff --git a/providers-sdk/v1/inventory/inventory.pb.go b/providers-sdk/v1/inventory/inventory.pb.go index 84dd6a429c..df304e3798 100644 --- a/providers-sdk/v1/inventory/inventory.pb.go +++ b/providers-sdk/v1/inventory/inventory.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: inventory.proto package inventory @@ -28,6 +28,7 @@ const ( type State int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH State_STATE_UNKNOWN State = 0 // eg. permission or io error State_STATE_ERROR State = 1 @@ -108,8 +109,11 @@ func (State) EnumDescriptor() ([]byte, []int) { type AssetCategory int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX AssetCategory_CATEGORY_INVENTORY AssetCategory = 0 - AssetCategory_CATEGORY_CICD AssetCategory = 1 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + AssetCategory_CATEGORY_CICD AssetCategory = 1 ) // Enum value maps for AssetCategory. @@ -155,40 +159,76 @@ func (AssetCategory) EnumDescriptor() ([]byte, []int) { type ProviderType int32 const ( - ProviderType_LOCAL_OS ProviderType = 0 - ProviderType_DOCKER_ENGINE_IMAGE ProviderType = 1 - ProviderType_DOCKER_ENGINE_CONTAINER ProviderType = 2 - ProviderType_SSH ProviderType = 3 - ProviderType_WINRM ProviderType = 4 - ProviderType_AWS_SSM_RUN_COMMAND ProviderType = 5 - ProviderType_CONTAINER_REGISTRY ProviderType = 6 - ProviderType_TAR ProviderType = 7 - ProviderType_MOCK ProviderType = 8 - ProviderType_VSPHERE ProviderType = 9 - ProviderType_ARISTAEOS ProviderType = 10 - ProviderType_AWS ProviderType = 12 - ProviderType_GCP ProviderType = 13 - ProviderType_AZURE ProviderType = 14 - ProviderType_MS365 ProviderType = 15 - ProviderType_IPMI ProviderType = 16 - ProviderType_VSPHERE_VM ProviderType = 17 - ProviderType_FS ProviderType = 18 - ProviderType_K8S ProviderType = 19 - ProviderType_EQUINIX_METAL ProviderType = 20 - ProviderType_DOCKER ProviderType = 21 // unspecified if this is a container or image - ProviderType_GITHUB ProviderType = 22 - ProviderType_VAGRANT ProviderType = 23 - ProviderType_AWS_EC2_EBS ProviderType = 24 - ProviderType_GITLAB ProviderType = 25 - ProviderType_TERRAFORM ProviderType = 26 - ProviderType_HOST ProviderType = 27 - ProviderType_UNKNOWN ProviderType = 28 - ProviderType_OKTA ProviderType = 29 - ProviderType_GOOGLE_WORKSPACE ProviderType = 30 - ProviderType_SLACK ProviderType = 31 - ProviderType_VCD ProviderType = 32 - ProviderType_OCI ProviderType = 33 - ProviderType_OPCUA ProviderType = 34 + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_LOCAL_OS ProviderType = 0 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_DOCKER_ENGINE_IMAGE ProviderType = 1 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_DOCKER_ENGINE_CONTAINER ProviderType = 2 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_SSH ProviderType = 3 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_WINRM ProviderType = 4 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_AWS_SSM_RUN_COMMAND ProviderType = 5 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_CONTAINER_REGISTRY ProviderType = 6 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_TAR ProviderType = 7 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_MOCK ProviderType = 8 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_VSPHERE ProviderType = 9 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_ARISTAEOS ProviderType = 10 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_AWS ProviderType = 12 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_GCP ProviderType = 13 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_AZURE ProviderType = 14 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_MS365 ProviderType = 15 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_IPMI ProviderType = 16 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_VSPHERE_VM ProviderType = 17 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_FS ProviderType = 18 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_K8S ProviderType = 19 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_EQUINIX_METAL ProviderType = 20 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_DOCKER ProviderType = 21 // unspecified if this is a container or image + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_GITHUB ProviderType = 22 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_VAGRANT ProviderType = 23 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_AWS_EC2_EBS ProviderType = 24 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_GITLAB ProviderType = 25 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_TERRAFORM ProviderType = 26 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_HOST ProviderType = 27 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_UNKNOWN ProviderType = 28 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_OKTA ProviderType = 29 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_GOOGLE_WORKSPACE ProviderType = 30 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_SLACK ProviderType = 31 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_VCD ProviderType = 32 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_OCI ProviderType = 33 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + ProviderType_OPCUA ProviderType = 34 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX ProviderType_GCP_COMPUTE_INSTANCE_SNAPSHOT ProviderType = 35 ) @@ -297,26 +337,44 @@ func (ProviderType) EnumDescriptor() ([]byte, []int) { return file_inventory_proto_rawDescGZIP(), []int{2} } +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX +// protolint:disable:next ENUM_NAMES_UPPER_CAMEL_CASE type DeprecatedV8_Kind int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX DeprecatedV8_Kind_KIND_UNKNOWN DeprecatedV8_Kind = 0 // at rest + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX DeprecatedV8_Kind_KIND_VIRTUAL_MACHINE_IMAGE DeprecatedV8_Kind = 1 - DeprecatedV8_Kind_KIND_CONTAINER_IMAGE DeprecatedV8_Kind = 2 - DeprecatedV8_Kind_KIND_CODE DeprecatedV8_Kind = 3 - DeprecatedV8_Kind_KIND_PACKAGE DeprecatedV8_Kind = 4 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_CONTAINER_IMAGE DeprecatedV8_Kind = 2 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_CODE DeprecatedV8_Kind = 3 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_PACKAGE DeprecatedV8_Kind = 4 // in motion + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX DeprecatedV8_Kind_KIND_VIRTUAL_MACHINE DeprecatedV8_Kind = 5 - DeprecatedV8_Kind_KIND_CONTAINER DeprecatedV8_Kind = 6 - DeprecatedV8_Kind_KIND_PROCESS DeprecatedV8_Kind = 7 - DeprecatedV8_Kind_KIND_API DeprecatedV8_Kind = 8 - DeprecatedV8_Kind_KIND_BARE_METAL DeprecatedV8_Kind = 9 - DeprecatedV8_Kind_KIND_NETWORK DeprecatedV8_Kind = 10 - DeprecatedV8_Kind_KIND_K8S_OBJECT DeprecatedV8_Kind = 11 - DeprecatedV8_Kind_KIND_AWS_OBJECT DeprecatedV8_Kind = 12 - DeprecatedV8_Kind_KIND_GCP_OBJECT DeprecatedV8_Kind = 13 - DeprecatedV8_Kind_KIND_AZURE_OBJECT DeprecatedV8_Kind = 14 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_CONTAINER DeprecatedV8_Kind = 6 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_PROCESS DeprecatedV8_Kind = 7 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_API DeprecatedV8_Kind = 8 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_BARE_METAL DeprecatedV8_Kind = 9 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_NETWORK DeprecatedV8_Kind = 10 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_K8S_OBJECT DeprecatedV8_Kind = 11 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_AWS_OBJECT DeprecatedV8_Kind = 12 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_GCP_OBJECT DeprecatedV8_Kind = 13 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + DeprecatedV8_Kind_KIND_AZURE_OBJECT DeprecatedV8_Kind = 14 ) // Enum value maps for DeprecatedV8_Kind. @@ -406,6 +464,7 @@ type Asset struct { // additional options for that asset Options map[string]string `protobuf:"bytes,20,rep,name=options,proto3" json:"options,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // platform id detection mechanisms + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED IdDetector []string `protobuf:"bytes,31,rep,name=id_detector,json=idDetector,proto3" json:"id_detector,omitempty"` // indicator is this is an inventory object or a CI/CD run Category AssetCategory `protobuf:"varint,32,opt,name=category,proto3,enum=cnquery.providers.v1.AssetCategory" json:"category,omitempty"` @@ -575,12 +634,14 @@ type Config struct { // FIXME: DEPRECATED, remove in v10.0 (or later) vv // This is replaced by type. We use a different number here so it doesn't - // conflict with the old "backend" while allowing us to load the field from yaml. + // conflict with the old "backend" while allowing us to load the field from + // yaml. Backend ProviderType `protobuf:"varint,28,opt,name=backend,proto3,enum=cnquery.providers.v1.ProviderType" json:"backend,omitempty"` Kind DeprecatedV8_Kind `protobuf:"varint,24,opt,name=kind,proto3,enum=cnquery.providers.v1.DeprecatedV8_Kind" json:"kind,omitempty"` // ^^ Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` - // Ports are not int by default, eg. docker://centos:latest parses a string as port - // Therefore it is up to the provider to convert the port to what they need + // Ports are not int by default, eg. docker://centos:latest parses a string + // as port. Therefore it is up to the provider to convert the port to what + // they need Port int32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` Path string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"` Id uint32 `protobuf:"varint,5,opt,name=id,proto3" json:"id,omitempty"` @@ -595,7 +656,8 @@ type Config struct { Discover *Discovery `protobuf:"bytes,27,opt,name=discover,proto3" json:"discover,omitempty"` // additional platform information, passed-through Runtime string `protobuf:"bytes,25,opt,name=runtime,proto3" json:"runtime,omitempty"` - // configuration to uniquely identify an specific asset for multi-asset api connection + // configuration to uniquely identify an specific asset for multi-asset + // connection PlatformId string `protobuf:"bytes,26,opt,name=platform_id,json=platformId,proto3" json:"platform_id,omitempty"` Capabilities []string `protobuf:"bytes,29,rep,name=capabilities,proto3" json:"capabilities,omitempty"` } @@ -875,9 +937,10 @@ type Platform struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Arch string `protobuf:"bytes,3,opt,name=arch,proto3" json:"arch,omitempty"` - Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Arch string `protobuf:"bytes,3,opt,name=arch,proto3" json:"arch,omitempty"` + Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED Family []string `protobuf:"bytes,5,rep,name=family,proto3" json:"family,omitempty"` Build string `protobuf:"bytes,6,opt,name=build,proto3" json:"build,omitempty"` Version string `protobuf:"bytes,7,opt,name=version,proto3" json:"version,omitempty"` @@ -998,18 +1061,20 @@ type TypeMeta struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Kind is a string value representing the REST resource this object represents. - // Servers may infer this from the endpoint the client submits requests to. - // Cannot be updated. - // In CamelCase. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // Kind is a string value representing the REST resource this object + // represents. Servers may infer this from the endpoint the client submits + // requests to. Cannot be updated. In CamelCase. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture + // /api-conventions.md#types-kinds // +optional Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` - // APIVersion defines the versioned schema of this representation of an object. - // Servers should convert recognized schemas to the latest internal value, and - // may reject unrecognized values. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + // APIVersion defines the versioned schema of this representation of an + // object. Servers should convert recognized schemas to the latest internal + // value, and may reject unrecognized values. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture + // /api-conventions.md#resources // +optional + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ApiVersion string `protobuf:"bytes,2,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` } @@ -1059,25 +1124,26 @@ func (x *TypeMeta) GetApiVersion() string { return "" } -// ObjectMeta is metadata that all persisted resources must have, which includes all objects -// users must create. +// ObjectMeta is metadata that all persisted resources must have, which includes +// +// all objects users must create. type ObjectMeta struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Name must be unique within a namespace. Is required when creating resources, although - // some resources may allow a client to request the generation of an appropriate name - // automatically. Name is primarily intended for creation idempotence and configuration - // definition. + // Name must be unique within a namespace. Is required when creating + // resources, although some resources may allow a client to request the + // generation of an appropriate name automatically. Name is primarily intended + // for creation idempotence and configuration definition. // Cannot be updated. // More info: http://kubernetes.io/docs/user-guide/identifiers#names // +optional Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Namespace defines the space within which each name must be unique. An empty namespace is - // equivalent to the "default" namespace, but "default" is the canonical representation. - // Not all objects are required to be scoped to a namespace - the value of this field for - // those objects will be empty. + // Namespace defines the space within which each name must be unique. An empty + // namespace is equivalent to the "default" namespace, but "default" is the + // canonical representation. Not all objects are required to be scoped to a + // namespace - the value of this field for those objects will be empty. // // Must be a DNS_LABEL. // Cannot be updated. @@ -1090,19 +1156,21 @@ type ObjectMeta struct { // More info: http://kubernetes.io/docs/user-guide/labels // +optional Labels map[string]string `protobuf:"bytes,11,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // Annotations is an unstructured key value map stored with a resource that may be - // set by external tools to store and retrieve arbitrary metadata. They are not - // queryable and should be preserved when modifying objects. + // Annotations is an unstructured key value map stored with a resource that \ + // may be set by external tools to store and retrieve arbitrary metadata. They + // are not queryable and should be preserved when modifying objects. // More info: http://kubernetes.io/docs/user-guide/annotations // +optional Annotations map[string]string `protobuf:"bytes,12,rep,name=annotations,proto3" json:"annotations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. If this object is managed by a controller, - // then an entry in this list will point to this controller, with the controller field set to true. - // There cannot be more than one managing controller. + // been deleted, this object will be garbage collected. If this object is + // managed by a controller, then an entry in this list will point to this + // controller, with the controller field set to true. There cannot be more + // than one managing controller. // +optional // +patchMergeKey=uid // +patchStrategy=merge + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE OwnerReferences []*OwnerReference `protobuf:"bytes,13,rep,name=ownerReferences,proto3" json:"ownerReferences,omitempty"` } @@ -1252,9 +1320,11 @@ type OwnerReference struct { unknownFields protoimpl.UnknownFields // API version of the referent. + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ApiVersion string `protobuf:"bytes,5,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` // Kind of the referent. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture + // /api-conventions.md#types-kinds Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` // Name of the referent. // More info: http://kubernetes.io/docs/user-guide/identifiers#names @@ -1331,7 +1401,8 @@ type Inventory struct { unknownFields protoimpl.UnknownFields // Standard object's metadata. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture + // /api-conventions.md#metadata Metadata *ObjectMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Specification of the desired behavior of the Inventory. Spec *InventorySpec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` @@ -1515,11 +1586,11 @@ var File_inventory_proto protoreflect.FileDescriptor var file_inventory_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x22, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, - 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, - 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x28, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x70, - 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, + 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x28, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x22, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xad, 0x07, 0x0a, 0x05, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x72, diff --git a/providers-sdk/v1/plugin/plugin.pb.go b/providers-sdk/v1/plugin/plugin.pb.go index 00f2b47a23..36c5f3d7e9 100644 --- a/providers-sdk/v1/plugin/plugin.pb.go +++ b/providers-sdk/v1/plugin/plugin.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: plugin.proto package plugin @@ -794,13 +794,13 @@ var File_plugin_proto protoreflect.FileDescriptor var file_plugin_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x28, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, - 0x76, 0x31, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x75, 0x70, 0x73, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x6c, 0x6c, 0x78, 0x2f, - 0x6c, 0x6c, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd5, 0x01, 0x0a, 0x0b, 0x50, 0x61, + 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x0d, 0x6c, 0x6c, 0x78, 0x2f, 0x6c, 0x6c, 0x78, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, + 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2f, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x28, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, + 0x31, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x75, 0x70, 0x73, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd5, 0x01, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x73, 0x65, 0x43, 0x4c, 0x49, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73, 0x18, diff --git a/providers-sdk/v1/plugin/plugin_grpc.pb.go b/providers-sdk/v1/plugin/plugin_grpc.pb.go index 2567c691dc..f5e471d51b 100644 --- a/providers-sdk/v1/plugin/plugin_grpc.pb.go +++ b/providers-sdk/v1/plugin/plugin_grpc.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.4 +// - protoc v4.25.0 // source: plugin.proto package plugin diff --git a/providers-sdk/v1/resources/resources.pb.go b/providers-sdk/v1/resources/resources.pb.go index a64deacba1..59f9378d92 100644 --- a/providers-sdk/v1/resources/resources.pb.go +++ b/providers-sdk/v1/resources/resources.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: resources.proto package resources diff --git a/providers-sdk/v1/upstream/gql/client.go b/providers-sdk/v1/upstream/gql/client.go new file mode 100644 index 0000000000..2f3bac75cb --- /dev/null +++ b/providers-sdk/v1/upstream/gql/client.go @@ -0,0 +1,35 @@ +package gql + +import ( + "encoding/json" + "net/http" + + "go.mondoo.com/cnquery/v9/providers-sdk/v1/upstream" + mondoogql "go.mondoo.com/mondoo-go" + "go.mondoo.com/mondoo-go/option" +) + +type MondooClient struct { + *mondoogql.Client +} + +// NewClient creates a new GraphQL client for the Mondoo API +// provide the http client used for rpc, to also pass in the proxy settings +func NewClient(upstream upstream.UpstreamConfig, httpClient *http.Client) (*MondooClient, error) { + gqlEndpoint := upstream.ApiEndpoint + "/query" + creds, err := json.Marshal(upstream.Creds) + if err != nil { + return nil, err + } + // Initialize the client + mondooClient, err := mondoogql.NewClient( + option.WithEndpoint(gqlEndpoint), + option.WithHTTPClient(httpClient), + option.WithServiceAccount(creds), + ) + if err != nil { + return nil, err + } + + return &MondooClient{mondooClient}, nil +} diff --git a/providers-sdk/v1/upstream/gql/vulnmgmt_gql.go b/providers-sdk/v1/upstream/gql/vulnmgmt_gql.go new file mode 100644 index 0000000000..97bb4c79a2 --- /dev/null +++ b/providers-sdk/v1/upstream/gql/vulnmgmt_gql.go @@ -0,0 +1,211 @@ +// FIXME: ??? should this file move to the resources inside the provider ??? +package gql + +import ( + "context" + + mondoogql "go.mondoo.com/mondoo-go" +) + +// FIXME: move these to the provider + +// LastAssessment fetches the las update time of the packages query +// This is also the lst time the vuln report was updated +func (c *MondooClient) LastAssessment(mrn string) (string, error) { + var m struct { + AssetLastPackageUpdateTime struct { + LastUpdated string + } `graphql:"assetLastPackageUpdateTime(input: $input)"` + } + err := c.Query(context.Background(), &m, map[string]interface{}{"input": mondoogql.AssetLastPackageUpdateTimeInput{Mrn: mondoogql.String(mrn)}}) + if err != nil { + return "", err + } + return m.AssetLastPackageUpdateTime.LastUpdated, nil +} + +type VulnReport struct { + AssetMrn string + Advisories []*Advisory + Cves []*Cve + Packages []*Package +} + +type Cve struct { + Id string + Source struct { + Id string + Name string + Url string + } + Title string + Description string + Summary string + PublishedAt string + ModifiedAt string + Url string + CvssScore struct { + Id string + Value int + Type int + Vector string + Source string + } + CvssScores []struct { + Id string + Value int + Type int + Vector string + Source string + } + Cwe string + State string +} + +type Advisory struct { + Id string + Source struct { + Id string + Name string + Url string + } + Title string + Description string + + Cves []struct { + Cve + } + CvssScore struct { + Id string + Value int + Type int + Vector string + Source string + } + Vendorscore int + PublishedAt string + ModifiedAt string +} + +type Package struct { + Id string + Name string + Version string + Arch string + Format string + + Namespace string + Description string + Status string + Available string + Origin string + + Score struct { + Id string + Value int + Type int + Vector string + Source string + } + + Advisories []struct { + Advisory + } + Cves []struct { + Cve + } +} + +// GetVulnReport fetches the vuln report for a given asset +func (c *MondooClient) GetVulnReport(mrn string) (*VulnReport, error) { + var m struct { + AssetVulnerabilityReportResponse struct { + AssetVulnerabilityCompactReport struct { + AssetMrn string + Advisories []struct { + Advisory + } + Cves []struct { + Cve + } + Packages []struct { + Package + } + } `graphql:"... on AssetVulnerabilityCompactReport"` + } `graphql:"assetVulnerabilityCompactReport(input: $input)"` + } + err := c.Query(context.Background(), &m, map[string]interface{}{"input": mondoogql.AssetVulnerabilityReportInput{AssetMrn: mondoogql.String(mrn)}}) + if err != nil { + return nil, err + } + + gqlVulnReport := &VulnReport{ + AssetMrn: m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.AssetMrn, + Advisories: make([]*Advisory, len(m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Advisories)), + Cves: make([]*Cve, len(m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Cves)), + Packages: make([]*Package, len(m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Packages)), + } + + for i, a := range m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Advisories { + gqlVulnReport.Advisories[i] = &a.Advisory + } + + for i, c := range m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Cves { + gqlVulnReport.Cves[i] = &c.Cve + } + + for i, p := range m.AssetVulnerabilityReportResponse.AssetVulnerabilityCompactReport.Packages { + gqlVulnReport.Packages[i] = &p.Package + } + + return gqlVulnReport, nil +} + +// GetIncognitoVulnReport fetches the vuln report for an anonymous asset +// This is a special case were we don't have an MRN, like in cnspec shell +func (c *MondooClient) GetIncognitoVulnReport(platform mondoogql.PlatformInput, pkgs []mondoogql.PackageInput) (*VulnReport, error) { + var m struct { + AssetVulnerabilityReportResponse struct { + AssetIncognitoVulnerabilityReport struct { + Advisories []struct { + Advisory + } + Cves []struct { + Cve + } + Packages []struct { + Package + } + } `graphql:"... on AssetIncognitoVulnerabilityReport"` + } `graphql:"analyseIncognitoAssetVulnerabilities(input: $input)"` + } + gqlInput := mondoogql.AnalyseIncognitoAssetInput{ + Platform: platform, + Packages: pkgs, + } + + err := c.Query(context.Background(), &m, map[string]interface{}{"input": gqlInput}) + if err != nil { + return nil, err + } + + gqlVulnReport := &VulnReport{ + Advisories: make([]*Advisory, len(m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Advisories)), + Cves: make([]*Cve, len(m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Cves)), + Packages: make([]*Package, len(m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Packages)), + } + + for i, a := range m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Advisories { + gqlVulnReport.Advisories[i] = &a.Advisory + } + + for i, c := range m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Cves { + gqlVulnReport.Cves[i] = &c.Cve + } + + for i, p := range m.AssetVulnerabilityReportResponse.AssetIncognitoVulnerabilityReport.Packages { + gqlVulnReport.Packages[i] = &p.Package + } + + return gqlVulnReport, nil +} diff --git a/providers-sdk/v1/upstream/health/health.pb.go b/providers-sdk/v1/upstream/health/health.pb.go index 19749bc043..5bbf59a948 100644 --- a/providers-sdk/v1/upstream/health/health.pb.go +++ b/providers-sdk/v1/upstream/health/health.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: health.proto package health @@ -40,9 +40,14 @@ const ( type HealthCheckResponse_ServingStatus int32 const ( - HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 - HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 - HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX + HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 + // protolint:disable:next ENUM_FIELD_NAMES_PREFIX HealthCheckResponse_SERVICE_UNKNOWN HealthCheckResponse_ServingStatus = 3 // Used only by the Watch method. ) @@ -145,6 +150,7 @@ type HealthCheckResponse struct { // returns rfc 3339 timestamp Time string `protobuf:"bytes,2,opt,name=time,proto3" json:"time,omitempty"` // returns the major api version + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ApiVersion string `protobuf:"bytes,3,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` // returns the git commit checksum Build string `protobuf:"bytes,4,opt,name=build,proto3" json:"build,omitempty"` diff --git a/providers-sdk/v1/upstream/mvd/cvss/cvss.pb.go b/providers-sdk/v1/upstream/mvd/cvss/cvss.pb.go index 608ae5b6f9..767f80d5a1 100644 --- a/providers-sdk/v1/upstream/mvd/cvss/cvss.pb.go +++ b/providers-sdk/v1/upstream/mvd/cvss/cvss.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: cvss.proto package cvss diff --git a/providers-sdk/v1/upstream/mvd/mvd.pb.go b/providers-sdk/v1/upstream/mvd/mvd.pb.go index f0e75e0a44..31cef9d1f2 100644 --- a/providers-sdk/v1/upstream/mvd/mvd.pb.go +++ b/providers-sdk/v1/upstream/mvd/mvd.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: mvd.proto package mvd @@ -27,7 +27,7 @@ const ( type AdvisoryState int32 const ( - AdvisoryState_RELEASED AdvisoryState = 0 + AdvisoryState_RELEASED AdvisoryState = 0 // protolint:disable ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH AdvisoryState_PENDING AdvisoryState = 1 AdvisoryState_IGNORED AdvisoryState = 2 AdvisoryState_NOT_AFFECTED AdvisoryState = 3 @@ -76,9 +76,11 @@ func (AdvisoryState) EnumDescriptor() ([]byte, []int) { return file_mvd_proto_rawDescGZIP(), []int{0} } +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX type CveState int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH CveState_PUBLIC CveState = 0 CveState_INVALID CveState = 1 CveState_RESERVED CveState = 2 @@ -229,6 +231,7 @@ type Package struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ID string `protobuf:"bytes,6,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` @@ -364,9 +367,10 @@ type AnalyseAssetRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Platform *Platform `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` - Packages []*Package `protobuf:"bytes,2,rep,name=packages,proto3" json:"packages,omitempty"` - KernelVersion string `protobuf:"bytes,3,opt,name=kernelVersion,proto3" json:"kernelVersion,omitempty"` + Platform *Platform `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` + Packages []*Package `protobuf:"bytes,2,rep,name=packages,proto3" json:"packages,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + KernelVersion string `protobuf:"bytes,3,opt,name=kernelVersion,proto3" json:"kernelVersion,omitempty"` } func (x *AnalyseAssetRequest) Reset() { @@ -506,23 +510,30 @@ type Advisory struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` - Mrn string `protobuf:"bytes,2,opt,name=Mrn,proto3" json:"Mrn,omitempty"` - Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` - Fixed []*Package `protobuf:"bytes,5,rep,name=fixed,proto3" json:"fixed,omitempty"` - Affected []*Package `protobuf:"bytes,6,rep,name=affected,proto3" json:"affected,omitempty"` - Refs []*Reference `protobuf:"bytes,7,rep,name=refs,proto3" json:"refs,omitempty"` - Cves []*CVE `protobuf:"bytes,20,rep,name=cves,proto3" json:"cves,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + Mrn string `protobuf:"bytes,2,opt,name=Mrn,proto3" json:"Mrn,omitempty"` + Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED + Fixed []*Package `protobuf:"bytes,5,rep,name=fixed,proto3" json:"fixed,omitempty"` + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED + Affected []*Package `protobuf:"bytes,6,rep,name=affected,proto3" json:"affected,omitempty"` + Refs []*Reference `protobuf:"bytes,7,rep,name=refs,proto3" json:"refs,omitempty"` + Cves []*CVE `protobuf:"bytes,20,rep,name=cves,proto3" json:"cves,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE FixedPlatforms []*FixedPlatform `protobuf:"bytes,30,rep,name=fixedPlatforms,proto3" json:"fixedPlatforms,omitempty"` Score int32 `protobuf:"varint,25,opt,name=score,proto3" json:"score,omitempty"` - WorstScore *cvss.Cvss `protobuf:"bytes,31,opt,name=worstScore,proto3" json:"worstScore,omitempty"` - Vendorscore float32 `protobuf:"fixed32,26,opt,name=vendorscore,proto3" json:"vendorscore,omitempty"` - State AdvisoryState `protobuf:"varint,27,opt,name=state,proto3,enum=mondoo.mvd.v1.AdvisoryState" json:"state,omitempty"` - Published string `protobuf:"bytes,23,opt,name=published,proto3" json:"published,omitempty"` - Modified string `protobuf:"bytes,24,opt,name=modified,proto3" json:"modified,omitempty"` - Supersedence []string `protobuf:"bytes,28,rep,name=supersedence,proto3" json:"supersedence,omitempty"` - Unscored bool `protobuf:"varint,29,opt,name=unscored,proto3" json:"unscored,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + WorstScore *cvss.Cvss `protobuf:"bytes,31,opt,name=worstScore,proto3" json:"worstScore,omitempty"` + Vendorscore float32 `protobuf:"fixed32,26,opt,name=vendorscore,proto3" json:"vendorscore,omitempty"` + State AdvisoryState `protobuf:"varint,27,opt,name=state,proto3,enum=mondoo.mvd.v1.AdvisoryState" json:"state,omitempty"` + Published string `protobuf:"bytes,23,opt,name=published,proto3" json:"published,omitempty"` + Modified string `protobuf:"bytes,24,opt,name=modified,proto3" json:"modified,omitempty"` + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED + Supersedence []string `protobuf:"bytes,28,rep,name=supersedence,proto3" json:"supersedence,omitempty"` + Unscored bool `protobuf:"varint,29,opt,name=unscored,proto3" json:"unscored,omitempty"` } func (x *Advisory) Reset() { @@ -681,6 +692,7 @@ type Reference struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` Source string `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"` @@ -752,12 +764,14 @@ type FixedPlatform struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE ID string `protobuf:"bytes,6,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Release string `protobuf:"bytes,2,opt,name=release,proto3" json:"release,omitempty"` Arch string `protobuf:"bytes,3,opt,name=arch,proto3" json:"arch,omitempty"` Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"` Build string `protobuf:"bytes,5,opt,name=build,proto3" json:"build,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE PatchName string `protobuf:"bytes,7,opt,name=patchName,proto3" json:"patchName,omitempty"` } @@ -1282,18 +1296,22 @@ type CVE struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` - Mrn string `protobuf:"bytes,2,opt,name=Mrn,proto3" json:"Mrn,omitempty"` - Summary string `protobuf:"bytes,3,opt,name=summary,proto3" json:"summary,omitempty"` - Score float32 `protobuf:"fixed32,4,opt,name=score,proto3" json:"score,omitempty"` - WorstScore *cvss.Cvss `protobuf:"bytes,7,opt,name=worstScore,proto3" json:"worstScore,omitempty"` - Unscored bool `protobuf:"varint,6,opt,name=unscored,proto3" json:"unscored,omitempty"` - State CveState `protobuf:"varint,5,opt,name=state,proto3,enum=mondoo.mvd.v1.CveState" json:"state,omitempty"` - Cvss []*cvss.Cvss `protobuf:"bytes,20,rep,name=cvss,proto3" json:"cvss,omitempty"` - Cwe string `protobuf:"bytes,21,opt,name=cwe,proto3" json:"cwe,omitempty"` - Published string `protobuf:"bytes,22,opt,name=published,proto3" json:"published,omitempty"` - Modified string `protobuf:"bytes,23,opt,name=modified,proto3" json:"modified,omitempty"` - Url string `protobuf:"bytes,24,opt,name=url,proto3" json:"url,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + Mrn string `protobuf:"bytes,2,opt,name=Mrn,proto3" json:"Mrn,omitempty"` + Summary string `protobuf:"bytes,3,opt,name=summary,proto3" json:"summary,omitempty"` + Score float32 `protobuf:"fixed32,4,opt,name=score,proto3" json:"score,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + WorstScore *cvss.Cvss `protobuf:"bytes,7,opt,name=worstScore,proto3" json:"worstScore,omitempty"` + Unscored bool `protobuf:"varint,6,opt,name=unscored,proto3" json:"unscored,omitempty"` + State CveState `protobuf:"varint,5,opt,name=state,proto3,enum=mondoo.mvd.v1.CveState" json:"state,omitempty"` + // protolint:disable:next REPEATED_FIELD_NAMES_PLURALIZED + Cvss []*cvss.Cvss `protobuf:"bytes,20,rep,name=cvss,proto3" json:"cvss,omitempty"` + Cwe string `protobuf:"bytes,21,opt,name=cwe,proto3" json:"cwe,omitempty"` + Published string `protobuf:"bytes,22,opt,name=published,proto3" json:"published,omitempty"` + Modified string `protobuf:"bytes,23,opt,name=modified,proto3" json:"modified,omitempty"` + Url string `protobuf:"bytes,24,opt,name=url,proto3" json:"url,omitempty"` } func (x *CVE) Reset() { @@ -1417,11 +1435,15 @@ type PlatformEolInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Platform *Platform `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` - DocsUrl string `protobuf:"bytes,2,opt,name=DocsUrl,proto3" json:"DocsUrl,omitempty"` - ProductUrl string `protobuf:"bytes,3,opt,name=ProductUrl,proto3" json:"ProductUrl,omitempty"` - ReleaseDate string `protobuf:"bytes,4,opt,name=ReleaseDate,proto3" json:"ReleaseDate,omitempty"` - EolDate string `protobuf:"bytes,5,opt,name=EolDate,proto3" json:"EolDate,omitempty"` + Platform *Platform `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + DocsUrl string `protobuf:"bytes,2,opt,name=DocsUrl,proto3" json:"DocsUrl,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + ProductUrl string `protobuf:"bytes,3,opt,name=ProductUrl,proto3" json:"ProductUrl,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + ReleaseDate string `protobuf:"bytes,4,opt,name=ReleaseDate,proto3" json:"ReleaseDate,omitempty"` + // protolint:disable:next FIELD_NAMES_LOWER_SNAKE_CASE + EolDate string `protobuf:"bytes,5,opt,name=EolDate,proto3" json:"EolDate,omitempty"` } func (x *PlatformEolInfo) Reset() { diff --git a/providers-sdk/v1/upstream/upstream.pb.go b/providers-sdk/v1/upstream/upstream.pb.go index 828100ac6c..1fdd488db8 100644 --- a/providers-sdk/v1/upstream/upstream.pb.go +++ b/providers-sdk/v1/upstream/upstream.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: upstream.proto package upstream diff --git a/providers-sdk/v1/vault/vault.pb.go b/providers-sdk/v1/vault/vault.pb.go index b9d964cbcf..351d14d7f7 100644 --- a/providers-sdk/v1/vault/vault.pb.go +++ b/providers-sdk/v1/vault/vault.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: vault.proto package vault @@ -23,19 +23,31 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX type CredentialType int32 const ( - CredentialType_undefined CredentialType = 0 - CredentialType_password CredentialType = 1 - CredentialType_private_key CredentialType = 2 - CredentialType_ssh_agent CredentialType = 3 - CredentialType_bearer CredentialType = 4 - CredentialType_credentials_query CredentialType = 5 - CredentialType_json CredentialType = 6 + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_undefined CredentialType = 0 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_password CredentialType = 1 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_private_key CredentialType = 2 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_ssh_agent CredentialType = 3 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_bearer CredentialType = 4 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_credentials_query CredentialType = 5 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_json CredentialType = 6 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE CredentialType_aws_ec2_instance_connect CredentialType = 7 - CredentialType_aws_ec2_ssm_session CredentialType = 8 - CredentialType_pkcs12 CredentialType = 9 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_aws_ec2_ssm_session CredentialType = 8 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + CredentialType_pkcs12 CredentialType = 9 ) // Enum value maps for CredentialType. @@ -93,13 +105,20 @@ func (CredentialType) EnumDescriptor() ([]byte, []int) { return file_vault_proto_rawDescGZIP(), []int{0} } +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX +// protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE type SecretEncoding int32 const ( + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH SecretEncoding_encoding_undefined SecretEncoding = 0 - SecretEncoding_encoding_json SecretEncoding = 1 - SecretEncoding_encoding_proto SecretEncoding = 2 - SecretEncoding_encoding_binary SecretEncoding = 3 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + SecretEncoding_encoding_json SecretEncoding = 1 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + SecretEncoding_encoding_proto SecretEncoding = 2 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + SecretEncoding_encoding_binary SecretEncoding = 3 ) // Enum value maps for SecretEncoding. @@ -145,19 +164,31 @@ func (SecretEncoding) EnumDescriptor() ([]byte, []int) { return file_vault_proto_rawDescGZIP(), []int{1} } +// protolint:disable:next ENUM_FIELD_NAMES_PREFIX type VaultType int32 const ( - VaultType_None VaultType = 0 - VaultType_KeyRing VaultType = 1 + // protolint:disable:next ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_None VaultType = 0 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_KeyRing VaultType = 1 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE VaultType_LinuxKernelKeyring VaultType = 2 - VaultType_EncryptedFile VaultType = 3 - VaultType_HashiCorp VaultType = 4 - VaultType_GCPSecretsManager VaultType = 5 - VaultType_AWSSecretsManager VaultType = 6 - VaultType_AWSParameterStore VaultType = 7 - VaultType_GCPBerglas VaultType = 8 - VaultType_Memory VaultType = 9 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_EncryptedFile VaultType = 3 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_HashiCorp VaultType = 4 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_GCPSecretsManager VaultType = 5 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_AWSSecretsManager VaultType = 6 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_AWSParameterStore VaultType = 7 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_GCPBerglas VaultType = 8 + // protolint:disable:next ENUM_FIELD_NAMES_UPPER_SNAKE_CASE + VaultType_Memory VaultType = 9 ) // Enum value maps for VaultType. @@ -428,14 +459,14 @@ type Credential struct { Type CredentialType `protobuf:"varint,2,opt,name=type,proto3,enum=cnquery.providers.v1.CredentialType" json:"type,omitempty"` User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"` Secret []byte `protobuf:"bytes,4,opt,name=secret,proto3" json:"secret,omitempty"` - // the following are optional and sugar for defining a secret - // those values are only allowed for reading in yaml values but not via API calls - Password string `protobuf:"bytes,21,opt,name=password,proto3" json:"password,omitempty"` // optional, could also be the password for the private key + // for user convenience we define password, this allows yaml/json writers + Password string `protobuf:"bytes,21,opt,name=password,proto3" json:"password,omitempty"` // for user convenience we define private_key, this allows yaml/json writers - // to just embed the string representation, otherwise it would need to be base64 encoded + // to just embed the string representation, otherwise it would need to be + // base64 encoded PrivateKey string `protobuf:"bytes,22,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` - // for user convenience we define private_key_path which loads a local file into the - // secret + // for user convenience we define private_key_path which loads a local file + // into the secret PrivateKeyPath string `protobuf:"bytes,23,opt,name=private_key_path,json=privateKeyPath,proto3" json:"private_key_path,omitempty"` } diff --git a/providers/atlassian/config/config.go b/providers/atlassian/config/config.go index f1624c32fe..ed60f967f0 100644 --- a/providers/atlassian/config/config.go +++ b/providers/atlassian/config/config.go @@ -10,7 +10,7 @@ import ( var Config = plugin.Provider{ Name: "atlassian", - ID: "go.mondoo.com/cnquery/providers/atlassian", + ID: "go.mondoo.com/cnquery/v9/providers/atlassian", Version: "9.1.4", ConnectionTypes: []string{ provider.DefaultConnectionType, diff --git a/providers/atlassian/go.mod b/providers/atlassian/go.mod index 5f12cc1aed..969489a784 100644 --- a/providers/atlassian/go.mod +++ b/providers/atlassian/go.mod @@ -49,7 +49,7 @@ require ( github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/getsentry/sentry-go v0.25.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -108,7 +108,7 @@ require ( go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.15.0 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/oauth2 v0.13.0 // indirect + golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/term v0.14.0 // indirect diff --git a/providers/atlassian/go.sum b/providers/atlassian/go.sum index a21d7f0aa7..c241b17627 100644 --- a/providers/atlassian/go.sum +++ b/providers/atlassian/go.sum @@ -142,6 +142,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= +github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -505,6 +507,8 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/providers/core/resources/core.lr b/providers/core/resources/core.lr index c6c92d44ac..6d5c86597d 100644 --- a/providers/core/resources/core.lr +++ b/providers/core/resources/core.lr @@ -58,6 +58,45 @@ asset.eol @defaults("date") { date time } +// Vulnerability Information +vulnmgmt {} + +// CVE information +vuln.cve @defaults("id") { + // CVE ID + id string + // CVSS score + cvss int + // CVSS vector + cvssVector string +} + +// Advisory information +vuln.advisory @defaults("id") { + // Advisory ID + id string + // CVE ID + cve string + // CVSS score + cvss float + // CVSS vector + cvssVector string + // Severity of the advisory + severity string + // Title of the advisory + title string + // Description of the advisory + description string +} + +// Package information relevant for vulnerability management +vuln.package @defaults("name version") { + // Package name + name string + // Package version + version string +} + // Date and time functions time { // The current time on the local system diff --git a/providers/core/resources/core.lr.go b/providers/core/resources/core.lr.go index 98ba41729f..90c8227b09 100644 --- a/providers/core/resources/core.lr.go +++ b/providers/core/resources/core.lr.go @@ -30,6 +30,22 @@ func init() { Init: initAssetEol, Create: createAssetEol, }, + "vulnmgmt": { + // to override args, implement: initVulnmgmt(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnmgmt, + }, + "vulncve": { + // to override args, implement: initVulncve(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulncve, + }, + "vulnadvisory": { + // to override args, implement: initVulnadvisory(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnadvisory, + }, + "vulnpackage": { + // to override args, implement: initVulnpackage(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnpackage, + }, "time": { // to override args, implement: initTime(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) Create: createTime, @@ -174,6 +190,42 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "asset.eol.date": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAssetEol).GetDate()).ToDataRes(types.Time) }, + "vulncve.id": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulncve).GetId()).ToDataRes(types.String) + }, + "vulncve.cvss": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulncve).GetCvss()).ToDataRes(types.Int) + }, + "vulncve.cvssVector": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulncve).GetCvssVector()).ToDataRes(types.String) + }, + "vulnadvisory.id": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetId()).ToDataRes(types.String) + }, + "vulnadvisory.cve": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetCve()).ToDataRes(types.String) + }, + "vulnadvisory.cvss": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetCvss()).ToDataRes(types.Float) + }, + "vulnadvisory.cvssVector": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetCvssVector()).ToDataRes(types.String) + }, + "vulnadvisory.severity": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetSeverity()).ToDataRes(types.String) + }, + "vulnadvisory.title": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetTitle()).ToDataRes(types.String) + }, + "vulnadvisory.description": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnadvisory).GetDescription()).ToDataRes(types.String) + }, + "vulnpackage.name": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnpackage).GetName()).ToDataRes(types.String) + }, + "vulnpackage.version": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnpackage).GetVersion()).ToDataRes(types.String) + }, "time.now": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlTime).GetNow()).ToDataRes(types.Time) }, @@ -338,6 +390,70 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlAssetEol).Date, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) return }, + "vulnmgmt.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).__id, ok = v.Value.(string) + return + }, + "vulncve.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulncve).__id, ok = v.Value.(string) + return + }, + "vulncve.id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulncve).Id, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulncve.cvss": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulncve).Cvss, ok = plugin.RawToTValue[int64](v.Value, v.Error) + return + }, + "vulncve.cvssVector": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulncve).CvssVector, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).__id, ok = v.Value.(string) + return + }, + "vulnadvisory.id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Id, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.cve": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Cve, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.cvss": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Cvss, ok = plugin.RawToTValue[float64](v.Value, v.Error) + return + }, + "vulnadvisory.cvssVector": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).CvssVector, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.severity": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Severity, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.title": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Title, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnadvisory.description": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnadvisory).Description, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnpackage.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnpackage).__id, ok = v.Value.(string) + return + }, + "vulnpackage.name": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnpackage).Name, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vulnpackage.version": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnpackage).Version, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, "time.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlTime).__id, ok = v.Value.(string) return @@ -685,6 +801,222 @@ func (c *mqlAssetEol) GetDate() *plugin.TValue[*time.Time] { return &c.Date } +// mqlVulnmgmt for the vulnmgmt resource +type mqlVulnmgmt struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnmgmtInternal it will be used here +} + +// createVulnmgmt creates a new instance of this resource +func createVulnmgmt(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnmgmt{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vulnmgmt", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnmgmt) MqlName() string { + return "vulnmgmt" +} + +func (c *mqlVulnmgmt) MqlID() string { + return c.__id +} + +// mqlVulncve for the vulncve resource +type mqlVulncve struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulncveInternal it will be used here + Id plugin.TValue[string] + Cvss plugin.TValue[int64] + CvssVector plugin.TValue[string] +} + +// createVulncve creates a new instance of this resource +func createVulncve(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulncve{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vulncve", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulncve) MqlName() string { + return "vulncve" +} + +func (c *mqlVulncve) MqlID() string { + return c.__id +} + +func (c *mqlVulncve) GetId() *plugin.TValue[string] { + return &c.Id +} + +func (c *mqlVulncve) GetCvss() *plugin.TValue[int64] { + return &c.Cvss +} + +func (c *mqlVulncve) GetCvssVector() *plugin.TValue[string] { + return &c.CvssVector +} + +// mqlVulnadvisory for the vulnadvisory resource +type mqlVulnadvisory struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnadvisoryInternal it will be used here + Id plugin.TValue[string] + Cve plugin.TValue[string] + Cvss plugin.TValue[float64] + CvssVector plugin.TValue[string] + Severity plugin.TValue[string] + Title plugin.TValue[string] + Description plugin.TValue[string] +} + +// createVulnadvisory creates a new instance of this resource +func createVulnadvisory(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnadvisory{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vulnadvisory", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnadvisory) MqlName() string { + return "vulnadvisory" +} + +func (c *mqlVulnadvisory) MqlID() string { + return c.__id +} + +func (c *mqlVulnadvisory) GetId() *plugin.TValue[string] { + return &c.Id +} + +func (c *mqlVulnadvisory) GetCve() *plugin.TValue[string] { + return &c.Cve +} + +func (c *mqlVulnadvisory) GetCvss() *plugin.TValue[float64] { + return &c.Cvss +} + +func (c *mqlVulnadvisory) GetCvssVector() *plugin.TValue[string] { + return &c.CvssVector +} + +func (c *mqlVulnadvisory) GetSeverity() *plugin.TValue[string] { + return &c.Severity +} + +func (c *mqlVulnadvisory) GetTitle() *plugin.TValue[string] { + return &c.Title +} + +func (c *mqlVulnadvisory) GetDescription() *plugin.TValue[string] { + return &c.Description +} + +// mqlVulnpackage for the vulnpackage resource +type mqlVulnpackage struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnpackageInternal it will be used here + Name plugin.TValue[string] + Version plugin.TValue[string] +} + +// createVulnpackage creates a new instance of this resource +func createVulnpackage(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnpackage{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vulnpackage", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnpackage) MqlName() string { + return "vulnpackage" +} + +func (c *mqlVulnpackage) MqlID() string { + return c.__id +} + +func (c *mqlVulnpackage) GetName() *plugin.TValue[string] { + return &c.Name +} + +func (c *mqlVulnpackage) GetVersion() *plugin.TValue[string] { + return &c.Version +} + // mqlTime for the time resource type mqlTime struct { MqlRuntime *plugin.Runtime diff --git a/providers/core/resources/core.lr.manifest.yaml b/providers/core/resources/core.lr.manifest.yaml index 8ce9aa4a79..3288f62b29 100644 --- a/providers/core/resources/core.lr.manifest.yaml +++ b/providers/core/resources/core.lr.manifest.yaml @@ -381,6 +381,34 @@ resources: variant: {} version: {} min_mondoo_version: 5.15.0 + vulnadvisory: + fields: + cve: {} + cvss: {} + cvssVector: {} + description: {} + id: {} + severity: {} + title: {} + min_mondoo_version: latest + vulncve: + fields: + cvss: {} + cvssVector: {} + id: {} + min_mondoo_version: latest + vulnmgmt: + fields: + advisories: {} + cves: {} + lastAssessment: {} + packages: {} + min_mondoo_version: latest + vulnpackage: + fields: + name: {} + version: {} + min_mondoo_version: latest yaml.path: fields: filepath: {} diff --git a/providers/core/resources/core.resources.json b/providers/core/resources/core.resources.json index 65c0a74f1c..f79e587076 100644 --- a/providers/core/resources/core.resources.json +++ b/providers/core/resources/core.resources.json @@ -1 +1 @@ -{"resources":{"asset":{"id":"asset","name":"asset","fields":{"arch":{"name":"arch","type":"\u0007","is_mandatory":true,"title":"Architecture this OS is running on","provider":"go.mondoo.com/cnquery/v9/providers/core"},"build":{"name":"build","type":"\u0007","is_mandatory":true,"title":"Build version of the platform (optional)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"eol":{"name":"eol","type":"\u001basset.eol","title":"Information about the assets platform end-of-life.","is_implicit_resource":true,"provider":"go.mondoo.com/cnquery/v9/providers/core"},"family":{"name":"family","type":"\u0019\u0007","is_mandatory":true,"title":"List of platform families that this platform belongs to","provider":"go.mondoo.com/cnquery/v9/providers/core"},"fqdn":{"name":"fqdn","type":"\u0007","is_mandatory":true,"title":"Fully qualified domain name (optional)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ids":{"name":"ids","type":"\u0019\u0007","is_mandatory":true,"title":"All identifiers for this asset","provider":"go.mondoo.com/cnquery/v9/providers/core"},"kind":{"name":"kind","type":"\u0007","is_mandatory":true,"title":"Kind of platform, for example:","desc":"api, baremetal, vm, vm-image, container, container-image, network, ...","provider":"go.mondoo.com/cnquery/v9/providers/core"},"labels":{"name":"labels","type":"\u001a\u0007\u0007","is_mandatory":true,"title":"Optional platform information","provider":"go.mondoo.com/cnquery/v9/providers/core"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Human readable name of the asset","provider":"go.mondoo.com/cnquery/v9/providers/core"},"platform":{"name":"platform","type":"\u0007","is_mandatory":true,"title":"Platform for this asset (redhat, windows, k8s-pod)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"runtime":{"name":"runtime","type":"\u0007","is_mandatory":true,"title":"Runtime is the specific kind of the platform. Examples include:","desc":"docker-container, podman-container, aws-ec2-instance, ...","provider":"go.mondoo.com/cnquery/v9/providers/core"},"title":{"name":"title","type":"\u0007","is_mandatory":true,"title":"Human-readable title of the platform (e.g., \"Red Hat 8, Container\")","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0007","is_mandatory":true,"title":"Version of the platform","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"General asset information","min_mondoo_version":"6.13.0","defaults":"name platform version","provider":"go.mondoo.com/cnquery/v9/providers/core"},"asset.eol":{"id":"asset.eol","name":"asset.eol","fields":{"date":{"name":"date","type":"\t","is_mandatory":true,"title":"End-of-Life date","provider":"go.mondoo.com/cnquery/v9/providers/core"},"docsUrl":{"name":"docsUrl","type":"\u0007","is_mandatory":true,"title":"Documentation URL","provider":"go.mondoo.com/cnquery/v9/providers/core"},"productUrl":{"name":"productUrl","type":"\u0007","is_mandatory":true,"title":"Product URL","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Information about the assets platform end-of-life.","min_mondoo_version":"latest","defaults":"date","provider":"go.mondoo.com/cnquery/v9/providers/core"},"mondoo":{"id":"mondoo","name":"mondoo","fields":{"arch":{"name":"arch","type":"\u0007","title":"Architecture of this client (e.g., linux-amd64)","min_mondoo_version":"latest","provider":"go.mondoo.com/cnquery/v9/providers/core"},"build":{"name":"build","type":"\u0007","title":"Build of the client (e.g., production, development)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"capabilities":{"name":"capabilities","type":"\u0019\u0007","title":"Connection capabilities","provider":"go.mondoo.com/cnquery/v9/providers/core"},"jobEnvironment":{"name":"jobEnvironment","type":"\n","title":"Agent execution environment","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0007","title":"Version of the client running on the asset","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Contextual information about MQL runtime and environment","min_mondoo_version":"5.15.0","defaults":"version","provider":"go.mondoo.com/cnquery/v9/providers/core"},"parse":{"id":"parse","name":"parse","title":"Provides common parsers (json, ini, certs, etc)","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"regex":{"id":"regex","name":"regex","fields":{"creditCard":{"name":"creditCard","type":"\u0008","title":"Matches credit card numbers","provider":"go.mondoo.com/cnquery/v9/providers/core"},"email":{"name":"email","type":"\u0008","title":"Matches email addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"emoji":{"name":"emoji","type":"\u0008","title":"Matches emojis","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ipv4":{"name":"ipv4","type":"\u0008","title":"Matches IPv4 addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ipv6":{"name":"ipv6","type":"\u0008","title":"Matches IPv6 addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"mac":{"name":"mac","type":"\u0008","title":"Matches MAC addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"semver":{"name":"semver","type":"\u0008","title":"Matches semantic version numbers","provider":"go.mondoo.com/cnquery/v9/providers/core"},"url":{"name":"url","type":"\u0008","title":"Matches URL addresses (HTTP/HTTPS)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"uuid":{"name":"uuid","type":"\u0008","title":"Matches hyphen-deliminated UUIDs","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Built-in regular expression functions","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"time":{"id":"time","name":"time","fields":{"day":{"name":"day","type":"\t","title":"One day, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"hour":{"name":"hour","type":"\t","title":"One hour, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"minute":{"name":"minute","type":"\t","title":"One minute, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"now":{"name":"now","type":"\t","title":"The current time on the local system","provider":"go.mondoo.com/cnquery/v9/providers/core"},"second":{"name":"second","type":"\t","title":"One second, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"today":{"name":"today","type":"\t","title":"The current day starting at midnight","provider":"go.mondoo.com/cnquery/v9/providers/core"},"tomorrow":{"name":"tomorrow","type":"\t","title":"The next day starting at midnight","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Date and time functions","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"uuid":{"id":"uuid","name":"uuid","fields":{"urn":{"name":"urn","type":"\u0007","title":"URN returns the RFC 2141 URN form of uuid","provider":"go.mondoo.com/cnquery/v9/providers/core"},"value":{"name":"value","type":"\u0007","is_mandatory":true,"title":"Canonical string representation xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","provider":"go.mondoo.com/cnquery/v9/providers/core"},"variant":{"name":"variant","type":"\u0007","title":"Variant encoded in UUID","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0005","title":"Version of UUID","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"init":{"args":[{"name":"value","type":"\u0007"}]},"title":"UUIDs based on RFC 4122 and DCE 1.1","min_mondoo_version":"5.15.0","defaults":"value","provider":"go.mondoo.com/cnquery/v9/providers/core"}}} \ No newline at end of file +{"resources":{"asset":{"id":"asset","name":"asset","fields":{"arch":{"name":"arch","type":"\u0007","is_mandatory":true,"title":"Architecture this OS is running on","provider":"go.mondoo.com/cnquery/v9/providers/core"},"build":{"name":"build","type":"\u0007","is_mandatory":true,"title":"Build version of the platform (optional)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"eol":{"name":"eol","type":"\u001basset.eol","title":"Information about the assets platform end-of-life.","is_implicit_resource":true,"provider":"go.mondoo.com/cnquery/v9/providers/core"},"family":{"name":"family","type":"\u0019\u0007","is_mandatory":true,"title":"List of platform families that this platform belongs to","provider":"go.mondoo.com/cnquery/v9/providers/core"},"fqdn":{"name":"fqdn","type":"\u0007","is_mandatory":true,"title":"Fully qualified domain name (optional)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ids":{"name":"ids","type":"\u0019\u0007","is_mandatory":true,"title":"All identifiers for this asset","provider":"go.mondoo.com/cnquery/v9/providers/core"},"kind":{"name":"kind","type":"\u0007","is_mandatory":true,"title":"Kind of platform, for example:","desc":"api, baremetal, vm, vm-image, container, container-image, network, ...","provider":"go.mondoo.com/cnquery/v9/providers/core"},"labels":{"name":"labels","type":"\u001a\u0007\u0007","is_mandatory":true,"title":"Optional platform information","provider":"go.mondoo.com/cnquery/v9/providers/core"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Human readable name of the asset","provider":"go.mondoo.com/cnquery/v9/providers/core"},"platform":{"name":"platform","type":"\u0007","is_mandatory":true,"title":"Platform for this asset (redhat, windows, k8s-pod)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"runtime":{"name":"runtime","type":"\u0007","is_mandatory":true,"title":"Runtime is the specific kind of the platform. Examples include:","desc":"docker-container, podman-container, aws-ec2-instance, ...","provider":"go.mondoo.com/cnquery/v9/providers/core"},"title":{"name":"title","type":"\u0007","is_mandatory":true,"title":"Human-readable title of the platform (e.g., \"Red Hat 8, Container\")","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0007","is_mandatory":true,"title":"Version of the platform","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"General asset information","min_mondoo_version":"6.13.0","defaults":"name platform version","provider":"go.mondoo.com/cnquery/v9/providers/core"},"asset.eol":{"id":"asset.eol","name":"asset.eol","fields":{"date":{"name":"date","type":"\t","is_mandatory":true,"title":"End-of-Life date","provider":"go.mondoo.com/cnquery/v9/providers/core"},"docsUrl":{"name":"docsUrl","type":"\u0007","is_mandatory":true,"title":"Documentation URL","provider":"go.mondoo.com/cnquery/v9/providers/core"},"productUrl":{"name":"productUrl","type":"\u0007","is_mandatory":true,"title":"Product URL","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Information about the assets platform end-of-life.","min_mondoo_version":"latest","defaults":"date","provider":"go.mondoo.com/cnquery/v9/providers/core"},"mondoo":{"id":"mondoo","name":"mondoo","fields":{"arch":{"name":"arch","type":"\u0007","title":"Architecture of this client (e.g., linux-amd64)","min_mondoo_version":"latest","provider":"go.mondoo.com/cnquery/v9/providers/core"},"build":{"name":"build","type":"\u0007","title":"Build of the client (e.g., production, development)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"capabilities":{"name":"capabilities","type":"\u0019\u0007","title":"Connection capabilities","provider":"go.mondoo.com/cnquery/v9/providers/core"},"jobEnvironment":{"name":"jobEnvironment","type":"\n","title":"Agent execution environment","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0007","title":"Version of the client running on the asset","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Contextual information about MQL runtime and environment","min_mondoo_version":"5.15.0","defaults":"version","provider":"go.mondoo.com/cnquery/v9/providers/core"},"parse":{"id":"parse","name":"parse","title":"Provides common parsers (json, ini, certs, etc)","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"regex":{"id":"regex","name":"regex","fields":{"creditCard":{"name":"creditCard","type":"\u0008","title":"Matches credit card numbers","provider":"go.mondoo.com/cnquery/v9/providers/core"},"email":{"name":"email","type":"\u0008","title":"Matches email addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"emoji":{"name":"emoji","type":"\u0008","title":"Matches emojis","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ipv4":{"name":"ipv4","type":"\u0008","title":"Matches IPv4 addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"ipv6":{"name":"ipv6","type":"\u0008","title":"Matches IPv6 addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"mac":{"name":"mac","type":"\u0008","title":"Matches MAC addresses","provider":"go.mondoo.com/cnquery/v9/providers/core"},"semver":{"name":"semver","type":"\u0008","title":"Matches semantic version numbers","provider":"go.mondoo.com/cnquery/v9/providers/core"},"url":{"name":"url","type":"\u0008","title":"Matches URL addresses (HTTP/HTTPS)","provider":"go.mondoo.com/cnquery/v9/providers/core"},"uuid":{"name":"uuid","type":"\u0008","title":"Matches hyphen-deliminated UUIDs","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Built-in regular expression functions","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"time":{"id":"time","name":"time","fields":{"day":{"name":"day","type":"\t","title":"One day, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"hour":{"name":"hour","type":"\t","title":"One hour, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"minute":{"name":"minute","type":"\t","title":"One minute, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"now":{"name":"now","type":"\t","title":"The current time on the local system","provider":"go.mondoo.com/cnquery/v9/providers/core"},"second":{"name":"second","type":"\t","title":"One second, used for durations","provider":"go.mondoo.com/cnquery/v9/providers/core"},"today":{"name":"today","type":"\t","title":"The current day starting at midnight","provider":"go.mondoo.com/cnquery/v9/providers/core"},"tomorrow":{"name":"tomorrow","type":"\t","title":"The next day starting at midnight","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Date and time functions","min_mondoo_version":"5.15.0","provider":"go.mondoo.com/cnquery/v9/providers/core"},"uuid":{"id":"uuid","name":"uuid","fields":{"urn":{"name":"urn","type":"\u0007","title":"URN returns the RFC 2141 URN form of uuid","provider":"go.mondoo.com/cnquery/v9/providers/core"},"value":{"name":"value","type":"\u0007","is_mandatory":true,"title":"Canonical string representation xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","provider":"go.mondoo.com/cnquery/v9/providers/core"},"variant":{"name":"variant","type":"\u0007","title":"Variant encoded in UUID","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0005","title":"Version of UUID","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"init":{"args":[{"name":"value","type":"\u0007"}]},"title":"UUIDs based on RFC 4122 and DCE 1.1","min_mondoo_version":"5.15.0","defaults":"value","provider":"go.mondoo.com/cnquery/v9/providers/core"},"vulnadvisory":{"id":"vulnadvisory","name":"vulnadvisory","fields":{"cve":{"name":"cve","type":"\u0007","is_mandatory":true,"title":"CVE ID","provider":"go.mondoo.com/cnquery/v9/providers/core"},"cvss":{"name":"cvss","type":"\u0006","is_mandatory":true,"title":"CVSS score","provider":"go.mondoo.com/cnquery/v9/providers/core"},"cvssVector":{"name":"cvssVector","type":"\u0007","is_mandatory":true,"title":"CVSS vector","provider":"go.mondoo.com/cnquery/v9/providers/core"},"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Description of the advisory","provider":"go.mondoo.com/cnquery/v9/providers/core"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Advisory ID","provider":"go.mondoo.com/cnquery/v9/providers/core"},"severity":{"name":"severity","type":"\u0007","is_mandatory":true,"title":"Severity of the advisory","provider":"go.mondoo.com/cnquery/v9/providers/core"},"title":{"name":"title","type":"\u0007","is_mandatory":true,"title":"Title of the advisory","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Advisory information","min_mondoo_version":"latest","defaults":"id","provider":"go.mondoo.com/cnquery/v9/providers/core"},"vulncve":{"id":"vulncve","name":"vulncve","fields":{"cvss":{"name":"cvss","type":"\u0005","is_mandatory":true,"title":"CVSS score","provider":"go.mondoo.com/cnquery/v9/providers/core"},"cvssVector":{"name":"cvssVector","type":"\u0007","is_mandatory":true,"title":"CVSS vector","provider":"go.mondoo.com/cnquery/v9/providers/core"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"CVE ID","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"CVE information","min_mondoo_version":"latest","defaults":"id","provider":"go.mondoo.com/cnquery/v9/providers/core"},"vulnmgmt":{"id":"vulnmgmt","name":"vulnmgmt","title":"Vulnerability Information","min_mondoo_version":"latest","provider":"go.mondoo.com/cnquery/v9/providers/core"},"vulnpackage":{"id":"vulnpackage","name":"vulnpackage","fields":{"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Package name","provider":"go.mondoo.com/cnquery/v9/providers/core"},"version":{"name":"version","type":"\u0007","is_mandatory":true,"title":"Package version","provider":"go.mondoo.com/cnquery/v9/providers/core"}},"title":"Package information relevant for vulnerability management","min_mondoo_version":"latest","defaults":"name version","provider":"go.mondoo.com/cnquery/v9/providers/core"}}} \ No newline at end of file diff --git a/providers/os/resources/os.lr b/providers/os/resources/os.lr index d48aa9494d..8fdae93734 100644 --- a/providers/os/resources/os.lr +++ b/providers/os/resources/os.lr @@ -18,6 +18,8 @@ alias os.unix.sshd = sshd alias k8s.kubelet = kubelet extend asset { + // Deprecated; will be removed in version 10.0 + // use vulnmgmt instead vulnerabilityReport() dict } @@ -52,10 +54,59 @@ platform.eol @defaults("date") { } platform { - // deprecated; use asset.vulnerabilityReport instead + // Deprecated; will be removed in version 10.0 + // use vulnmgmt instead vulnerabilityReport() dict } +extend vulnmgmt { + // TODO: fill all the fields at once, see os stdout, stderr example + // List of all CVEs affecting the asset + cves() []vuln.cve + // List of all Advisories affecting the asset + advisories() []vuln.advisory + // List of all packages affected by vulnerabilities + packages() []vuln.package + // Last time the vulnerability information was updated + lastAssessment() time +} + +// CVE information +vuln.cve @defaults("id") { + // CVE ID + id string + // CVSS score + cvss int + // CVSS vector + cvssVector string +} + +// Advisory information +vuln.advisory @defaults("id") { + // Advisory ID + id string + // CVE ID + cve string + // CVSS score + cvss float + // CVSS vector + cvssVector string + // Severity of the advisory + severity string + // Title of the advisory + title string + // Description of the advisory + description string +} + +// Package information relevant for vulnerability management +vuln.package @defaults("name version") { + // Package name + name string + // Package version + version string +} + // All platform/package advisories platform.advisories { []audit.advisory diff --git a/providers/os/resources/os.lr.go b/providers/os/resources/os.lr.go index a70d19778c..3e8cc5074f 100644 --- a/providers/os/resources/os.lr.go +++ b/providers/os/resources/os.lr.go @@ -38,6 +38,22 @@ func init() { // to override args, implement: initPlatform(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) Create: createPlatform, }, + "vulnmgmt": { + // to override args, implement: initVulnmgmt(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnmgmt, + }, + "vuln.cve": { + // to override args, implement: initVulnCve(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnCve, + }, + "vuln.advisory": { + // to override args, implement: initVulnAdvisory(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnAdvisory, + }, + "vuln.package": { + // to override args, implement: initVulnPackage(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createVulnPackage, + }, "platform.advisories": { // to override args, implement: initPlatformAdvisories(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) Create: createPlatformAdvisories, @@ -503,6 +519,54 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "platform.vulnerabilityReport": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlPlatform).GetVulnerabilityReport()).ToDataRes(types.Dict) }, + "vulnmgmt.cves": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnmgmt).GetCves()).ToDataRes(types.Array(types.Resource("vuln.cve"))) + }, + "vulnmgmt.advisories": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnmgmt).GetAdvisories()).ToDataRes(types.Array(types.Resource("vuln.advisory"))) + }, + "vulnmgmt.packages": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnmgmt).GetPackages()).ToDataRes(types.Array(types.Resource("vuln.package"))) + }, + "vulnmgmt.lastAssessment": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnmgmt).GetLastAssessment()).ToDataRes(types.Time) + }, + "vuln.cve.id": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnCve).GetId()).ToDataRes(types.String) + }, + "vuln.cve.cvss": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnCve).GetCvss()).ToDataRes(types.Int) + }, + "vuln.cve.cvssVector": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnCve).GetCvssVector()).ToDataRes(types.String) + }, + "vuln.advisory.id": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetId()).ToDataRes(types.String) + }, + "vuln.advisory.cve": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetCve()).ToDataRes(types.String) + }, + "vuln.advisory.cvss": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetCvss()).ToDataRes(types.Float) + }, + "vuln.advisory.cvssVector": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetCvssVector()).ToDataRes(types.String) + }, + "vuln.advisory.severity": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetSeverity()).ToDataRes(types.String) + }, + "vuln.advisory.title": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetTitle()).ToDataRes(types.String) + }, + "vuln.advisory.description": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnAdvisory).GetDescription()).ToDataRes(types.String) + }, + "vuln.package.name": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnPackage).GetName()).ToDataRes(types.String) + }, + "vuln.package.version": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlVulnPackage).GetVersion()).ToDataRes(types.String) + }, "platform.advisories.cvss": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlPlatformAdvisories).GetCvss()).ToDataRes(types.Resource("audit.cvss")) }, @@ -1977,6 +2041,86 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlPlatform).VulnerabilityReport, ok = plugin.RawToTValue[interface{}](v.Value, v.Error) return }, + "vulnmgmt.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).__id, ok = v.Value.(string) + return + }, + "vulnmgmt.cves": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).Cves, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "vulnmgmt.advisories": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).Advisories, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "vulnmgmt.packages": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).Packages, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "vulnmgmt.lastAssessment": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnmgmt).LastAssessment, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) + return + }, + "vuln.cve.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnCve).__id, ok = v.Value.(string) + return + }, + "vuln.cve.id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnCve).Id, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.cve.cvss": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnCve).Cvss, ok = plugin.RawToTValue[int64](v.Value, v.Error) + return + }, + "vuln.cve.cvssVector": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnCve).CvssVector, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).__id, ok = v.Value.(string) + return + }, + "vuln.advisory.id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Id, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.cve": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Cve, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.cvss": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Cvss, ok = plugin.RawToTValue[float64](v.Value, v.Error) + return + }, + "vuln.advisory.cvssVector": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).CvssVector, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.severity": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Severity, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.title": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Title, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.advisory.description": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnAdvisory).Description, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.package.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnPackage).__id, ok = v.Value.(string) + return + }, + "vuln.package.name": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnPackage).Name, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "vuln.package.version": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlVulnPackage).Version, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, "platform.advisories.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlPlatformAdvisories).__id, ok = v.Value.(string) return @@ -4490,6 +4634,280 @@ func (c *mqlPlatform) GetVulnerabilityReport() *plugin.TValue[interface{}] { }) } +// mqlVulnmgmt for the vulnmgmt resource +type mqlVulnmgmt struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnmgmtInternal it will be used here + Cves plugin.TValue[[]interface{}] + Advisories plugin.TValue[[]interface{}] + Packages plugin.TValue[[]interface{}] + LastAssessment plugin.TValue[*time.Time] +} + +// createVulnmgmt creates a new instance of this resource +func createVulnmgmt(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnmgmt{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vulnmgmt", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnmgmt) MqlName() string { + return "vulnmgmt" +} + +func (c *mqlVulnmgmt) MqlID() string { + return c.__id +} + +func (c *mqlVulnmgmt) GetCves() *plugin.TValue[[]interface{}] { + return plugin.GetOrCompute[[]interface{}](&c.Cves, func() ([]interface{}, error) { + if c.MqlRuntime.HasRecording { + d, err := c.MqlRuntime.FieldResourceFromRecording("vulnmgmt", c.__id, "cves") + if err != nil { + return nil, err + } + if d != nil { + return d.Value.([]interface{}), nil + } + } + + return c.cves() + }) +} + +func (c *mqlVulnmgmt) GetAdvisories() *plugin.TValue[[]interface{}] { + return plugin.GetOrCompute[[]interface{}](&c.Advisories, func() ([]interface{}, error) { + if c.MqlRuntime.HasRecording { + d, err := c.MqlRuntime.FieldResourceFromRecording("vulnmgmt", c.__id, "advisories") + if err != nil { + return nil, err + } + if d != nil { + return d.Value.([]interface{}), nil + } + } + + return c.advisories() + }) +} + +func (c *mqlVulnmgmt) GetPackages() *plugin.TValue[[]interface{}] { + return plugin.GetOrCompute[[]interface{}](&c.Packages, func() ([]interface{}, error) { + if c.MqlRuntime.HasRecording { + d, err := c.MqlRuntime.FieldResourceFromRecording("vulnmgmt", c.__id, "packages") + if err != nil { + return nil, err + } + if d != nil { + return d.Value.([]interface{}), nil + } + } + + return c.packages() + }) +} + +func (c *mqlVulnmgmt) GetLastAssessment() *plugin.TValue[*time.Time] { + return plugin.GetOrCompute[*time.Time](&c.LastAssessment, func() (*time.Time, error) { + return c.lastAssessment() + }) +} + +// mqlVulnCve for the vuln.cve resource +type mqlVulnCve struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnCveInternal it will be used here + Id plugin.TValue[string] + Cvss plugin.TValue[int64] + CvssVector plugin.TValue[string] +} + +// createVulnCve creates a new instance of this resource +func createVulnCve(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnCve{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vuln.cve", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnCve) MqlName() string { + return "vuln.cve" +} + +func (c *mqlVulnCve) MqlID() string { + return c.__id +} + +func (c *mqlVulnCve) GetId() *plugin.TValue[string] { + return &c.Id +} + +func (c *mqlVulnCve) GetCvss() *plugin.TValue[int64] { + return &c.Cvss +} + +func (c *mqlVulnCve) GetCvssVector() *plugin.TValue[string] { + return &c.CvssVector +} + +// mqlVulnAdvisory for the vuln.advisory resource +type mqlVulnAdvisory struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnAdvisoryInternal it will be used here + Id plugin.TValue[string] + Cve plugin.TValue[string] + Cvss plugin.TValue[float64] + CvssVector plugin.TValue[string] + Severity plugin.TValue[string] + Title plugin.TValue[string] + Description plugin.TValue[string] +} + +// createVulnAdvisory creates a new instance of this resource +func createVulnAdvisory(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnAdvisory{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vuln.advisory", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnAdvisory) MqlName() string { + return "vuln.advisory" +} + +func (c *mqlVulnAdvisory) MqlID() string { + return c.__id +} + +func (c *mqlVulnAdvisory) GetId() *plugin.TValue[string] { + return &c.Id +} + +func (c *mqlVulnAdvisory) GetCve() *plugin.TValue[string] { + return &c.Cve +} + +func (c *mqlVulnAdvisory) GetCvss() *plugin.TValue[float64] { + return &c.Cvss +} + +func (c *mqlVulnAdvisory) GetCvssVector() *plugin.TValue[string] { + return &c.CvssVector +} + +func (c *mqlVulnAdvisory) GetSeverity() *plugin.TValue[string] { + return &c.Severity +} + +func (c *mqlVulnAdvisory) GetTitle() *plugin.TValue[string] { + return &c.Title +} + +func (c *mqlVulnAdvisory) GetDescription() *plugin.TValue[string] { + return &c.Description +} + +// mqlVulnPackage for the vuln.package resource +type mqlVulnPackage struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlVulnPackageInternal it will be used here + Name plugin.TValue[string] + Version plugin.TValue[string] +} + +// createVulnPackage creates a new instance of this resource +func createVulnPackage(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlVulnPackage{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("vuln.package", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlVulnPackage) MqlName() string { + return "vuln.package" +} + +func (c *mqlVulnPackage) MqlID() string { + return c.__id +} + +func (c *mqlVulnPackage) GetName() *plugin.TValue[string] { + return &c.Name +} + +func (c *mqlVulnPackage) GetVersion() *plugin.TValue[string] { + return &c.Version +} + // mqlPlatformAdvisories for the platform.advisories resource type mqlPlatformAdvisories struct { MqlRuntime *plugin.Runtime diff --git a/providers/os/resources/os.lr.manifest.yaml b/providers/os/resources/os.lr.manifest.yaml index 653a7760c5..94b4490715 100644 --- a/providers/os/resources/os.lr.manifest.yaml +++ b/providers/os/resources/os.lr.manifest.yaml @@ -875,6 +875,34 @@ resources: name != "Guest" } title: Search for a specific SID and check for its values + vuln.advisory: + fields: + cve: {} + cvss: {} + cvssVector: {} + description: {} + id: {} + severity: {} + title: {} + min_mondoo_version: latest + vuln.cve: + fields: + cvss: {} + cvssVector: {} + id: {} + min_mondoo_version: latest + vuln.package: + fields: + name: {} + version: {} + min_mondoo_version: latest + vulnmgmt: + fields: + advisories: {} + cves: {} + lastAssessment: {} + packages: {} + min_mondoo_version: latest windows: fields: computerInfo: {} diff --git a/providers/os/resources/vulnmgmt.go b/providers/os/resources/vulnmgmt.go new file mode 100644 index 0000000000..9aa9458a96 --- /dev/null +++ b/providers/os/resources/vulnmgmt.go @@ -0,0 +1,193 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package resources + +import ( + "errors" + "time" + + "github.com/rs/zerolog/log" + "go.mondoo.com/cnquery/v9/llx" + "go.mondoo.com/cnquery/v9/providers-sdk/v1/resources" + "go.mondoo.com/cnquery/v9/providers-sdk/v1/upstream/gql" + "go.mondoo.com/cnquery/v9/providers/os/connection/shared" + mondoogql "go.mondoo.com/mondoo-go" +) + +func (v *mqlVulnmgmt) lastAssessment() (*time.Time, error) { + mcc := v.MqlRuntime.Upstream + if mcc == nil || mcc.ApiEndpoint == "" { + return nil, resources.MissingUpstreamError{} + } + + // get new gql client + mondooClient, err := gql.NewClient(mcc.UpstreamConfig, mcc.HttpClient) + if err != nil { + return nil, err + } + + if v.MqlRuntime.Upstream.AssetMrn == "" { + return nil, errors.New("no asset mrn available") + } + lastUpdate, err := mondooClient.LastAssessment(v.MqlRuntime.Upstream.AssetMrn) + if err != nil { + return nil, err + } + + log.Debug().Str("time", lastUpdate).Msg("search for package last update") + if lastUpdate == "" { + return nil, errors.New("no update time available") + } + + var lastUpdateTime *time.Time + if lastUpdate != "" { + parsedLastUpdateTime, err := time.Parse(time.RFC3339, lastUpdate) + if err != nil { + return nil, errors.New("could not parse last update time: " + lastUpdate) + } + lastUpdateTime = &parsedLastUpdateTime + } else { + lastUpdateTime = &llx.NeverFutureTime + } + + return lastUpdateTime, nil +} + +func (v *mqlVulnmgmt) cves() ([]interface{}, error) { + vulnReport, err := v.getReport() + if err != nil { + return nil, err + } + + mqlVulnCves := make([]interface{}, len(vulnReport.Cves)) + for i, c := range vulnReport.Cves { + mqlVulnCve, err := CreateResource(v.MqlRuntime, "vuln.cve", map[string]*llx.RawData{ + "id": llx.StringData(c.Id), + "cvss": llx.IntData(int64(c.CvssScore.Value)), + "cvssVector": llx.StringData(c.CvssScore.Vector), + }) + if err != nil { + return nil, err + } + mqlVulnCves[i] = mqlVulnCve + } + + return mqlVulnCves, nil +} + +func (v *mqlVulnmgmt) advisories() ([]interface{}, error) { + vulnReport, err := v.getReport() + if err != nil { + return nil, err + } + + mqlVulAdvisories := make([]interface{}, len(vulnReport.Advisories)) + for i, a := range vulnReport.Advisories { + mqlVulnAdvisory, err := CreateResource(v.MqlRuntime, "vuln.advisory", map[string]*llx.RawData{ + "id": llx.StringData(a.Id), + "title": llx.StringData(a.Title), + "description": llx.StringData(a.Description), + }) + if err != nil { + return nil, err + } + mqlVulAdvisories[i] = mqlVulnAdvisory + } + + return mqlVulAdvisories, nil +} + +func (v *mqlVulnmgmt) packages() ([]interface{}, error) { + vulnReport, err := v.getReport() + if err != nil { + return nil, err + } + + mqlVulnPackages := make([]interface{}, len(vulnReport.Packages)) + for i, p := range vulnReport.Packages { + mqlVulnPackage, err := CreateResource(v.MqlRuntime, "vuln.package", map[string]*llx.RawData{ + "name": llx.StringData(p.Name), + "version": llx.StringData(p.Version), + }) + if err != nil { + return nil, err + } + mqlVulnPackages[i] = mqlVulnPackage + } + + return mqlVulnPackages, nil +} + +func (v *mqlVulnmgmt) getReport() (*gql.VulnReport, error) { + mcc := v.MqlRuntime.Upstream + if mcc == nil || mcc.ApiEndpoint == "" { + return nil, resources.MissingUpstreamError{} + } + + // get new gql client + mondooClient, err := gql.NewClient(mcc.UpstreamConfig, mcc.HttpClient) + if err != nil { + return nil, err + } + + if v.MqlRuntime.Upstream.AssetMrn == "" { + log.Debug().Msg("no asset mrn available") + return v.getIncognitoReport(mondooClient) + } + // gqlVulnReport, err := GetVulnReport("//assets.api.mondoo.app/spaces/test-infallible-taussig-796596/assets/2YTpHJnJXnfmuBtQde2HQgWqX1n") + gqlVulnReport, err := mondooClient.GetVulnReport(v.MqlRuntime.Upstream.AssetMrn) + if err != nil { + return nil, err + } + + log.Debug().Interface("gqlReport", gqlVulnReport).Msg("search for asset vuln report") + if gqlVulnReport == nil { + return nil, errors.New("no vulnerability report available") + } + + return gqlVulnReport, nil +} + +func (v *mqlVulnmgmt) getIncognitoReport(mondooClient *gql.MondooClient) (*gql.VulnReport, error) { + // FIXCME: when we don't have a MRN, we need to: + // - creeate asset + // - create packages + // - get "incognito" vulnReport + // - procede as usual + + conn := v.MqlRuntime.Connection.(shared.Connection) + platform := conn.Asset().Platform + + pkgsRes, err := CreateResource(v.MqlRuntime, "packages", nil) + if err != nil { + return nil, err + } + pkgs := pkgsRes.(*mqlPackages) + pkgsList := pkgs.GetList().Data + + gqlPackages := make([]mondoogql.PackageInput, len(pkgsList)) + for i, p := range pkgs.GetList().Data { + mqlPkg := p.(*mqlPackage) + gqlPackages[i] = mondoogql.PackageInput{ + Name: mondoogql.String(mqlPkg.Name.Data), + Version: mondoogql.String(mqlPkg.Version.Data), + Arch: mondoogql.NewStringPtr(mondoogql.String(mqlPkg.Arch.Data)), + } + } + + gqlVulnReport, err := mondooClient.GetIncognitoVulnReport(mondoogql.PlatformInput{ + Name: mondoogql.NewStringPtr(mondoogql.String(platform.Name)), + Release: mondoogql.NewStringPtr(mondoogql.String(platform.Version)), + }, gqlPackages) + if err != nil { + return nil, err + } + + log.Debug().Interface("gqlReport", gqlVulnReport).Msg("search for asset vuln report") + if gqlVulnReport == nil { + return nil, errors.New("no vulnerability report available") + } + + return gqlVulnReport, nil +} diff --git a/providers/vsphere/resources/vsphere.lr b/providers/vsphere/resources/vsphere.lr index b1700f227e..33aab2518c 100644 --- a/providers/vsphere/resources/vsphere.lr +++ b/providers/vsphere/resources/vsphere.lr @@ -6,7 +6,7 @@ option go_package = "go.mondoo.com/cnquery/v9/providers/vsphere/resources" // vSphere asset resource extend asset { - // Full advisory & vulnerability report + // Will be deprecated; Full advisory & vulnerability report vulnerabilityReport() dict } diff --git a/shared/proto/cnquery.pb.go b/shared/proto/cnquery.pb.go index 366afb7ac6..05e7eed2d8 100644 --- a/shared/proto/cnquery.pb.go +++ b/shared/proto/cnquery.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: cnquery.proto package proto diff --git a/shared/proto/cnquery_grpc.pb.go b/shared/proto/cnquery_grpc.pb.go index da0ab77561..da271ffd99 100644 --- a/shared/proto/cnquery_grpc.pb.go +++ b/shared/proto/cnquery_grpc.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.4 +// - protoc v4.25.0 // source: cnquery.proto package proto