-
Notifications
You must be signed in to change notification settings - Fork 176
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 a config system for Panther detections #950
Merged
+133
−36
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
91685a4
panther_config: Add a fork-friendly configuration scheme
jof 6800a1e
Apply `panther_config` to existing uses of example.com
jof 63e69d1
Merge branch 'main' into jof/public/config
arielkr256 64f8062
Merge branch 'main' into jof/public/config
arielkr256 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
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.github/CODEOWNERS merge=ours | ||
global_helpers/panther_config_overrides.py merge=ours |
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Any | ||
|
||
import panther_config_defaults | ||
import panther_config_overrides | ||
|
||
|
||
class Config: # pylint: disable=too-few-public-methods | ||
def __getattr__(self, name) -> Any: | ||
if hasattr(panther_config_overrides, name): | ||
return getattr(panther_config_overrides, name) | ||
return getattr(panther_config_defaults, name, None) | ||
|
||
|
||
config = Config() |
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AnalysisType: global | ||
GlobalID: "panther_config" | ||
Filename: panther_config.py | ||
Description: Configuration values for Panther |
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Here, default values for `panther_config.config` are defined | ||
""" | ||
|
||
# A list of public DNS domain names that fall under the administrative domain of | ||
# the Panther installation | ||
ORGANIZATION_DOMAINS = ["example.com"] | ||
|
||
DROPBOX_ALLOWED_SHARE_DOMAINS = ORGANIZATION_DOMAINS | ||
DROPBOX_TRUSTED_OWNERSHIP_DOMAINS = ORGANIZATION_DOMAINS | ||
GSUITE_TRUSTED_FORWARDING_DESTINATION_DOMAINS = ORGANIZATION_DOMAINS | ||
GSUITE_TRUSTED_OWNERSHIP_DOMAINS = ORGANIZATION_DOMAINS | ||
MS_EXCHANGE_ALLOWED_FORWARDING_DESTINATION_DOMAINS = ORGANIZATION_DOMAINS | ||
MS_EXCHANGE_ALLOWED_FORWARDING_DESTINATION_EMAILS = ["postmaster@" + ORGANIZATION_DOMAINS[0]] |
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AnalysisType: global | ||
GlobalID: "panther_config_defaults" | ||
Filename: panther_config_defaults.py | ||
Description: Default Configuration values for Panther |
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Here, you can override the default, example configuration values from `panther_config_defaults` | ||
|
||
Any attribute found to be defined in here will take precedence at lookup time. | ||
For example, we can totally re-define a value: | ||
|
||
# Total Override | ||
panther_config_defaults.py | ||
``` | ||
SUSPICIOUS_DOMAINS = [ "evil.example.com" ] | ||
``` | ||
|
||
panther_config_overrides.py | ||
``` | ||
SUSPICIOUS_DOMAINS = [ "betrug.example.com" ] | ||
``` | ||
|
||
and at lookup-time: | ||
``` | ||
from panther_config import config | ||
print(config.SUSPICIOUS_DOMAINS) | ||
``` | ||
prints ["betrug.example.com"] | ||
|
||
# Mixing Values | ||
panther_config_defaults.py | ||
``` | ||
INTERNAL_NETWORKS = [ "10.0.0.0/8" ] | ||
``` | ||
|
||
panther_config_overrides.py | ||
``` | ||
import panther_config_defaults | ||
INTERNAL_NETWORKS = panther_config_defaults.INTERNAL_NETWORKS + [ "192.0.2.0/24" ] | ||
``` | ||
|
||
and at lookup-time: | ||
``` | ||
from panther_config import config | ||
print(config.INTERNAL_NETWORKS) | ||
``` | ||
prints ["10.0.0.0/8", "192.0.2.0/24" ] | ||
""" |
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AnalysisType: global | ||
GlobalID: "panther_config_overrides" | ||
Filename: panther_config_overrides.py | ||
Description: Overridden Configuration values for Panther |
This file contains 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 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 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 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 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 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 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 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 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 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
11 changes: 6 additions & 5 deletions
11
rules/microsoft_rules/microsoft_exchange_external_forwarding.py
This file contains 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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
ALLOWED_FORWARDING_DESTINATION_DOMAINS = ["company.com"] | ||
|
||
ALLOWED_FORWARDING_DESTINATION_EMAILS = ["[email protected]"] | ||
from panther_config import config | ||
|
||
|
||
def rule(event): | ||
if event.get("operation", "") in ("Set-Mailbox", "New-InboxRule"): | ||
for param in event.get("parameters", []): | ||
if param.get("Name", "") in ("ForwardingSmtpAddress", "ForwardTo", "ForwardingAddress"): | ||
to_email = param.get("Value", "") | ||
if to_email.lower().replace("smtp:", "") in ALLOWED_FORWARDING_DESTINATION_EMAILS: | ||
if ( | ||
to_email.lower().replace("smtp:", "") | ||
in config.MS_EXCHANGE_ALLOWED_FORWARDING_DESTINATION_EMAILS | ||
): | ||
return False | ||
for domain in ALLOWED_FORWARDING_DESTINATION_DOMAINS: | ||
for domain in config.MS_EXCHANGE_ALLOWED_FORWARDING_DESTINATION_DOMAINS: | ||
if to_email.lower().replace("smtp:", "").endswith(domain): | ||
return False | ||
return True | ||
|
This file contains 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
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.
Awesome PR, thanks for opening it. Should add this file .gitattributes with
ours
ownership so it always overrides the upstream?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.
Yeah, I think that probably makes sense. From my user-perspective, we only ever merge upstream into our fork (or rebase). So long as we're never merging in the other direction (fork->upstream), this seems like the right choice.
Will add.