-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11818 from teacup-on-rockingchair/firewall_by_pro…
…file_variable Firewall technology related rules per service and package change logic according to interactive profile variable
- Loading branch information
Showing
34 changed files
with
563 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
linux_os/guide/system/network/var_network_filtering_service.var
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
documentation_complete: true | ||
|
||
title: 'Network filtering service' | ||
|
||
description: |- | ||
Network filtering service: iptables, nftables, firewalld or ufw | ||
|
||
type: string | ||
|
||
operator: equals | ||
|
||
interactive: true | ||
|
||
options: | ||
iptables: iptables | ||
nftables: nftables | ||
firewalld: firewalld | ||
ufw: ufw | ||
default: firewalld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
shared/templates/package_installed_guard_var/ansible.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# platform = multi_platform_sle | ||
# reboot = false | ||
# strategy = enable | ||
# complexity = low | ||
# disruption = low | ||
|
||
{{{ ansible_instantiate_variables(VARIABLE) }}} | ||
|
||
- name: Ensure {{{ PKGNAME }}} is installed | ||
ansible.builtin.package: | ||
name: "{{{ PKGNAME }}}" | ||
state: present | ||
{{% if OPERATION == "pattern match" %}} | ||
when: {{{ VARIABLE }}} is regex("{{{ VALUE }}}") | ||
{{% else %}} | ||
when: {{{ VARIABLE }}} == "{{{ VALUE }}}" | ||
{{% endif %}} |
17 changes: 17 additions & 0 deletions
17
shared/templates/package_installed_guard_var/bash.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# platform = multi_platform_sle | ||
# reboot = false | ||
# strategy = enable | ||
# complexity = low | ||
# disruption = low | ||
|
||
{{{ bash_instantiate_variables(VARIABLE) }}} | ||
|
||
{{% if OPERATION == "pattern match" %}} | ||
if [[ "{{{ VALUE }}}" =~ ${{{ VARIABLE }}} ]]; then | ||
{{{ bash_package_install(package=PKGNAME) }}} | ||
fi | ||
{{% else %}} | ||
if [ ${{{ VARIABLE }}} == {{{ VALUE }}} ]; then | ||
{{{ bash_package_install(package=PKGNAME) }}} | ||
fi | ||
{{% endif %}} |
26 changes: 26 additions & 0 deletions
26
shared/templates/package_installed_guard_var/oval.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<def-group> | ||
{{%- set variable_value_test_id = _RULE_ID + "_test_variable_" + VARIABLE -%}} | ||
{{% if OPERATION is defined %}} | ||
{{%- set variable_value_op = OPERATION -%}} | ||
{{% else %}} | ||
{{%- set variable_value_op = "equals" -%}} | ||
{{% endif %}} | ||
<definition class="compliance" id="{{{ _RULE_ID }}}" | ||
version="1"> | ||
{{{ oval_metadata("The " + pkg_system|upper + " package " + PKGNAME + " should be installed.", affected_platforms=["multi_platform_sle"]) }}} | ||
<criteria operator="OR" comment="package {{{ PKGNAME }}} is installed or not needed"> | ||
<criteria comment="{{{ PKGNAME }}} is not needed" operator="AND"> | ||
<criterion comment="variable {{{ VARIABLE }}} is set to {{{ VALUE }}}" | ||
test_ref="{{{ variable_value_test_id }}}" negate="true"/> | ||
</criteria> | ||
<criteria comment="package {{{ PKGNAME }}} is installed and needed" operator="AND"> | ||
<criterion comment="package {{{ PKGNAME }}} is installed" | ||
test_ref="test_package_{{{ PKGNAME }}}_installed" /> | ||
<criterion comment="variable {{{ VARIABLE }}} is set to {{{ VALUE }}}" | ||
test_ref="{{{ variable_value_test_id }}}" /> | ||
</criteria> | ||
</criteria> | ||
</definition> | ||
{{{ oval_test_external_variable_value(variable=VARIABLE, value=VALUE, test_id=variable_value_test_id, operation=variable_value_op) }}} | ||
{{{ oval_test_package_installed(package=PKGNAME, evr=EVR, test_id="test_package_"+PKGNAME+"_installed") }}} | ||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import re | ||
|
||
|
||
def preprocess(data, lang): | ||
if "evr" in data: | ||
evr = data["evr"] | ||
if evr and not re.match(r'\d:\d[\d\w+.]*-\d[\d\w+.]*', evr, 0): | ||
raise RuntimeError( | ||
"ERROR: input violation: evr key should be in " | ||
"epoch:version-release format, but package {0} has set " | ||
"evr to {1}".format(data["pkgname"], evr)) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
supported_languages: | ||
- ansible | ||
- bash | ||
- oval |
18 changes: 18 additions & 0 deletions
18
shared/templates/package_removed_guard_var/ansible.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# platform = multi_platform_sle | ||
# reboot = false | ||
# strategy = disable | ||
# complexity = low | ||
# disruption = low | ||
|
||
{{{ ansible_instantiate_variables(VARIABLE) }}} | ||
|
||
- name: Ensure {{{ PKGNAME }}} is removed | ||
ansible.builtin.package: | ||
name: "{{{ PKGNAME }}}" | ||
state: absent | ||
when: {{{ VARIABLE }}} != "{{{ VALUE }}}" | ||
{{% if OPERATION == "pattern match" %}} | ||
when: {{{ VARIABLE }}} is not regex("{{{ VALUE }}}") | ||
{{% else %}} | ||
when: {{{ VARIABLE }}} != "{{{ VALUE }}}" | ||
{{% endif %}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# platform = multi_platform_sle | ||
# reboot = false | ||
# strategy = disable | ||
# complexity = low | ||
# disruption = low | ||
|
||
# CAUTION: This remediation script will remove {{{ PKGNAME }}} | ||
# from the system, and may remove any packages | ||
# that depend on {{{ PKGNAME }}}. Execute this | ||
# remediation AFTER testing on a non-production | ||
# system! | ||
|
||
{{{ bash_instantiate_variables(VARIABLE) }}} | ||
|
||
{{% if OPERATION == "pattern match" %}} | ||
if ! [[ "{{{ VALUE }}}" =~ ${{{ VARIABLE }}} ]]; then | ||
{{{ bash_package_remove(package=PKGNAME) }}} | ||
fi | ||
{{% else %}} | ||
if [ ${{{ VARIABLE }}} != {{{ VALUE }}} ]; then | ||
{{{ bash_package_remove(package=PKGNAME) }}} | ||
fi | ||
{{% endif %}} |
Oops, something went wrong.