Skip to content

Commit 267eaae

Browse files
authored
Merge branch 'py3' into py3_merge_fix
2 parents 8dfe247 + 1f455dc commit 267eaae

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

hubblestack/extmods/grains/cloud_details.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def _get_aws_details():
4949
# Else it will throw an Exception
5050
int(aws['cloud_account_id'])
5151
aws['cloud_instance_id'] = requests.get('http://169.254.169.254/latest/meta-data/instance-id',
52-
headers=aws_token_header, timeout=3, proxies=proxies).text
53-
52+
headers=aws_token_header, timeout=3,
53+
proxies=proxies).text
5454
except (requests.exceptions.RequestException, ValueError):
5555
# Not on an AWS box
5656
aws = None
@@ -61,13 +61,16 @@ def _get_aws_details():
6161
aws_extra['cloud_availability_zone'] = res.get('availabilityZone')
6262
aws_extra['cloud_ami_id'] = res.get('imageId')
6363
aws_extra['cloud_region'] = res.get('region')
64-
r = requests.get('http://169.254.169.254/latest/meta-data/public-hostname', headers=aws_token_header, timeout=3, proxies=proxies)
64+
r = requests.get('http://169.254.169.254/latest/meta-data/public-hostname',
65+
headers=aws_token_header, timeout=3, proxies=proxies)
6566
if r.status_code == requests.codes.ok:
6667
aws_extra['cloud_public_hostname'] = r.text
67-
r = requests.get('http://169.254.169.254/latest/meta-data/public-ipv4', headers=aws_token_header, timeout=3, proxies=proxies)
68+
r = requests.get('http://169.254.169.254/latest/meta-data/public-ipv4',
69+
headers=aws_token_header, timeout=3, proxies=proxies)
6870
if r.status_code == requests.codes.ok:
6971
aws_extra['cloud_public_ipv4'] = r.text
70-
r = requests.get('http://169.254.169.254/latest/meta-data/local-hostname', headers=aws_token_header, timeout=3, proxies=proxies)
72+
r = requests.get('http://169.254.169.254/latest/meta-data/local-hostname',
73+
headers=aws_token_header, timeout=3, proxies=proxies)
7174
if r.status_code == requests.codes.ok:
7275
aws_extra['cloud_private_hostname'] = r.text
7376
for key in aws_extra.keys():
@@ -228,5 +231,4 @@ def _build_gpc_extra(gcp_header, proxies):
228231
'externalIp' in item]
229232
gcp_extra[grain_name_accessconfig_external_ips] = ','.join(external_ips_list)
230233

231-
232234
return gcp_extra

hubblestack/extmods/modules/nebula_osquery.py

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ def queries(query_group,
116116

117117
query_data = query_data.get(query_group, {})
118118

119+
if not query_group:
120+
return None
119121
if not query_data:
120122
return None
121123

hubblestack/status.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def stats(cls):
479479
min_t = min([x['first_t'] for x in stats_short.values() if x['first_t'] > 0])
480480
time_stats = {'time': max_t, 'dt': min_dt, 'start': min_t}
481481
stats_short['HEALTH'] = health_stats = {
482-
'buckets': {k: n.buckets for k, n in cls.dat.iteritems()},
482+
'buckets': {k: n.buckets for k, n in cls.dat.items()},
483483
'last_activity': time_stats,
484484
}
485485
stats_short['__doc__'] = {

tests/unittests/test_stat_nova.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ def test_virtual(self):
1111

1212
def test_merge_yaml(self):
1313
ret = {}
14-
data = {'stat': {'passwd_owner_group': {'nova_profile': 'ubuntu-1604-level-1-scored-v1-0-0',
15-
'data': {'Ubuntu-16.04': [{'/etc/passwd': {'gid': 0, 'tag': 'CIS-12.4', 'group': 'root', 'uid': 0, 'user': 'root'}}]},
16-
'description': 'Verify User/Group Ownership on /etc/passwd'}}}
14+
data = {
15+
'stat': {'passwd_owner_group': {
16+
'nova_profile': 'ubuntu-1604-level-1-scored-v1-0-0',
17+
'data': {'Ubuntu-16.04': [{'/etc/passwd': {'gid': 0,
18+
'tag': 'CIS-12.4',
19+
'group': 'root',
20+
'uid': 0,
21+
'user': 'root'}}]},
22+
'description': 'Verify User/Group Ownership on /etc/passwd'}}}
1723
profile = 'ubuntu-1604-level-1-scored-v1-0-0'
1824
val = hubblestack.files.hubblestack_nova.stat_nova._merge_yaml(ret, data, profile)
19-
assert val['stat'] == [{'passwd_owner_group': {'nova_profile': 'ubuntu-1604-level-1-scored-v1-0-0',
20-
'data': {'Ubuntu-16.04': [{'/etc/passwd': {'group': 'root', 'gid': 0, 'tag': 'CIS-12.4', 'uid': 0, 'user': 'root'}}]},
21-
'description': 'Verify User/Group Ownership on /etc/passwd'}}]
25+
assert val['stat'] == [{'passwd_owner_group': {
26+
'nova_profile': 'ubuntu-1604-level-1-scored-v1-0-0',
27+
'data': {'Ubuntu-16.04': [{'/etc/passwd': {'group': 'root',
28+
'gid': 0,
29+
'tag': 'CIS-12.4',
30+
'uid': 0,
31+
'user': 'root'}}]},
32+
'description': 'Verify User/Group Ownership on /etc/passwd'}}]
2233

2334
def test_merge_yaml_recurssive(self):
2435
ret = {}

0 commit comments

Comments
 (0)