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

[uss_qualifier] Inspect all collected queries for the usage of https (NET0220) #188

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

Shastick
Copy link
Contributor

@Shastick Shastick commented Sep 7, 2023

Checking for NET0220 by ensuring all queries to USSes are relying on https.

In order to validate that queries are not sent in cleartext while not breaking local non-https setups, this:

  • tags all/most queries with the server_id it is intended to
  • adds a local_debug flag to service providers, observers and dss'es
  • adds a check to the aggregate checks that validates all recorded queries are using https when they target an USS that isn't in local_debug mode.

Open questions/notes:

  • We may want to add the participant_id/server_id to the UTM session object? That might make this PR a bit simple.

@Shastick Shastick force-pushed the net-0220-https-checks branch 3 times, most recently from 8089da4 to f704892 Compare September 7, 2023 19:24
if not found_cleartext_query:
self.check(
"All interactions happen over https",
self._queries_by_participant.keys(),
Copy link
Member

Choose a reason for hiding this comment

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

When possible, we should attribute failed checks to the specific participant failing them -- multiple participants for a single check means any one (or multiple) of the specified participants may have failed the check. So, instead, we should iterate over participants and, for each participant, check whether all their queries use https. If yes, pass; if no, fail; if no queries available, don't perform check. (yes, in that case there will be multiple instances of the same check: one instance for each relevant participant)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. This brings us back to the question of attributing queries to participants, and whether to do so by looking at the host-name or URL, or by tagging the requests where they are made:

We can probably set the server_id field for all queries. Though, what should we do if we run into a query that is not associated with an SP? I guess failing hard so that we uncover these when scenarios are developed?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think server_id should be the means we can use to identify the participants. I think we would want to use all data we have available to us to make the check, but I think we can actually simply ignore queries where we don't have a server ID. For instance, if we added a test portion that interacted with a third entity other than a Service Provider or Display Provider and we happened not to populated server_id in our queries to them, I don't think that would justify failing hard.

That said, we may not be populating server_id in all the places that we should, so failing hard temporarily to make sure we've identified all those places seems fine.

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 guess we could add a dev flag somewhere that will have more stringent internal requirements?

Or is leaving the code as-is fine and we remove the check at a later stage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed with @BenjaminPelletier offline: we'll leave this "debug" flag hardcoded for now. Once things are stable we can simply remove it.

@Shastick Shastick force-pushed the net-0220-https-checks branch 5 times, most recently from 437e27f to 717c3da Compare September 11, 2023 07:14
@Shastick
Copy link
Contributor Author

Modulo the dev option, this is ready for another round of review.

monitoring/monitorlib/fetch/__init__.py Outdated Show resolved Hide resolved
monitoring/monitorlib/fetch/__init__.py Outdated Show resolved Hide resolved
if query.request.url.startswith("http://"):
found_cleartext_query = True
if participant_id not in self._debug_mode_usses:
self.record_note(
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to attach this information to the failed check itself as notes do not obviously attach to any particular check. record_failed has an optional parameter for relevant queries that we should use as much as possible -- it should be populated with the timestamps for this set of queries in this case.

@Shastick Shastick force-pushed the net-0220-https-checks branch from ea12c80 to b12444d Compare September 13, 2023 06:00
@Shastick
Copy link
Contributor Author

Looks like the "strict dev mode" is working as intended: freshly merged tests cause this failure:

2023-09-13 06:09:37.699 | WARNING  | monitoring.uss_qualifier.suites.suite:_print_failed_check:50 - New failed check:
  details: '
  
    Severity Medium upgraded to Critical because USS_QUALIFIER_STOP_FAST environment
    variable indicates true'
  documentation_url: https://github.com/interuss/monitoring/blob/3b806aabb95cd436c072eba9ac22deae51d3936a/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/aggregate_checks.md#no-unattributed-queries-check
  name: No unattributed queries
  participants: []
  requirements: []
  severity: Critical
  summary: 'found unattributed queries: [''http://v22a.ridsp.uss1.localutm/mock/ridsp/v2/uss/flights?view=37.17008162687164%2C-80.60282480412947%2C37.22330680061591%2C-80.5495996303852&recent_positions_duration=60'',
    ''http://v22a.ridsp.uss1.localutm/mock/ridsp/v2/uss/flights?view=37.172210633821415%2C-80.6006957971797%2C37.221177793666136%2C-80.55172863733499&recent_positions_duration=60'',
    ''http://v22a.ridsp.uss1.localutm/mock/ridsp/v2/uss/flights?view=37.189952358402834%2C-80.58295407259827%2C37.203436069084724%2C-80.5694703619164&recent_positions_duration=60'']'
  timestamp: '2023-09-13T06:09:37.696861Z'

I'll tweak these tests ASAP

@Shastick Shastick force-pushed the net-0220-https-checks branch 6 times, most recently from 9b39aff to a2c4757 Compare September 13, 2023 10:50
@Shastick
Copy link
Contributor Author

PR ready for final reviw

Copy link
Member

@BenjaminPelletier BenjaminPelletier left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! Just 2 copy/paste cleanup items, and one optional note

@BenjaminPelletier BenjaminPelletier changed the title [uss_qualifier] inspect all collected queries for the usage of https (NET0220) [uss_qualifier] Inspect all collected queries for the usage of https (NET0220) Sep 13, 2023
@Shastick Shastick force-pushed the net-0220-https-checks branch 2 times, most recently from f71e8fe to 508a6f6 Compare September 14, 2023 09:15
@Shastick Shastick force-pushed the net-0220-https-checks branch from 508a6f6 to 89b8f8f Compare September 14, 2023 09:19
@Shastick
Copy link
Contributor Author

Deduped test-case doc and rebased, we should be ready to merge this.

@BenjaminPelletier BenjaminPelletier merged commit 2a87098 into interuss:main Sep 14, 2023
9 checks passed
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.

2 participants