Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface fields at inventory-networks root level #573

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def generate_random_agent():
return agent


def generate_random_host(is_root_level=False):
if is_root_level:
def generate_random_host(is_root_level_level=False):
if is_root_level_level:
host = {
'ip': f'{random.randint(1, 255)}.{random.randint(0, 255)}.{random.randint(0, 255)}.{random.randint(0, 255)}',
'mac': f'{random.randint(0, 255):02x}:{random.randint(0, 255):02x}:{random.randint(0, 255):02x}:{random.randint(0, 255):02x}:{random.randint(0, 255):02x}:{random.randint(0, 255):02x}',
Expand Down Expand Up @@ -158,14 +158,25 @@ def generate_random_network():
}
return network

def generate_random_interface(is_root_level=False):
if is_root_level:
interface = {
'mtu': f'{random.randint(1000000, 99999999)}',
'state': random.choice(['Active', 'Inactive', 'Unknown']),
'type': random.choice(['wireless', 'ethernet'])
}
else:
interface = {
'alias': f'alias{random.randint(0, 9999)}',
'name': f'name{random.randint(0, 9999)}',
}

return interface

def generate_random_observer():
observer = {
'ingress': {
'interface': {
'alias': f'alias{random.randint(0, 9999)}',
'name': f'name{random.randint(0, 9999)}'
}
'interface': generate_random_interface(False)
}
}
return observer
Expand All @@ -179,7 +190,8 @@ def generate_random_data(number):
'agent': generate_random_agent(),
'host': generate_random_host(True),
'network': generate_random_network(),
'observer': generate_random_observer()
'observer': generate_random_observer(),
'interface': generate_random_interface(True)
}
data.append(event_data)
return data
Expand Down
4 changes: 4 additions & 0 deletions ecs/states-inventory-networks/fields/custom/interface.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
- name: interface
reusable:
top_level: true
expected:
- { at: observer.egress.interface, as: observer.ingress.interface }
title: Interface
type: group
group: 2
Expand Down