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

[enh] Add fail2ban helpers #364

Merged
merged 10 commits into from Feb 18, 2019
Merged

[enh] Add fail2ban helpers #364

merged 10 commits into from Feb 18, 2019

Conversation

JimboJoe
Copy link
Member

@JimboJoe JimboJoe commented Sep 2, 2017

Problems

To enhance applications protection against hackers/spammers, etc., we can propose helpers to ease the creating of fail2ban jails.

Solution

Add ynh_add_fail2ban_config and ynh_remove_fail2ban_config helpers.
A successful implementation example is the piwigo app.

PR Status

Working, but opinion welcome!
And should be implemented in other applications to validate its principle.

Validation

  • Principle agreement 0/2 :
  • Quick review 0/1 :
  • Simple test 0/1 :
  • Deep review 0/1 :

@Psycojoker
Copy link
Member

As anyone tested those? I have no knowledge of fail2ban.

@JimboJoe
Copy link
Member Author

JimboJoe commented Oct 7, 2017

At the moment, only the (nearly official) Piwigo application implemented it. So maybe should we wait for a couple of other successful implementations to merge it...?

@alexAubin alexAubin added this to the 2.7.x (fixes) or 2.8 milestone Oct 7, 2017
@yunohost-bot yunohost-bot modified the milestones: 2.7.x (fixes) or 2.8, 3.x Nov 8, 2017
@alexAubin
Copy link
Member

As far as I know, fail2ban's conf format changed in Stretch so that might affect these helpers :s

@Psycojoker
Copy link
Member

At the moment, only the (nearly official) Piwigo application implemented it. So maybe should we wait for a couple of other successful implementations to merge it...?

Any update on that?

@JimboJoe
Copy link
Member Author

It's currently being implemented in Wordpress, and has evolved here.

@alexAubin
Copy link
Member

About this :

we should be careful that the fail2ban conf format changed a bit in stretch and is backward-incompatible. I don't know if these helpers are affected... but right now, the step in the stretch migration is to remove all existing fail2ban conf and regenerate it from scratch :s

@alexAubin
Copy link
Member

Bumpitybump, is there any update on this ? Are the helpers stable enough to be considered merged in the core ? (Do they work on Stretch ?)

@alexAubin alexAubin changed the title Add fail2ban helpers [enh] Add fail2ban helpers May 10, 2018
@JimboJoe
Copy link
Member Author

I've updated the helpers to be on-par with the ones from Experimental_helpers.
I've tested again piwigo on Stretch and they work as advertised.
I understand you had to delete all existing fail2ban jails when migrating from Jessie to Stretch, so that means existing apps won't be protected by fail2ban until their next upgrade (which I find perfectly acceptable)?

@alexAubin
Copy link
Member

I understand you had to delete all existing fail2ban jails when migrating from Jessie to Stretch, so that means existing apps won't be protected by fail2ban until their next upgrade

Yes indeed :s

@JimboJoe
Copy link
Member Author

This helper currently only works on Stretch...

@zamentur
Copy link
Member

Not a problem if it only works on Stretch, we could merged it only in stretch...

@alexAubin alexAubin changed the base branch from unstable to stretch-unstable June 17, 2018 02:11
@alexAubin alexAubin modified the milestones: 2.7.x, 3.1.x Jun 19, 2018
@Psycojoker
Copy link
Member

We are now on stretch, shouldn't we merge this?

@alexAubin alexAubin modified the milestones: 3.1.x, 3.2.x Aug 15, 2018
@alexAubin alexAubin added this to the 3.x milestone Dec 10, 2018
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Is anyone know why is there a '1' as a second argument for this helper ?
I can't find any version of ynh_backup_if_checksum_is_different with a second argument.

This is crashing getopts, which is another problem to fix

@maniackcrudelis
Copy link
Contributor

@YunoHost/apps

@alexAubin alexAubin modified the milestones: 3.x, 3.5.x Feb 4, 2019
@alexAubin
Copy link
Member

Bump @YunoHost/apps , it'd be nice to have this for 3.5 :s (in particular, @Josue-T , it was noted "Josue will have a look at integrating fail2ban in his apps, which requires to have several regex instead of just one. He'll iterate on the design." 😅 so if you happen to have time to work on this that'd be great !)

@Josue-T
Copy link
Contributor

Josue-T commented Feb 4, 2019

Yes, I might find some time for that in theses next 2 weeks.
If not I think we should merge this as it is because I might not find the time for the theses next month

…tations

Using a template file make more easy to use a custom failregex.
It also give the possiblitity to use custom settings in the fail2ban config
@Josue-T
Copy link
Contributor

Josue-T commented Feb 15, 2019

Now I updated the helper.

Tested on synapse

@maniackcrudelis
Copy link
Contributor

@Josue-T that's a completely different helper !
You break getopts usage as well as usage of this helper in one line without template.

Maybe for synapse you need to use a template, but most of the apps don't need that and works perfectly with the previous version of this helper.
So, if you want to ADD a template usage for this helper, why not, but I don't think that to force to use a template is a good idea.

@Josue-T
Copy link
Contributor

Josue-T commented Feb 15, 2019

It's just more like the helper nginx.

I think it's the last time change the way how this helper work. And I think that probably many apps need more flexibility than what this helper provided.

@Josue-T
Copy link
Contributor

Josue-T commented Feb 15, 2019

If you really want to keep first idea. We can make a helper ynh_add_fail2ban_config with the old idea. And a other helper ynh_add_fail2ban_template with my idea.

@maniackcrudelis
Copy link
Contributor

nginx doesn't have a standard config, each app has a different config.
You could have said that it's like php, which is true. And actually, this helper could use a template less architecture. But the helper was built over the way we were handling php by that time.

Anyway, except synapse, no app is using a template for fail2ban. And so far we don't need to add that in apps. So we should keep that helper as simple to use as we can. So, like it was.

Again, if you need a template feature for synapse with fail2ban, I agree to ADD this to the helper. But, this shouldn't break the way the helper was working so far.
Nor breaking getopts...

So, add 2 arguments to the helper, one for using a template, another for adding other variables. That's a good thing for those who could need a specific fail2ban config. But do not break the helper because you need a specific way to handle the config.

@Josue-T
Copy link
Contributor

Josue-T commented Feb 15, 2019

Now there are the 2 possibility

@maniackcrudelis
Copy link
Contributor

LGTM, but not tested.

@maniackcrudelis
Copy link
Contributor

Bump

@YunoHost/apps

Copy link
Member

@alexAubin alexAubin left a comment

Choose a reason for hiding this comment

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

Not really reviewed but trusting you guys ... Would merge in a few days if no opposition (still would be nice to have other opinions from @YunoHost/apps )

@maniackcrudelis
Copy link
Contributor

Let's merge in 3 days

@alexAubin
Copy link
Member

Thanks for the review folks, finally sounds like we gonna merge this \o/

serfefefeveimage

@alexAubin alexAubin merged commit 8085838 into YunoHost:stretch-unstable Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants