Skip to content

Manage compliance status if policy only assigned to hostgroup#613

Merged
adamruzicka merged 1 commit into
theforeman:masterfrom
ATIX-AG:fix_compliance_status
Jun 25, 2026
Merged

Manage compliance status if policy only assigned to hostgroup#613
adamruzicka merged 1 commit into
theforeman:masterfrom
ATIX-AG:fix_compliance_status

Conversation

@sbernhard

Copy link
Copy Markdown
Contributor

If a host doesn't have policies assigned directly, but only via hostgroup, it still should re-calculate the compliance status.

Comment thread app/models/foreman_openscap/compliance_status.rb Outdated

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we also get a redmine?

Comment thread app/models/foreman_openscap/compliance_status.rb Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates compliance status evaluation so hosts inherit compliance policy applicability from hostgroups (including inherited hostgroup policies), ensuring compliance status is recalculated even when no policies are assigned directly to the host.

Changes:

  • Switch compliance status relevance check from host.policies to host.combined_policies.
  • Switch compliance status calculation input set from host.policies to host.combined_policies (host + hostgroup + inherited).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/models/foreman_openscap/compliance_status.rb Outdated

def to_status(options = {})
latest_reports = host.policies.map { |p| host.last_report_for_policy p }.flatten
latest_reports = host.combined_policies.map { |p| host.last_report_for_policy p }.flatten
Comment thread app/models/foreman_openscap/compliance_status.rb
…stgroup

If a host doesn't have policies assigned directly, but only via
hostgroup, it still should re-calculate the compliance status.
@sbernhard sbernhard force-pushed the fix_compliance_status branch from eb53eee to e0d9dc2 Compare June 24, 2026 19:23
@sbernhard

Copy link
Copy Markdown
Contributor Author

@adamruzicka good to merge?

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@adamruzicka adamruzicka merged commit 985314c into theforeman:master Jun 25, 2026
16 checks passed
@adamruzicka

Copy link
Copy Markdown
Contributor

Thank you @sbernhard !

@maximiliankolb maximiliankolb deleted the fix_compliance_status branch June 25, 2026 11:10
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.

4 participants