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

fix: Allow inline comments in clamd.conf #1308

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

userwiths
Copy link
Contributor

This PR attempts to resolve the issue mentioned in #1175

  1. Regex has been changed in order to allow matching a given line even if it has a comment (separated with space or not) from the main expression.
  2. When passing through an argument, check if it contains the comment character # and if it does, try to get the content on its left side.

Thoughts:

  1. I have some doubts strtok is the best choice.
  2. Another approach, better imo, would be to get the first match from the regex expression. I failed to find an example in the project where cli_regexec returns the made matches (most likely in the 4th argument, but it seems its used mostly with NULL through out the project).

@micahsnyder
Copy link
Contributor

Thanks for the PR! I will try to review this after we have things lined up to publish 1.4.0, or after 1.4.0 ships.

@micahsnyder micahsnyder force-pushed the fix/allow-inline-comments branch from ef7d483 to 8e9d15f Compare January 10, 2025 03:39
Copy link
Contributor

@micahsnyder micahsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebased this PR to re-run the tests.

I found just minor clang-format issues.

In manual testing, I found that for string-based options (vs bool, size, or number args) -- spaces before a # end up getting included in the option value.

For example, I tried this for freshclam.conf:

DatabaseMirror http://localhost:8000 # database.clamav.net

The result was that it tried to download daily.cvd from:
http://localhost:8000 /daily.cvd (with a space in the middle).

I would have to remove the space between 8000 and # to make it work. Like this:

DatabaseMirror http://localhost:8000# database.clamav.net

But this doesn't look very natural and is bound to get complaints from users that try this feature.

I also had trouble with getting a bool to work. I tried this in freshclam.conf, but it didn't enable verbose mode:

LogVerbose yes #no

@userwiths
Copy link
Contributor Author

userwiths commented Jan 14, 2025

Yeah, the clang-format I probably forgot about, now it should be formated as its supposed to.
I expected the tests to fail with the issue about spaces after arg, but on second thought there were no inline comments in the tests, currently added trimming of trailing spaces

Tried to see how I could implement a test for this fix, but I'm not sure if its possible to printout the options even in debug mode, as its managed in libclamav and not here.

Other caveat

If someone has # as a part of his option (dont know how viable that is, as a part of directory/file name for example) it would probably break their config too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants