Skip to content
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

feat gsn-11659: make logic in line with security hub filtering #27

Merged

Conversation

carlovoSBP
Copy link
Contributor

No description provided.

return any(search(pattern, resource)
for resource in self.resource_ids
for pattern in resource_id_patterns)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is not needed.

return any(search(pattern, resource)
for resource in self.resource_ids
for pattern in resource_id_patterns)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is not needed.

return any(search(pattern, resource)
for resource in self.resource_ids
for pattern in resource_id_patterns)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is not needed.

return any(search(pattern, resource)
for resource in self.resource_ids
for pattern in resource_id_patterns)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is not needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is nicer?

    return (
        not resource_id_patterns 
        or any(search(pattern, resource) 
            for resource in self.resource_ids 
            for pattern in resource_id_patterns
        )
    )

Copy link
Collaborator

@marwinbaumannsbp marwinbaumannsbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@@ -311,11 +311,15 @@ def is_matching_resource_ids(self, resource_id_patterns) -> bool:

Returns:
True if any match is found, False otherwise.
An empty resource_id_patterns list will always return True, like Security Hub does per resource.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True if any resource ID matches any pattern, or if patterns list is empty. False otherwise.

return any(search(pattern, resource)
for resource in self.resource_ids
for pattern in resource_id_patterns)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is nicer?

    return (
        not resource_id_patterns 
        or any(search(pattern, resource) 
            for resource in self.resource_ids 
            for pattern in resource_id_patterns
        )
    )

for rule_tag in rule_tags
for tag in self.tags)

if rule_tags:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you like the comment above then to make it consistent:

return (
    not rule_tags 
    or any(
        tag.get(rule_tag['key']) == rule_tag.get('value') 
        for rule_tag in rule_tags 
        for tag in self.tags
    )
)

@carlovoSBP carlovoSBP force-pushed the gsn-11659-sec-hub-logic branch from 7b46666 to 6400d25 Compare December 20, 2024 11:41
@marwinbaumannsbp marwinbaumannsbp merged commit c547732 into schubergphilis:main Dec 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants