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

Add tainted nextcloud-logs.yaml parser to crowdsec.service #54

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

stephdl
Copy link
Collaborator

@stephdl stephdl commented Sep 13, 2024

With this pull request I add a tainted configuration to the nextcloud parser of crowdsec

Sadly crowdsec does not offer to overwrite its configuration files like fail2ban, we need to modify the configuration and crowdsec should see them as tainted and does not overwrite them.

we have to modify it for two things

  • we do not have json output
  • the message name in journald is nextloud-app and not nextcloud

evidences of the ban

Sep 13 16:54:52 R2-pve.rocky9-pve2.org crowdsec3[43722]: time="2024-09-13T14:54:52Z" level=info msg="Ip 192.168.13.25 performed 'crowdsecurity/nextcloud-bf' (12 events over 13m10.249879085s) at 2024-09-13 14:54:52.125479573 +0000 UTC"
Sep 13 16:54:52 R2-pve.rocky9-pve2.org crowdsec3[43722]: time="2024-09-13T14:54:52Z" level=info msg="(localhost/crowdsec) crowdsecurity/nextcloud-bf by ip 192.168.13.25 : 4m ban on Ip 192.168.13.25"

Crowdsec has seen the parsed has been tainted

Sep 13 08:47:39 R1-pve crowdsec4[76868]: time="2024-09-13T06:47:39Z" level=warning msg="⚠️ crowdsecurity/nextcloud-logs is tainted, --force to overwrite"

NethServer/dev#7018

@stephdl stephdl self-assigned this Sep 13, 2024
@DavidePrincipi
Copy link
Member

  • we do not have json output
  • the message name in journald is nextloud-app and not nextcloud

As alternative to a custom configuration, can we switch to Nextcloud JSON log and set Podman log tag to "nextcloud"?

Copy link
Member

@DavidePrincipi DavidePrincipi left a comment

Choose a reason for hiding this comment

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

Please choose a different path for the new .yaml file.

@@ -38,6 +38,7 @@ ExecStart=/usr/bin/podman run \
--volume ./crowdsec_config:/etc/crowdsec:Z \
--volume %N-data:/var/lib/crowdsec/data:Z \
--volume ${CROWDSEC_JOURNAL}:/run/log/journal \
--volume ./tainted/nextcloud-logs.yaml:/etc/crowdsec/hub/parsers/s01-parse/crowdsecurity/nextcloud-logs.yaml:Z \
Copy link
Member

@DavidePrincipi DavidePrincipi Sep 18, 2024

Choose a reason for hiding this comment

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

In 10initialize, the Nextcloud collection (and the included parser) is installed after the tainted parser YAML file is mounted as a Podman volume. Is this safe for both new installs and updates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for upgrades yes no issue

for first install I missed it, we need to reload the configuration at the end, it is the easiest way

imageroot/state/tainted/nextcloud-logs.yaml Outdated Show resolved Hide resolved
Copy link
Member

@DavidePrincipi DavidePrincipi left a comment

Choose a reason for hiding this comment

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

LGTM

@stephdl stephdl merged commit 7574782 into main Sep 20, 2024
4 checks passed
@stephdl stephdl deleted the nextcloud_jail branch September 20, 2024 07:49
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