Skip to content

ROX-33306: Add helper text and validation to File Path criterion#19257

Open
sachaudh wants to merge 2 commits intomasterfrom
ROX-33306/file-path-text-input
Open

ROX-33306: Add helper text and validation to File Path criterion#19257
sachaudh wants to merge 2 commits intomasterfrom
ROX-33306/file-path-text-input

Conversation

@sachaudh
Copy link
Contributor

@sachaudh sachaudh commented Mar 2, 2026

Description

Jira: ROX-33306

Adds inline helper text and client-side validation to the File Path policy criterion text input:

  • Helper text explains expected input format ("Enter an absolute file path. Supports glob patterns.")
  • Placeholder shows example glob pattern (/home/**/.ssh/id_*)
  • Validation enforces absolute paths (must start with /) and rejects directory traversal (..)
  • Error messages display inline below the input using PatternFly FormHelperText
  • CSS fix to allow helper text to wrap properly within policy sections

Changes apply to both container and node-level File Path descriptors.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Verified helper text and placeholder render correctly on the File Path criterion
  • Tested validation shows error for relative paths and paths with ..
  • Confirmed valid absolute paths and glob patterns pass validation
  • Checked error/helper text display toggles correctly based on input state

Screenshots

file-path-helper-and-validation.mov

The File Path criterion was changed from a dropdown to a text input by
backend PRs 19057/19063, but lacked guidance for users on glob syntax
support and had no client-side input validation.

Add helper text explaining glob pattern support, a placeholder showing
a realistic sensitive file path pattern, and lightweight client-side
validation that checks for absolute paths and rejects directory
traversal. Glob syntax validation is intentionally left to the backend
(Go's doublestar library) to avoid client/server mismatch.

Also extend TextDescriptor type with helperText and validate fields so
other text criteria can reuse this pattern.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
@openshift-ci
Copy link

openshift-ci bot commented Mar 2, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Use segment-based directory traversal check to match backend behavior,
avoiding false positives on filenames containing consecutive dots (e.g.
file..bak). Simplify showError logic since the validator already handles
empty strings. Add unit tests covering edge cases.

Partially generated by AI.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 2, 2026

Images are ready for the commit at 9307234.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-215-g93072347b1.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.63%. Comparing base (5b00d69) to head (9307234).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19257      +/-   ##
==========================================
- Coverage   49.64%   49.63%   -0.01%     
==========================================
  Files        2679     2679              
  Lines      202130   202130              
==========================================
- Hits       100339   100326      -13     
- Misses      94315    94326      +11     
- Partials     7476     7478       +2     
Flag Coverage Δ
go-unit-tests 49.63% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


#policy-sections .pf-v5-c-form__helper-text {
white-space: normal;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper text was not properly wrapping so added this to fix that

@sachaudh sachaudh marked this pull request as ready for review March 3, 2026 14:47
@sachaudh sachaudh requested a review from a team as a code owner March 3, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants