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 macOS network interface plugin #839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cecinestpasunepipe
Copy link
Contributor

(DIS-3024)

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

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

Project coverage is 75.64%. Comparing base (95f27ae) to head (7cedb4b).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
dissect/target/plugins/os/unix/bsd/osx/network.py 95.89% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #839      +/-   ##
==========================================
+ Coverage   75.51%   75.64%   +0.12%     
==========================================
  Files         305      312       +7     
  Lines       26348    26625     +277     
==========================================
+ Hits        19897    20140     +243     
- Misses       6451     6485      +34     
Flag Coverage Δ
unittests 75.64% <96.00%> (+0.12%) ⬆️

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.

@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-3024_network_class_mac branch 8 times, most recently from 0e9676d to bee41b3 Compare September 3, 2024 20:17
@Schamper Schamper changed the title Add MacNetworkPlugin Add macOS network plugin Sep 5, 2024
@Schamper Schamper changed the title Add macOS network plugin Add macOS network interface plugin Sep 5, 2024
Comment on lines +14 to +15
plistlease = {}
plistnetwork = {}
Copy link
Member

Choose a reason for hiding this comment

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

I think an @cache better shows your intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate please?

Copy link
Member

Choose a reason for hiding this comment

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

Use the @cache decorator instead of a manually maintained dict.

Comment on lines +12 to +13
SYSTEM = "/Library/Preferences/SystemConfiguration/preferences.plist"
DHCP = "/private/var/db/dhcpclient/leases"
Copy link
Member

Choose a reason for hiding this comment

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

Can you inline these in the code.

Comment on lines +58 to +64
record = MacInterfaceRecord(_target=self.target)
record.source = "NetworkServices"
device = interface.get("Interface", {})
record.name = device.get("DeviceName")
record.type = device.get("Type")
record.vlan = vlan_lookup.get(record.name)
record.interface_service_order = service_order.index(_id) if _id in service_order else None
Copy link
Member

Choose a reason for hiding this comment

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

We don't really use this way of initializing a record anywhere else, can you change that to how we usually do it?

from dissect.target.plugins.os.unix.bsd.osx.network import MacNetworkPlugin
from dissect.target.target import Target

fake_plist = {
Copy link
Member

Choose a reason for hiding this comment

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

I think if you make this a fixture, you can get rid of all the deep copies.

Comment on lines +14 to +15
plistlease = {}
plistnetwork = {}
Copy link
Member

Choose a reason for hiding this comment

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

Use the @cache decorator instead of a manually maintained dict.

@@ -175,7 +175,7 @@ def DynamicDescriptor(types): # noqa
[
*COMMON_INTERFACE_ELEMENTS,
("varint", "vlan"),
("string", "proxy"),
("net.ipaddress[]", "proxy"),
Copy link
Member

Choose a reason for hiding this comment

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

As I don't think you'll want to add it in this PR, can you add a ticket to extend the macOS network interface plugin with proxy records that include the type, port and exclusions.

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.

3 participants