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(networkfirewall): add new check networkfirewall_policy_rule_group_associated #5225

Conversation

HugoPBrito
Copy link
Member

Context

Amazon Network Firewall policies are integral to securing network configurations in AWS environments. A firewall policy specifies how traffic is monitored and managed, controlling how data packets flow into and out of Amazon Virtual Private Cloud (VPC). Without associated rule groups, the policy cannot filter traffic or handle threats effectively, which may leave the network open to unauthorized access or data breaches.

Description

This check ensures that each Network Firewall policy has at least one stateful or stateless rule group associated with it. Rule groups are essential components of the firewall policy, used to define packet filtering and traffic flow rules. If no rule groups are associated, the firewall cannot enforce any security protocols, rendering it ineffective. Having properly configured rule groups ensures that traffic is monitored, filtered, and handled according to security standards, safeguarding your VPC from unauthorized access or malicious activities.

Checklist

License

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

@HugoPBrito HugoPBrito requested review from a team as code owners September 27, 2024 09:55
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.11%. Comparing base (9d4fa55) to head (19fa8ed).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
...ervices/networkfirewall/networkfirewall_service.py 79.16% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5225      +/-   ##
==========================================
+ Coverage   89.09%   89.11%   +0.01%     
==========================================
  Files         987      990       +3     
  Lines       30310    30435     +125     
==========================================
+ Hits        27006    27121     +115     
- Misses       3304     3314      +10     

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

Comment on lines 18 to 19
print(firewall.stateless_rule_groups)
print(firewall.stateful_rule_groups)
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
print(firewall.stateless_rule_groups)
print(firewall.stateful_rule_groups)

Comment on lines 21 to 22
firewall.stateful_rule_groups == []
and firewall.stateless_rule_groups == []
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
firewall.stateful_rule_groups == []
and firewall.stateless_rule_groups == []
not firewall.stateful_rule_groups
and not firewall.stateless_rule_groups

)
]
except Exception as error:
logger.error(
Copy link
Member

Choose a reason for hiding this comment

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

Use the logger pattern, please.

Comment on lines 14 to 15
self._describe_firewall()
self._describe_firewall_policy()
Copy link
Member

Choose a reason for hiding this comment

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

Can you use threading call for both functions, please?

"Software and Configuration Checks/Industry and Regulatory Standards/NIST 800-53"
],
"ServiceName": "Network Firewall",
"SubServiceName": "Firewall Policy",
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
"SubServiceName": "Firewall Policy",
"SubServiceName": "",

"CheckType": [
"Software and Configuration Checks/Industry and Regulatory Standards/NIST 800-53"
],
"ServiceName": "Network Firewall",
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
"ServiceName": "Network Firewall",
"ServiceName": "network-firewall",

"RelatedUrl": "https://docs.aws.amazon.com/network-firewall/latest/developerguide/rule-groups.html",
"Remediation": {
"Code": {
"CLI": "aws network-firewall update-firewall-policy --firewall-policy-arn <policy-arn> --rule-group-arn <rule-group-arn>",
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": "aws network-firewall update-firewall-policy --firewall-policy-arn <policy-arn> --rule-group-arn <rule-group-arn>",
"CLI": "",

Since this cannot be done with only one single command.

@sergargar sergargar merged commit 8805230 into master Sep 30, 2024
10 of 11 checks passed
@sergargar sergargar deleted the PRWLR-4557-ensure-network-firewall-policies-have-at-least-one-rule-group-associated branch September 30, 2024 16:04
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.

2 participants