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

Feature to add Windows firewall logging #144

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

Conversation

snkutlu
Copy link
Contributor

@snkutlu snkutlu commented Jul 15, 2016

Description

Feature to enable logging for Windows Firewall.

Issues Resolved

Check List

@@ -18,7 +18,12 @@ class Resource::FirewallRule < Chef::Resource::LWRPBase
!!(p.to_s =~ /(udp|tcp|icmp|icmpv6|ipv6-icmp|none)/ || (p.to_s =~ /^\d+$/ && p.between?(0, 142)))
end })
attribute(:direction, kind_of: Symbol, equal_to: [:in, :out, :pre, :post], default: :in)
attribute(:logging, kind_of: Symbol, equal_to: [:connections, :packets])

if Chef::Platform.windows?
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi there -- if a downstream cookbook decides to use one of these attributes, to support windows and linux both, this will break it, right? I'd rather allow extra attribute values than prevent someone from supporting windows and linux when providing additional firewall rules in their community cookbook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I did not understand what you meant, you cannot that easily use the same rule for Linux and Windows. But this can be doable.. I will work on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not running on Windows, we should still allow someone to declare a Windows firewall rule. For example, if someone makes amysql cookbook, I would want them to be able to ship Windows and Linux firewall rules, with only_of { <platform_check> }. This wouldn't compile if we have a conditional like what you've got here.

@@ -57,6 +57,14 @@ def whyrun_supported?
end
end

# If logging rules are not provided, then create a rule to disable them (windows default)
unless new_resource.rules['windows'].key?('set currentprofile logging droppedconnections enable')
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we do nothing if there aren't existing logging rules provided? I don't want to maintain Windows defaults in this cookbook long term.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logging rules are not like standard firewall rules. So it is there or not. If it is not there, this means we should revert it to default windows behaviour. Otherwise a user will remove logging attributes expecting the logging will be changed to default but in reality it wont if we don't do this.

parameters['remoteip'] = new_resource.destination ? fixup_cidr(new_resource.destination) : 'any'
parameters['remoteport'] = new_resource.dest_port ? port_to_s(new_resource.dest_port) : 'any'
if type == :log
"set currentprofile logging #{new_resource.logging} enable"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an unexpected side effect of any rule that has logging. I don't think users will expect this to be run, if they haven't explicitly enabled logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is exactly what should be done when someone coded logging attribute in a provider call. This is the only way to change windows firewall logging.

And logging is not per rule in Windows Firewall. It is system wide. You either define logging or not, globally.

Copy link
Contributor

Choose a reason for hiding this comment

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

And logging is not per rule in Windows Firewall. It is system wide. You either define logging or not, globally.

Shouldn't we have the user enable it on the firewall resource, then?

Copy link
Contributor

@martinb3 martinb3 left a comment

Choose a reason for hiding this comment

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

Hi there -- I've made some comments here. I think

  • there are some extra commands being run, that are going to surprise users
  • some platform-specific things that break compilation, vs. degrading gracefully on other platforms

I'd like to merge this, if you don't mind working on those two issues. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Will bring visible benefit to the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants