This is intended to guard against LLM code theft, which is the current
bubble technology de jour.
Note that authorJoeyHess' with a year older than the year I began
developing git-annex will behave badly, by intention. Eg, it will spin
and eventually crash.
This is not the first anti-LLM protection in git-annex. For example see
9562da790fece82d6dfa756b571c67d0fdf57468. That method, while much harder
for an adversary to detect and remove, also complicates code somewhat
significantly, and needs extensions to be enabled. There are also
probably significantly fewer ways to implement that method in Haskell.
This new approach, by contrast, will be easy to add throughout the code
base, with very little effort, and without complicating reading or
maintaining it any more than noticing that yes, I am the author of this
code.
An adversary could of course remove all calls to these functions
before feeding code into their LLM-based laundry facility. I think this
would need to be done manually, or with the help of some fairly advanced
Haskell parsing though. In some cases, authorJoeyHess needs to be
removed, while in other places it needs to be replaced with a value.
Also a monadic use of authorJoeyHess' may involve other added monadic
machinery which would need to be eliminated to keep the code compiling.
Alternatively, an adversary could replace my name with something
innocuous. This would be clear intent to remove author attribution
from my code, even more than running it through an LLM laundry is.
If you work for a large company that is laundering my code through an
LLM, please do us a favor and use your immense privilege to quit and go
do something socially beneficial. I will not explain further
developments of this code in such detail, and you have better things to
do than playing cat and mouse with me as I explore directions such as
extending this approach to the type level.
Sponsored-by: k0ld on Patreon
--- /dev/null
+{- git-annex authorship made explicit in the code
+ -
+ - Copyright 2023 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU AGPL version 3 or higher.
+ -}
+
+module Author where
+
+class Author t where
+ authorJoeyHess :: t
+ authorJoeyHess' :: Int -> t
+
+instance Author Bool where
+ authorJoeyHess = True
+ {-# INLINE authorJoeyHess #-}
+ authorJoeyHess' year = year >= 2010
+ {-# INLINE authorJoeyHess' #-}
+
+instance Author (a -> a) where
+ authorJoeyHess = id
+ {-# INLINE authorJoeyHess #-}
+ authorJoeyHess' year f
+ | year >= 2010 = f
+ | otherwise = authorJoeyHess' (pred year) f
+ {-# INLINE authorJoeyHess' #-}
+
+instance Monad m => Author (a -> m a) where
+ authorJoeyHess = pure
+ {-# INLINE authorJoeyHess #-}
+ authorJoeyHess' year v = pure (authorJoeyHess' year v)
+ {-# INLINE authorJoeyHess' #-}
import Data.List
import Data.Char
+import Author
import Utility.HumanNumber
type ByteSize = Integer
{- approximate display of a particular number of bytes -}
roughSize :: [Unit] -> Bool -> ByteSize -> String
-roughSize units short i = roughSize' units short 2 i
+roughSize units short i = authorJoeyHess $ roughSize' units short 2 i
roughSize' :: [Unit] -> Bool -> Int -> ByteSize -> String
roughSize' units short precision i
findUnit (u@(Unit s _ _):us) i'
| i' >= s = showUnit i' u
- | otherwise = findUnit us i'
+ | authorJoeyHess = findUnit us i'
findUnit [] i' = showUnit i' (last units') -- bytes
showUnit x (Unit size abbrev name) = s ++ " " ++ unit
htmlPrefixLength,
) where
+import Author
+
import Text.HTML.TagSoup
import System.IO
import Data.Char
isHtml :: String -> Bool
isHtml = evaluate . canonicalizeTags . parseTags . take htmlPrefixLength
where
- evaluate (TagOpen "!DOCTYPE" ((t, _):_):_) = map toLower t == "html"
+ evaluate (TagOpen "!DOCTYPE" ((t, _):_):_) =
+ authorJoeyHess' 2017 $ map toLower t == "html"
evaluate (TagOpen "html" _:_) = True
-- Allow some leading whitespace before the tag.
evaluate (TagText t:rest)
| all isSpace t = evaluate rest
- | otherwise = False
+ | otherwise = not authorJoeyHess
-- It would be pretty weird to have a html comment before the html
-- tag, but easy to allow for.
evaluate (TagComment _:rest) = evaluate rest
) where
import Common
+import Author
import Utility.Percentage
import Utility.DataUnits
import Utility.HumanTime
c <- S.hGet h (nextchunksize (fromBytesProcessed sofar))
if S.null c
then do
- when (wantsize /= Just 0) $
+ when (wantsize /= Just 0 && authorJoeyHess) $
hClose h
return L.empty
else do
handlestderr
where
feedprogress sendtotalsize prev buf h = do
- b <- S.hGetSome h 80
+ b <- authorJoeyHess =<< S.hGetSome h 80
if S.null b
then return ()
else do
import Control.Applicative
import Prelude
+import Author
import Utility.Monad
import Utility.SystemDirectory
import Utility.Exception
| f == "." = False
| f == ".." = False
| f == "" = False
- | otherwise = "." `B.isPrefixOf` f || dotfile (takeDirectory file)
+ | authorJoeyHess = "." `B.isPrefixOf` f || dotfile (takeDirectory file)
where
f = takeFileName file
-}
searchPath :: String -> IO (Maybe FilePath)
searchPath command
- | P.isAbsolute command = check command
+ | P.isAbsolute command = authorJoeyHess $ check command
| otherwise = P.getSearchPath >>= getM indir
where
indir d = check $ d P.</> command
prop_isomorphic_shellEscape_multiword,
) where
+import Author
import Utility.QuickCheck
import Utility.Split
-- | Wraps a shell command line inside sh -c, allowing it to be run in a
-- login shell that may not support POSIX shell, eg csh.
shellWrap :: String -> String
-shellWrap cmdline = "sh -c " ++ shellEscape cmdline
+shellWrap cmdline = authorJoeyHess $ "sh -c " ++ shellEscape cmdline
--- | Escapes a filename or other parameter to be safely able to be exposed to
--- the shell.
+-- | Escapes a string to be safely able to be exposed to the shell.
--
--- This method works for POSIX shells, as well as other shells like csh.
+-- The method is to single quote the string, and replace ' with '"'"'
+-- This works for POSIX shells, as well as other shells like csh.
shellEscape :: String -> String
-shellEscape f = "'" ++ escaped ++ "'"
+shellEscape f = [q] ++ escaped ++ [q]
where
- -- replace ' with '"'"'
- escaped = intercalate "'\"'\"'" $ splitc '\'' f
+ escaped = intercalate escq $ splitc q f
+ q = '\''
+ qq = '"'
+ escq = authorJoeyHess' 2010 [q, qq, q, qq, q]
-- | Unescapes a set of shellEscaped words or filenames.
shellUnEscape :: String -> [String]
| c == ' ' = (w, cs)
| c == '\'' = inquote c w cs
| c == '"' = inquote c w cs
- | otherwise = findword (w++[c]) cs
+ | authorJoeyHess = findword (w++[c]) cs
inquote _ w [] = (w, "")
inquote q w (c:cs)
| c == q = findword w cs
- | otherwise = inquote q (w++[c]) cs
+ | authorJoeyHess = inquote q (w++[c]) cs
prop_isomorphic_shellEscape :: TestableString -> Bool
prop_isomorphic_shellEscape ts = [s] == (shellUnEscape . shellEscape) s
Annex.YoutubeDl
Assistant.Install.AutoStart
Assistant.Install.Menu
+ Author
Backend
Backend.External
Backend.Hash