Skip to content

Commit c8d3c87

Browse files
authored
Merge pull request #1931 from candrews/oscap-docker-fixes
oscap-docker: remove atomic, fix environment variable configuration
2 parents 7111011 + 497effd commit c8d3c87

File tree

3 files changed

+161
-503
lines changed

3 files changed

+161
-503
lines changed

utils/oscap-docker.in

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,20 @@
2121
''' oscap docker command '''
2222

2323
import argparse
24-
from oscap_docker_python.oscap_docker_util import OscapAtomicScan, \
25-
OscapDockerScan, isAtomicLoaded
24+
from oscap_docker_python.oscap_docker_util import OscapDockerScan
2625

2726
import docker
2827
import traceback
2928
import sys
3029
from requests import exceptions
3130

3231

33-
def ping_docker():
34-
''' Simple check if the docker daemon is running '''
35-
# Class docker.Client was renamed to docker.APIClient in
36-
# python-docker-py 2.0.0.
37-
try:
38-
client = docker.APIClient()
39-
except AttributeError:
40-
client = docker.Client()
41-
client.ping()
42-
43-
4432
if __name__ == '__main__':
4533
parser = argparse.ArgumentParser(description='oscap docker',
4634
epilog='See `man oscap` to learn \
4735
more about OSCAP-ARGUMENTS')
4836
parser.add_argument('--oscap', dest='oscap_binary', default='',
4937
help='Set the oscap binary to use')
50-
51-
parser.add_argument('--disable-atomic', dest='noatomic', action='store_true',
52-
help="Force to use native docker API instead of atomic")
5338
subparser = parser.add_subparsers(help="commands")
5439

5540
# Scan CVEs in image
@@ -87,35 +72,14 @@ if __name__ == '__main__':
8772
sys.exit(2)
8873

8974
try:
90-
ping_docker()
91-
92-
except exceptions.ConnectionError:
93-
print("The docker daemon does not appear to be running")
94-
sys.exit(1)
95-
96-
try:
97-
if isAtomicLoaded() and not args.noatomic:
98-
print("Using Atomic API")
99-
OS = OscapAtomicScan(oscap_binary=args.oscap_binary)
100-
if args.action == "scan":
101-
rc = OscapAtomicScan.scan(OS, args.scan_target, leftover_args)
102-
elif args.action == "scan_cve":
103-
rc = OscapAtomicScan.scan_cve(OS, args.scan_target, leftover_args)
104-
else:
105-
parser.print_help()
106-
sys.exit(2)
107-
108-
else: # without atomic
109-
print("Using native Docker API")
110-
111-
ODS = OscapDockerScan(args.scan_target, args.is_image, args.oscap_binary)
112-
if args.action == "scan":
113-
rc = OscapDockerScan.scan(ODS, leftover_args)
114-
elif args.action == "scan_cve":
115-
rc = OscapDockerScan.scan_cve(ODS, leftover_args)
116-
else:
117-
parser.print_help()
118-
sys.exit(2)
75+
ODS = OscapDockerScan(args.scan_target, args.is_image, args.oscap_binary)
76+
if args.action == "scan":
77+
rc = OscapDockerScan.scan(ODS, leftover_args)
78+
elif args.action == "scan_cve":
79+
rc = OscapDockerScan.scan_cve(ODS, leftover_args)
80+
else:
81+
parser.print_help()
82+
sys.exit(2)
11983

12084
except (ValueError, RuntimeError) as e:
12185
raise e

0 commit comments

Comments
 (0)