<commit_before>#!/usr/bin/env bash

# Author:
#      <NAME>, <<EMAIL>>


. ${srcdir}/../test_common.sh

# Test Cases.

function test_mitre {

    if [ ! -d /tmp/ValidationSupportFiles ]; then
        eval "which unzip > /dev/null 2>&1"    
        if [ ! $? -eq 0 ]; then	
            echo -e "No unzip found in $PATH!\n" 
	    return 255; # Test is not applicable.
        fi
        /usr/bin/unzip -u ValidationSupportFiles.zip -d /tmp
    fi

    local ret_val=0;
    local DEFFILE=${srcdir}/$1
    local RESFILE="$DEFFILE".results

    [ -f $RESFILE ] && rm -f $RESFILE
    ../../utils/.libs/oscap oval eval --results $RESFILE $DEFFILE
    ret_val=$?
    
    if [ $ret_val -eq 0 ]; then
        return 0;
    elif [ $ret_val -eq 2 ]; then
	return 1;
    elif [ $ret_val -eq 1 ]; then
        return 255;
    else
	return "$ret_val"
    fi
}

# Testing.
test_init "test_mitre.log"

# INDEPENDET
test_run "ind-def_unknown_test.xml" test_mitre ind-def_unknown_test.xml
test_run "ind-def_variable_test.xml" test_mitre ind-def_variable_test.xml

#  our bug in internal probe
#test_run "ind-def_environmentvariable_test.xml" test_mitre ind-def_environmentvariable_test.xml

test_run "ind-def_family_test.xml" test_mitre ind-def_family_test.xml

# [E:oval_test.c:368:oval_test_parse_tag] Unknown test oval:org.mitre.oval.test:tst:305.
# [E:oval_defModel.c:262:oval_definition_model_import] Failed to merge the definition model from: ../ind-def_filehash58_test.xml.
#test_run "ind-def_filehash58_test.xml" test_mitre ind-def_filehash58_test.xml

#  their bug in: oval:org.mitre.oval.test:tst:102
#  unsupport recursion up: oval:org.mitre.oval.test:obj:562
#< filehash_test >
#
#Deprecated As Of Version: 5.8
#Reason: Replaced by the filehash58_test.
#Comment: This object has been deprecated and may be removed in a future version of the language.
#test_run "ind-def_filehash_test.xml" test_mitre ind-def_filehash_test.xml

test_run "ind-def_ldap_test.xml" test_mitre ind-def_ldap_test.xml
test_run "ind-def_sql_test.xml" test_mitre ind-def_sql_test.xml

#  unsupported recursion up: oval:org.mitre.oval.test:obj:577<commit_msg>[tests] run environmentvariable mitre test<commit_after>#!/usr/bin/env bash

# Author:
#      <NAME>, <<EMAIL>>


. ${srcdir}/../test_common.sh

# Test Cases.

function test_mitre {

    if [ ! -d /tmp/ValidationSupportFiles ]; then
        eval "which unzip > /dev/null 2>&1"    
        if [ ! $? -eq 0 ]; then	
            echo -e "No unzip found in $PATH!\n" 
	    return 255; # Test is not applicable.
        fi
        /usr/bin/unzip -u ValidationSupportFiles.zip -d /tmp
    fi

    local ret_val=0;
    local DEFFILE=${srcdir}/$1
    local RESFILE="$DEFFILE".results

    [ -f $RESFILE ] && rm -f $RESFILE
    ../../utils/.libs/oscap oval eval --results $RESFILE $DEFFILE
    ret_val=$?
    
    if [ $ret_val -eq 0 ]; then
        return 0;
    elif [ $ret_val -eq 2 ]; then
	return 1;
    elif [ $ret_val -eq 1 ]; then
        return 255;
    else
	return "$ret_val"
    fi
}

# Testing.
test_init "test_mitre.log"

# INDEPENDET
test_run "ind-def_unknown_test.xml" test_mitre ind-def_unknown_test.xml
test_run "ind-def_variable_test.xml" test_mitre ind-def_variable_test.xml

#  our bug in internal probe
test_run "ind-def_environmentvariable_test.xml" test_mitre ind-def_environmentvariable_test.xml

test_run "ind-def_family_test.xml" test_mitre ind-def_family_test.xml

# [E:oval_test.c:368:oval_test_parse_tag] Unknown test oval:org.mitre.oval.test:tst:305.
# [E:oval_defModel.c:262:oval_definition_model_import] Failed to merge the definition model from: ../ind-def_filehash58_test.xml.
#test_run "ind-def_filehash58_test.xml" test_mitre ind-def_filehash58_test.xml

#  their bug in: oval:org.mitre.oval.test:tst:102
#  unsupport recursion up: oval:org.mitre.oval.test:obj:562
#< filehash_test >
#
#Deprecated As Of Version: 5.8
#Reason: Replaced by the filehash58_test.
#Comment: This object has been deprecated and may be removed in a future version of the language.
#test_run "ind-def_filehash_test.xml" test_mitre ind-def_filehash_test.xml

test_run "ind-def_ldap_test.xml" test_mitre ind-def_ldap_test.xml
test_run "ind-def_sql_test.xml" test_mitre ind-def_sql_test.xml

#  unsupported recursion up: oval:org.mitre.oval.test:obj:577
{'fraction_non_alphanumeric': 0.11664329125759701, 'fraction_numerical': 0.020570359981299673, 'mean_word_length': 3.518479408658923, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 34}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5417600', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1572, 'n_words': 363}