#1219

hooks: a dangling .zero junction can disable beforeTool blocking on Windows

OpenEddieMurphy89opened 24d ago

Version / branch / commit

main at 17fcd26602dc685fd1596739c4d718932d856d9e; found while reviewing #1211.

OS and environment

Windows 10/11, cmd.exe; junction created with mklink /J (no symlink privilege needed).

Steps to reproduce

  1. Create a workspace directory with a .zero junction pointing at a target directory.
  2. Put a valid hooks.json under the target.
  3. Remove the junction target, leaving .zero as a dangling junction.
  4. Load the project hook layer / run a beforeTool hook in that workspace.

Expected behavior

The hook config is known to exist but cannot be resolved, so LoadConfig returns ErrInvalidConfig and beforeTool stays blocked.

Actual behavior

On Windows, os.Lstat reports a junction as ModeIrregular rather than ModeSymlink. danglingSymlinkInPath only checked the symlink bit, so it skipped the dangling .zero junction. LoadConfig returned no error and no diagnostics, and beforeTool ran with no policy.

Relevant logs, screenshots, or error messages

Reproduced on Windows with mklink /J; Lstat returned mode ?rw-rw-rw- with no symlink bit, ReadFile returned not-exist, and LoadConfig returned no error. PR #1211 now checks Lstat existence plus Stat not-exist, which treats any dangling link/junction as invalid, and adds a Windows junction regression test.

Activity

1
Vasanthdev200415d ago

Marking this bug and issue-approved. I reproduced the junction case myself while reviewing #1211: a dangling .zero junction made with mklink /J was skipped by the symlink-only check, and the Windows test in that PR fails when the fix is reduced to the symlink bit. #1211 is the fix and is approved from my side.