You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code Duplication The functions validate_expected_network_neighborhood_list and validate_expected_network_neighborhood are very similar to their network_neighbors counterparts. Consider refactoring to reduce duplication.
Repeated Code Multiple instances of similar code blocks for validating network neighborhood and generated network policies. Consider extracting this into a reusable function.
-raise ValueError("expected entry is not valid, it should contain either dns, ipAddress or namespaceSelector/podSelector")+class InvalidNetworkEntryError(ValueError):+ pass+raise InvalidNetworkEntryError("Expected entry is not valid. It should contain either dns, ipAddress, or namespaceSelector/podSelector.")+
Apply this suggestion
Suggestion importance[1-10]: 8
Why: Defining a specific exception class improves error handling by providing more precise and informative error messages, which is beneficial for debugging and maintenance.
8
Add example values for ingress and egress fields in the NetworkNeighborhood template
Consider adding example values for the ingress and egress fields to provide a more comprehensive template for users.
Why: Providing example values for ingress and egress fields enhances the template's usability and helps users understand how to configure these fields effectively.
8
Add a "dnsNames" field to internal egress rules for consistency and potential future use
Consider adding a "dnsNames" field to the internal egress rules, similar to the external ones. This can help in cases where DNS resolution is needed for internal services.
Why: Adding a "dnsNames" field to internal egress rules can improve consistency and future-proof the configuration for potential DNS resolution needs, although it is not immediately necessary.
7
Maintainability
Replace hardcoded sleep duration multiplier with a constant
Consider using a constant or configuration variable for the sleep duration instead of hardcoding the value 6. This would make the code more maintainable and easier to adjust in the future.
-TestUtil.sleep(6 * int(update_period_in_seconds), "wait for node-agent update period", "info")+SLEEP_MULTIPLIER = 6+TestUtil.sleep(SLEEP_MULTIPLIER * int(update_period_in_seconds), "wait for node-agent update period", "info")
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Using a constant for the sleep duration multiplier improves maintainability by making it easier to adjust the value in the future without searching through the code.
7
Best practice
Use a more descriptive variable name for better code readability
Consider using a more descriptive variable name for nn_json. Something like network_neighborhood_json would be clearer and more self-explanatory.
-# TODO rewrite to use networkneighborhood for the graph-# self.validate_expected_network_neighborhood(namespace=namespace, actual_network_neighborhood=graph, expected_network_neighborhood=expected_network_neighborhood_list[i])+self.validate_expected_network_neighborhood(namespace=namespace, actual_network_neighborhood=graph, expected_network_neighborhood=expected_network_neighborhood_list[i])
Apply this suggestion
Suggestion importance[1-10]: 5
Why: Addressing TODO comments is important to prevent technical debt, but the suggestion assumes the implementation is straightforward without additional context.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
enhancement, tests
Description
NetworkNeighbors
withNetworkNeighborhood
across multiple files.network neighborhood
terminology.Changes walkthrough 📝
8 files
ks_vuln_scan_tests.py
Update variable name to neighborhood_map
configurations/system/tests_cases/ks_vuln_scan_tests.py
neighbors_map
toneighborhood_map
.network_policy_tests.py
Rename network neighbors to network neighborhood
configurations/system/tests_cases/network_policy_tests.py
expected_network_neighbors
toexpected_network_neighborhood
.kubectl_wrapper.py
Update kind name in kubectl wrapper
infrastructure/kubectl_wrapper.py
NetworkNeighbors
toNetworkNeighborhood
inkubescape_namespaced_kinds
.statics.py
Update plural form for network neighborhood
systest_utils/statics.py
NETWORK_NEIGHBOR_PLURAL
tonetworkneighborhoods
.base_network_policy.py
Refactor network neighbors to network neighborhood
tests_scripts/helm/base_network_policy.py
network_neighbors
tonetwork_neighborhood
.base_k8s.py
Rename method for network neighborhood retrieval
tests_scripts/kubernetes/base_k8s.py
get_network_neighbors
toget_network_neighborhood
.networkneighborhood.yaml
Update CRD kind and structure for network neighborhood
configurations/kubescape-crds/supported/networkneighborhood.yaml
NetworkNeighbors
toNetworkNeighborhood
.containers
field withingress
andegress
.busybox-known-server.json
Update JSON structure for network neighborhood
configurations/network-policy/expected-network-neighbors/busybox-known-server.json
NetworkNeighbors
toNetworkNeighborhood
.containers
field withingress
andegress
.1 files
network_policy.py
Update test scripts for network neighborhood terminology
tests_scripts/helm/network_policy.py
network_neighbors
tonetwork_neighborhood
.1 files
system_test_mapping.json
Update test mapping descriptions for network neighborhood
system_test_mapping.json
network neighborhood
terminology.