Skip to content

Commit

Permalink
STIG: firewall need to be enabled validation
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Aug 8, 2022
1 parent 9c815bd commit b94a066
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/y2security/stig_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require "y2security/security_policy_validator"
require "y2security/security_policy_issues"
require "y2network/connection_config/wireless"
require "installation/security_settings"

Yast.import "Lan"

Expand Down Expand Up @@ -107,5 +108,23 @@ def storage_issues
def plain_filesystem?(filesystem)
filesystem.ancestors.none? { |d| d.respond_to?(:encrypted?) && d.encrypted? }
end

# Returns the issues in the firewall proposal
#
# * Firewall must be enabled
#
# @return [Array<Y2Issues::Issue>]
def firewall_issues
settings = Installation::SecuritySettings.instance

return [] if !!settings.enable_firewall

[
Y2Issues::Issue.new(
_("Firewall is not enabled"),
severity: :error, location: "proposal:firewall"
)
]
end
end
end
26 changes: 26 additions & 0 deletions test/y2security/stig_validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,30 @@
end
end
end

context "when validating the firewall scope" do
let(:security_settings) { Installation::SecuritySettings.instance }
let(:enabled) { true }

before do
security_settings.enable_firewall = enabled
end

context "and the firewall is enabled" do
it "returns no issues" do
issues = subject.issues(:firewall)
expect(issues).to be_empty
end
end

context "and the firewall is not enabled " do
let(:enabled) { false }

it "returns an issue pointing that the firewall is not enabled" do
issues = subject.issues(:firewall)
expect(issues.size).to eq(1)
expect(issues.first.message).to include("Firewall is not enabled")
end
end
end
end

0 comments on commit b94a066

Please sign in to comment.