Skip to content

introduce F2B v0.11#1965

Merged
georglauterbach merged 19 commits intomasterfrom
f2b-0.11
May 15, 2021
Merged

introduce F2B v0.11#1965
georglauterbach merged 19 commits intomasterfrom
f2b-0.11

Conversation

@georglauterbach
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach commented May 12, 2021

Description

This PR replaces F2B 0.10 with the latest F2B 0.11.2. This is done as Debian 11 has still no ETA. This change is easily revertible. When Debian 11 launches with the latest F2B, this PR can be reverted in a manner of minutes.

Fixes #1810

Type of change

  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@georglauterbach georglauterbach added area/dependency meta/needs triage This issue / PR needs checks and verification from maintainers priority/medium service/security/fail2ban kind/improvement Improve an existing feature, configuration file or the documentation labels May 12, 2021
@georglauterbach georglauterbach requested review from a team and casperklein May 12, 2021 09:45
@georglauterbach georglauterbach self-assigned this May 12, 2021
@georglauterbach
Copy link
Copy Markdown
Member Author

@casperklein Although unit tests fail, it is only one tests, which is version related:

 not ok 28 checking setup.sh: setup.sh debug fail2ban
# (from function `assert_output' in file test/test_helper/bats-assert/src/assert.bash, line 231,
#  in test file test/mail_fail2ban.bats, line 143)
#   `assert_output --partial "Unbanned IP from dovecot: 192.0.66.4"' failed
# 
# -- output does not contain substring --
# substring (1 lines):
#   Unbanned IP from dovecot: 192.0.66.4
# output (3 lines):
#   Unbanned IP from dovecot: 1
#   Unbanned IP from postfix: 0
#   Unbanned IP from postfix-sasl: 0
# --
# 

Can you have a look?

@georglauterbach
Copy link
Copy Markdown
Member Author

@docker-mailserver/maintainers If someone is not fine with getting the latest Fail2Ban, please share your concerns here :)

@wernerfred
Copy link
Copy Markdown
Member

@docker-mailserver/maintainers If someone is not fine with getting the latest Fail2Ban, please share your concerns here :)

If it doesn't solve the issue discussed in #1810 and still needs the "hacking" i see no real benefit. If there is an advantage then go for it (imho)

@georglauterbach
Copy link
Copy Markdown
Member Author

@wernerfred You right: I think that

I've tested 0.11 on the host and it flawlessly banned all the "auth failures"

is one good arguments. The other one may be that we should be at the forefront of security. I like having the latest versions :D

Comment thread Dockerfile Outdated
razor rpm2cpio rsyslog sasl2-bin spamassassin supervisor \
unrar-free unzip whois xz-utils >/dev/null && \
# Fail2Ban
curl -Lso fail2ban.deb https://github.com/fail2ban/fail2ban/releases/download/0.11.2/fail2ban_0.11.2-1.upstream1_all.deb && \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we do this to be on forefront of security then we should check the downloaded files integrity/signing shouldn't we?

Copy link
Copy Markdown
Member Author

@georglauterbach georglauterbach May 12, 2021

Choose a reason for hiding this comment

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

Yes, we should do that. Can you help? Not sure what's the best solution, I mean, how to check this. The release page of F2B offers a link to check a hash sum.

Copy link
Copy Markdown
Member

@wernerfred wernerfred May 12, 2021

Choose a reason for hiding this comment

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

Give me a moment

Copy link
Copy Markdown
Member Author

@georglauterbach georglauterbach May 12, 2021

Choose a reason for hiding this comment

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

One easy method, without using GPG, would be to check the pre-computed SHA152 sum like this:

sha512sum --check --status <<< "09d91ad0f499b0825b9d6da1d175400aa32498aff5705624e88b3d7e02cf727403c49b967c732e42182e25d4f439de0faf681f9f6d3598364e3f2f2e3453f8bf  fail2ban_0.11.2-1.upstream1_all.deb"

which could be written directly into the Dockerfile. Moreover, sha512sum is from the coreutiles package - no extra package dependency necessary. The downside is: just an integrity check, no signature verification.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be enough, to ensure the file was not altered.

However, my checksum differs:

echo "44fe3d67e7d24bba4fc81ee672059dcb67980258db6101bcd8740736a9d9110f *fail2ban.deb" | sha256sum --check --status

or

sha256sum --check --status <<< "44fe3d67e7d24bba4fc81ee672059dcb67980258db6101bcd8740736a9d9110f *fail2ban.deb"

Copy link
Copy Markdown
Member

@wernerfred wernerfred May 12, 2021

Choose a reason for hiding this comment

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

Is there a reason for the package pinning in that particular case

no just personal habit ;) sorry

IMO we don't need FAIL2BAN_VERSION at all. There are not that much releases of f2b. And as you said, when there is a new version, we have to adjust the Dockerfile and maybe f2b_url either way.

Agree 👍🏻

In context of security, this feels wrong: wget -q --no-check-certificate.

True but doesn't matter if the signing is correct. There is no need to use wget, we can also use curl if that does behave other than wget in CI. If you look at the linked example in my comment above i do not use --no-check-certificate and have no issues with gh action or am i missing smth?

What kind of improved security do we get from this, compared to the very simple file hash comparison

We are not only checking if the file got altered but also if it was created by fail2ban or did i get it wrong?
Nevertheless the hash comparison adds that bit of security compared to having no check at all that i am fine with both ☑️

ARG should be ENV

I disagree as we have no benefit of having these as ENV in the Container later on. We only need them during build an therefore ARG should be enough. But as the behavior does not change i do not insist of using ARG

Copy link
Copy Markdown
Member

@wernerfred wernerfred May 12, 2021

Choose a reason for hiding this comment

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

docker build passes without error or warning, i'm running the test suite right now

image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

docker build passes without error or warning, i'm running the test suite right now

image

I will commit some of the suggested changes, but you'd need to do final adjustments to this yourself:)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are not only checking if the file got altered but also if it was created by fail2ban or did i get it wrong?

Correct. I considered this only as a temporary addition (until Debian 11 is released). So manually sign checking once and then hard-coding the checksum would be enough (way less additions to Dockerfile needed).

If we are going this route long-term, then the gpg solution is more complete and convenient 👍

We only need them during build an therefore ARG should be enough.

Good point. I had the wrong assumption, that using ARG in Dockerfile and not providing a build-arg for that during the build would throw a warning. That is not the case.
Maybe we should think about replacing most ENV with ARG in the whole Dockerfile. The ENVs are populated by the start-mailserver.sh script. So we don't need to bake them into the image.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ENVs are populated by the start-mailserver.sh script. So we don't need to bake them into the image.

Good point

Copy link
Copy Markdown
Member

@wernerfred wernerfred left a comment

Choose a reason for hiding this comment

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

I suggested changes to drop the FAIL2BAN_VERSION and removed the version pinning of packages

Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
georglauterbach and others added 4 commits May 12, 2021 19:28
Co-authored-by: Frederic Werner <[email protected]>
Co-authored-by: Frederic Werner <[email protected]>
Co-authored-by: Frederic Werner <[email protected]>
Co-authored-by: Frederic Werner <[email protected]>
@georglauterbach
Copy link
Copy Markdown
Member Author

@casperklein @wernerfred I'm low on time today and tomorrow (Bachelor's thesis is waiting for me). Can you take care of the changes you suggested. I'm more than happy to review this in the end.

@georglauterbach
Copy link
Copy Markdown
Member Author

LGTM

Anything left to do?

Copy link
Copy Markdown
Member

@wernerfred wernerfred left a comment

Choose a reason for hiding this comment

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

I think this is fine to merge.
Do we need a documentation Update?

@georglauterbach
Copy link
Copy Markdown
Member Author

I think this is fine to merge.
Do we need a documentation Update?

I don't think docs needs an update. I will go ahead and merge this.

@georglauterbach georglauterbach merged commit 75e74e4 into master May 15, 2021
@georglauterbach georglauterbach deleted the f2b-0.11 branch May 15, 2021 09:11
@casperklein
Copy link
Copy Markdown
Member

casperklein commented May 15, 2021

Not doc, but we should mention it in the changelog as a breaking change, when v10 will be released.

@casperklein
Copy link
Copy Markdown
Member

I just wondered, why there is no new image @ dockerhub. --> build-multiarch-and-publish failed 😕

@wernerfred
Copy link
Copy Markdown
Member

wernerfred commented May 15, 2021

Do we have an arch problem?

@casperklein casperklein mentioned this pull request May 15, 2021
11 tasks
@casperklein
Copy link
Copy Markdown
Member

Yes. But what exactly goes wrong is hard to tell, because all error output is suppressed.

@wernerfred
Copy link
Copy Markdown
Member

What are the next steps? How to debug this? Should we open a PR after #1970 got merged to see the build output on arm or do we revert this PR?

@casperklein
Copy link
Copy Markdown
Member

#1970 does not add additional output. It will only help for future PRs, so that we know in advance before merging, the build fails.

To get more output and track down which command exactly fails, we would have to remove all the &>/dev/null, -qq etc parts.

I did this locally, but unfortunately, my build for arm64/armv7 both succeed. I looked for the "exit code 60" in google and the first result was about a certificate problem of curl. @aendeavor mentioned:

The --no-check-certificate is needed in CI as wget behaves strangely in pipelines

If I had to blindly guess, I would say, that curl behaves similar. curl --insecure should then fix it.

To track down this and future problems more easily, it's probably a good idea, to remove the &>/dev/null statements.

@georglauterbach
Copy link
Copy Markdown
Member Author

I did this locally, but unfortunately, my build for arm64/armv7 both succeed. I looked for the "exit code 60" in google and the first result was about a certificate problem of curl. @aendeavor mentioned:

The --no-check-certificate is needed in CI as wget behaves strangely in pipelines

If I had to blindly guess, I would say, that curl behaves similar. curl --insecure should then fix it.

That is probably it.

To track down this and future problems more easily, it's probably a good idea, to remove the &>/dev/null statements.

Yes.

@casperklein casperklein mentioned this pull request May 15, 2021
11 tasks
@casperklein
Copy link
Copy Markdown
Member

Another problem: With the commit of #1970 test_merge_requests.yml got broken, because it's not using buildx compared to default_on_push.yml

As long this is not fixed, we cannot test #1971.

@casperklein
Copy link
Copy Markdown
Member

I can try to adjust test_merge_requests.yml to use buildx, but that will take some time as I am not that familiar with gh actions.

@wernerfred @aendeavor if one of you could do it, I wouldn't be sad 😘

Or do you have any other suggestions how to proceed?

@georglauterbach
Copy link
Copy Markdown
Member Author

I can try to adjust test_merge_requests.yml to use buildx, but that will take some time as I am not that familiar with gh actions.

@wernerfred @aendeavor if one of you could do it, I wouldn't be sad 😘

Or do you have any other suggestions how to proceed?

Still low on time to be honest 🙈 I have not done the build stuff at all. But I will help if I can. Remember, we've got time, no need to hurry. 9.1.0 is out there and solid :D

@casperklein
Copy link
Copy Markdown
Member

casperklein commented May 15, 2021

I had a look and will give it a try. Doesn't seem that hard as I thought.

Edit: See #1972

@wernerfred
Copy link
Copy Markdown
Member

If I had to blindly guess, I would say, that curl behaves similar. curl --insecure should then fix it.

But why does it work in the PR test then? This run is also in CI environment. Strange

@casperklein
Copy link
Copy Markdown
Member

Good point. That would indicate it's just related to arm builds? Or the curl guess is wrong.

@wernerfred
Copy link
Copy Markdown
Member

To get more output and track down which command exactly fails, we would have to remove all the &>/dev/null, -qq etc parts.

We can still revert #1965 and restore the f2b-0.11 branch. Then master will be clean again and we can use the recovered branch to create another PR that doesn't use -qq etc. to nail down the issue. If it passes (bc your PR #1970 will show it then) we can add back those arguments and merge.

@georglauterbach
Copy link
Copy Markdown
Member Author

georglauterbach commented May 16, 2021

When #1972 passes on master, do we really need to revert this PR? We could just add another that removes the -qq and [&]>/dev/null, if we want to.

@wernerfred
Copy link
Copy Markdown
Member

Absolute, will have the Same result. Just a Point of having a broken state commited to master for a certain amount of time

@georglauterbach
Copy link
Copy Markdown
Member Author

Absolute, will have the Same result. Just a Point of having a broken state commited to master for a certain amount of time

I can live with that, since master represents :edge and does not build stable images :D

@casperklein
Copy link
Copy Markdown
Member

casperklein commented May 17, 2021

Another downside of the &>/dev/null snippets is, that we missed the apt-get info, that gnupg is already available and don't need to be installed for fail2ban 😉

ed fetchmail file gamin gnupg gzip iproute2 iptables \

@wernerfred wernerfred added this to the v10.0.0 milestone May 18, 2021
@polarathene polarathene mentioned this pull request May 24, 2021
11 tasks
georglauterbach added a commit that referenced this pull request Aug 30, 2022
This new script is a clean way of handling the installation of packages.
I think the huge `RUN` command in `Dockerfile` was hard to read and
maintain.

Using a script is a non-issue, as the image is rebuilt whenever the
script is touched.

Moreover, this commit implicitly removed the explicit Fail2Ban
installation and therefore #1965, BECAUSE Debian 11 now ships with the
latest and greatest Fail2Ban version (even more up-to-date than out
current version it seems).
@georglauterbach georglauterbach mentioned this pull request Aug 30, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement Improve an existing feature, configuration file or the documentation meta/needs triage This issue / PR needs checks and verification from maintainers priority/medium service/security/fail2ban

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Review/Improve] fail2ban service Can't block Spambots

3 participants