This policy example will check if a given secret is duplicated between two providers.The policy will be non-compliant if the secret is duplicated between two providers.
package mainimport rego.v1default allow := false# Allow if secret has no duplicates at allallow if { len(input.Duplicates) == 0}# Allow if all duplicates are from the same provider as the secret itselfallow if { provider_id := input.ProviderId count({x | input.Duplicates[x]; same_provider(input.Duplicates[x],provider_id)}) == len(input.Duplicates)}same_provider(key,base) if { key.Provider == base}