-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CL4B] GuardDuty Basics Scenario in Python #7624
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
base: main
Are you sure you want to change the base?
Conversation
# GuardDuty code examples for the SDK for Python. | ||
guardduty_Hello: | ||
title: Hello &GD; | ||
title_abbrev: Hello &GD; |
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.
The entity abbreviation is GDU
from test_tools.eventbridge_stubber import EventBridgeStubber | ||
from test_tools.glacier_stubber import GlacierStubber | ||
from test_tools.glue_stubber import GlueStubber | ||
from test_tools.guardduty_stubber import GuardDutyStubber |
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.
Same issue with the stubber as the Inspector version.
guardduty_wrapper = GuardDutyWrapper.from_client() | ||
|
||
# List existing detectors | ||
detector_ids = guardduty_wrapper.list_detectors() |
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.
The Hello example should be self-contained, and not use the wrapper functions.
self.detector_id = existing_detectors[0] | ||
print(f"Using existing detector: {self.detector_id}") | ||
else: | ||
self.detector_id = self._create_new_detector() |
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.
The new detector creation fails with an error that there is already a detector. This seems ok, but then the scenario exits without continuing.
versions: | ||
- sdk_version: 3 | ||
github: python/example_code/guardduty | ||
excerpts: |
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.
This one includes both classes, which is good. But it should also use a synopsis list.
from botocore.exceptions import ClientError | ||
|
||
|
||
def test_scenario_create_detector_success(scenario_data, monkeypatch): |
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.
We probably don't want to do any monkeypatch tests unless we have a good reason to. The stubber methods should be sufficient.
@pytest.mark.integ | ||
def test_guardduty_integration(): | ||
""" | ||
Integration test that works with existing detectors or creates a new one, |
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.
Same comments about the tests as in the Inspector PR.
|
||
print( | ||
"GuardDuty detectors continue to monitor your account and may incur charges. " | ||
"You can disable the detector to stop monitoring, or delete it entirely." |
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.
This statement mentions disabling the detector, but that is not a choice in the options.
The changes in this PR were generated using CodeLoom-4-BedRock(CL4B) for GuardDuty service in Python language