Skip to content

feat(PDRIVE-526, PDRIVE-687): add run_oc_command argument validation … - #110

Draft
hoberger-rh wants to merge 1 commit into
RedHatInsights:mainfrom
hoberger-rh:PDRIVE-526
Draft

feat(PDRIVE-526, PDRIVE-687): add run_oc_command argument validation …#110
hoberger-rh wants to merge 1 commit into
RedHatInsights:mainfrom
hoberger-rh:PDRIVE-526

Conversation

@hoberger-rh

@hoberger-rh hoberger-rh commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

feat(PDRIVE-526, PDRIVE-687): add run_oc_command argument validation and SafeCmdString pre-commit check

Add _validate_args_safe() to OcApiUtils that validates all run_oc_command
arguments against an allowlist of safe patterns (flags, resource names,
JSONPath expressions, field selectors). Raises ValueError on invalid input.

  • Add mypy-based pre-commit hook to check SafeCmdString type usage (PDRIVE-687)
  • Add unit tests for _validate_args_safe() covering allowed patterns
    and edge cases
  • Add dynamic test that discovers all rule classes, executes their methods,
    and validates the actual args passed to run_oc_command against the allowlist
  • Enforce _validate_args_safe() in test mock (OperatorTestBase.run_oc_command)
    so future rule tests catch invalid args at test time

Assisted-by: Claude Code (Claude Opus 4.6) noreply@anthropic.com

…and SafeCmdString pre-commit check

Add _validate_args_safe() to OcApiUtils that validates all run_oc_command
arguments against an allowlist of safe patterns (flags, resource names,
JSONPath expressions, field selectors). Raises ValueError on invalid input.

- Add mypy-based pre-commit hook to check SafeCmdString type usage (PDRIVE-687)
- Add unit tests for _validate_args_safe() covering allowed patterns
  and edge cases
- Add dynamic test that discovers all rule classes, executes their methods,
  and validates the actual args passed to run_oc_command against the allowlist
- Enforce _validate_args_safe() in test mock (OperatorTestBase.run_oc_command)
  so future rule tests catch invalid args at test time

Assisted-by: Claude Code (Claude Opus 4.6) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bc3f7b51-8ec5-4dac-b71d-7d76c308f97c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@b7e912a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/in_cluster_checks/utils/oc_api_utils.py 93.93% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #110   +/-   ##
=======================================
  Coverage        ?   87.21%           
=======================================
  Files           ?       56           
  Lines           ?     6541           
  Branches        ?        0           
=======================================
  Hits            ?     5705           
  Misses          ?      836           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants