apache / apache/maven-enforcer

[MENFORCER-390] "requireFilesExist" no longer handles non-canonical paths

Open
#501 4 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
161
Forks
180
Avg merge
1d 20m
Merged PRs (30d)
8

Description

**[Gene Smith](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=gene)** opened **[MENFORCER-390](https://issues.apache.org/jira/browse/MENFORCER-390?redirect=false)** and commented

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.

 

---

**Affects:** 3.0.0

**Remote Links:**
- [GitHub Pull Request #297
](https://github.com/apache/maven-enforcer/pull/297)

2 votes, 6 watchers

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the requireFileExists rule and review the linked Maven Enforcer pull request #297. Clarify which path semantics are required for the affected use case, then define completion criteria that distinguish resolved paths, canonical paths, symbolic links, and case sensitivity.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.