adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone

Blame SOURCES/openscap-1.2.17-revert-warnings-by-default.patch

bcc67f
From b93c8a3ec57a5fd18868de3a1abfda488fa0013d Mon Sep 17 00:00:00 2001
bcc67f
From: Jan Cerny <jcerny@redhat.com>
bcc67f
Date: Tue, 23 Jan 2018 17:19:46 +0100
bcc67f
Subject: [PATCH] Revert "Merge pull request #630 from
bcc67f
 mpreisler/warning_default_verbose_level"
bcc67f
bcc67f
This reverts commit 91feb5cc9658598db8e2b374b92ddae5f8577762, reversing
bcc67f
changes made to ef57380289a6548ea7abb6627fa1fd4845000bf8.
bcc67f
---
bcc67f
 src/XCCDF/public/xccdf_session.h                   |  3 ---
bcc67f
 src/XCCDF/tailoring.c                              |  2 +-
bcc67f
 src/XCCDF/xccdf_session.c                          | 11 +++------
bcc67f
 src/XCCDF_POLICY/check_engine_plugin.c             | 26 ++++++++--------------
bcc67f
 src/XCCDF_POLICY/public/check_engine_plugin.h      |  1 -
bcc67f
 src/common/debug.c                                 |  2 +-
bcc67f
 tests/API/OVAL/unittests/test_external_variable.sh |  6 +----
bcc67f
 .../OVAL/unittests/test_object_component_type.sh   |  2 ++
bcc67f
 .../unittests/test_remediation_subs_unresolved.sh  |  2 --
bcc67f
 tests/probes/sql57/unsupported_engine.sh           |  2 --
bcc67f
 tests/probes/sysctl/test_sysctl_probe_all.sh       |  2 --
bcc67f
 utils/oscap.c                                      |  3 +--
bcc67f
 12 files changed, 18 insertions(+), 44 deletions(-)
bcc67f
bcc67f
diff --git a/src/XCCDF/public/xccdf_session.h b/src/XCCDF/public/xccdf_session.h
bcc67f
index f9992399..6b6e09e7 100644
bcc67f
--- a/src/XCCDF/public/xccdf_session.h
bcc67f
+++ b/src/XCCDF/public/xccdf_session.h
bcc67f
@@ -414,11 +414,8 @@ int xccdf_session_load_oval(struct xccdf_session *session);
bcc67f
  *
bcc67f
  * @memberof xccdf_session
bcc67f
  * @param session XCCDF Session
bcc67f
- * @param plugin_name Name of the plugin to load
bcc67f
- * @param quiet If true we will not output errors if loading fails
bcc67f
  * @returns zero on success
bcc67f
  */
bcc67f
-int xccdf_session_load_check_engine_plugin2(struct xccdf_session *session, const char* plugin_name, bool quiet);
bcc67f
 int xccdf_session_load_check_engine_plugin(struct xccdf_session *session, const char* plugin_name);
bcc67f
 
bcc67f
 /**
bcc67f
diff --git a/src/XCCDF/tailoring.c b/src/XCCDF/tailoring.c
bcc67f
index 62661040..51b05f9e 100644
bcc67f
--- a/src/XCCDF/tailoring.c
bcc67f
+++ b/src/XCCDF/tailoring.c
bcc67f
@@ -187,7 +187,7 @@ struct xccdf_tailoring *xccdf_tailoring_parse(xmlTextReaderPtr reader, struct xc
bcc67f
 		}
bcc67f
 		case XCCDFE_PROFILE: {
bcc67f
 			if (benchmark != NULL) {
bcc67f
-				dI("Parsing Tailoring Profiles without reference to Benchmark");
bcc67f
+				dW("Parsing Tailoring Profiles without reference to Benchmark");
bcc67f
 			}
bcc67f
 			struct xccdf_item *item = xccdf_profile_parse(reader, benchmark);
bcc67f
 			if (!xccdf_tailoring_add_profile(tailoring, XPROFILE(item))) {
bcc67f
diff --git a/src/XCCDF/xccdf_session.c b/src/XCCDF/xccdf_session.c
bcc67f
index ccb95821..7b1a6df5 100644
bcc67f
--- a/src/XCCDF/xccdf_session.c
bcc67f
+++ b/src/XCCDF/xccdf_session.c
bcc67f
@@ -1072,9 +1072,9 @@ int xccdf_session_load_oval(struct xccdf_session *session)
bcc67f
 	return 0;
bcc67f
 }
bcc67f
 
bcc67f
-int xccdf_session_load_check_engine_plugin2(struct xccdf_session *session, const char *plugin_name, bool quiet)
bcc67f
+int xccdf_session_load_check_engine_plugin(struct xccdf_session *session, const char *plugin_name)
bcc67f
 {
bcc67f
-	struct check_engine_plugin_def *plugin = check_engine_plugin_load2(plugin_name, quiet);
bcc67f
+	struct check_engine_plugin_def *plugin = check_engine_plugin_load(plugin_name);
bcc67f
 
bcc67f
 	if (!plugin)
bcc67f
 		return -1; // error already set
bcc67f
@@ -1091,11 +1091,6 @@ int xccdf_session_load_check_engine_plugin2(struct xccdf_session *session, const
bcc67f
 	}
bcc67f
 }
bcc67f
 
bcc67f
-int xccdf_session_load_check_engine_plugin(struct xccdf_session *session, const char *plugin_name)
bcc67f
-{
bcc67f
-	return xccdf_session_load_check_engine_plugin2(session, plugin_name, false);
bcc67f
-}
bcc67f
-
bcc67f
 int xccdf_session_load_check_engine_plugins(struct xccdf_session *session)
bcc67f
 {
bcc67f
 	xccdf_session_unload_check_engine_plugins(session);
bcc67f
@@ -1105,7 +1100,7 @@ int xccdf_session_load_check_engine_plugins(struct xccdf_session *session)
bcc67f
 	while (*known_plugins) {
bcc67f
 		// We do not report failure when a known plugin doesn't load properly, that's because they
bcc67f
 		// are optional and we don't know if it's not there or if it just failed to load.
bcc67f
-		if (xccdf_session_load_check_engine_plugin2(session, *known_plugins, true) != 0)
bcc67f
+		if (xccdf_session_load_check_engine_plugin(session, *known_plugins) != 0)
bcc67f
 			oscap_clearerr();
bcc67f
 
bcc67f
 		known_plugins++;
bcc67f
diff --git a/src/XCCDF_POLICY/check_engine_plugin.c b/src/XCCDF_POLICY/check_engine_plugin.c
bcc67f
index d36f4cd9..9f3024c5 100644
bcc67f
--- a/src/XCCDF_POLICY/check_engine_plugin.c
bcc67f
+++ b/src/XCCDF_POLICY/check_engine_plugin.c
bcc67f
@@ -47,7 +47,7 @@ static void check_engine_plugin_def_free(struct check_engine_plugin_def *plugin)
bcc67f
 	free(plugin);
bcc67f
 }
bcc67f
 
bcc67f
-struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool quiet)
bcc67f
+struct check_engine_plugin_def *check_engine_plugin_load(const char* path)
bcc67f
 {
bcc67f
 	struct check_engine_plugin_def *ret = check_engine_plugin_def_new();
bcc67f
 
bcc67f
@@ -61,10 +61,9 @@ struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool
bcc67f
 	if (!ret->module_handle) {
bcc67f
 		error = dlerror();
bcc67f
 
bcc67f
-		if (!quiet)
bcc67f
-			oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
-				"Failed to load extra check engine from '%s'. Details: '%s'.",
bcc67f
-				path, error);
bcc67f
+		oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
+			"Failed to load extra check engine from '%s'. Details: '%s'.",
bcc67f
+			path, error);
bcc67f
 
bcc67f
 		check_engine_plugin_def_free(ret);
bcc67f
 		return NULL;
bcc67f
@@ -74,10 +73,9 @@ struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool
bcc67f
 	*(void **)(&entry_fn) = dlsym(ret->module_handle, STRINGIZE(OPENSCAP_CHECK_ENGINE_PLUGIN_ENTRY));
bcc67f
 
bcc67f
 	if ((error = dlerror()) != NULL) {
bcc67f
-		if (!quiet)
bcc67f
-			oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
-				"Failed to retrieve module entry '%s' from loaded extra check engine '%s'. Details: '%s'.",
bcc67f
-				STRINGIZE(OPENSCAP_CHECK_ENGINE_PLUGIN_ENTRY), path, error);
bcc67f
+		oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
+			"Failed to retrieve module entry '%s' from loaded extra check engine '%s'. Details: '%s'.",
bcc67f
+			STRINGIZE(OPENSCAP_CHECK_ENGINE_PLUGIN_ENTRY), path, error);
bcc67f
 
bcc67f
 		dlclose(ret->module_handle);
bcc67f
 		check_engine_plugin_def_free(ret);
bcc67f
@@ -85,9 +83,8 @@ struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool
bcc67f
 	}
bcc67f
 
bcc67f
 	if ((*entry_fn)(ret) != 0) {
bcc67f
-		if (!quiet)
bcc67f
-			oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
-				"Failed to fill check_engine_plugin_def when loading check engine plugin '%s'.", path);
bcc67f
+		oscap_seterr(OSCAP_EFAMILY_GLIBC,
bcc67f
+			"Failed to fill check_engine_plugin_def when loading check engine plugin '%s'.", path);
bcc67f
 
bcc67f
 		dlclose(ret->module_handle);
bcc67f
 		check_engine_plugin_def_free(ret);
bcc67f
@@ -97,11 +94,6 @@ struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool
bcc67f
 	return ret;
bcc67f
 }
bcc67f
 
bcc67f
-struct check_engine_plugin_def *check_engine_plugin_load(const char* path)
bcc67f
-{
bcc67f
-	return check_engine_plugin_load2(path, false);
bcc67f
-}
bcc67f
-
bcc67f
 void check_engine_plugin_unload(struct check_engine_plugin_def *plugin)
bcc67f
 {
bcc67f
 	if (!plugin->module_handle) {
bcc67f
diff --git a/src/XCCDF_POLICY/public/check_engine_plugin.h b/src/XCCDF_POLICY/public/check_engine_plugin.h
bcc67f
index 4a992ae3..7878fe07 100644
bcc67f
--- a/src/XCCDF_POLICY/public/check_engine_plugin.h
bcc67f
+++ b/src/XCCDF_POLICY/public/check_engine_plugin.h
bcc67f
@@ -52,7 +52,6 @@ struct check_engine_plugin_def
bcc67f
 	const char *(*get_capabilities_fn)(void**);
bcc67f
 };
bcc67f
 
bcc67f
-struct check_engine_plugin_def *check_engine_plugin_load2(const char* path, bool quiet);
bcc67f
 struct check_engine_plugin_def *check_engine_plugin_load(const char* path);
bcc67f
 void check_engine_plugin_unload(struct check_engine_plugin_def *plugin);
bcc67f
 
bcc67f
diff --git a/src/common/debug.c b/src/common/debug.c
bcc67f
index 80731b0f..cb1f9290 100644
bcc67f
--- a/src/common/debug.c
bcc67f
+++ b/src/common/debug.c
bcc67f
@@ -86,7 +86,7 @@ oscap_verbosity_levels oscap_verbosity_level_from_cstr(const char *level_name)
bcc67f
 bool oscap_set_verbose(const char *verbosity_level, const char *filename, bool is_probe)
bcc67f
 {
bcc67f
 	if (verbosity_level == NULL) {
bcc67f
-		verbosity_level = "WARNING";
bcc67f
+		return true;
bcc67f
 	}
bcc67f
 	__debuglog_level = oscap_verbosity_level_from_cstr(verbosity_level);
bcc67f
 	if (__debuglog_level == DBG_UNKNOWN) {
bcc67f
diff --git a/tests/API/OVAL/unittests/test_external_variable.sh b/tests/API/OVAL/unittests/test_external_variable.sh
bcc67f
index 8f6a2e8c..e23dd556 100755
bcc67f
--- a/tests/API/OVAL/unittests/test_external_variable.sh
bcc67f
+++ b/tests/API/OVAL/unittests/test_external_variable.sh
bcc67f
@@ -9,11 +9,7 @@ stderr=$(mktemp ${name}.err.XXXXXX)
bcc67f
 echo "stderr file: $stderr"
bcc67f
 
bcc67f
 $OSCAP oval eval --results $result --variables $srcdir/external_variables.xml $srcdir/$name.oval.xml 2> $stderr
bcc67f
-# filter out the expected warnings in stderr
bcc67f
-
bcc67f
-sed -i -E "/^W: oscap:[ ]+Referenced variable has no values \(oval:x:var:[13689]\)/d" "$stderr"
bcc67f
-[ -f $stderr ]; [ ! -s $stderr ]; rm $stderr
bcc67f
-
bcc67f
+[ ! -s $stderr ] && rm $stderr
bcc67f
 [ -s $result ]
bcc67f
 
bcc67f
 assert_exists 10 '/oval_results/oval_definitions/variables/external_variable'
bcc67f
diff --git a/tests/API/OVAL/unittests/test_object_component_type.sh b/tests/API/OVAL/unittests/test_object_component_type.sh
bcc67f
index f9189c08..30c84a44 100755
bcc67f
--- a/tests/API/OVAL/unittests/test_object_component_type.sh
bcc67f
+++ b/tests/API/OVAL/unittests/test_object_component_type.sh
bcc67f
@@ -8,6 +8,8 @@ set -o pipefail
bcc67f
 $OSCAP oval eval $srcdir/test_object_component_type.oval.xml 2> $stderr || ret=$?
bcc67f
 [ $ret -eq 1 ]
bcc67f
 
bcc67f
+stderr_line_count=`cat $stderr | wc -l`
bcc67f
+[ $stderr_line_count -eq 2 ]
bcc67f
 grep -q "Entity [']something_bogus['] has not been found in textfilecontent_item (id: [0-9]\+) specified by object [']oval:oscap:obj:10[']." $stderr
bcc67f
 grep -q "Expected record data type, but found string data type in subexpression entity in textfilecontent_item (id: [0-9]\+) specified by object [']oval:oscap:obj:10[']."  $stderr
bcc67f
 
bcc67f
diff --git a/tests/API/XCCDF/unittests/test_remediation_subs_unresolved.sh b/tests/API/XCCDF/unittests/test_remediation_subs_unresolved.sh
bcc67f
index 44ae2f77..f48239d9 100755
bcc67f
--- a/tests/API/XCCDF/unittests/test_remediation_subs_unresolved.sh
bcc67f
+++ b/tests/API/XCCDF/unittests/test_remediation_subs_unresolved.sh
bcc67f
@@ -35,8 +35,6 @@ assert_exists 1 '//score[text()="0.000000"]'
bcc67f
 ret=0
bcc67f
 $OSCAP xccdf eval --remediate --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
bcc67f
 [ $ret -eq 2 ]
bcc67f
-# filter out the expected warning in stderr
bcc67f
-sed -i -E "/^W: oscap: The xccdf:rule-result\/xccdf:instance element was not found./d" "$stderr"
bcc67f
 [ -f $stderr ]; [ ! -s $stderr ]; rm $stderr
bcc67f
 
bcc67f
 $OSCAP xccdf validate-xml $result
bcc67f
diff --git a/tests/probes/sql57/unsupported_engine.sh b/tests/probes/sql57/unsupported_engine.sh
bcc67f
index 6243cff3..f90d6c8b 100755
bcc67f
--- a/tests/probes/sql57/unsupported_engine.sh
bcc67f
+++ b/tests/probes/sql57/unsupported_engine.sh
bcc67f
@@ -10,8 +10,6 @@ echo "stderr file: $stderr"
bcc67f
 
bcc67f
 echo "Evaluating content."
bcc67f
 $OSCAP oval eval --results $result $srcdir/${name}.oval.xml 2> $stderr
bcc67f
-# filter out the expected error in stderr
bcc67f
-sed -i -E "/^E: lt-probe_sql57: DB engine not supported: sqlserver/d" "$stderr"
bcc67f
 [ -f $stderr ]; [ ! -s $stderr ]; rm $stderr
bcc67f
 echo "Validating results."
bcc67f
 #$OSCAP oval validate-xml --results --schematron $result
bcc67f
diff --git a/tests/probes/sysctl/test_sysctl_probe_all.sh b/tests/probes/sysctl/test_sysctl_probe_all.sh
bcc67f
index 435eaf5d..fa353925 100755
bcc67f
--- a/tests/probes/sysctl/test_sysctl_probe_all.sh
bcc67f
+++ b/tests/probes/sysctl/test_sysctl_probe_all.sh
bcc67f
@@ -29,8 +29,6 @@ grep unix-sys:name "$result" | sed -E 's;.*>(.*)<.*;\1;g' | sort > "$ourNames"
bcc67f
 
bcc67f
 diff "$sysctlNames" "$ourNames"
bcc67f
 
bcc67f
-# remove oscap error message related to permissions from stderr
bcc67f
-sed -i -E "/^E: lt-probe_sysctl: Can't read sysctl value from /d" "$stderr"
bcc67f
 [ ! -s $stderr ]
bcc67f
 
bcc67f
 rm $stderr $result $ourNames $sysctlNames
bcc67f
diff --git a/utils/oscap.c b/utils/oscap.c
bcc67f
index 9d3386fd..1f22c49b 100644
bcc67f
--- a/utils/oscap.c
bcc67f
+++ b/utils/oscap.c
bcc67f
@@ -130,8 +130,7 @@ static int print_versions(const struct oscap_action *action)
bcc67f
 	const char * const *known_plugins = check_engine_plugin_get_known_plugins();
bcc67f
 	bool known_plugin_found = false;
bcc67f
 	while (*known_plugins) {
bcc67f
-		// try to load the plugin but output no errors if it fails (quiet=true)
bcc67f
-		struct check_engine_plugin_def *plugin = check_engine_plugin_load2(*known_plugins, true);
bcc67f
+		struct check_engine_plugin_def *plugin = check_engine_plugin_load(*known_plugins);
bcc67f
 		if (plugin) {
bcc67f
 			printf("%s (from %s)\n", check_engine_plugin_get_capabilities(plugin), *known_plugins);
bcc67f
 			check_engine_plugin_unload(plugin);
bcc67f
-- 
bcc67f
2.14.3
bcc67f