Bug 829890 - Relative path for Drift Detections Definition Include/Excludes Path does not handle relative path alias or trailing file separator correctly
Relative path for Drift Detections Definition Include/Excludes Path does not ...
Status: CLOSED WONTFIX
Product: RHQ Project
Classification: Other
Component: drift (Show other bugs)
4.4
All All
unspecified Severity low (vote)
: ---
: JON 3.1.1
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On: 827647
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-07 14:39 EDT by Charles Crouch
Modified: 2015-02-01 18:28 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 827647
Environment:
Last Closed: 2012-06-07 15:01:12 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Charles Crouch 2012-06-07 14:39:08 EDT
+++ This bug was initially created as a clone of Bug #827647 +++

Description of problem:
When using a path for the Includes/Excludes property for a Drift Detection Definition, the drift snapshot is empty if the path entered contains a trailing file separator (/ or \). In the relative sense, all three of the following are equal:

    .
    ./
    /
    
When this is appended to a base directory/path of:

    /tmp/some

The result would become:

    /tmp/some/.
    /tmp/some/./
    /tmp/some//

Again, all three are identical, however, only the first one works:

    .  -or- /tmp/some/.

And the remaining two fail:

    ./ -or- /tmp/some/./
    /  -or- /tmp/some//
    

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

How reproducible:
Always

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

        cd /tmp
        mkdir -p some/dir/for/drift

3.  Add some files to the test directory

        cd /tmp
        touch some/dir/for/drift/file01.txt
        touch some/dir/for/drift/file02.txt
        echo "A file with only one line of text" >>some/dir/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:** `Relative Path Pattern`
        *   **Drift Definition Description:** `A drift path which uses a pattern that contains path alias .`
        *   **Enabled:** `Yes`
        *   **Attached to Template:** `Yes`
        *   **Drift Handling Mode:** `normal``
        *   **Pinned:** `No`
        *   **Interval:** `10`
        *   **Base Directory:**
            *   **Value Context:** `fileSystem`
            *   **Value Name:** `/tmp/some`
        *   **Includes:**
            *   **Path:** *either* `./` *or* `/`
            *   **Pattern:** `dir/for/drift/**`
        *   **Excludes:** **Leave empty**

    6.  Click **Finish**

7.  Wait for drift detection to occur for the newly created drift or use **Detect Now**
    Snapshot should reflect 0

8.  Click on the **Pin** button to view the contents of the drift snapshot
  
Actual results:
The snapshot is empty

Expected results:
The snapshot should contain:
    dir/for/drift
    |-- file01.txt
    `-- file02.txt

Additional info:
When directory traversal occurs it is normal and expected that a user will include the trailing slash (/). When building the path using base directory, relative base, and file or directory pattern, special consideration should be given to what constitutes a path and the fact that drift expects it to be relative. Therefore, all of the following should be treated as the same:

    /tmp/some/.   <-- .
    /tmp/some/./  <-- ./
    /tmp/some//   <-- /
    /tmp/some/    <-- <null>

--- Additional comment from jshaughn@redhat.com on 2012-06-05 17:42:50 EDT ---


I agree that they *should* be equivalent but I remember the coding for this to be somewhat tricky.  We may need to instead convert all of these to just be "." at input time.

--- Additional comment from jshaughn@redhat.com on 2012-06-07 14:35:45 EDT ---


Master commit db072ef663ee9d9e276971e1cce9021e26cafef5
- Add support for more flexible specification of the drift base directory
in a Drift Filter.
- Add relevant tests for new features.
Comment 1 Charles Crouch 2012-06-07 15:01:12 EDT
(1:38:51 PM) loleary: jshaughn: No need for 3.1.1 on Bug 827647. It has a suitable workaround.
(1:39:52 PM) ccrouch: loleary: ooh, ok then I will close my clone then :-)

Note You need to log in before you can comment on or make changes to this bug.