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 772646b commit 0dcb265
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2792,8 +2792,9 @@ 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 `# This diff might contain sensitive data. The spec["object-templates"][]["recordDiff"] field must be ` +
`set to "InStatus" for the differences to be recorded in the policy status. Consider existing access to ` +
`the ConfigurationPolicy objects and the etcd encryption configuration before you proceed.`
}

return ""
Expand Down
15 changes: 9 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,9 @@ 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.`,
`# This diff might contain sensitive data. The spec["object-templates"][]["recordDiff"] field must be ` +
`set to "InStatus" for the differences to be recorded in the policy status. Consider existing access ` +
`to the ConfigurationPolicy objects and the etcd encryption configuration before you proceed.`,
))
})

Expand Down Expand Up @@ -179,8 +180,9 @@ 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.`,
`# This diff might contain sensitive data. The spec["object-templates"][]["recordDiff"] field must be ` +
`set to "InStatus" for the differences to be recorded in the policy status. Consider existing access ` +
`to the ConfigurationPolicy objects and the etcd encryption configuration before you proceed.`,
))
})

Expand Down Expand Up @@ -210,8 +212,9 @@ 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.`,
`# This diff might contain sensitive data. The spec["object-templates"][]["recordDiff"] field must be ` +
`set to "InStatus" for the differences to be recorded in the policy status. Consider existing access ` +
`to the ConfigurationPolicy objects and the etcd encryption configuration before you proceed.`,
))

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

0 comments on commit 0dcb265

Please sign in to comment.