Skip to content

fix: anchor grep pattern in deleteResourcesInNamespaceMatchingPattern#119

Open
atharrva01 wants to merge 1 commit intoopenMF:devfrom
atharrva01:fix/namespace-deletion-anchored-pattern
Open

fix: anchor grep pattern in deleteResourcesInNamespaceMatchingPattern#119
atharrva01 wants to merge 1 commit intoopenMF:devfrom
atharrva01:fix/namespace-deletion-anchored-pattern

Conversation

@atharrva01
Copy link
Copy Markdown

Summary

I fixed unsafe namespace matching in deleteResourcesInNamespaceMatchingPattern() by changing it from a substring match to an exact match.

Previously, using infra could also match namespaces like infra-monitoring or infrastructure, which could lead to unintended deletions during cleanup on shared clusters.

I updated the grep check to anchor against the full namespace/<name> format, so only the exact configured namespace is matched.

Impact

  • Prevents accidental deletion of similarly named namespaces
  • Keeps existing behavior unchanged for valid namespace names
  • Low-risk, minimal change limited to delete filtering logic

Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
@atharrva01 atharrva01 requested a review from a team April 22, 2026 07:33
@atharrva01
Copy link
Copy Markdown
Author

hi @tdaly61 , I’d really appreciate a quick review on this small safety fix I made for namespace deletion matching, updated it to use exact matches to prevent accidental deletes on shared clusters.

@tdaly61
Copy link
Copy Markdown
Collaborator

tdaly61 commented Apr 22, 2026

Hi @atharrva01 thanks for looking at this but may I ask have you tested the changes , have you deployed Mifos Gazelle ?

@atharrva01
Copy link
Copy Markdown
Author

hi @tdaly61 , I tested this locally by simulating the kubectl get namespaces -o name output.

The namespaces used in this project (infra, vnext, mifosx, paymenthub from config/config.ini) are short plain strings. On a shared cluster, I found that adjacent namespaces like infra-monitoring, vnext-staging, or mifosx-old were also getting matched by the old unanchored grep, which meant they could be deleted unintentionally.

Before fix: pattern infra:
infra, infra-monitoring, infrastructure, infra-test → all matched

After fix: pattern infra:
infra → only the intended namespace matched

I confirmed the same behavior for all four patterns (vnext, mifosx, paymenthub). No cluster deployment was needed since the issue was only in the grep pattern, which I verified directly.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants