Sha256: 86c2c54e794502e144d6439cd294fd258bb81f51a777d5a246d04d0ed8eb9bda

Contents?: true

Size: 756 Bytes

Versions: 35

Compression:

Stored size: 756 Bytes

Contents

require 'serverspec'
require 'serverspec/type/base'

module Serverspec::Type
  class WindowsFirewall < Base

    def initialize
      @runner = Specinfra::Runner
    end

    def has_open_port?(port)
      command_result = @runner.run_command("((New-Object -comObject HNetCfg.FwPolicy2).rules | where-object { $_.LocalPorts -eq #{port} -and $_.Action -eq 1}).Enabled")
      command_result.stdout.gsub(/\n/, '') == "True"
    end

    def enabled?
      command_result = @runner.run_command("(get-service MpsSvc).Status")
      command_result.stdout.gsub(/\n/, '') == "Running"
    end

    def to_s
      "Windows Firewall"
    end

  end

  def windows_firewall
    WindowsFirewall.new
  end
end

include Serverspec::Type

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
octopus-serverspec-extensions-0.18.1 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.18.0 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.17.3 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.17.2 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.17.1 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.17.0 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.5 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.4 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.3 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.2 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.1 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.15.0 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.6 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.5 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.4 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.3 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.2 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.1 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.13.0 lib/octopus_serverspec_extensions/type/windows_firewall.rb
octopus-serverspec-extensions-0.12.2 lib/octopus_serverspec_extensions/type/windows_firewall.rb