diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 21:43:23 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 21:43:23 +0200 |
| commit | c497d173b24b1b8247fac9e996e5c0fe690c1769 (patch) | |
| tree | 2318ff1cf393e3a6c2a7d54c89e205ac6a9a5c73 /internal/extract | |
| parent | 360591d6e18d8676a2f86185ed42f46852387f85 (diff) | |
| download | krino-c497d173b24b1b8247fac9e996e5c0fe690c1769.tar.gz krino-c497d173b24b1b8247fac9e996e5c0fe690c1769.zip | |
plan 9: undo review matches review, --min-age validated, future mtimes, rule names, conflict enum, dependency gate, absolute tool paths
Diffstat (limited to 'internal/extract')
| -rw-r--r-- | internal/extract/extract.go | 5 | ||||
| -rw-r--r-- | internal/extract/tools_test.go | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/internal/extract/extract.go b/internal/extract/extract.go index 9768db1..ad51c00 100644 --- a/internal/extract/extract.go +++ b/internal/extract/extract.go @@ -99,7 +99,10 @@ func newWithPath(path string) *Extractor { tools := make(map[string]string, len(toolNames)) for _, name := range toolNames { for _, dir := range dirs { - if dir == "" { + // A relative entry would find a tool relative to the working + // directory - a bin/pdftotext an unpacked download left behind + // (review planapply F7) - so only absolute entries count. + if dir == "" || !filepath.IsAbs(dir) { continue } p := filepath.Join(dir, name) diff --git a/internal/extract/tools_test.go b/internal/extract/tools_test.go index b481e8a..756903d 100644 --- a/internal/extract/tools_test.go +++ b/internal/extract/tools_test.go @@ -261,3 +261,18 @@ func TestFingerprintFollowsTools(t *testing.T) { t.Error("replacing pdftotext did not change the fingerprint") } } + +// TestToolLookupSkipsRelativePathEntries: a relative PATH entry would make +// a tool's path relative to the working directory - a bin/pdftotext left by +// an unpacked download - so it is ignored (review planapply F7). +func TestToolLookupSkipsRelativePathEntries(t *testing.T) { + wd := t.TempDir() + if err := os.Mkdir(filepath.Join(wd, "bin"), 0o755); err != nil { + t.Fatal(err) + } + fakeTool(t, filepath.Join(wd, "bin"), "pdftotext", "echo injected") + t.Chdir(wd) + if e := newWithPath("bin"); e.tools["pdftotext"] != "" { + t.Errorf("tool found through a relative PATH entry: %q", e.tools["pdftotext"]) + } +} |
