Skip to content

Commit e44775f

Browse files
committed
Add Audit support in CLI
1 parent 89ab393 commit e44775f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

DockerENT/controller.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ def main(docker_containers,
2828

2929
process_pool = pool.Pool(process_count)
3030
output_q = multiprocessing.Manager().Queue()
31+
audit_q = None
32+
33+
if audit:
34+
audit_q = multiprocessing.Manager().Queue()
3135

3236
if docker_containers is not None:
3337
scanner_workers.docker_scan_worker(
3438
containers=docker_containers,
3539
plugins=docker_plugins,
3640
process_pool=process_pool,
37-
output_queue=output_q
41+
output_queue=output_q,
42+
audit=audit,
43+
audit_queue=audit_q
3844
)
3945

4046
if docker_nws is not None:
@@ -51,3 +57,10 @@ def main(docker_containers,
5157
output_worker.output_handler(
5258
queue=output_q,
5359
target=output)
60+
61+
if audit:
62+
output_worker.output_handler(
63+
queue=audit_q,
64+
target=output,
65+
filename='audit.json'
66+
)

DockerENT/output_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
_log = logging.getLogger(__name__)
66

77

8-
def output_handler(queue, target):
8+
def output_handler(queue, target, filename='out.json'):
99
"""Worker function passes the queue to target.
1010
1111
:param queue: This queue holds the output from each plugin executed.
@@ -17,4 +17,4 @@ def output_handler(queue, target):
1717
:return: None
1818
"""
1919
output_plugin = importlib.import_module('DockerENT.output_plugins.'+target)
20-
output_plugin.write(queue)
20+
output_plugin.write(queue, filename)

DockerENT/scanner_workers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def executor(target,
5858
module.scan(target, output_queue, audit, audit_queue)
5959

6060

61-
def docker_scan_worker(containers, plugins, process_pool, output_queue):
61+
def docker_scan_worker(containers, plugins, process_pool, output_queue,
62+
audit, audit_queue):
6263
"""Docker scan worker.
6364
6465
:param containers: Containers to scan.
@@ -98,7 +99,8 @@ def docker_scan_worker(containers, plugins, process_pool, output_queue):
9899
executor_args = []
99100
for container in containers:
100101
for plugin in plugins:
101-
executor_args.append((container.id, plugin, output_queue, True,))
102+
executor_args.append(
103+
(container.id, plugin, output_queue, True, audit, audit_queue))
102104

103105
_log.debug(executor_args)
104106

0 commit comments

Comments
 (0)