Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 5b27c2a

Browse files
committed
Moved audit runner to separate function
1 parent 280d5f5 commit 5b27c2a

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

_modules/hubble.py

+24-11
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,30 @@ def audit(configs=None,
135135
configs = [os.path.join(os.path.sep, os.path.join(*(con.split('.yaml')[0]).split('.')))
136136
for con in configs]
137137

138+
ret = _run_audit(
139+
configs,
140+
tags,
141+
verbose=verbose,
142+
debug=debug,
143+
show_profile=show_profile
144+
)
145+
146+
if show_compliance:
147+
compliance = _calculate_compliance(results)
148+
if compliance:
149+
results['Compliance'] = compliance
150+
151+
if not called_from_top and not results:
152+
results['Messages'] = 'No audits matched this host in the specified profiles.'
153+
154+
if not show_success and 'Success' in results:
155+
results.pop('Success')
156+
157+
return ret
158+
159+
160+
def _run_audit(configs, tags, verbose, debug, show_profile):
161+
138162
results = {}
139163

140164
# Compile a list of audit data sets which we need to run
@@ -243,21 +267,10 @@ def audit(configs=None,
243267
for failure_index in reversed(sorted(set(failures_to_remove))):
244268
results['Failure'].pop(failure_index)
245269

246-
if show_compliance:
247-
compliance = _calculate_compliance(results)
248-
if compliance:
249-
results['Compliance'] = compliance
250-
251270
for key in results.keys():
252271
if not results[key]:
253272
results.pop(key)
254273

255-
if not called_from_top and not results:
256-
results['Messages'] = 'No audits matched this host in the specified profiles.'
257-
258-
if not show_success and 'Success' in results:
259-
results.pop('Success')
260-
261274
return results
262275

263276

0 commit comments

Comments
 (0)