diff --git a/src/go.mod b/src/go.mod index 0b05db11..a304d386 100644 --- a/src/go.mod +++ b/src/go.mod @@ -23,15 +23,15 @@ require ( github.com/nxadm/tail v1.4.8 github.com/oriser/regroup v0.0.0-20210730155327-fca8d7531263 github.com/otterize/go-procnet v0.1.1 - github.com/otterize/intents-operator/src v0.0.0-20240512111236-ce49ec0fb292 + github.com/otterize/intents-operator/src v0.0.0-20240521082058-1af3a2354a2d github.com/otterize/nilable v0.0.0-20240410132629-f242bb6f056f github.com/prometheus/client_golang v1.18.0 github.com/samber/lo v1.33.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/viper v1.13.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/suessflorian/gqlfetch v0.6.0 - github.com/vektah/gqlparser/v2 v2.5.11 + github.com/vektah/gqlparser/v2 v2.5.12 go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.41.0 go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.41.0 @@ -52,7 +52,7 @@ require ( require ( github.com/agnivade/levenshtein v1.1.1 // indirect - github.com/alexflint/go-arg v1.4.3 // indirect + github.com/alexflint/go-arg v1.5.0 // indirect github.com/alexflint/go-scalar v1.2.0 // indirect github.com/aws/aws-sdk-go-v2 v1.26.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.9 // indirect diff --git a/src/go.sum b/src/go.sum index a747810b..f3d40d18 100644 --- a/src/go.sum +++ b/src/go.sum @@ -47,9 +47,8 @@ github.com/Shopify/sarama v1.34.1/go.mod h1:NZSNswsnStpq8TUdFaqnpXm2Do6KRzTIjdBd github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= -github.com/alexflint/go-arg v1.4.3 h1:9rwwEBpMXfKQKceuZfYcwuc/7YY7tWJbFsgG5cAU/uo= -github.com/alexflint/go-arg v1.4.3/go.mod h1:3PZ/wp/8HuqRZMUUgu7I+e1qcpUbvmS258mRXkFH4IA= -github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= +github.com/alexflint/go-arg v1.5.0 h1:rwMKGiaQuRbXfZNyRUvIfke63QvOBt1/QTshlGQHohM= +github.com/alexflint/go-arg v1.5.0/go.mod h1:A7vTJzvjoaSTypg4biM5uYNTkJ27SkNTArtYXnlqVO8= github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw= github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= github.com/amit7itz/goset v1.2.1 h1:usFphDJfZgwnqfbKT8zI+2juuOgsZ6O8UA7NMRUVG7s= @@ -343,8 +342,8 @@ github.com/oriser/regroup v0.0.0-20210730155327-fca8d7531263 h1:Qd1Ml+uEhpesT8Og github.com/oriser/regroup v0.0.0-20210730155327-fca8d7531263/go.mod h1:odkMeLkWS8G6+WP2z3Pn2vkzhPSvBtFhAUYTKXAtZMQ= github.com/otterize/go-procnet v0.1.1 h1:5vRwX35VrsWcy2uP05sA4PmwpRoAu2L4vMJou4og8Kk= github.com/otterize/go-procnet v0.1.1/go.mod h1:WEm282HzrSVBZg6DX2fNB4dpVHBPTCjzHWvqOfauV+Q= -github.com/otterize/intents-operator/src v0.0.0-20240512111236-ce49ec0fb292 h1:Vo5Nlm9Sq0Uqe6zgVd7EnRLUoV1G5nzk/RDgmaab82Q= -github.com/otterize/intents-operator/src v0.0.0-20240512111236-ce49ec0fb292/go.mod h1:FnfWnqyeahR1hwn+9gJ7/TJyOjFfg6QQdVTSDA1Ll/Y= +github.com/otterize/intents-operator/src v0.0.0-20240521082058-1af3a2354a2d h1:PEvLC1HC0YJYhlTj7ecQ668fiiNrK0rvnxpEpndjfgg= +github.com/otterize/intents-operator/src v0.0.0-20240521082058-1af3a2354a2d/go.mod h1:7vDL6/NAo7AobUGqDGU/277xGyb0KTRQoqRjoouhh44= github.com/otterize/lox v0.0.0-20220525164329-9ca2bf91c3dd h1:7Sb95VrtAPb9m2ewtqLnX1oeKQy03dt7yr6F/hP7Htg= github.com/otterize/lox v0.0.0-20220525164329-9ca2bf91c3dd/go.mod h1:RXvgymN8MxiELFkmGHzJ23KJU2ObVsNsNSM80/HO8qQ= github.com/otterize/nilable v0.0.0-20240410132629-f242bb6f056f h1:gv92189CW53A+Y0UQ550zr6RfCBYqvYJ8oq6Jll1YqQ= @@ -410,8 +409,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/suessflorian/gqlfetch v0.6.0 h1:6e+Oe9mWbbjSmJez+6I4tyskQMy6lQlFFQYj64gaCQU= @@ -426,8 +425,8 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/vektah/gqlparser v1.3.1 h1:8b0IcD3qZKWJQHSzynbDlrtP3IxVydZ2DZepCGofqfU= github.com/vektah/gqlparser v1.3.1/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= -github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= -github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vektah/gqlparser/v2 v2.5.12 h1:COMhVVnql6RoaF7+aTBWiTADdpLGyZWU3K/NwW0ph98= +github.com/vektah/gqlparser/v2 v2.5.12/go.mod h1:WQQjFc+I1YIzoPvZBhUQX7waZgg3pMLi0r8KymvAE2w= github.com/vishalkuo/bimap v0.0.0-20220726225509-e0b4f20de28b h1:Wrh+B5ZP52L9v5h9h3owZTzgotdbBd9sfirUbRmCWD4= github.com/vishalkuo/bimap v0.0.0-20220726225509-e0b4f20de28b/go.mod h1:dxXQNHjw3hAY1z8izMtjimf/IjtT/o7ZZezj7XI8Vy0= github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= diff --git a/src/mapper/pkg/cloudclient/schema.graphql b/src/mapper/pkg/cloudclient/schema.graphql index 44a0239b..f62c33dc 100644 --- a/src/mapper/pkg/cloudclient/schema.graphql +++ b/src/mapper/pkg/cloudclient/schema.graphql @@ -323,7 +323,12 @@ enum ComponentType { NETWORK_MAPPER } -type CreateGithubIntegrationResponse { +type CreateGitHubIntegrationResponse { + integration: Integration! + nextURL: String! +} + +type CreateGitLabIntegrationResponse { integration: Integration! nextURL: String! } @@ -482,6 +487,7 @@ enum EventType { INTENTS_DISCOVERED_CAPTURE INTENTS_DISCOVERED_KAFKA INTENTS_DISCOVERED_ISTIO + INTENTS_DISCOVERED_TCP MAPPER_EXPORT MAPPER_VISUALIZE KAFKA_SERVER_CONFIG_APPLIED @@ -550,22 +556,13 @@ type GCPResource { resource: String! } -type GitHubAccessGraphFilter { - environmentIds: [ID!] - clusterIds: [ID!] - namespaceIds: [ID!] - serviceIds: [ID!] - serviceFilterType: IDFilterOperators - lastSeenAfter: Time -} - type GitHubRepoFilterPair { - filter: GitHubAccessGraphFilter! + filter: IntegrationAccessGraphFilter! repoInfo: GitHubRepoInfo! } input GitHubRepoFilterPairInput { - filter: InputGitHubAccessGraphFilter! + filter: InputIntegrationAccessGraphFilter! repoInfo: GitHubRepoInfoInput! } @@ -591,6 +588,38 @@ input GitHubSettingsInput { repoFilterPairs: [GitHubRepoFilterPairInput!]! } +type GitLabRepoFilterPair { + filter: IntegrationAccessGraphFilter! + repoInfo: GitLabRepoInfo! +} + +input GitLabRepoFilterPairInput { + filter: InputIntegrationAccessGraphFilter! + repoInfo: GitLabRepoInfoInput! +} + +type GitLabRepoInfo { + projectPath: String! + baseBranch: String! + intentsPath: String! +} + +input GitLabRepoInfoInput { + projectPath: String! + baseBranch: String! + intentsPath: String! +} + +type GitLabSettings { + isActive: Boolean! + repoFilterPairs: [GitLabRepoFilterPair!]! +} + +input GitLabSettingsInput { + isActive: Boolean! + repoFilterPairs: [GitLabRepoFilterPairInput!]! +} + type HTTPConfig { path: String! methods: [HTTPMethod!] @@ -650,7 +679,12 @@ input InputAccessGraphFilter { lastSeen: InputTimeFilterValue } -input InputGitHubAccessGraphFilter { +input InputIDFilterValue { + value: [ID!]! + operator: IDFilterOperators! +} + +input InputIntegrationAccessGraphFilter { environmentIds: [ID!] clusterIds: [ID!] serviceIds: [ID!] @@ -658,11 +692,6 @@ input InputGitHubAccessGraphFilter { namespaceIds: [ID!] } -input InputIDFilterValue { - value: [ID!]! - operator: IDFilterOperators! -} - input InputTimeFilterValue { value: Time! operator: TimeFilterOperators! @@ -683,11 +712,21 @@ type Integration { awsInfo: AWSInfo gcpInfo: GCPInfo azureInfo: AzureInfo - githubSettings: GitHubSettings + gitHubSettings: GitHubSettings + gitLabSettings: GitLabSettings organizationId: String! status: IntegrationStatus } +type IntegrationAccessGraphFilter { + environmentIds: [ID!] + clusterIds: [ID!] + namespaceIds: [ID!] + serviceIds: [ID!] + serviceFilterType: IDFilterOperators + lastSeenAfter: Time +} + type IntegrationComponents { intentsOperator: IntentsOperatorComponent! credentialsOperator: CredentialsOperatorComponent! @@ -725,6 +764,7 @@ enum IntegrationType { AWS GCP GITHUB + GITLAB AZURE } @@ -846,6 +886,11 @@ enum InviteStatus { ACCEPTED } +input IpBlockInput { + cidr: String! + except: [String!] +} + input IstioStatusInput { serviceAccountName: String! isServiceAccountShared: Boolean! @@ -1046,21 +1091,32 @@ type Mutation { name: String azureIntegration: AzureInfoInput ): Integration -"""Create a new Github integration""" - createGithubIntegration( +"""Create a new GitHub integration""" + createGitHubIntegration( name: String! - githubSettings: GitHubSettingsInput! - ): CreateGithubIntegrationResponse + gitHubSettings: GitHubSettingsInput! + ): CreateGitHubIntegrationResponse +"""Create a new GitLab integration""" + createGitLabIntegration( + name: String! + gitLabSettings: GitLabSettingsInput! + ): CreateGitLabIntegrationResponse """Create a new GCP integration""" createGCPIntegration( name: String! gcpIntegration: GCPInfoInput! ): Integration -"""Update Github integration""" - updateGithubIntegration( +"""Update GitHub integration""" + updateGitHubIntegration( + id: ID! + name: String! + gitHubSettings: GitHubSettingsInput! + ): Integration +"""Update GitLab integration""" + updateGitLabIntegration( id: ID! name: String! - githubSettings: GitHubSettingsInput! + gitLabSettings: GitLabSettingsInput! ): Integration """Update AWS integration""" updateAWSIntegration( @@ -1157,6 +1213,7 @@ type Mutation { id: ID! name: String imageURL: String + settings: OrganizationSettingsInput ): Organization! """Remove user from organization""" removeUserFromOrganization( @@ -1167,6 +1224,11 @@ type Mutation { namespace: String! services: [ProtectedServiceInput!]! ): Boolean! +"""Update service""" + updateService( + id: ID! + tags: [String!] + ): Service! sendTelemetries( telemetries: [TelemetryInput!]! ): Boolean! @@ -1232,17 +1294,40 @@ enum NetworkPoliciesStep { COMPLETED } +input NetworkPolicyEgressRuleInput { + to: [PeerInput!]! +} + input NetworkPolicyInput { namespace: String! name: String! serverName: String! externalNetworkTrafficPolicy: Boolean! + spec: NetworkPolicySpecInput +} + +input NetworkPolicySpecInput { + egress: [NetworkPolicyEgressRuleInput!]! } type Organization { id: ID! - name: String + name: String! imageURL: String + settings: OrganizationSettings + created: Time! +} + +type OrganizationSettings { + domains: [String] +} + +input OrganizationSettingsInput { + domains: [String] +} + +input PeerInput { + ipBlock: IpBlockInput! } input ProtectedServiceInput { @@ -1438,6 +1523,7 @@ type ServerProtectionStatuses { type Service { id: ID! name: String! + tags: [String!] namespace: Namespace environment: Environment! """If service is Kafka, its KafkaServerConfig.""" @@ -1474,6 +1560,13 @@ type ServiceClientIntents { asServer: ClientIntentsFiles } +enum ServiceTags { + PCI + PII + HIPAA + SENSITIVE +} + enum ServiceType { NODE_GROUP PREFIX_GROUP diff --git a/src/mapper/pkg/resolvers/schema.helpers.resolvers.go b/src/mapper/pkg/resolvers/schema.helpers.resolvers.go index 6cd19e37..c5af16e1 100644 --- a/src/mapper/pkg/resolvers/schema.helpers.resolvers.go +++ b/src/mapper/pkg/resolvers/schema.helpers.resolvers.go @@ -54,6 +54,8 @@ func updateTelemetriesCounters(sourceType SourceType, intent model.Intent) { telemetrysender.IncrementUniqueCounterNetworkMapper(telemetriesgql.EventTypeIntentsDiscoveredKafka, intentKey) } else if sourceType == SourceTypeIstio { telemetrysender.IncrementUniqueCounterNetworkMapper(telemetriesgql.EventTypeIntentsDiscoveredIstio, intentKey) + } else if sourceType == SourceTypeTCPScan { + telemetrysender.IncrementUniqueCounterNetworkMapper(telemetriesgql.EventTypeIntentsDiscoveredTcp, intentKey) } } @@ -484,6 +486,7 @@ func (r *Resolver) handleTCPResult(ctx context.Context, srcIdentity model.Otteri dest.LastSeen, intent, ) + updateTelemetriesCounters(SourceTypeTCPScan, intent) } func (r *Resolver) handleReportCaptureResults(ctx context.Context, results model.CaptureResults) error {