Skip to content

Commit

Permalink
Update the message when recordDiff is disabled by default
Browse files Browse the repository at this point in the history
This provides more context as to why it may be unsafe to enable it.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl committed May 21, 2024
1 parent 8f027e0 commit dea3344
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2792,8 +2792,10 @@ func handleDiff(
case policyv1.RecordDiffInStatus:
return computedDiff
case policyv1.RecordDiffCensored:
return `# This diff may contain sensitive data. The "recordDiff" field must be set to "InStatus" ` +
`to record a diff.`
return `# The difference is redacted because it contains sensitive data. To override, the ` +
`spec["object-templates"][].recordDiff field must be set to "InStatus" for the difference to be recorded ` +
`in the policy status. Consider existing access to the ConfigurationPolicy objects and the etcd ` +
`encryption configuration before you proceed with an override.`
}

return ""
Expand Down
18 changes: 12 additions & 6 deletions test/e2e/case39_diff_generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ var _ = Describe("Diff generation with sensitive input", Ordered, func() {

diff, _, _ := unstructured.NestedString(relatedObjects[0].(map[string]interface{}), "properties", "diff")
Expect(diff).To(Equal(
`# This diff may contain sensitive data. The "recordDiff" field must be set to "InStatus" ` +
`to record a diff.`,
`# The difference is redacted because it contains sensitive data. To override, the ` +
`spec["object-templates"][].recordDiff field must be set to "InStatus" for the difference to be ` +
`recorded in the policy status. Consider existing access to the ConfigurationPolicy objects and the ` +
`etcd encryption configuration before you proceed with an override.`,
))
})

Expand Down Expand Up @@ -179,8 +181,10 @@ var _ = Describe("Diff generation with sensitive input", Ordered, func() {

diff, _, _ := unstructured.NestedString(relatedObjects[0].(map[string]interface{}), "properties", "diff")
Expect(diff).To(Equal(
`# This diff may contain sensitive data. The "recordDiff" field must be set to "InStatus" ` +
`to record a diff.`,
`# The difference is redacted because it contains sensitive data. To override, the ` +
`spec["object-templates"][].recordDiff field must be set to "InStatus" for the difference to be ` +
`recorded in the policy status. Consider existing access to the ConfigurationPolicy objects and the ` +
`etcd encryption configuration before you proceed with an override.`,
))
})

Expand Down Expand Up @@ -210,8 +214,10 @@ var _ = Describe("Diff generation with sensitive input", Ordered, func() {

diff, _, _ := unstructured.NestedString(relatedObjects[0].(map[string]interface{}), "properties", "diff")
Expect(diff).To(Equal(
`# This diff may contain sensitive data. The "recordDiff" field must be set to "InStatus" ` +
`to record a diff.`,
`# The difference is redacted because it contains sensitive data. To override, the ` +
`spec["object-templates"][].recordDiff field must be set to "InStatus" for the difference to be ` +
`recorded in the policy status. Consider existing access to the ConfigurationPolicy objects and the ` +
`etcd encryption configuration before you proceed with an override.`,
))

By("Enforcing the policy removes the diff message")
Expand Down

0 comments on commit dea3344

Please sign in to comment.