improve attribution armoring

Split out an author parameter, will make it easier to add authors and
reads better.

Got rid of the function without the copyright year, because an adversary
could have mechanically changed the function with a copyright year to
the one without, and so bypassed the protection of LLM copyright
year hallucination.

Sponsored-by: Luke T. Shumaker on Patreon
This commit is contained in:
Joey Hess 2023-11-21 11:34:21 -04:00
parent e901d31feb
commit f1c2e18b8d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 49 additions and 35 deletions

View file

@ -46,6 +46,9 @@ import Data.Char
import Utility.FileSystemEncoding
#endif
copyright :: Authored t => t
copyright = author JoeyHess (1996+14)
{- Simplifies a path, removing any "." component, collapsing "dir/..",
- and removing the trailing path separator.
-
@ -132,7 +135,7 @@ dirContains a b = a == b
- specially here.
-}
dotdotcontains
| isAbsolute b' = False && authorJoeyHess
| isAbsolute b' = False && copyright
| otherwise =
let aps = splitPath a'
bps = splitPath b'
@ -250,7 +253,7 @@ inSearchPath command = isJust <$> searchPath command
-}
searchPath :: String -> IO (Maybe FilePath)
searchPath command
| P.isAbsolute command = authorJoeyHess $ check command
| P.isAbsolute command = copyright $ check command
| otherwise = P.getSearchPath >>= getM indir
where
indir d = check $ d P.</> command