import_content was trying to save everything, even when it shouldn't. Also fixed a mistake when running list on a single benchmark. --- src/bin/secstate | 2 +- src/secstate/main.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/bin/secstate b/src/bin/secstate index a7bf097..8cd84f2 100644 --- a/src/bin/secstate +++ b/src/bin/secstate @@ -111,7 +111,7 @@ def import_content(arguments): (options, args) = parser.parse_args(arguments)
for arg in args: - (benchmark, def_model) = sec_instance.import_content(arg, options.cpe, options.puppet) + (benchmark, def_model) = sec_instance.import_content(arg, options.cpe, options.puppet, save=True) if (benchmark == None) and (def_model == None): return -1 oscap.oval_definition_model_free(def_model) diff --git a/src/secstate/main.py b/src/secstate/main.py index dfa12e9..e22172f 100644 --- a/src/secstate/main.py +++ b/src/secstate/main.py @@ -344,7 +344,7 @@ class Secstate: return (benchmark, def_model)
- def import_content(self, content, cpe=False, puppet=False, changes=True, save=True): + def import_content(self, content, cpe=False, puppet=False, changes=True, save=False): """ Function: Validates XCCDF/OVAL content and optionally saves it to the data store Input: File containing content @@ -544,7 +544,7 @@ class Secstate: for arg in args: (benchmark, def_model) = self.import_content(arg) if (benchmark == None) and (def_model == None): - self.log.error("Error importing benchmark: %(bench)s" % {'bench':arg}) + self.log.error("Error importing content: %(bench)s" % {'bench':arg}) return False
else: @@ -804,7 +804,8 @@ class Secstate: ret = self.sublist(benchmark, config, def_model, key, recurse, show_all)
else: - ret = self.sublist(benchmark, config, def_model, arg, recurse, show_all) + if not self.content.has_key(arg): + ret = self.sublist(benchmark, config, def_model, arg, recurse, show_all)
oscap.xccdf_benchmark_free(benchmark) oscap.oval_definition_model_free(def_model)