Skip to content

Fix private IP ingestion in network_interface_unix and network_interface_windows. - #9884

Merged
lucasmrod merged 1 commit into
mainfrom
issue-8924-fix-private-ip-ingestion
Feb 16, 2023
Merged

Fix private IP ingestion in network_interface_unix and network_interface_windows.#9884
lucasmrod merged 1 commit into
mainfrom
issue-8924-fix-private-ip-ingestion

Conversation

@lucasmrod

@lucasmrod lucasmrod commented Feb 16, 2023

Copy link
Copy Markdown
Member

#8924

This is reproduced in dogfood for dogfood-centos-box and dogfood-ubuntu-box where their "Private IP" is also their "Public IP". Given that these hosts have their "Primary IP" configured to be their "Public IP" alongside their "Private IP", the network_interface_unix and network_interface_windows queries are now changed to ingest only private IPs for the "Private IP" field.

  • Changes file added for user-visible changes in changes/ or orbit/changes/.
    See Changes files for more information.
  • [ ] Documented any API changes (docs/Using-Fleet/REST-API.md or docs/Contributing/API-for-contributors.md)
  • [ ] Documented any permissions changes
  • [ ] Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • [ ] Added support on fleet's osquery simulator cmd/osquery-perf for new osquery data ingestion features.
  • [ ] Added/updated tests
  • Manual QA for all new/changed functionality
    • For Orbit and Fleet Desktop changes:
      • [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux.
      • [ ] Auto-update manual QA, from released version of component to new version (see tools/tuf/test).

@lucasmrod
lucasmrod requested review from a team and rynsatterlee as code owners February 16, 2023 17:11
OR (split(ia.address, '.', 0) = '192' AND split(ia.address, '.', 1) = '168')
)
-- Private IPv6 addresses start with 'fc' or 'fd'.
OR (inet_aton(ia.address) IS NULL AND regex_match(lower(ia.address), '^f[cd][0-9a-f][0-9a-f]:[0-9a-f:]+', 0) IS NOT NULL)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is more for my own understanding, but according to this ULAs are in the range fc00::/7 so shouldn't using ^f[cd] as the reg-exp suffice here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

True. I was a little defensive and wanted to check that it looks like a IPv6 address, but maybe we can assume we are always getting a valid IPv6 string from this column... and just do ^f[cd] as you propose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Defensive is good, let's keep it that way. I was just curious about it.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Base: 60.63% // Head: 60.57% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (8929c79) compared to base (5f19f0b).
Patch coverage: 100.00% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9884      +/-   ##
==========================================
- Coverage   60.63%   60.57%   -0.07%     
==========================================
  Files         492      492              
  Lines       49416    49788     +372     
==========================================
+ Hits        29964    30157     +193     
- Misses      16662    16823     +161     
- Partials     2790     2808      +18     
Impacted Files Coverage Δ
server/service/osquery_utils/queries.go 49.42% <100.00%> (+0.41%) ⬆️
server/fleet/app.go 9.09% <0.00%> (-1.08%) ⬇️
cmd/fleet/cron.go 36.67% <0.00%> (-0.62%) ⬇️
server/fleet/teams.go 0.00% <0.00%> (ø)
cmd/fleetctl/preview.go 49.84% <0.00%> (ø)
server/service/teams.go 100.00% <0.00%> (ø)
server/fleet/datastore.go 0.00% <0.00%> (ø)
server/fleet/activities.go 0.00% <0.00%> (ø)
server/service/client_teams.go 0.00% <0.00%> (ø)
server/service/client_appconfig.go 0.00% <0.00%> (ø)
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lucasmrod
lucasmrod merged commit b757e44 into main Feb 16, 2023
@lucasmrod
lucasmrod deleted the issue-8924-fix-private-ip-ingestion branch February 16, 2023 20:16
juan-fdz-hawa pushed a commit that referenced this pull request Feb 21, 2023
…erface_windows`. (#9884)

#8924

This is reproduced in dogfood for `dogfood-centos-box` and
`dogfood-ubuntu-box` where their "Private IP" is also their "Public IP".
Given that these hosts have their "Primary IP" configured to be their
"Public IP" alongside their "Private IP", the `network_interface_unix`
and `network_interface_windows` queries are now changed to ingest only
private IPs for the "Private IP" field.

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- ~[ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)~
- ~[ ] Documented any permissions changes~
- ~[ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)~
- ~[ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.~
- ~[ ] Added/updated tests~
- [X] Manual QA for all new/changed functionality
  - ~For Orbit and Fleet Desktop changes:~
- ~[ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.~
- ~[ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).~
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