-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CL4B] Inspector Basics Scenario in Python #7625
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
# snippet-start:[inspector.yaml] | ||
# Inspector code examples for the AWS SDK for Python (Boto3). | ||
inspector_Hello: | ||
title: Hello &Inspector; |
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 may have to add something to get the entities correct. For example, Inspector is INS1long.
title: Get &Inspector; account status | ||
title_abbrev: Get account status | ||
synopsis: get the status of &Inspector; for your account. | ||
category: Basics |
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.
It's setting the category of all of these to Basics, I'm not sure that is necessary.
excerpts: | ||
- description: Run an interactive scenario demonstrating &Inspector; features. | ||
snippet_tags: | ||
- python.example_code.inspector.InspectorScenario |
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.
Usually we show the wrapper here as well.
title: Learn the basics of &Inspector; | ||
title_abbrev: Learn the basics | ||
synopsis: learn the basics of &Inspector;. | ||
category: Scenarios |
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 section should have a synopsis list.
from test_tools.glacier_stubber import GlacierStubber | ||
from test_tools.glue_stubber import GlueStubber | ||
from test_tools.iam_stubber import IamStubber | ||
from test_tools.inspector_stubber import InspectorStubber |
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.
It's missing the line that adds the stubber below, which is causing the stubbed tests to fail with this error: test_tools.stubber_factory.StubberFactoryNotImplemented: If you see this exception, it probably means that you forg...
for finding in findings_list[ | ||
:2 | ||
]: # Show first 2 findings per severity | ||
title = finding.get("title", "No title") |
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.
I'm unable to verify if any of these print statements work without simulating a severity finding.
"vulnerablePackages", [] | ||
) | ||
if vulnerable_packages: | ||
package = vulnerable_packages[0] |
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.
If we aren't able to verify this with a finding, we probably shouldn't include it.
|
||
|
||
@pytest.mark.integ | ||
def test_get_account_status_integration(): |
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 would prefer to have a single integration test that runs the entire scenario and verifies that it makes it to the end successfully. When I ran these tests, it left my account with Inspector enabled instead of returning it to the disabled state.
|
||
|
||
@pytest.mark.parametrize( | ||
"error_code", [None, "ValidationException", "AccessDeniedException"] |
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.
I was unable to run these tests without the stubber properly initialized.
print(f"CWE IDs: {', '.join(cwes)}") | ||
|
||
# Show EPSS score | ||
epss_score = details.get("epssScore") |
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 may need more parameter validation. For example, this property is an array, but the code is referencing and displaying it like a string.
The changes in this PR were generated using CodeLoom-4-BedRock(CL4B) for Inspector service in Python language