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

feat(Kafka): New Kafka AWS checks #4021

Merged
merged 25 commits into from
May 22, 2024

Conversation

puchy22
Copy link
Contributor

@puchy22 puchy22 commented May 16, 2024

Context

New checks to cover basic security best practices for Apache Kafka service managed by AWS.

  • kafka_cluster_enhanced_monitoring_enabled
  • kafka_cluster_in_transit_encryption_enabled
  • kafka_cluster_is_public
  • kafka_cluster_mutual_tls_authentication_enabled
  • kafka_cluster_unrestricted_access_disabled
  • kafka_cluster_encryption_at_rest_uses_cmk

Description

Added new checks with metadata and respective unit testing

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label May 16, 2024
@puchy22 puchy22 marked this pull request as ready for review May 20, 2024 09:12
@puchy22 puchy22 requested review from a team as code owners May 20, 2024 09:12
@github-actions github-actions bot added documentation provider/azure Issues/PRs related with the Azure provider provider/gcp Issues/PRs related with the Google Cloud Platform provider provider/kubernetes Issues/PRs related with the Kubernetes provider labels May 20, 2024
Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.33%. Comparing base (73b3484) to head (9eb9a23).
Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4021      +/-   ##
==========================================
- Coverage   86.51%   86.33%   -0.18%     
==========================================
  Files         776      789      +13     
  Lines       24163    24707     +544     
==========================================
+ Hits        20904    21332     +428     
- Misses       3259     3375     +116     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jfagoagas jfagoagas removed documentation provider/aws Issues/PRs related with the AWS provider provider/azure Issues/PRs related with the Azure provider labels May 20, 2024
@jfagoagas jfagoagas removed provider/gcp Issues/PRs related with the Google Cloud Platform provider provider/kubernetes Issues/PRs related with the Kubernetes provider labels May 20, 2024
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label May 20, 2024
report.resource_arn = arn_cluster
report.resource_tags = cluster.tags
report.status = "FAIL"
report.status_extended = f"Kafka cluster '{cluster.name}' does not have encryption at rest enabled with a CMK."
Copy link
Member

Choose a reason for hiding this comment

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

Would it be interesting to put a FAIL if it is encrypted with another type of key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is only two types of managers or AWS or CUSTOMER, if the manager is AWS it FAIL and if is CUSTOMER like is reflected on check it will PASS. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kms/client/describe_key.html

f"Kafka cluster '{cluster.name}' has enhanced monitoring enabled."
)

if cluster.enhanced_monitoring == "DEFAULT":
Copy link
Member

Choose a reason for hiding this comment

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

Which are the possible values here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'DEFAULT'|'PER_BROKER'|'PER_TOPIC_PER_BROKER'|'PER_TOPIC_PER_PARTITION'

I only put DEFAULT as FAIL because every other method is an enhance over default monitoring.

"RelatedUrl": "https://docs.aws.amazon.com/msk/latest/developerguide/msk-encryption.html",
"Remediation": {
"Code": {
"CLI": "",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"CLI": "",
"CLI": "https://docs.prowler.com/checks/aws/general-policies/bc_aws_general_32/#cli",

report.resource_arn = arn_cluster
report.resource_tags = cluster.tags
report.status = "FAIL"
report.status_extended = f"Kafka cluster '{cluster.name}' does not have encryption in transit enabled"
Copy link
Member

Choose a reason for hiding this comment

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

Please add a final dot in all the statuses extended.

report.resource_tags = cluster.tags
report.status = "FAIL"
report.status_extended = (
f"Kafka cluster '{cluster.name}' does not have public access disabled."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
f"Kafka cluster '{cluster.name}' does not have public access disabled."
f"Kafka cluster '{cluster.name}' is publicly accessible."

{
"Provider": "aws",
"CheckID": "kafka_cluster_unrestricted_access_disabled",
"CheckTitle": "Ensure Kafka Cluster is not publicly accessible",
Copy link
Member

Choose a reason for hiding this comment

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

Is not this confusing with the check kafka_cluster_is_public?

@sergargar sergargar self-assigned this May 20, 2024
sergargar
sergargar previously approved these changes May 21, 2024
Copy link
Member

@sergargar sergargar left a comment

Choose a reason for hiding this comment

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

Good job @puchy22 !!

@sergargar sergargar merged commit 0e71756 into prowler-cloud:master May 22, 2024
10 of 11 checks passed
@puchy22 puchy22 deleted the kafka_aws_checks branch May 31, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants