adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone

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

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