honeynet / riotpot

the IoT and OT (Operational Technology) Honeypot
MIT License
18 stars 4 forks source link

TODO to implement Port-Based Filtering in getProxies Route Function #47

Open Mehul-Kumar-27 opened 6 months ago

Mehul-Kumar-27 commented 6 months ago

There is a TODO mentioned at riotpot/pkg/api/proxy.go in the getProxies route function which requires implementing functionality to filter proxies based on their ports.

I would like to work on this and plan to implement it in the following manner:

@RicYaben , sir, could you please provide your views on this?

RicYaben commented 6 months ago

Hey there, please join the Honeynet Slack group. Please don't mention me in the comments, I may participate in this project but I do not own it.

For the first part, routes do use upper cases or verbs. These go in the requests, you either send a get request, post, or patch. I do not see how is this an improvement over the path proxies with a get command. I believe there is already a handler for this use-case?

Example of that same code a bit cleaner:

portStr := ctx.Param("port")
if port == '' {
 return proxy.Proxies.GetProxies()
}

// iterator here and the current logic
...
return ctx.JSON(ok, proxies)

As for the handler, the logic you mention does the same in both cases except the one below returns everything? the code does not look very good. If you want to add filters, I would expect the handler to actually handle different cases where we need to find a specific proxy based on other characteristics (e.g., assigned port, id, name, etc.).