-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(security hub): solve Security Hub format requirements #2520
fix(security hub): solve Security Hub format requirements #2520
Conversation
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.
Good job! Please check my comments to merge 🚀
prowler/lib/outputs/json.py
Outdated
# Description should NOT be longer than 1024 characters | ||
finding_output.Description = ( | ||
(finding.status_extended[:1000] + "..") | ||
if len(finding.status_extended) > 100 | ||
else finding.status_extended | ||
) |
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.
Could you include this as a part of the class validator? It's so easy to do it with Pydantic https://docs.pydantic.dev/latest/usage/validators/
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.
Also, you are doing the comparison with 100
as length.
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.
Why do I need validators? I want to change the field, not to validate it.
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.
Because you are doing a validation checking the field length, also with that you have all the logic to build the model within the class since you can do that:
class JSONASFF(BaseModel):
Description: str
@validator('Description')
def description_sould_not_exceed_1024_chars(cls, value):
if len(value) > 1000:
return value[:1000] + ".."
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.
Also, please include tests that validates the new logic included
if ( | ||
len(associated_standards) < 20 | ||
): # AssociatedStandards should NOT have more than 20 items | ||
associated_standards.append({"StandardsId": key}) | ||
item = f"{key} {' '.join(value)}" | ||
if len(item) > 64: | ||
item = item[0:63] | ||
compliance_summary.append(item) |
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.
Could you include this as a part of the class validator? It's so easy to do it with Pydantic https://docs.pydantic.dev/latest/usage/validators/
b660a46
to
2ce8a18
Compare
2ce8a18
to
1d6ab73
Compare
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.
🚀
Description
Solve Security Hub format requirements:
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.