Closed dwertent closed 9 months ago
PR Description updated to latest commit (https://github.com/kubescape/storage/commit/942f4500a8bc4752c7672ba1834f0d69511ce26a)
๐ก General suggestions: The PR is well-structured and addresses the issue of IP duplication effectively. The use of hashing to create unique identifiers for each rule and policy reference is a good approach. However, it would be beneficial to handle the error returned by the hash function in a more informative way, rather than just ignoring it.
relevant file | pkg/apis/softwarecomposition/networkpolicy/networkpolicy.go |
suggestion | Handle the error returned by the hash function. Currently, if the hash function returns an error, it is ignored. It would be better to log the error or handle it in a way that would not silently fail the operation. [important] |
relevant line | '+ if ruleHash, err := hash(rule); err == nil {' |
relevant file | pkg/apis/softwarecomposition/networkpolicy/networkpolicy.go |
suggestion | Consider using a more descriptive name for the variable 's' in the hash function. Variable names should be descriptive and convey the purpose of the variable. [medium] |
relevant line | '+func hash(s any) (string, error) {' |
Summary:
Type
bug_fix, tests
Description
This PR addresses the issue of IP duplication in the network policy. The main changes include:
PR changes walkthrough
1 files
networkpolicy.go
pkg/apis/softwarecomposition/networkpolicy/networkpolicy.go
**The changes in this file mainly focus on fixing the IP
duplication issue in the network policy. This is achieved by
implementing a hashing function to create unique identifiers
for each rule and policy reference. These hashes are then
used to prevent duplication in both ingress and egress
rules. The changes also include the addition of new imports
to support the hashing function.**
1 files
networkpolicy_test.go
pkg/apis/softwarecomposition/networkpolicy/networkpolicy_test.go
**The changes in this file include the addition of a new test
case to verify the correct functioning of the IP duplication
fix. The test case checks if the policy is enriched when
multiple IPs are present in known servers.**
User description
Sorry, we do not accept changes directly against this repository. Please see CONTRIBUTING.md for information on where and how to contribute instead.