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

Do not allow the space policy to be pruned #1492

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion policy/resolved_policy_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"slices"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -272,7 +273,12 @@ func (n *rpBuilderPolicyNode) getId() string {
func (n *rpBuilderPolicyNode) isPrunable() bool {
// We do not allow pruning the root node. This covers cases where the policy matches the asset filters,
// but we have no active checks or queries. This will end up reporting a U for the score
return !n.isRoot

// The space policy is not prunable because its score is the one that is actually used to determine an
// asset score. This is because the asset score is dropped and recomputed to become a combination of
// the security and vulnerability scores
isSpace := strings.HasPrefix(n.policy.Mrn, "//captain.api.mondoo.app/spaces/")
return !n.isRoot && !isSpace
}

func (n *rpBuilderPolicyNode) build(rp *ResolvedPolicy, data *rpBuilderData) error {
Expand Down
Loading