-
Notifications
You must be signed in to change notification settings - Fork 5
Rank rules on evidence, and gate TCP/TLS on the endpoint #173
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
Open
hellais
wants to merge
1
commit into
main
Choose a base branch
from
rules-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,23 @@ | |
| from enum import IntEnum | ||
| from typing import List, Tuple | ||
|
|
||
| RULES_VERSION = 1 | ||
| RULES_VERSION = 2 | ||
|
|
||
|
|
||
| class Evidence(IntEnum): | ||
| """How much a row has to say about its layer, independent of the score. | ||
|
|
||
| The triple cannot answer this: a rule scores (0, 0, 0) whether the layer | ||
| was never exercised, or was exercised and then discarded because an | ||
| earlier layer was untrustworthy. Both are "no verdict", but only the | ||
| second one names a cause, and neither is "we looked and found nothing | ||
| wrong". Ordered, so aggregates can prefer the row that saw the most. | ||
| """ | ||
|
|
||
| NONE = 0 # layer produced no data on this row | ||
| DISCARDED = 1 # observed, but an earlier layer makes it uninterpretable | ||
| SCORED = 2 # observed and scored | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole block needs to be removed. |
||
|
|
||
|
|
||
| class Evidence(IntEnum): | ||
|
|
@@ -244,15 +260,25 @@ def outcome(self) -> Tuple[float, float, float]: | |
| ok=0.0, | ||
| comment="Failure against an address that mostly succeeds in the control.", | ||
| ), | ||
| # Replaces dns_untrusted, which masked on the measurement's DNS verdict and | ||
| # so discarded every address once any lookup looked poisoned. The question | ||
| # is about the address, not the measurement: an address the control also | ||
| # returned, or one that completed a valid handshake, is worth connecting to | ||
| # whatever the system resolver did. Strictly narrower than the old rule, so | ||
| # it can only unmask rows, never mask new ones. | ||
| Rule( | ||
| rule_id="dns_untrusted", | ||
| condition="dns_blocked > 0 AND dns_ok <= (dns_blocked + dns_down)", | ||
| rule_id="endpoint_untrusted", | ||
| condition=( | ||
| "NOT ip_trusted AND dns_blocked > 0 " | ||
| "AND dns_ok <= (dns_blocked + dns_down)" | ||
| ), | ||
| blocked=0.0, | ||
| down=0.0, | ||
| ok=0.0, | ||
| comment=( | ||
| "DNS was not trustworthy, so the addresses we connected to cannot " | ||
| "be trusted either. Masked." | ||
| "The address came from a lookup that looks poisoned and nothing " | ||
| "independent vouches for it, so connecting to it says nothing " | ||
| "about the target. Masked." | ||
| # TODO(art): this sits below connect_ok, so a successful connection | ||
| # to a blockpage address is still scored as OK. Is that right? | ||
| ), | ||
|
|
@@ -325,13 +351,23 @@ def outcome(self) -> Tuple[float, float, float]: | |
| ok=0.0, | ||
| comment="Failure where the control succeeds, with a less specific error.", | ||
| ), | ||
| # See the TCP rule of the same name. Note this sits BELOW the | ||
| # failure_ctrl_ok_* rules, so a TLS failure against an address the control | ||
| # succeeds on is already scored as blocking before we get here. | ||
| Rule( | ||
| rule_id="dns_untrusted", | ||
| condition="dns_blocked > 0 AND dns_ok <= (dns_blocked + dns_down)", | ||
| rule_id="endpoint_untrusted", | ||
| condition=( | ||
| "NOT ip_trusted AND dns_blocked > 0 " | ||
| "AND dns_ok <= (dns_blocked + dns_down)" | ||
| ), | ||
| blocked=0.0, | ||
| down=0.0, | ||
| ok=0.0, | ||
| comment="DNS was not trustworthy, so this result cannot be either. Masked.", | ||
| comment=( | ||
| "The address came from a lookup that looks poisoned and nothing " | ||
| "independent vouches for it, so the handshake result is not about " | ||
| "the target. Masked." | ||
| ), | ||
| evidence=Evidence.DISCARDED, | ||
| ), | ||
| Rule( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add this to a database column