chaos-client
chaos-client copied to clipboard
Unexpected exit code and inconsistent error messages
chaos-client version:
0.2.0
Current Behavior:
Not sure if this should be considered a bug report or a feature request.
After the initial opts
validation, the application always exits with an exit code 0
. For example, the query fails if an unexpected status code is returned by the server. However, this is not represented in the exit code.
Current behaviour:
chaos -key $key -d example-app.de
> [ERR] Could not get subdomains for example-app.de: invalid status code received: 429 - {"error":"too many requests"}
# Get the exit code of the previous command
echo $?
> 0
Expected behaviour:
chaos -key $key -d example-app.de
> [ERR] Could not get subdomains for example-app.de: invalid status code received: 429 - {"error":"too many requests"}
# Get the exit code of the previous command
echo $?
> 1
Additionally; failed queries are not displayed when using the -silent
flag. This behaviour is inconsistent with error messages displayed during the opts
check:
Current behaviour:
# testcase 1 (correct)
chaos
> [FTL] Authorization token not specified
# testcase 2 (correct)
chaos -silent
> [FTL] Authorization token not specified
# testcase 3 (incorrect)
chaos -silent -key $key -d example-app.de # We asume for this query a 429 server error occurs
> # Empty Reply. However, we would expect an error message
Steps To Reproduce:
To reproduce the 429 error you can query multiple domains at the same time. (It seems there's a bug, even with minutes between queries I still get an 429. This was mentioned in the Discord as well I think)
Anything else:
I would like to contribute to this project and fix this issue. However I'm not sure if my fix approach would be fine with you.
The following code snippet "only" throws a regular Error
.
https://github.com/projectdiscovery/chaos-client/blob/b7336605fd9d104c2c80549da6af7d2cfbe9f65c/internal/runner/runner.go#L59-L63
Instead all these gologger.Error().Msgf
errors could be replaced with gologger.Fatal().Msgf
(which exits the program with the exit code 1
). This would be similar to:
https://github.com/projectdiscovery/chaos-client/blob/b7336605fd9d104c2c80549da6af7d2cfbe9f65c/internal/runner/options.go#L84-L86
However, this would immediately exit the client as soon as a single server error is encountered. This could disrupt the tool when scanning multiple domains at once.
@timoles Thanks for opening this issue. As we are processing a list of domains, I think that gologger.Error().Msgf
is preferable over gologger.Fatal().Msgf
since it would cause the tool to exit, whereas 429 seems like e recoverable error (maybe we could introduce a delay before the subsequent request).
I cannot reproduce the status code equal to 1
on OSX. Were you testing on Linux?