Blob Blame History Raw
From ce74fde37771fa2cf6d947e5aaeebd9a197db50b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
Date: Tue, 9 Nov 2021 09:15:20 +0100
Subject: [PATCH] Print warning for local files

This will explicitely display users that they're using local
files instead of the remote resource.

See https://bugzilla.redhat.com/show_bug.cgi?id=1970529#c6
---
 src/DS/sds.c                                   | 4 +++-
 tests/DS/test_ds_use_local_remote_resources.sh | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/DS/sds.c b/src/DS/sds.c
index a26fdbb09..243b62968 100644
--- a/src/DS/sds.c
+++ b/src/DS/sds.c
@@ -407,7 +407,9 @@ static int _handle_disabled_downloads(struct ds_sds_session *session, const char
 	char *local_filepath = oscap_path_join(local_files, relative_filepath);
 	struct stat sb;
 	if (stat(local_filepath, &sb) == 0) {
-		dI("Using local file '%s' instead of '%s'", local_filepath, xlink_href);
+		ds_sds_session_remote_resources_progress(session)(true,
+			"WARNING: Using local file '%s' instead of '%s'",
+			local_filepath, xlink_href);
 		struct oscap_source *source_file = oscap_source_new_from_file(local_filepath);
 		xmlDoc *doc = oscap_source_get_xmlDoc(source_file);
 		if (doc == NULL) {
diff --git a/tests/DS/test_ds_use_local_remote_resources.sh b/tests/DS/test_ds_use_local_remote_resources.sh
index 789dc8326..2feb47da1 100755
--- a/tests/DS/test_ds_use_local_remote_resources.sh
+++ b/tests/DS/test_ds_use_local_remote_resources.sh
@@ -24,6 +24,7 @@ $OSCAP xccdf eval --local-files "$tmpdir3" --profile "$PROFILE" --results "$resu
 
 grep -q "WARNING: Datastream component 'scap_org.open-scap_cref_remote.oval.xml' points out to the remote 'https://www.example.com/security/data/oval/remote.oval.xml'. Use '--fetch-remote-resources' option to download it." "$stderr" && false
 grep -q "WARNING: Skipping 'https://www.example.com/security/data/oval/remote.oval.xml' file which is referenced from datastream" "$stderr" && false
+grep -q "WARNING: Using local file '$tmpdir3/remote.oval.xml' instead of 'https://www.example.com/security/data/oval/remote.oval.xml'" "$stderr"
 
 assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
 # the remote_res rule is a multicheck with 2 oval definitions so it's twice here