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

test(test): Adding fuzzer for ContainerPolicy #1797

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

prady0t
Copy link

@prady0t prady0t commented Jul 7, 2024

Purpose of PR?:

This is a fuzzer for ContainerPolicy

func (p *PolicyServer) ContainerPolicy(c context.Context, data *pb.Policy) (*pb.Response, error) {

For seed corpus I referred to this policy and removed Metadata.Name from it.
With this we are testing if invalid policy results in PolicyStatus_Invalid or not.
To run the fuzz test,

cd KubeArmor/policy
go test -fuzz=Fuzz

Addresses #1367

Does this PR introduce a breaking change?
NO

@prady0t
Copy link
Author

prady0t commented Jul 10, 2024

Already found an issue with this. I ran the fuzzer for a while and It failed for this input :

{
    "0000": "00000000000000",
    "oBjeCt": {
        "metAdAtA": {
            "nAme": "0"
        }
    }
}

Which is totally understandable. To fix this we can also have a condition in fuzzer to check for status as Applied if we have policyEvent.Object.Metadata.Name != "" . Here's the log :

--- FAIL: FuzzContainerPolicy (0.00s)
    --- FAIL: FuzzContainerPolicy/69798181ccc6962d (0.00s)
        ContainerPoilcy_fuzz_test.go:58: Unexpected status: Applied, [123 32 32 32 32 34 48 48 48 48 34 58 32 34 48 48 48 48 48 48 48 48 48 48 48 48 48 48 34 44 32 32 32 32 34 111 66 106 101 67 116 34 58 32 123 32 32 32 32 32 34 109 101 116 65 100 65 116 65 34 58 32 123 32 32 32 32 32 32 34 110 65 109 101 34 58 32 34 48 34 125 125 125]
FAIL
exit status 1
FAIL    github.com/kubearmor/KubeArmor/KubeArmor/policy 0.011s

Marking this as a draft for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant