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

Command line length limit #254

Closed
fsacer opened this issue Feb 18, 2023 · 8 comments · Fixed by #264
Closed

Command line length limit #254

fsacer opened this issue Feb 18, 2023 · 8 comments · Fixed by #264

Comments

@fsacer
Copy link

fsacer commented Feb 18, 2023

Not sure if there is any length limit for the command line log in place (I think I might have had it a couple of times where some software executed a long base64 encoded script via bash) or if it is configurable somewhere?

@bostjan
Copy link
Member

bostjan commented Mar 26, 2023

(I am not sure why I am either not getting email notifications about newly opened issues, or missing these notifications in my inbox. Sorry for the late response.)

@fsacer, you can find various limits here. The main ones are:

  • SNOOPY_DATASOURCE_MESSAGE_MAX_SIZE (max length of a response from each individual datasource)
  • SNOOPY_LOG_MESSAGE_BUF_SIZE (max overall length of a formatted message)

So, in your case, 2K characters was probably the limit you've hit.

Technically, you can raise them by rebuilding yourself with the correct -D... flags. So far, the use case for even longer log messages has not been presented/suggested, but now that you mention it, I can't really recall a reason for it being statically defined instead of being configurable in the config file, except maybe needing to take care of fewer dynamic memory allocations.

What's the actual use case here, what is generating these large base64-encoded command line arguments?

@fsacer
Copy link
Author

fsacer commented May 23, 2023

Hey sorry for the late response, the use case here was that a CTF challenge was running a script base64 encoded script so I was only able to read part of it because of the length limits. It would definitely be useful to be able to configure this via snoopy's config file.

@fsacer fsacer closed this as completed May 23, 2023
@fsacer fsacer reopened this May 23, 2023
@bostjan
Copy link
Member

bostjan commented Jul 15, 2023

Let me think about this.

@fsacer
Copy link
Author

fsacer commented Jul 17, 2023

cool, would really be nice to have the config option for this

@bostjan
Copy link
Member

bostjan commented Jul 17, 2023

@fsacer, I am thinking about having:

  • Two configurable values in the config file, one for per-datasource max result length, and the other for the max overall message length.
  • Two maximum limits for the above, that can't be increased from the config file. The intention here is to protect the system from unintended excessive resource consumption, and changing these will require a rebuild from sources.

What would be your idea of the maximum limits mentioned above? Or, maybe a bit simpler way of putting it - what is the absolute max message length that you're expecting to see in your use case?

@fsacer
Copy link
Author

fsacer commented Jul 18, 2023

Based on this issue microsoft/azure-pipelines-tasks#6509 I am thinking 100k could be a good fail-safe maximum, the default limit could stay at 2k or changed to 8k like in cmd.exe.

@bostjan
Copy link
Member

bostjan commented Jul 28, 2023

Alright, this just landed in master. @fsacer, would you be kind enough to try it out before I release it in a stable version?

Note to self - I should probably add a few more functional tests, to make sure the new configurable limits are really applied as intended.

PS: I thought this was going to be a relatively small change, but I didn't realise at the time just how ingrained in the codebase the static message limit definitions have became over time.

@fsacer
Copy link
Author

fsacer commented Aug 7, 2023

hey thanks, I will try to test it out when I play the next challenge, will update here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment