diff --git a/shared/templates/file_groupowner/oval.template b/shared/templates/file_groupowner/oval.template index 276965ad77ca..5c1a8bfdf9a1 100644 --- a/shared/templates/file_groupowner/oval.template +++ b/shared/templates/file_groupowner/oval.template @@ -13,23 +13,12 @@ {{% endif %}} - {{%- if MISSING_FILE_PASS -%}} - {{# Any number of files can exist, from zero to any #}} - {{% set FILE_EXISTENCE = "any_exist" %}} - {{%- else -%}} - {{# All defined files must exist. When using regex, at least one file must match #}} - {{% set FILE_EXISTENCE = "all_exist" %}} - {{%- endif -%}} - {{% for filepath in FILEPATH %}} - + - - - {{{ FILEGID }}} - + {{%- if IS_DIRECTORY -%}} {{%- if RECURSIVE %}} @@ -46,8 +35,14 @@ {{{ filepath }}} {{%- endif %}} symlink_file_groupowner{{{ FILEID }}}_uid_{{{ FILEGID }}} + state_file_groupowner{{{ FILEID }}}_gid_{{{ FILEGID }}}_{{{ loop.index0 }}} + + + {{{ FILEGID }}} + {{% endfor %}} + symbolic link diff --git a/shared/templates/file_groupowner/tests/correct_groupowner.pass.sh b/shared/templates/file_groupowner/tests/correct_groupowner.pass.sh index f02a02ebcaed..6f209457054a 100644 --- a/shared/templates/file_groupowner/tests/correct_groupowner.pass.sh +++ b/shared/templates/file_groupowner/tests/correct_groupowner.pass.sh @@ -1,5 +1,4 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if IS_DIRECTORY and FILE_REGEX %}} diff --git a/shared/templates/file_groupowner/tests/incorrect_groupowner.fail.sh b/shared/templates/file_groupowner/tests/incorrect_groupowner.fail.sh index 15857443e840..dce6c878376f 100644 --- a/shared/templates/file_groupowner/tests/incorrect_groupowner.fail.sh +++ b/shared/templates/file_groupowner/tests/incorrect_groupowner.fail.sh @@ -1,5 +1,4 @@ #!/bin/bash -# groupadd group_test diff --git a/shared/templates/file_groupowner/tests/missing_file_test.pass.sh b/shared/templates/file_groupowner/tests/missing_file_test.pass.sh index 015ff98c99d5..479678a7fed9 100644 --- a/shared/templates/file_groupowner/tests/missing_file_test.pass.sh +++ b/shared/templates/file_groupowner/tests/missing_file_test.pass.sh @@ -1,5 +1,4 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if MISSING_FILE_PASS %}} diff --git a/shared/templates/file_owner/oval.template b/shared/templates/file_owner/oval.template index 090ea49863a6..82308fbd4d4a 100644 --- a/shared/templates/file_owner/oval.template +++ b/shared/templates/file_owner/oval.template @@ -13,22 +13,12 @@ {{% endif %}} - {{%- if MISSING_FILE_PASS -%}} - {{# Any number of files can exist, from zero to any #}} - {{% set FILE_EXISTENCE = "any_exist" %}} - {{%- else -%}} - {{# All defined files must exist. When using regex, at least one file must match #}} - {{% set FILE_EXISTENCE = "all_exist" %}} - {{%- endif -%}} {{% for filepath in FILEPATH %}} - + - - - {{{ FILEUID }}} - + {{%- if IS_DIRECTORY -%}} {{%- if RECURSIVE %}} @@ -45,8 +35,14 @@ {{{ filepath }}} {{%- endif %}} symlink_file_owner{{{ FILEID }}}_uid_{{{ FILEUID }}} + state_file_owner{{{ FILEID }}}_uid_{{{ FILEUID }}}_{{{ loop.index0 }}} + + + {{{ FILEUID }}} + {{% endfor %}} + symbolic link diff --git a/shared/templates/file_owner/tests/correct_owner.pass.sh b/shared/templates/file_owner/tests/correct_owner.pass.sh index c22c6a58f1c1..b7dfcb8865cb 100644 --- a/shared/templates/file_owner/tests/correct_owner.pass.sh +++ b/shared/templates/file_owner/tests/correct_owner.pass.sh @@ -1,5 +1,4 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if IS_DIRECTORY and FILE_REGEX %}} diff --git a/shared/templates/file_owner/tests/incorrect_owner.fail.sh b/shared/templates/file_owner/tests/incorrect_owner.fail.sh index 8f402412e15d..04012bfd5fc4 100644 --- a/shared/templates/file_owner/tests/incorrect_owner.fail.sh +++ b/shared/templates/file_owner/tests/incorrect_owner.fail.sh @@ -1,5 +1,4 @@ #!/bin/bash -# useradd testuser_123 diff --git a/shared/templates/file_owner/tests/missing_file_test.pass.sh b/shared/templates/file_owner/tests/missing_file_test.pass.sh index 4e3683f9dcf1..45f176226d94 100644 --- a/shared/templates/file_owner/tests/missing_file_test.pass.sh +++ b/shared/templates/file_owner/tests/missing_file_test.pass.sh @@ -1,5 +1,4 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if MISSING_FILE_PASS %}} diff --git a/shared/templates/file_permissions/oval.template b/shared/templates/file_permissions/oval.template index a22bb1046877..f314b5757b9e 100644 --- a/shared/templates/file_permissions/oval.template +++ b/shared/templates/file_permissions/oval.template @@ -1,19 +1,3 @@ -{{%- if ALLOW_STRICTER_PERMISSIONS %}} - {{# - When allowing stricter permissions, the check looks for files/directories - that have any extra permission bit set. The permissions mode (STATEMODE) - is negated (inverted) and becomes a mask for permissions that should not be set. - #}} - {{% set FILE_EXISTENCE = "at_least_one_exists" %}} -{{%- else -%}} - {{%- if MISSING_FILE_PASS -%}} - {{# Any number of files can exist, from zero to any #}} - {{% set FILE_EXISTENCE = "any_exist" %}} - {{%- else -%}} - {{# All defined files must exist. When using regex, at least one file must match #}} - {{% set FILE_EXISTENCE = "all_exist" %}} - {{%- endif -%}} -{{%- endif -%}} {{% if FILEPATH is not string %}} @@ -22,28 +6,24 @@ ") }}} {{% for filepath in FILEPATH %}} - + {{% endfor %}} {{% else %}} {{{ oval_metadata("This test makes sure that " + FILEPATH + " has mode " + FILEMODE + ". If the target file or directory has an extended ACL, then it will fail the mode check. ") }}} - + {{% endif %}} {{% for filepath in FILEPATH %}} - + - - - {{{ STATEMODE | indent(6) }}} - - + {{%- if IS_DIRECTORY %}} {{%- if RECURSIVE %}} ^{{{ filepath[:-1] }}} @@ -58,17 +38,13 @@ {{%- else %}} {{{ filepath }}} {{%- endif %}} - - {{%- if ALLOW_STRICTER_PERMISSIONS %}} - {{# - This filter is required because of an issue in OpenSCAP. The issue has been fixed in: - https://github.com/OpenSCAP/openscap/pull/1709 but this line should be kept until the - fix is widely available. The fix is expected to be part of OpenSCAP >= 1.3.5. - #}} - state_file_permissions{{{ FILEID }}}_{{{ loop.index0 }}}_mode_not_{{{ FILEMODE }}} - {{%- endif %}} exclude_symlinks_{{{ FILEID }}} + state_file_permissions{{{ FILEID }}}_{{{ loop.index0 }}}_mode_{{{ FILEMODE }}}{{{ 'or_stricter_' if ALLOW_STRICTER_PERMISSIONS }}} + + + {{{ STATEMODE | indent(6) }}} + {{% endfor %}} diff --git a/shared/templates/file_permissions/template.py b/shared/templates/file_permissions/template.py index 6e20a625d978..4f46d1b7a1ac 100644 --- a/shared/templates/file_permissions/template.py +++ b/shared/templates/file_permissions/template.py @@ -50,11 +50,8 @@ def preprocess(data, lang): "true\n" + mode_str) else: - value = "false" - if data['allow_stricter_permissions']: - value = "true" mode_str = ( - "{}false\n" + mode_str) mode_int = mode_int >> 1 data["statemode"] = mode_str.rstrip("\n") diff --git a/shared/templates/file_permissions/tests/correct_permissions.pass.sh b/shared/templates/file_permissions/tests/correct_permissions.pass.sh index 02d480c9984e..db3417dcc760 100644 --- a/shared/templates/file_permissions/tests/correct_permissions.pass.sh +++ b/shared/templates/file_permissions/tests/correct_permissions.pass.sh @@ -1,5 +1,4 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if IS_DIRECTORY and FILE_REGEX %}} diff --git a/shared/templates/file_permissions/tests/lenient_permissions.fail.sh b/shared/templates/file_permissions/tests/lenient_permissions.fail.sh index dc6c6015921a..91413fca4ed7 100644 --- a/shared/templates/file_permissions/tests/lenient_permissions.fail.sh +++ b/shared/templates/file_permissions/tests/lenient_permissions.fail.sh @@ -1,11 +1,10 @@ #!/bin/bash -# {{% for path in FILEPATH %}} {{% if IS_DIRECTORY and FILE_REGEX %}} echo "Create specific tests for this rule because of regex" {{% elif IS_DIRECTORY and RECURSIVE %}} -find -L {{{ path }}} -type d -exec chmod 777 {} \; +find -L {{{ path }}} -type d -maxdepth 1 -exec chmod 777 {} \; {{% else %}} if [ ! -f {{{ path }}} ]; then mkdir -p "$(dirname '{{{ path }}}')"