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

Create base class for the network plugin #810

Merged

Conversation

Miauwkeru
Copy link
Contributor

closes #774

@Miauwkeru Miauwkeru linked an issue Aug 7, 2024 that may be closed by this pull request
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 75.53%. Comparing base (ba9bf7b) to head (d7773bc).

Files Patch % Lines
dissect/target/plugins/general/network.py 94.64% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #810      +/-   ##
==========================================
+ Coverage   75.48%   75.53%   +0.04%     
==========================================
  Files         298      299       +1     
  Lines       25684    25744      +60     
==========================================
+ Hits        19388    19445      +57     
- Misses       6296     6299       +3     
Flag Coverage Δ
unittests 75.53% <95.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Miauwkeru Miauwkeru force-pushed the 774-create-base-class-for-default-os-network-interface-plugin branch from 6c7ae43 to 8fea5e4 Compare August 8, 2024 09:27
@Miauwkeru Miauwkeru requested a review from Schamper August 8, 2024 09:28
[
*COMMON_INTERFACE_ELEMENTS,
("string", "vlan"),
("string", "dns_server"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be just "dns"?

[
*COMMON_INTERFACE_ELEMENTS,
("string", "vlan"),
("string", "dns_server"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be just "dns"?

Comment on lines 26 to 30
output_list = []
for record in self.find_interfaces():
if output := getattr(record, field_name, None):
output_list.append(output)
return output_list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
output_list = []
for record in self.find_interfaces():
if output := getattr(record, field_name, None):
output_list.append(output)
return output_list
yield from filter( lambda elem: elem is not None,
map( lambda elem: getattr(elem, field_name, None), self.find_interfaces() )
)

but maybe this is just making things more complex...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adjusted the current one slightly to remove indentation and add support for list operations.

("string", "mac"),
("net.ipaddress", "ip"),
("net.ipaddress", "gateway"),
("string", "source"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dns not part of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the ticket, with dns not being explicitly part of unix stuff.
I did see you can retrieve that information using systemd or resolvectl, so it probably should be added.
I will also adjust it a little bit, as a single interface can have multiple ips and gateways and so on.

Also add caching of the records, so they would only need to be computed once in the future
@Miauwkeru Miauwkeru requested a review from Schamper August 12, 2024 08:55
@Miauwkeru Miauwkeru merged commit 789009d into main Aug 12, 2024
18 checks passed
@Miauwkeru Miauwkeru deleted the 774-create-base-class-for-default-os-network-interface-plugin branch August 12, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create base class for default OS network interface plugin
3 participants