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

aws.securityhub_findings: Improve support for CDR #11158

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

kcreddy
Copy link
Contributor

@kcreddy kcreddy commented Sep 17, 2024

Proposed commit message

Improve support for CDR.

  • Update securityhub_findings data stream's ingest pipeline to support CDR.
  • Update securityhub_findings data stream's mappings according to the new fields.
  • Update Findings Summary dashboard with 3 new visualisations using newly added fields.

Fixes: #11040

Note to reviewers: Please DM me for access to the document(s) linked in the issue, it might help in the review.

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.

How to test this PR locally

cd packages/aws && elastic-package stack down && elastic-package build && elastic-package stack up --version=8.14.0 -d -v && eval "$(elastic-package stack shellinit)" && elastic-package test pipeline --generate -v --data-streams=securityhub_findings

Related issues

Screenshots

Screenshot 2024-09-23 at 5 47 15 PM

@kcreddy kcreddy added enhancement New feature or request Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations] labels Sep 17, 2024
@kcreddy kcreddy self-assigned this Sep 17, 2024
@elastic-vault-github-plugin-prod
Copy link

elastic-vault-github-plugin-prod bot commented Sep 17, 2024

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@kcreddy kcreddy marked this pull request as ready for review September 23, 2024 12:24
@kcreddy kcreddy requested review from a team as code owners September 23, 2024 12:24
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@andrewkroh andrewkroh added the dashboard Relates to a Kibana dashboard bug, enhancement, or modification. label Sep 23, 2024
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

The issue refers to a document upload, but I cannot find it. So I cannot see whether this follows what has been designed. Is there a reason this is not a public document in the issue?

- set:
field: rule.remediation
tag: set_rule_remediation
value: '{{{aws.securityhub_findings.remediation.recommendation.text}}} \n {{{aws.securityhub_findings.remediation.recommendation.url}}}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this \n intentional? It won't be expanded since we are in single quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I've modified it in f898ffc to make it similar to Wiz.

"remediation": "Follow the step below to ensure that each [Pod](https://kubernetes.io/docs/concepts/workloads/pods) should runs containers with allowed additional capabilities: \r\n* The following capabilities are not allowed : {{removeUnnecessaryCapabilities}} . \r\n* `securityContext.capabilities.drop` key is set to `ALL`. \r\n",

The field is a markdown and should be expanded. Example:
Screenshot 2024-09-24 at 3 20 59 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxcold, does this make sense to use \r\n as delimiter to append remediation.text and remediation.url to derive the field rule.remediation? The outcome is similar to Wiz.

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

I'm not completely comfortable approving this based on a set of linked proposals that don't have a conclusion (there are items that appear to be still under discussion) and are spread across those documents. IMO a summary acceptance document should be prepared and made public so that users can see what the intended behaviour is, and so that reviewers and maintainers can have truth to base future work on.

Comment on lines 1596 to 1597
String[] tokenList = res.Id.splitOnToken("/");
res_name = tokenList[tokenList.length - 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there is no /, !bang. Is there guaranteed to be one?

Copy link
Contributor Author

@kcreddy kcreddy Sep 25, 2024

Choose a reason for hiding this comment

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

As per https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html, it is possible that / may not occur. Also, for S3 object, taking the last / would only provide incomplete object prefix.
Hence, I updated to split on : and take the last :. This would mean previous i-0e2ede89308a594d7 would now be instance/i-0e2ede89308a594d7, i.e., an additional <resource-type>/ will be added as prefix. Is this tradeoff okay?
Note that this case of deriving resource.name by / or : will only happen if the .Name is not present in Details.

Copy link
Contributor

@CohenIdo CohenIdo left a comment

Choose a reason for hiding this comment

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

It seems that some fields (host.name, rule.author) that were mapped here are missing.

@andrewkroh
Copy link
Member

andrewkroh commented Sep 25, 2024

IMO a summary acceptance document should be prepared and made public so that users can see what the intended behaviour is, and so that reviewers and maintainers can have truth to base future work on.

++

Logistically, I think a markdown doc in https://github.com/elastic/integrations/tree/main/docs would be ideal for integration developers. It's public, version controlled, and close to the integrations that will implement its guidance. @maxcold, WDYT?

@kcreddy
Copy link
Contributor Author

kcreddy commented Sep 25, 2024

It seems that some fields (host.name, rule.author) that were mapped here are missing.

@CohenIdo, The host.name was missed. Actually, the host.name is infact not available when resource is an AwsEc2Instance, but it is present for AwsEcsContainer. I added accordingly.

Also, I missed adding host.ip for AwsEc2Instance which is also added now.
Commit 0897d24 has both changes.

As per clarification from @maxcold, I skipped rule.author

@kcreddy
Copy link
Contributor Author

kcreddy commented Sep 26, 2024

IMO a summary acceptance document should be prepared and made public so that users can see what the intended behaviour is, and so that reviewers and maintainers can have truth to base future work on.

++

Logistically, I think a markdown doc in https://github.com/elastic/integrations/tree/main/docs would be ideal for integration developers. It's public, version controlled, and close to the integrations that will implement its guidance.

Regards to #11158 (review):

@maxcold / @CohenIdo, could you make the guide Adapting data stream to Cloud Security in Kibana publicly available in https://github.com/elastic/integrations/tree/main/docs?

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
62.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @kcreddy

@CohenIdo CohenIdo self-requested a review September 26, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard Relates to a Kibana dashboard bug, enhancement, or modification. enhancement New feature or request Integration:aws AWS Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws.securityhub_findings: Implement mappings for Cloud Security Workflow
5 participants