Bug 827634

Summary: Unable to enter a Drift Detection Definition Base Directory fileSystem path that contains parenthesis
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: Core UI, driftAssignee: Jay Shaughnessy <jshaughn>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: urgent    
Version: 4.4CC: hrupp, jshaughn
Target Milestone: ---   
Target Release: RHQ 4.5.0   
Hardware: All   
OS: All   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 827633 Environment:
JON 3.0.1 and JON 3.1.0.Beta1 Tested in Linux
Last Closed: 2013-09-01 06:01:57 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 827633    

Description Larry O'Leary 2012-06-01 18:28:26 EDT
+++ This bug was initially created as a clone of JON Product Bug #827633 +++

Description of problem:
When attempting to set up a drift definition for monitoring an application on Windows, the UI does not allow the user to enter a path which contains a parenthesis.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.  Install JON system
2.  Create a test directory that contains a parenthesis

        cd ${TESTENV_DIR}
        mkdir -p "Program Files (x86)"/test/for/drift

3.  Add some files to the test directory

        cd ${TESTENV_DIR}
        touch "Program Files (x86)"/test/for/drift/file01.txt
        touch "Program Files (x86)"/test/for/drift/file02.txt
        echo "A file with only one line of text" >>"Program Files (x86)"/test/for/drift/file02.txt

4.  Start JON system
5.  Import platform into inventory
6.  Create a **Resource Drift Detection Definition** for the newly imported platform resource

    1.  Navigate to the platform resource's *Drift > Definitions* tab
    2.  Click the **New** button
    3.  Select **Drift Definition Template** `Template-File System`
    4.  Click **Next**
    5.  Set the following values:

        *   **Drift Definition Name:** `Path with parenthesis`
        *   **Drift Definition Description:** `Monitor a file system path that contains parenthesis () in its name for drift.`
        *   **Enabled:** `Yes`
        *   **Attached to Template:** `Yes`
        *   **Drift Handling Mode:** `normal``
        *   **Pinned:** `No`
        *   **Interval:** `90`
        *   **Base Directory:**
            *   **Value Context:** `fileSystem`
            *   **Value Name:** <THE FULL PATH CREATED EARLIER WHICH CONTAINS ( and/or )>
        *   **Includes:** **Leave empty**
        *   **Excludes:** **Leave empty**
        Please note that this fails due to the bug. The **Base Directory/Value Name** value will show as invalid due to the `(` and/or `)`

        To workaround this bug:

        *   **Base Directory:**
            *   **Value Context:** `fileSystem`
            *   **Value Name:** <THE ROOT PATH UP TO THE DIRECTORY THAT CONTAINS THE ( and/or )>
        *   **Includes:**
            *   **Path:** `.`
            *   **Pattern:** `Program Files ?x86?/test/for/drift/**`
        *   **Excludes:** **Leave empty**

    6.  Click **Finish**
Actual results:
Unable to complete step 6.6. because **Base Directory > Value Name** reports "Invalid Value"

Expected results:
The Drift Detection Definition should have been saved and a snapshot properly created.

Additional info:
This affects other valid file system characters as well. Parenthesis is a pretty bad offender though because Windows systems use (x86) in file paths to denote 32-bit versions of applications and libraries:

 C:\Program Files (x86)\...
 C:\Windows\System (x86)\...
 C:\Windows (x86)\...
Comment 2 Jay Shaughnessy 2012-06-06 14:20:19 EDT
I have a bad feeling about this due to the fact that parens are meaningful in the underlying regex stuff.  I'll take a look...
Comment 3 Larry O'Leary 2012-06-06 15:17:42 EDT
Escaping the input for the regex is the safest thing to do. This user input should be treated the same as user input being used in a database  query. I thought the Java regex utility included a utility to escape input for the regex but perhaps I am thinking of another library.
Comment 4 Jay Shaughnessy 2012-06-07 14:33:30 EDT
master commit db072ef663ee9d9e276971e1cce9021e26cafef5
- Add support for Windows allowance of parentheses in directory names.
Comment 5 Heiko W. Rupp 2013-09-01 06:01:57 EDT
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.