Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions schemas/oval/5.11.1/unix-definitions-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3253,6 +3253,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11.1/unix-system-characteristics-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11.2/unix-definitions-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3287,6 +3287,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11.2/unix-system-characteristics-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11.3/unix-definitions-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3287,6 +3287,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11.3/unix-system-characteristics-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11/unix-definitions-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3066,6 +3066,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
20 changes: 20 additions & 0 deletions schemas/oval/5.11/unix-system-characteristics-schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,26 @@ ACTIVE_DEAD_GATEWAY_DETECTION                                
<xsd:documentation>The SHA-512 method corresponds to the $6$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="yescrypt">
<xsd:annotation>
<xsd:documentation>The yescrypt method corresponds to the $y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="gost-yescrypt">
<xsd:annotation>
<xsd:documentation>The gost-yescrypt method corresponds to the $gy$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="sm3-yescrypt">
<xsd:annotation>
<xsd:documentation>The sm3-yescrypt method corresponds to the $sm3y$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="scrypt">
<xsd:annotation>
<xsd:documentation>The scrypt method corresponds to the $7$ prefix.</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="">
<xsd:annotation>
<xsd:documentation>The empty string value is permitted here to allow for empty elements associated with variable references.</xsd:documentation>
Expand Down
41 changes: 41 additions & 0 deletions src/OVAL/probes/unix/shadow_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdbool.h>

#include "_seap.h"
#include "probe-api.h"
Expand Down Expand Up @@ -96,6 +97,18 @@ struct result_info {
static SEXP_t *parse_enc_mth(const char *pwd)
{
char *mth_str;
bool yescrypt_mth = false;

if (pwd == NULL)
goto fail;

while (*pwd == '!')
pwd++;

if (*pwd == '\0' ||
*pwd == '*' ||
strcmp(pwd, "x") == 0)
goto fail;

switch (*pwd) {
case '_':
Expand All @@ -121,6 +134,30 @@ static SEXP_t *parse_enc_mth(const char *pwd)
mth_str = "SHA-512";
pwd++;
break;
case '7':
mth_str = "scrypt";
yescrypt_mth = true;
pwd++;
break;
case 'g':
if (strncmp(pwd, "gy", 2))
goto fail;
mth_str = "gost-yescrypt";
yescrypt_mth = true;
pwd += 2;
break;
case 's':
if (strncmp(pwd, "sm3y", 4))
goto fail;
mth_str = "sm3-yescrypt";
yescrypt_mth = true;
pwd += 4;
break;
case 'y':
mth_str = "yescrypt";
yescrypt_mth = true;
pwd++;
break;
default:
if (strncmp(pwd, "md5", 3))
goto fail;
Expand All @@ -131,6 +168,10 @@ static SEXP_t *parse_enc_mth(const char *pwd)
if (*pwd != '$')
goto fail;

if (yescrypt_mth && oval_schema_version_cmp(over,
OVAL_SCHEMA_VERSION(5.11)) < 0)
goto fail;

return SEXP_string_newf("%s", mth_str);
default:
return SEXP_string_newf("DES");
Expand Down
1 change: 1 addition & 0 deletions tests/probes/shadow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if(ENABLE_PROBES_UNIX)
add_oscap_test("test_probes_shadow.sh")
add_oscap_test("test_probes_shadow_offline.sh")
add_oscap_test("test_probes_shadow_yescrypt.sh" LABELS unix linux_only)
endif()
79 changes: 79 additions & 0 deletions tests/probes/shadow/test_probes_shadow_yescrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

. "$builddir/tests/test_common.sh"

set -e -o pipefail

tmpdir=""

function test_probes_shadow_yescrypt {
probecheck "shadow" || return 255
[[ $(uname) == Linux ]] || return 255

tmpdir=$(make_temp_dir /tmp "test_shadow_yescrypt")
trap 'rm -rf "$tmpdir"' EXIT
mkdir -p "$tmpdir/etc"
cp "$srcdir/test_probes_shadow_yescrypt.shadow" "$tmpdir/etc/shadow"
set_offline_chroot_dir "$tmpdir"

local definition="$tmpdir/definitions.xml"
local result="$tmpdir/results.xml"
local items='//*[local-name()="shadow_item"]'
local invalid_items="$items[*[local-name()='username' and starts-with(., 'invalid_')]]"
local hashless_items="$items[*[local-name()='username' and starts-with(., 'hashless_')]]"
local schema_version

for schema_version in 5.8 5.9 5.10 5.10.1 5.11 5.11.1 5.11.2 5.11.3; do
sed "s/SCHEMA_VERSION_PLACEHOLDER/$schema_version/" \
"$srcdir/test_probes_shadow_yescrypt.xml" > "$definition"
local modern_count
case $schema_version in
5.8|5.9|5.10|5.10.1)
xsed -i '/OVAL_5_11_ENCRYPT_METHOD/d' "$definition"
modern_count=0
;;
5.11|5.11.1|5.11.2|5.11.3)
modern_count=4
;;
*)
printf 'Unexpected OVAL schema version: %s\n' "$schema_version" >&2
return 1
;;
esac
$OSCAP oval eval --results "$result" "$definition"

verify_results "def" "$definition" "$result" 1
verify_results "tst" "$definition" "$result" 8
assert_exists 36 "$items"
local method method_items
for method in yescrypt gost-yescrypt sm3-yescrypt scrypt; do
method_items="$items[starts-with(*[local-name()='username'], '${method}_')]"
assert_exists 4 "$method_items"
assert_exists "$modern_count" "$method_items/*[local-name()='encrypt_method']"
assert_exists "$modern_count" \
"$method_items/*[local-name()='encrypt_method' and text()='$method']"
done
assert_exists 1 "$items/*[local-name()='encrypt_method' and text()='SHA-512']"
assert_exists 2 "$items/*[local-name()='encrypt_method' and text()='DES']"
assert_exists 9 "$invalid_items"
assert_exists 0 "$invalid_items/*[local-name()='encrypt_method']"
assert_exists 8 "$hashless_items"
assert_exists 0 "$hashless_items/*[local-name()='encrypt_method']"
done

# OVAL versions before 5.8 do not support encrypt_method.
sed 's/SCHEMA_VERSION_PLACEHOLDER/5.4/' \
"$srcdir/test_probes_shadow_yescrypt.xml" > "$definition"
xsed -i '/<unix-def:encrypt_method>/d' "$definition"
$OSCAP oval eval --results "$result" "$definition"
verify_results "def" "$definition" "$result" 1
verify_results "tst" "$definition" "$result" 8
assert_exists 36 "$items"
assert_exists 0 "$items/*[local-name()='encrypt_method']"

set_offline_chroot_dir ""
}

test_init
test_run "test_probes_shadow_yescrypt" test_probes_shadow_yescrypt
test_exit
Loading
Loading