katana icon indicating copy to clipboard operation
katana copied to clipboard

From Discord: Katana as an SDK issue

Open MetzinAround opened this issue 1 year ago • 1 comments

katana version: 2

Current Behavior:

When I tried to use Katana as an SDK, I encountered an issue. I added Katana as a package and ran it, but it didn't work. I tried go version go1.21.5 linux/amd64, and it seems Katana isn't stable in this version. Later, I investigated and found the problematic code block in Katana. The problematic part was the Do function inside pkg/engine/common/base.go. In the Do function, the for loop at the top was for item := range crawlSession.Queue.Pop(), but it wasn't affected by the code at line 244 that I'm showing below katana issue 1

The go func(){} structure runs asynchronously, causing the for loop to complete without waiting for a new variable assignment to the queue, which was why Katana wasn't functioning. I resolved the issue by modifying the relevant code block as follows. Keep this in mind if you encounter a similar problem. 😅 katana 2

MetzinAround avatar Jan 04 '24 03:01 MetzinAround

          @Serhatcck I think the issue could have been a too short timeout for the specific target, since go routine is anyway awaited via the `wg.Wait()` at the end. Have you tried with a larger `-timeout` (default is 10s)

Originally posted by @Mzack9999 in https://github.com/projectdiscovery/katana/issues/717#issuecomment-2007177171

dogancanbakir avatar Mar 29 '24 09:03 dogancanbakir