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

New Table: Windows Firewall Rules #7403

Merged

Conversation

aleksmaus
Copy link
Contributor

@aleksmaus aleksmaus commented Dec 1, 2021

This change adds the new table windows_firewall_rules as requested in the issue: #7335

There are couple of deviations from the original requirement:

  • No version column, since it's not available through the API.
  • Reordered columns slightly.
  • Using enabled column name instead of active, more consistent with the API naming.
  • Using INTEGER for enabled column instead of TRUE/FALSE TEXT value.
  • Renamed rule_action into action field, more consistent with the API naming.
  • Renamed profile into profiles column that contains decoded comma separated text values like Private,Public. Could create individual rows for each if needed. Let me know.

Screenshot:
Screen Shot 2021-12-01 at 9 48 39 AM

I was not sure if we can use ATL CComPtr wrappers for example, it's cleaner this way.
Can rewrite without them if needed. Let me know.

Looking for a feedback if there is anything needs to be changed/added/removed.

Fixes: #7335

@aleksmaus aleksmaus requested review from a team as code owners December 1, 2021 15:03
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 1, 2021

CLA Signed

The committers are authorized under a signed CLA.

Copy link
Member

@directionless directionless left a comment

Choose a reason for hiding this comment

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

Thanks fo much for the implementation! I'm really excited to see this get into osquery

specs/windows/defender_firewall_rules.table Outdated Show resolved Hide resolved
@amalone-scwx
Copy link

Are these specific to Defender, or does it apply to Windows network firewall rules in-general?

@aleksmaus
Copy link
Contributor Author

Are these specific to Defender, or does it apply to Windows network firewall rules in-general?

This is windows firewall in general, using API defined in:
https://docs.microsoft.com/en-us/windows/win32/api/netfw/

https://en.wikipedia.org/wiki/Windows_Firewall
"Windows Firewall (officially called Windows Defender Firewall in Windows 10), is a firewall component of Microsoft Windows."

@amalone-scwx
Copy link

Maybe windows_firewall_rules is a better name, so as not to be confused with "Defender ATP"? Also, is there a way to get the ports open in the firewall? Admins will want to know which TCP and UDP ports are open for each rule.

@aleksmaus
Copy link
Contributor Author

Maybe windows_firewall_rules is a better name, so as not to be confused with "Defender ATP"? Also, is there a way to get the ports open in the firewall? Admins will want to know which TCP and UDP ports are open for each rule.

Renamed table defender_firewall_rules to windows_firewall_rules.
Added columns:

  • local_addresses
  • remote_addresses
  • local_ports
  • remote_ports
  • icmp_types_codes

Screen Shot 2021-12-01 at 5 52 53 PM

@amalone-scwx
Copy link

LGTM

@aleksmaus aleksmaus changed the title New Table: Windows Defender Firewall Rules New Table: Windows Firewall Rules Dec 2, 2021
@zwass zwass closed this Dec 8, 2021
@zwass zwass reopened this Dec 8, 2021
@aleksmaus
Copy link
Contributor Author

@zwass Thanks! Looks like still blocked on CLA verification. Will check with our team.

@zwass
Copy link
Member

zwass commented Dec 8, 2021

Thought that might help! I don't seem to have admin access to our EasyCLA account so not sure if there's anything else I can do at the moment.

@aleksmaus
Copy link
Contributor Author

/easycla

Copy link
Member

@alessandrogario alessandrogario left a comment

Choose a reason for hiding this comment

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

Hello @aleksmaus,

thanks for the PR! I have left some comments

@aleksmaus
Copy link
Contributor Author

Hello @aleksmaus,

thanks for the PR! I have left some comments

Thanks for the feedback! Most of the patterns borrowed from the existing code to make it consistent. Will update for suggested changes.

@aleksmaus
Copy link
Contributor Author

@alessandrogario I've made the changes that you requested. Could you take a look if this matches what you meant?
Also let me know if need to get rid of ATL.

@directionless
Copy link
Member

It looks like the CLA resolved itself. Closing and reopening is the simple way to get it to check.

FWIW a common issue is having commits that aren't tied to your github username in the PR. But for more complex stuff I usually dig up the easyCLA support email address.

@aleksmaus aleksmaus force-pushed the feature/defender_firewall_rules branch from 88f2b1d to 3f8f133 Compare December 17, 2021 00:55
Copy link
Member

@alessandrogario alessandrogario left a comment

Choose a reason for hiding this comment

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

This is really good code @aleksmaus! I have left some additional comments, I think we can merge this soon

osquery/tables/networking/windows/windows_firewall_rules.h Outdated Show resolved Hide resolved
osquery/tables/networking/CMakeLists.txt Show resolved Hide resolved
osquery/tables/networking/windows/windows_firewall_rules.h Outdated Show resolved Hide resolved
tests/integration/tables/windows_firewall_rules.cpp Outdated Show resolved Hide resolved
tests/integration/tables/windows_firewall_rules.cpp Outdated Show resolved Hide resolved
tests/integration/tables/windows_firewall_rules.cpp Outdated Show resolved Hide resolved
@aleksmaus aleksmaus force-pushed the feature/defender_firewall_rules branch from 9a59731 to 9ae981d Compare December 18, 2021 02:41
Copy link
Member

@alessandrogario alessandrogario left a comment

Choose a reason for hiding this comment

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

We have concluded that ATL should be removed since it does require a valid Visual Studio license, and not everyone contributing to osquery is eligible to use the Community Edition

Copy link
Member

@alessandrogario alessandrogario left a comment

Choose a reason for hiding this comment

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

This is excellent work, thank you for this cool table @aleksmaus!

@aleksmaus
Copy link
Contributor Author

This is excellent work, thank you for this cool table @aleksmaus!

Thank you for the code reviews @alessandrogario!

description("Provides the list of Windows firewall rules.")
schema([
Column("name", TEXT, "Friendly name of the rule"),
Column("app_name", TEXT, "Friendly name of the application to which the rule applies"),
Copy link
Member

Choose a reason for hiding this comment

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

Is there a non-friendly, but authoritative, way to link this rule to an app? (I haven't looked at the underlying API yet)

Copy link
Member

Choose a reason for hiding this comment

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

Digging through https://docs.microsoft.com/en-us/windows/win32/api/netfw/nn-netfw-inetfwrule

I think get_ServiceName is worth adding, since that's documented as an optional parameter that may take the place of app name.

get_grouping might also be interesting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add

@aleksmaus
Copy link
Contributor Author

Added grouping and service_name columns per @directionless request.

Screen Shot 2021-12-21 at 10 56 32 AM

Screen Shot 2021-12-21 at 10 57 12 AM

@Smjert
Copy link
Member

Smjert commented Dec 23, 2021

Closing and reopening so that it aligns with the latest master.

@Smjert Smjert closed this Dec 23, 2021
@Smjert Smjert reopened this Dec 23, 2021
@james-elastic
Copy link

Gentle bump, Is there anything else needed to get the pr merged?

@directionless directionless merged commit 9ecb3f0 into osquery:master Jan 18, 2022
aikuchin pushed a commit to aikuchin/osquery that referenced this pull request Jul 11, 2023
…2 to master

* commit 'c97a1b416492585e049010deea36d2992b680556': (52 commits)
  Fix user_time and system_time unit in processes table on M1 (osquery#7473)
  Add BOOST_USE_ASAN define when enabling Asan (osquery#7469)
  Removing unnecessary macOS version check (osquery#7451)
  Add `utc` flag back for compatibility(osquery#7460)
  Add osquery version to macOS app bundle Info.plist (osquery#7452)
  Fix submodule cache for macOS CI runner (osquery#7456)
  New Table: Windows Firewall Rules (osquery#7403)
  Remove utc flag from example config file (osquery#7437)
  Update the ATC table `path` column check to be case insensitive (osquery#7442)
  Fix typos in documentation (osquery#7443)
  Fix a crash when Yara uses its own strutils functions (osquery#7439)
  Update `time` table to reflect UTC values (osquery#7276)
  Update sqlite to version 3.37.0 (osquery#7426)
  Fix linking of thirdparty_sleuthkit (osquery#7425)
  Apple Silicon support (osquery#7330)
  Fix how we disable tables in the fuzzer init method (osquery#7419)
  Prevent running discovery queries when fuzzing (osquery#7418)
  Hide the deprecate `antispyware` column in `windows_security_center` (osquery#7411)
  Fix typo in docs (osquery#7412)
  CHANGELOG 5.1.0 (osquery#7406)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Table Request: Windows Defender Firewall Rules
7 participants