From 8ea47110fc0a5d367dd06ed33ef05927dd4ed0b5 Mon Sep 17 00:00:00 2001 From: P0lskay <49369886+P0lskay@users.noreply.github.com> Date: Thu, 12 Sep 2024 06:33:27 +0300 Subject: [PATCH 1/3] fix prefix check for list of polr with namespace in memory mode Signed-off-by: P0lskay <49369886+P0lskay@users.noreply.github.com> --- pkg/storage/inmemory/polr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/inmemory/polr.go b/pkg/storage/inmemory/polr.go index f087fa8..056e823 100644 --- a/pkg/storage/inmemory/polr.go +++ b/pkg/storage/inmemory/polr.go @@ -29,7 +29,7 @@ func (p *polrdb) List(ctx context.Context, namespace string) ([]v1alpha2.PolicyR res := make([]v1alpha2.PolicyReport, 0) for k, v := range p.db { - if namespace == "" || strings.HasPrefix(k, namespace) { + if namespace == "" || strings.HasPrefix(strings.TrimPrefix(k, "polr/"), namespace) { res = append(res, v) klog.Infof("value found for prefix:%s, key:%s", namespace, k) } From 1948cef5b45b5efa035d3aa48bc7d054d463bab5 Mon Sep 17 00:00:00 2001 From: P0lskay <49369886+P0lskay@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:23:40 +0300 Subject: [PATCH 2/3] fix prefix check for list of ephr with namespace in memory mode Signed-off-by: P0lskay <49369886+P0lskay@users.noreply.github.com> --- pkg/storage/inmemory/ephr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/inmemory/ephr.go b/pkg/storage/inmemory/ephr.go index 8588bd4..a025678 100644 --- a/pkg/storage/inmemory/ephr.go +++ b/pkg/storage/inmemory/ephr.go @@ -29,7 +29,7 @@ func (e *ephrdb) List(ctx context.Context, namespace string) ([]reportsv1.Epheme res := make([]reportsv1.EphemeralReport, 0) for k, v := range e.db { - if namespace == "" || strings.HasPrefix(k, namespace) { + if namespace == "" || strings.HasPrefix(strings.TrimPrefix(k, "ephr/"),, namespace) { res = append(res, v) klog.Infof("value found for prefix:%s, key:%s", namespace, k) } From cf76f2945095d8ff6965e51a78f21f1bb6928f23 Mon Sep 17 00:00:00 2001 From: Vishal Choudhary Date: Thu, 12 Sep 2024 20:28:24 +0530 Subject: [PATCH 3/3] Update pkg/storage/inmemory/ephr.go Signed-off-by: Vishal Choudhary --- pkg/storage/inmemory/ephr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/inmemory/ephr.go b/pkg/storage/inmemory/ephr.go index a025678..654bf40 100644 --- a/pkg/storage/inmemory/ephr.go +++ b/pkg/storage/inmemory/ephr.go @@ -29,7 +29,7 @@ func (e *ephrdb) List(ctx context.Context, namespace string) ([]reportsv1.Epheme res := make([]reportsv1.EphemeralReport, 0) for k, v := range e.db { - if namespace == "" || strings.HasPrefix(strings.TrimPrefix(k, "ephr/"),, namespace) { + if namespace == "" || strings.HasPrefix(strings.TrimPrefix(k, "ephr/"), namespace) { res = append(res, v) klog.Infof("value found for prefix:%s, key:%s", namespace, k) }