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][Dashboard Enhancements] Update Compliance Dashboard Data API to include Benchmarks Cloud Assets Data #170795

Closed
5 tasks done
Omolola-Akinleye opened this issue Nov 7, 2023 · 5 comments · Fixed by #171312
Assignees
Labels
8.12 candidate Feature:Cloud-Security Cloud Security related features Team:Cloud Security Cloud Security team related verified

Comments

@Omolola-Akinleye
Copy link
Contributor

Omolola-Akinleye commented Nov 7, 2023

Motivation

To see the Compliance Dashboard View with benchmarks UI, We will need to update the API that returns cloud assets by benchmark data so that I can view an updated and aggregated trend of scores by benchmark ID.

  1. Create score_by_benchmark_id aggregation
    The score_by_aggregration will query for the following fields:
  • aggregate by rule.benchmark.id and rule.benchmark.version
  • passed findings count
  • failed findings count
  • total findings
  1. Add score_by_benchmark_id_version aggregation into findings stats Benchmark score index. See x-pack/plugins/cloud_security_posture/server/tasks/findings_stats_task.ts
esClient.index({
      index: BENCHMARK_SCORE_INDEX_DEFAULT_NS,
      document: {
        policy_template: policyTemplateTrend.key,
        passed_findings: policyTemplateTrend.passed_findings.doc_count,
        failed_findings: policyTemplateTrend.failed_findings.doc_count,
        total_findings: policyTemplateTrend.total_findings.value,
        score_by_cluster_id: clustersStats,
        // add score_by_benchmark_id_version 
      },
    })
  1. The logs-cloud_security_posture.scores-default Index Response
    Sample Output
policy_template: policyTemplateTrend.key,
        passed_findings: policyTemplateTrend.passed_findings.doc_count,
        failed_findings: policyTemplateTrend.failed_findings.doc_count,
        total_findings: policyTemplateTrend.total_findings.value,
        score_by_cluster_id: clustersStats,
scores_by_benchmark_id: [
{
   'cis_aws': {
    'v1_3_0':{
      total_findings: 123,
      passed_findings: 100,
      failed_findings: 23
    }
 },
 'cis_gcp': {
   `v1_2_0`:{
    total_findings: 123,
    passed_findings: 100,
    failed_findings: 23
     },
  `v1_3_0`:{
    total_findings: 123,
    passed_findings: 100,
    failed_findings: 23
   }
},
// add benchmark ID records...
]
  1. Integrate score_by_benchmark_id trend aggregation with the benchmark aggregation results.
  2. Update the ComplianceDashboardData API endpoint/Contract to include a list of benchmarks
interface BenchmarkData {
  meta: {
    benchmarkId: CspFinding['rule']['benchmark']['id'];
    benchmarkVersion: CspFinding['rule']['benchmark']['version'];
    benchmarkName: CspFinding['rule']['benchmark']['name'];
    assetCount: number;
  };
  stats: Stats;
  groupedFindingsEvaluation: GroupedFindingsEvaluation[];
  trend: PostureTrend[];
}`


export interface ComplianceDashboardData {
  stats: Stats;
  groupedFindingsEvaluation: GroupedFindingsEvaluation[];
  clusters: Cluster[];
  trend: PostureTrend[];
  benchmark: BenchmarkData[]
}

Definition of Done

Preview Give feedback
  1. 4 of 4
    8.12 candidate Feature:Cloud-Security Team:Cloud Security verified
    Omolola-Akinleye

Epic - https://github.com/elastic/security-team/issues/7621

@Omolola-Akinleye Omolola-Akinleye self-assigned this Nov 7, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 7, 2023
@Omolola-Akinleye Omolola-Akinleye removed the needs-team Issues missing a team label label Nov 7, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 7, 2023
@Omolola-Akinleye Omolola-Akinleye removed the needs-team Issues missing a team label label Nov 7, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 7, 2023
@Omolola-Akinleye Omolola-Akinleye removed the needs-team Issues missing a team label label Nov 7, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 7, 2023
@Omolola-Akinleye Omolola-Akinleye added the Team:Cloud Security Cloud Security team related label Nov 7, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Nov 7, 2023
@kfirpeled
Copy link
Contributor

I do not think we have to change that much, if we already collect data per account, we can easily add the benchmark details of that account. As later on sum up all the data into a single row.

wdyt? would that work? And if so, it could be a much simpler solution.

@kfirpeled
Copy link
Contributor

Also, please take into account that both the benchmark id and the benchmark version matter here. As we discussed in the kick-off. It is being planned to be able to separate between benchmarks versions once we would support that.

@Omolola-Akinleye
Copy link
Contributor Author

Omolola-Akinleye commented Nov 8, 2023

I do not think we have to change that much, if we already collect data per account, we can easily add the benchmark details of that account. As later on sum up all the data into a single row.

wdyt? would that work? And if so, it could be a much simpler solution.

@kfirpeled Do you mind elaborating? Correct me if I'm wrong but I thought the Benchmark section Compliance scores will focus on collecting scores data per benchmark. If we continue collecting data per account and add benchmark id and rule version, wouldn't still see the same scores?

Here is example if i add benchmark id and version to each account.

"score_by_cluster_id": {
            "439975565995": {
              "total_findings": 1408,
              "passed_findings": 228,
              "failed_findings": 1180,
              "benchmark_id": 'cis_gcp',
              "benchmark_version: "1.3.0"
            },
            "704479110758": {
              "total_findings": 2000,
              "passed_findings": 1000,
              "failed_findings": 1000
               "benchmark_id": 'cis_aws',
              "benchmark_version: "1.5.0"
            },
             "704479110754": {
              "total_findings": 3000,
              "passed_findings":2000,
              "failed_findings": 1000
               "benchmark_id": 'cis_aws',
              "benchmark_version: "1.5.0"
            },
           "704479110757": {
              "total_findings": 3000,
              "passed_findings":2000,
              "failed_findings": 1000
               "benchmark_id": 'cis_aws',
              "benchmark_version: "1.6.0"
            }

vs a separate benchmark scores

"score_by_benchmark_id": {
            "cis_gcp_v1.2.0": {
              "total_findings": 1408,
              "passed_findings": 228,
              "failed_findings": 1180,
            },
            "cis_aws_v1.5.0": {
              "total_findings": 5000,
              "passed_findings": 3000
              "failed_findings": 2000
            },
             "cis_aws_v1.6.0": {
              "total_findings": 3000
              "passed_findings": 1000,
              "failed_findings":2000
            }```

@kfirpeled kfirpeled added the Feature:Cloud-Security Cloud Security related features label Nov 12, 2023
@Omolola-Akinleye Omolola-Akinleye linked a pull request Nov 15, 2023 that will close this issue
@animehart
Copy link
Contributor

Screenshot 2023-12-12 at 3 55 45 PM 2 Benchmarks with Same ID but Different version shows up as different element. Verified Screenshot 2023-12-12 at 3 01 10 PM Screenshot 2023-12-12 at 3 01 43 PM benchmark id, benchmark version, failed findings, passed findings, resource type are shown in the Benchmark response and can also be seen in the UI : Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.12 candidate Feature:Cloud-Security Cloud Security related features Team:Cloud Security Cloud Security team related verified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants