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

Allow also posix and community.general Ansible modules #279

Merged

Conversation

mildas
Copy link
Contributor

@mildas mildas commented Oct 31, 2024

Modules with these FQCN should be accepted as well, not just modules from ansible.builtin.

@@ -55,6 +55,8 @@ def process_task(task, all_allowed_modules):
found_allowed_modules.update(process_task(block_task, all_allowed_modules))
else:
keywords = set(kw.replace('ansible.builtin.', '') for kw in original_keywords)
keywords = set(kw.replace('community.general.', '') for kw in keywords)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about something like this:

keywords = set()
for kw in original_keywords:
    keywords.add(re.sub(r'(ansible.builtin.|community.general.|ansible.posix.)', r'', kw))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes 3 similar lines to 3 different lines and that's fine. But adds complexity and reduces readability. So I'd stay with my solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably pointless now, but maybe this would have been a reasonable alternative for avoiding the multiple iterations of keywords:

filters = lambda kw: (kw
    .replace('ansible.builtin.', '')
    .replace('community.general.', '')
    .replace('ansible.posix.', '')
)
keywords = set(map(filters, original_keywords))

(or a more traditional version with backslashes instead of wrapping the lambda body in ( )).

@matusmarhefka matusmarhefka merged commit 4a53d70 into RHSecurityCompliance:main Oct 31, 2024
3 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