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

Dispatch fails by sending unprocessable entity 422 #521

Open
petar-nikolovski-cif opened this issue Oct 5, 2022 · 0 comments
Open

Dispatch fails by sending unprocessable entity 422 #521

petar-nikolovski-cif opened this issue Oct 5, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@petar-nikolovski-cif
Copy link

petar-nikolovski-cif commented Oct 5, 2022

What happened

When using kube-hunter with --dispatch http and --report json our API fails with 422 unprocessable entity. This is because this piece of code in the dispatcher:

r = requests.request(
    dispatch_method, dispatch_url, json=report, headers={"Content-Type": "application/json"}, verify=False
)

is sending a string instead of a dictionary for json argument. That is JSONReporter class should not use json.dumps method:

class JSONReporter(BaseReporter):
    def get_report(self, **kwargs):
        report = super().get_report(**kwargs)
        return json.dumps(report)

# instead:

class JSONReporter(BaseReporter):
    def get_report(self, **kwargs):
        return super().get_report(**kwargs)

Or at least dispatch method should deserialize the report before sending it to requests: json=json.loads(report).

Expected behavior

App should be able to process entity.

@petar-nikolovski-cif petar-nikolovski-cif added the bug Something isn't working label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant