|
|
5a421d |
From ce74fde37771fa2cf6d947e5aaeebd9a197db50b Mon Sep 17 00:00:00 2001
|
|
|
5a421d |
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
|
|
|
5a421d |
Date: Tue, 9 Nov 2021 09:15:20 +0100
|
|
|
5a421d |
Subject: [PATCH] Print warning for local files
|
|
|
5a421d |
|
|
|
5a421d |
This will explicitely display users that they're using local
|
|
|
5a421d |
files instead of the remote resource.
|
|
|
5a421d |
|
|
|
5a421d |
See https://bugzilla.redhat.com/show_bug.cgi?id=1970529#c6
|
|
|
5a421d |
---
|
|
|
5a421d |
src/DS/sds.c | 4 +++-
|
|
|
5a421d |
tests/DS/test_ds_use_local_remote_resources.sh | 1 +
|
|
|
5a421d |
2 files changed, 4 insertions(+), 1 deletion(-)
|
|
|
5a421d |
|
|
|
5a421d |
diff --git a/src/DS/sds.c b/src/DS/sds.c
|
|
|
5a421d |
index a26fdbb09..243b62968 100644
|
|
|
5a421d |
--- a/src/DS/sds.c
|
|
|
5a421d |
+++ b/src/DS/sds.c
|
|
|
5a421d |
@@ -407,7 +407,9 @@ static int _handle_disabled_downloads(struct ds_sds_session *session, const char
|
|
|
5a421d |
char *local_filepath = oscap_path_join(local_files, relative_filepath);
|
|
|
5a421d |
struct stat sb;
|
|
|
5a421d |
if (stat(local_filepath, &sb) == 0) {
|
|
|
5a421d |
- dI("Using local file '%s' instead of '%s'", local_filepath, xlink_href);
|
|
|
5a421d |
+ ds_sds_session_remote_resources_progress(session)(true,
|
|
|
5a421d |
+ "WARNING: Using local file '%s' instead of '%s'",
|
|
|
5a421d |
+ local_filepath, xlink_href);
|
|
|
5a421d |
struct oscap_source *source_file = oscap_source_new_from_file(local_filepath);
|
|
|
5a421d |
xmlDoc *doc = oscap_source_get_xmlDoc(source_file);
|
|
|
5a421d |
if (doc == NULL) {
|
|
|
5a421d |
diff --git a/tests/DS/test_ds_use_local_remote_resources.sh b/tests/DS/test_ds_use_local_remote_resources.sh
|
|
|
5a421d |
index 789dc8326..2feb47da1 100755
|
|
|
5a421d |
--- a/tests/DS/test_ds_use_local_remote_resources.sh
|
|
|
5a421d |
+++ b/tests/DS/test_ds_use_local_remote_resources.sh
|
|
|
5a421d |
@@ -24,6 +24,7 @@ $OSCAP xccdf eval --local-files "$tmpdir3" --profile "$PROFILE" --results "$resu
|
|
|
5a421d |
|
|
|
5a421d |
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
|
|
|
5a421d |
grep -q "WARNING: Skipping 'https://www.example.com/security/data/oval/remote.oval.xml' file which is referenced from datastream" "$stderr" && false
|
|
|
5a421d |
+grep -q "WARNING: Using local file '$tmpdir3/remote.oval.xml' instead of 'https://www.example.com/security/data/oval/remote.oval.xml'" "$stderr"
|
|
|
5a421d |
|
|
|
5a421d |
assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
|
|
|
5a421d |
# the remote_res rule is a multicheck with 2 oval definitions so it's twice here
|