Skip to content

fix(parser): support host namespaces inside nested security contexts with validation precedence#56

Open
i-OmSharma wants to merge 1 commit into
optiqor:mainfrom
i-OmSharma:bug/fix-host-namespace-nesting
Open

fix(parser): support host namespaces inside nested security contexts with validation precedence#56
i-OmSharma wants to merge 1 commit into
optiqor:mainfrom
i-OmSharma:bug/fix-host-namespace-nesting

Conversation

@i-OmSharma

Copy link
Copy Markdown

📝 Summary of Changes

This PR addresses the false-negative parser issue where nested host namespace configurations (hostNetwork, hostPID, hostIPC) under security boundaries like podSecurityContext were being silently ignored.

  1. Nested Context Extraction (pkg/parser/helm.go):
    • Enhanced applySecFields to scan and unpack nested scalar keys for all three host namespace flags.
    • Incorporated precise nil-guards (if out.HostNetwork == nil) to preserve standard Kubernetes priority semantics—ensuring workload-level explicit declarations safely override nested maps.
  2. Comprehensive Test Multi-Matrix (pkg/parser/helm_test.go):
    • Added host-namespace-flags-nested-under-podSecurityContext case to verify that nested flags are no longer dropped and evaluate cleanly to true.
    • Added workload-level-host-flags-take-precedence case to lock in structural fallback rules.

Closes #39


🧪 Testing Details

  • Verified locally by executing the internal test suite: go test -v -race -count=1 ./pkg/parser/...
  • All 10 Go framework packages and race detectors pass with 100% success.

@i-OmSharma i-OmSharma requested a review from btwshivam as a code owner June 17, 2026 10:33
@github-actions

Copy link
Copy Markdown

First PR — welcome aboard!

A few things to expect:

  1. CI: every PR runs build + race tests + lint on Ubuntu and macOS. If something fails, the log will tell you exactly which gate.
  2. DCO: every commit needs Signed-off-by:. git commit -s adds it automatically.
  3. Conventional Commits: PR titles like feat(analyze): new rule or fix(cli): handle X. We squash-merge by default.
  4. Review: a maintainer will review within 72 hours. Suggestions are conversations, not orders — push back if something doesn't fit your context.

If you get stuck, reply here or jump to Discussions. We want this PR to land.

@github-actions github-actions Bot added testing Test coverage and golden fixtures area/parser YAML / Helm parser size/M 51–200 lines labels Jun 17, 2026
@i-OmSharma

Copy link
Copy Markdown
Author

Hi @btwshivam,

I have opened this PR to resolve the nested host namespace parsing issue cleanly. All automated CI pipelines, linter workflows, and cross-platform tests (macOS/Ubuntu) have passed successfully with 100% green status!

🔍 Quick Architectural Summary:

  1. Precision Extraction (pkg/parser/helm.go): Updated applySecFields to safely iterate and parse nested configurations (hostNetwork, hostPID, hostIPC) inside boundaries like podSecurityContext.
  2. Precedence Protection: Enforced rigid nil-guards (if out.HostNetwork == nil) so that explicit workload-level security settings always maintain top-level priority over nested blocks, keeping behaviors predictable.
  3. Double-Edge Test Coverage (pkg/parser/helm_test.go): Injected two core table-driven test cases validating both the clean extraction of nested flags and the correct fallback precedence execution.

The diff is completely atomic (+78 lines) and contains 0 merge conflicts against main. Ready for your review and merge! 🚀

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

Labels

area/parser YAML / Helm parser size/M 51–200 lines testing Test coverage and golden fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: host namespace flags are ignored inside security contexts

1 participant