You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jason (Jira)" <ji...@apache.org> on 2023/11/24 15:37:00 UTC

[jira] [Commented] (MENFORCER-390) "requireFilesExist" no longer handles non-canonical paths

    [ https://issues.apache.org/jira/browse/MENFORCER-390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17789499#comment-17789499 ] 

Jason commented on MENFORCER-390:
---------------------------------

Hit this yesterday and was deeply confused as to what was going on. I worked around the issue by using Atlassian's `bash-maven-plugin` and some basic BASH, but this is less than optimal.

Looking at the change from MENFORCE-364, I honestly think it should be reverted.

Filesystems are case-(in)sensitve, not operating systems. `requireFilesDontExist` was not updated. Handling symbolic links was broken. OSs can have *multiple* filesystems connected with different case-sensitivity.

Despite all the limitations, `file.exists()` is the simplest way to deal with this without creating unexpected edge cases.

Those who have more exacting/unusual needs can craft a custom plugin (or something) to handle their case. They should not break Maven for everyone.

All that said, I did implement a partial fix which highlights some of the issues that can arise. You can view it here: https://github.com/roadSurfer/maven-enforcer/tree/MENFORCER-390_impl


> "requireFilesExist" no longer handles non-canonical paths
> ---------------------------------------------------------
>
>                 Key: MENFORCER-390
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-390
>             Project: Maven Enforcer Plugin
>          Issue Type: Bug
>          Components: requireFilesExist, Standard Rules
>    Affects Versions: 3.0.0
>            Reporter: Gene Smith
>            Priority: Major
>
> With the commit to resolve MENFORCER-364, the rule "requireFileExists" checks that the canonical path of a file is the same as the absolute path.
> But not all absolute paths are canonical.
>  * absolute paths can involve symbolic links
>  * and they are allowed to have parts which are relative
>  ** {{/../}}
>  ** {{/./}}{{}}{{}}{{}}
> And when it fails to handle a path, it can report that a file does not exist, even though the local system will resolve the path.
> A blunt solution might be three separate rules:
>  * requireFileExists
>  ** the provided path must resolve to a file (which may be a directory or link)
>  * requireCanonicalFileExists
>  ** the provided path must exist as a canonical file
>  * requireCasesenstiveFileExists
>  ** the provided path must file a file
>  ** the file name must have the same case (upper//lower) as the
>  ** the parts of the path from the file up must have the same case until they go through a symbolic link
> I have used  the "nio" package to handle some of stuff before.  I will add a comment with some java code I would start with.  Since the outcome here is very dependent on the use case you pick, the java will be "meta code" with ??? where you have to know the use case to know the outcome.
> but basically, with "nio" you can march up a path checking for symbolic links and such.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)