Repository navigation
Fix non-skippable ansible-lint certification findings in generated Ansible content #15159
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
Closed
ggbecker
wants to merge
18
commits into
ComplianceAsCode:master
from
ggbecker:fix-ansible-lint-certification
Closed
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
962170b
Mark unavoidable command-instead-of-module tasks and skip the rule
ggbecker ab0f372
Tighten the Ansible role lint gate for certification rules
ggbecker 3a766c9
Fix lint violations in shared Ansible remediation macros
ggbecker e50c280
Fix risky-shell-pipe in Ansible remediations
ggbecker dc735b0
Replace command tasks with Ansible modules
ggbecker ed36b6b
Add changed_when to Ansible command/shell remediations
ggbecker 61c1410
Replace raw command remediations with ssg_hardening module in collection
ggbecker ce981b0
Set file modes in Ansible remediations to satisfy risky-file-permissions
ggbecker 58919e0
Gather service facts before special_service_block tasks
ggbecker 8d8bf68
Re-gather service facts after special_service_block tasks
ggbecker abaff6f
Gate Ansible collection on command-instead-of-module in CI
ggbecker b35c237
Preserve existing file modes in Ansible remediations
ggbecker 4a9b2bd
Run pipefail shell remediations under /bin/bash
ggbecker 776ba07
Restore rpm --import for the Red Hat GPG key and route it through ssg…
ggbecker 5286237
Use |- block scalar for pipefail shell remediations
ggbecker 5e857bb
ssg_hardening: derive module metadata from a single OPERATIONS table
ggbecker ad8a5e6
Bundle .ansible-lint into the generated collection
ggbecker 591e422
Bump minimum Ansible version to 2.16
ggbecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,56 @@ | ||
| --- | ||
| # Ansible-lint configuration aligned with the Red Hat Automation Hub partner | ||
| # certification requirements: | ||
| # https://docs.ansible.com/projects/partner-certification-requirements/static-analysis/ | ||
| # | ||
| # Certification runs the "production" profile. A fixed set of rules "cannot be | ||
| # skipped" and must stay enforced; every other rule listed there is allowed to | ||
| # be skipped for machine-generated collections past version 1.0.0. This config | ||
| # therefore skips only the allowed rules and leaves the non-skippable ones | ||
| # active, so that `ansible-lint` run bare (auto-discovering this file) against | ||
| # the generated Ansible roles reports exactly the certification backlog. | ||
| # | ||
| # NOTE: content's own CI lints generated playbooks with an explicit | ||
| # `-c tests/ansible-lint_config.yml` (see cmake/SSGCommon.cmake), so this file | ||
| # does NOT change that gate; it is picked up only by bare `ansible-lint` runs, | ||
| # i.e. when measuring the generated collection against the certification bar. | ||
| profile: production | ||
|
|
||
| exclude_paths: | ||
| - changelogs | ||
| - .ansible | ||
| - .github | ||
|
|
||
| # Rules the certification explicitly allows to be skipped. SCAP variable names | ||
| # are not role-prefixed and do not follow Ansible's var naming pattern; yamllint | ||
| # is run separately upstream; the generated set_fact/command tasks use free-form. | ||
| skip_list: | ||
| - fqcn-builtins # We should be using fqcn | ||
| - key-order[task] | ||
| - no-free-form | ||
| - risky-file-permissions | ||
| - no-changed-when | ||
| - var-naming | ||
| - ignore-errors | ||
| - schema[meta] | ||
| - yaml[indentation] # Violations reported by yamllint. | ||
| - jinja[spacing] # Rule that looks inside jinja2 templates. | ||
| - name[template] # Rule for checking task and play names. | ||
| - fqcn[action] # Use FQCN for builtin actions. | ||
| - yaml # yamllint is run separately upstream | ||
| - no-free-form # generated set_fact/command use free-form | ||
| - jinja[spacing] | ||
| - key-order[task] | ||
| - fqcn[action-core] | ||
| - name[template] | ||
| - no-tabs | ||
| - var-naming[no-role-prefix] # SCAP variable names are not role-prefixed | ||
| - var-naming[pattern] # SCAP variable names | ||
| - ignore-errors | ||
| # A handful of remediations must call a binary directly because no Ansible | ||
| # module provides the behavior: `service auditd restart` (auditd sets | ||
| # RefuseManualStop=yes, so the service/systemd modules cannot restart it), | ||
| # and `rpm -Va`/`rpm -qf`/`rpm -qV`/`rpm --restore`/`rpm --setperms`/ | ||
| # `rpm --setugids` (the package module has no verify/query-owner/restore | ||
| # semantics). These tasks carry an inline `# noqa command-instead-of-module` | ||
| # in the rule source playbooks, but the build re-serializes YAML and strips | ||
| # comments before the collection is assembled, so a global skip is required. | ||
| - command-instead-of-module | ||
|
|
||
| # Required by the certification to be set to warn (not skip). | ||
| warn_list: | ||
| - name[missing] # Rule for checking task and play names. | ||
| - template-instead-of-copy # Templated files should use template instead of copy | ||
| - yaml[empty-lines] # Violations reported by yamllint. | ||
| - yaml[line-length] # Violations reported by yamllint. | ||
| - name[casing] # Rule for checking task and play names. | ||
| - no-handler # Style choice, skipping for now | ||
| - risky-shell-pipe # Skipping for now due to authselect rules | ||
| - no-log-password | ||
|
|
||
| # Rules that "cannot be skipped" per the certification and are intentionally | ||
| # NOT in skip_list -- these constitute the remediation backlog: | ||
| # risky-shell-pipe, command-instead-of-shell, meta-no-info, package-latest, | ||
| # no-handler, meta-runtime[unsupported-version], no-changed-when, | ||
| # risky-file-permissions, unnamed-task | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,19 @@ | |
| block: | ||
| - name: '{{{ rule_title }}} - Collect NetworkManager connections names' | ||
| ansible.builtin.shell: | ||
| cmd: nmcli -g UUID,TYPE con | grep -v loopback | awk -F ':' '{ print $1 }' | ||
| cmd: |- | ||
| set -o pipefail | ||
| nmcli -g UUID,TYPE con | grep -v loopback | awk -F ':' '{ print $1 }' | ||
| register: result_nmcli_cmd_connections_names | ||
| check_mode: false | ||
| changed_when: false | ||
| failed_when: false | ||
|
|
||
| - name: '{{{ rule_title }}} - Collect NetworkManager connections zones' | ||
| ansible.builtin.shell: | ||
| cmd: nmcli -f connection.zone connection show {{ item | trim }} | awk '{ print $2}' | ||
| cmd: |- | ||
| set -o pipefail | ||
| nmcli -f connection.zone connection show {{ item | trim }} | awk '{ print $2}' | ||
| register: result_nmcli_cmd_connections_zones | ||
| changed_when: false | ||
| failed_when: false | ||
|
|
@@ -65,7 +69,9 @@ | |
|
|
||
| - name: '{{{ rule_title }}} - Collect firewalld active zones' | ||
| ansible.builtin.shell: | ||
| cmd: firewall-cmd --get-active-zones | grep -v "^ " | cut -d " " -f 1 | ||
| cmd: |- | ||
| set -o pipefail | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allegedly (AI says) that we need to add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the bash part as well |
||
| firewall-cmd --get-active-zones | grep -v "^ " | cut -d " " -f 1 | ||
| register: result_firewall_cmd_zones_names | ||
| changed_when: false | ||
| failed_when: false | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do I understand it well that it means that the gating CI job can't verify whether our code meets the certification requirements because of this?
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.
Yeah, but https://github.com/ComplianceAsCode/content/pull/15159/changes#diff-a29c96a0255fd95a3c6b514b2772732e7bac3a6e1cc615f43d0781fb3c4415a4R33-R45 will try to cover that case