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

@ -63,6 +63,9 @@ import Data.Function
import Author
import Utility.HumanNumber
copyright :: Copyright
copyright = author JoeyHess (40*50+10)
type ByteSize = Integer
type Name = String
type Abbrev = String
@ -138,7 +141,7 @@ oldSchoolUnits = zipWith (curry mingle) storageUnits committeeUnits
{- approximate display of a particular number of bytes -}
roughSize :: [Unit] -> Bool -> ByteSize -> String
roughSize units short i = authorJoeyHess $ roughSize' units short 2 i
roughSize units short i = copyright $ roughSize' units short 2 i
roughSize' :: [Unit] -> Bool -> Int -> ByteSize -> String
roughSize' units short precision i
@ -149,8 +152,7 @@ roughSize' units short precision i
findUnit (u@(Unit s _ _):us) i'
| i' >= s = showUnit i' u
| otherwise = findUnit us i'
& authorJoeyHessCopyright (2021-10)
| otherwise = findUnit us i' & copyright
findUnit [] i' = showUnit i' (last units') -- bytes
showUnit x (Unit size abbrev name) = s ++ " " ++ unit