Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Security] Backport 1.8.1 #9433

Conversation

opauloh
Copy link
Contributor

@opauloh opauloh commented Mar 22, 2024

Summary

This PR adds a backport version to cloud_security_posture package 1.8.*, it includes the following changes:

  • Fixed Pipeline Ingest Error due to missing cluster_id used in the copy_from;
    Reasoning: Pipeline error were preventing the following pipelines from being executed + generating unnecessary data

  • Sets placeholder value for azure account.id when it is not available;

  • Sets placeholder value for gcp account.id when it is not available;

Reasoning: GCP and Azure integrations can push data belonging to a CSPM Organization where the cloud.account.id field can be missing, but The Cloud Security features in Kibana 8.13 require the field cloud.account.id to be always available in the Cloud Security Posture indices.

  • Removes cloud.account.name when it is empty;

Reasoning: GCP integration can push data belonging to a CSPM Organization where the cloud.account.name is empty when it should be missing.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • No more gaps in Kibana when filtering cloud.provider : gcp and Grouping by Cloud account
image
  • No records with empty cloud.account.name
image
  • No records with missing or empty cloud.account.id or
image image

How to test this PR locally

Follow the guide describe here to test this PR locally.

To collect the necessary data you can execute the following Reindex command in the dev tools (The pipeline is the important part!), point host and credentials to one of the long-running environments

POST _reindex?wait_for_completion=true
{
  "conflicts": "proceed", 
  "source": {
     "remote": {
      "host": "${ES_REMOTE_HOST}",
      "username": "${ES_REMOTE_USER}",
      "password": "${ES_REMOTE_PASS}"
    },
    "index": "logs-cloud_security_posture.findings_latest-default",
    "query": {
      "match_all": {}  
    }
  },
  "dest": {
    "op_type": "create",
    "index": "logs-cloud_security_posture.findings_latest-default",
    "pipeline": "logs-cloud_security_posture.findings-1.8.1"
  }
}

Related issues

Screenshots

image

Pipeline

[
  {
    "set": {
      "field": "ecs.version",
      "value": "8.6.0"
    }
  },
  {
    "set": {
      "field": "rule.benchmark.posture_type",
      "value": "kspm",
      "description": "Backward compatibility cloudbeat version < 8.7",
      "if": "ctx.rule?.benchmark?.posture_type == null"
    }
  },
  {
    "set": {
      "field": "orchestrator.cluster.id",
      "copy_from": "cluster_id",
      "description": "Backward compatibility cloudbeat version < 8.8",
      "if": "ctx.cluster_id != null && ctx.orchestrator?.cluster?.id == null"
    }
  },
  {
    "set": {
      "field": "cloud.account.id",
      "value": "azure",
      "description": "Sets placeholder value for azure account id when it is not available",
      "if": "(ctx.cloud?.account?.id == null || ctx.cloud?.account?.id == '') && ctx.cloud?.provider == 'azure'"
    }
  },
  {
    "set": {
      "field": "cloud.account.id",
      "value": "gcp",
      "description": "Sets placeholder value for gcp account id when it is not available",
      "if": "(ctx.cloud?.account?.id == null || ctx.cloud?.account?.id == '' ) && ctx.cloud?.provider == 'gcp'"
    }
  },
  {
    "remove": {
      "field": "cloud.account.name",
      "ignore_missing": true,
      "description": "Removes cloud.account.name when it is empty",
      "if": "ctx.cloud?.account?.name == ''"
    }
  },
  {
    "pipeline": {
      "name": "global@custom",
      "ignore_missing_pipeline": true,
      "description": "[Fleet] Global pipeline for all data streams"
    }
  },
  {
    "pipeline": {
      "name": "logs@custom",
      "ignore_missing_pipeline": true,
      "description": "[Fleet] Pipeline for all data streams of type `logs`"
    }
  },
  {
    "pipeline": {
      "name": "logs-cloud_security_posture.integration@custom",
      "ignore_missing_pipeline": true,
      "description": "[Fleet] Pipeline for all data streams of type `logs` defined by the `cloud_security_posture` integration"
    }
  },
  {
    "pipeline": {
      "name": "logs-cloud_security_posture.findings@custom",
      "ignore_missing_pipeline": true,
      "description": "[Fleet] Pipeline for the `cloud_security_posture.findings` dataset"
    }
  }
]

Remove cloud.account.name null fields, Set cloud.account.id for azure and gcp when not available, fix cluster_id missing pipeline error
@opauloh opauloh added bug Something isn't working, use only for issues Team:Cloud Security Label for the Cloud Security team [elastic/cloud-security-posture] labels Mar 22, 2024
@opauloh opauloh requested a review from a team as a code owner March 22, 2024 21:24
@opauloh opauloh changed the title Add .buildkite and .ci to backport branch: backport-cloud_security_po… [Cloud Security] Backport 1.8.1 Mar 22, 2024
@elasticmachine
Copy link

💚 Build Succeeded

Copy link

Quality Gate passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No Coverage information No data about Coverage
No Duplication information No data about Duplication

See analysis details on SonarQube

Copy link
Contributor

@kfirpeled kfirpeled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

field: cloud.account.id
value: 'gcp'
description: 'Sets placeholder value for gcp account id when it is not available'
if: (ctx.cloud?.account?.id == null || ctx.cloud?.account?.id == '' ) && ctx.cloud?.provider == 'gcp'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't mention AWS here and in the description, can you remind me why the problem does not apply to AWS documents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CSPM AWS, Benchmark Rules at the organization level that don't have an account associated with it are going to fallback to the Management Account. And as a management account is a pre-requirement to create an organization this means our native CSPM AWS will always have a cloud.account.id .

Pinging @oren-zohar to confirm that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This quite a deep context one need to know to understand why we don't have this check for AWS. if we rely heavily on this field, I'd add this check for aws anyway, even if we are sure now that it can't be missing

if: ctx.cluster_id != null && ctx.orchestrator?.cluster?.id == null
- set:
field: cloud.account.id
value: 'azure'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this value goes directly to the UX, does it make sense to have something more elaborate as a value? Eg. smth like global-azure-findings or non-organisation-specific-findings. The values I came up with are just for example, maybe it worth consulting with the product

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, however, as we are short in time as public release targets for tomorrow I am merging this patch as we would not have the time to elaborate on that properly, but we can discuss that async and patch another integration version if needed.

cc @kfirpeled

@opauloh opauloh merged commit adec55d into elastic:backport-cloud_security_posture-1.8 Mar 26, 2024
5 checks passed
@opauloh opauloh deleted the backport-cloud_security_posture-1.8 branch March 26, 2024 05:04
@elasticmachine
Copy link

Package cloud_security_posture - 1.8.1 containing this change is available at https://epr.elastic.co/search?package=cloud_security_posture

@andrewkroh andrewkroh added the Integration:cloud_security_posture Security Posture Management label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, use only for issues Integration:cloud_security_posture Security Posture Management Team:Cloud Security Label for the Cloud Security team [elastic/cloud-security-posture]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants