OpenMediaVault-Plugin-Developers / openmediavault-fail2ban

11 stars 5 forks source link

weird formatting in update log #28

Closed rabelux closed 7 months ago

rabelux commented 4 years ago

I just updated via webgui and the output looks kinda weird. see attached log. I tried to find where in this repo these strings are configured but didn't find a location. As this is the only plugin where i noticed this issue I guess it has to be this repo where it has to be fixed. @ryecoaaron do you know how/where this is generated?

raspberrypi:
----------
          ID: remove_default_fail2ban_config
    Function: file.absent
        Name: /etc/fail2ban/jail.d/defaults-debian.conf
      Result: True
     Comment: File /etc/fail2ban/jail.d/defaults-debian.conf is not present
     Started: 02:13:50.191689
    Duration: 2.535 ms
     Changes:   
----------
          ID: configure_fail2ban
    Function: file.managed
        Name: /etc/fail2ban/jail.conf
      Result: True
     Comment: File /etc/fail2ban/jail.conf is in the correct state
     Started: 02:13:50.194539
    Duration: 130.704 ms
     Changes:   
----------
          ID: remove_jail_conf_files
    Function: module.run
      Result: True
     Comment: file.find: ['/etc/fail2ban/jail.d/openmediavault-36b96e6c-9187-4b93-b0c6-05c6d3e29dc3.conf', '/etc/fail2ban/jail.d/openmediavault-4e3a2d25-326c-4dc8-bc05-22f303a62b75.conf.disabled', '/etc/fail2ban/jail.d/openmediavault-59650e01-5e07-4076-9b15-ce352f4b4356.conf', '/etc/fail2ban/jail.d/openmediavault-5f2b2d25-726c-5dc8-ac05-79f303a62b35.conf.disabled', '/etc/fail2ban/jail.d/openmediavault-645ae684-0950-4fcf-92fc-eba1b88775b1.conf.disabled', '/etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b21.conf.disabled', '/etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b60.conf.disabled', '/etc/fail2ban/jail.d/openmediavault-7e9a7d35-326c-4dc8-bc05-35f308a62b78.conf.disabled']
     Started: 02:13:50.328084
    Duration: 4.777 ms
     Changes:   
              ----------
              file.find:
                  - /etc/fail2ban/jail.d/openmediavault-36b96e6c-9187-4b93-b0c6-05c6d3e29dc3.conf
                  - /etc/fail2ban/jail.d/openmediavault-4e3a2d25-326c-4dc8-bc05-22f303a62b75.conf.disabled
                  - /etc/fail2ban/jail.d/openmediavault-59650e01-5e07-4076-9b15-ce352f4b4356.conf
                  - /etc/fail2ban/jail.d/openmediavault-5f2b2d25-726c-5dc8-ac05-79f303a62b35.conf.disabled
                  - /etc/fail2ban/jail.d/openmediavault-645ae684-0950-4fcf-92fc-eba1b88775b1.conf.disabled
                  - /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b21.conf.disabled
                  - /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b60.conf.disabled
                  - /etc/fail2ban/jail.d/openmediavault-7e9a7d35-326c-4dc8-bc05-35f308a62b78.conf.disabled
----------
          ID: configure_fail2ban_jail_36b96e6c-9187-4b93-b0c6-05c6d3e29dc3
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-36b96e6c-9187-4b93-b0c6-05c6d3e29dc3.conf
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-36b96e6c-9187-4b93-b0c6-05c6d3e29dc3.conf updated
     Started: 02:13:50.333235
    Duration: 27.318 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_59650e01-5e07-4076-9b15-ce352f4b4356
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-59650e01-5e07-4076-9b15-ce352f4b4356.conf
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-59650e01-5e07-4076-9b15-ce352f4b4356.conf updated
     Started: 02:13:50.360870
    Duration: 17.666 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_645ae684-0950-4fcf-92fc-eba1b88775b1
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-645ae684-0950-4fcf-92fc-eba1b88775b1.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-645ae684-0950-4fcf-92fc-eba1b88775b1.conf.disabled updated
     Started: 02:13:50.378856
    Duration: 17.546 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_6e3a7d25-326c-4dc8-bc05-63f303a62b60
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b60.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b60.conf.disabled updated
     Started: 02:13:50.396721
    Duration: 17.547 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_6e3a7d25-326c-4dc8-bc05-63f303a62b21
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b21.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-6e3a7d25-326c-4dc8-bc05-63f303a62b21.conf.disabled updated
     Started: 02:13:50.414587
    Duration: 18.207 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_7e9a7d35-326c-4dc8-bc05-35f308a62b78
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-7e9a7d35-326c-4dc8-bc05-35f308a62b78.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-7e9a7d35-326c-4dc8-bc05-35f308a62b78.conf.disabled updated
     Started: 02:13:50.433172
    Duration: 17.592 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_4e3a2d25-326c-4dc8-bc05-22f303a62b75
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-4e3a2d25-326c-4dc8-bc05-22f303a62b75.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-4e3a2d25-326c-4dc8-bc05-22f303a62b75.conf.disabled updated
     Started: 02:13:50.451080
    Duration: 17.742 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: configure_fail2ban_jail_5f2b2d25-726c-5dc8-ac05-79f303a62b35
    Function: file.managed
        Name: /etc/fail2ban/jail.d/openmediavault-5f2b2d25-726c-5dc8-ac05-79f303a62b35.conf.disabled
      Result: True
     Comment: File /etc/fail2ban/jail.d/openmediavault-5f2b2d25-726c-5dc8-ac05-79f303a62b35.conf.disabled updated
     Started: 02:13:50.469195
    Duration: 17.981 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: start_fail2ban_service
    Function: service.running
        Name: fail2ban
      Result: True
     Comment: Service restarted
     Started: 02:13:50.623599
    Duration: 4137.358 ms
     Changes:   
              ----------
              fail2ban:
                  True

Summary for raspberrypi
-------------
Succeeded: 12 (changed=10)
Failed:     0
-------------
Total states run:     12
Total run time:    4.427 s
ryecoaaron commented 4 years ago

Those weird symbols are what normally colorizes the output. Not sure why they are showing up in the web interface. I will have to try it when I get a chance. Not sure there is anything the plugin can do about it though.

rabelux commented 4 years ago

Agree, it's probably OMV that should ignore it. When checking logs in the web interface it also shows these symbols:

grafik

viewing the logfile in terminal looks good though an contains the mentioned colouring:

grafik

votdev commented 4 years ago

According to https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-fail2ban/blob/master/usr/share/openmediavault/engined/inc/90fail2ban.inc#L25 the content comes directly from the log file. If those characters are in the file, why should OMV filter them?

votdev commented 4 years ago

If you like to get it filtered you could try to use journalctl like this here. Maybe SYSTEMD_COLORS=0 will do the job. If it works you're welcome to open a PR that will fix it.

votdev commented 4 years ago

@ryecoaaron If you call salt-call somewhere in the code you can use --no-color to suppress the color output. Maybe https://github.com/openmediavault/openmediavault/commit/71bd9882e6c147b80afcba0c291ec13aefd2dce5 will help you, too.

ryecoaaron commented 4 years ago

@votdev None of the plugins use salt-call. So, we should be ok there. I remember the colors causing issues. I just need to look at how fail2ban logs now.

votdev commented 4 years ago

@ryecoaaron FYI https://github.com/openmediavault/openmediavault/commit/fbf2bda17100f21afceabc88fb3b9556aef62f30

rabelux commented 4 years ago

thanks guys for looking into this

ryecoaaron commented 4 years ago

I don't see any way to get fail2ban to not log in color to its log file though.

votdev commented 4 years ago

I don't see any way to get fail2ban to not log in color to its log file though.

Where or what is creating this content? It looks like output from Salt. Is it `omv-salt?

ryecoaaron commented 4 years ago

@votdev /usr/bin/fail2ban-server logs to the /var/log/fail2ban.log file. There is no argument to remove the colorization.

ryecoaaron commented 7 months ago

Closing due to age.