mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-28 23:22:00 +03:00
parent
a1e0ec5970
commit
8fd2aed8bf
16
app/Main.hs
16
app/Main.hs
@ -24,6 +24,7 @@ default (T.Text)
|
|||||||
data UpdateOptions
|
data UpdateOptions
|
||||||
= UpdateOptions
|
= UpdateOptions
|
||||||
{ pr :: Bool,
|
{ pr :: Bool,
|
||||||
|
cve :: Bool,
|
||||||
cachix :: Bool,
|
cachix :: Bool,
|
||||||
outpaths :: Bool
|
outpaths :: Bool
|
||||||
}
|
}
|
||||||
@ -43,6 +44,7 @@ updateOptionsParser :: O.Parser UpdateOptions
|
|||||||
updateOptionsParser =
|
updateOptionsParser =
|
||||||
UpdateOptions
|
UpdateOptions
|
||||||
<$> O.flag False True (O.long "pr" <> O.help "Make a pull request using Hub.")
|
<$> O.flag False True (O.long "pr" <> O.help "Make a pull request using Hub.")
|
||||||
|
<*> O.flag False True (O.long "cve" <> O.help "Make a CVE vulnerability report.")
|
||||||
<*> O.flag False True (O.long "cachix" <> O.help "Push changes to Cachix")
|
<*> O.flag False True (O.long "cachix" <> O.help "Push changes to Cachix")
|
||||||
<*> O.flag False True (O.long "outpaths" <> O.help "Calculate outpaths to determine the branch to target")
|
<*> O.flag False True (O.long "outpaths" <> O.help "Calculate outpaths to determine the branch to target")
|
||||||
|
|
||||||
@ -124,19 +126,19 @@ main = do
|
|||||||
setupNixpkgs token
|
setupNixpkgs token
|
||||||
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||||
deleteDone token
|
deleteDone token
|
||||||
UpdateList UpdateOptions {pr, cachix, outpaths} -> do
|
UpdateList UpdateOptions {pr, cachix, cve, outpaths} -> do
|
||||||
token <- getGithubToken
|
token <- getGithubToken
|
||||||
updates <- T.readFile "packages-to-update.txt"
|
updates <- T.readFile "packages-to-update.txt"
|
||||||
setupNixpkgs token
|
setupNixpkgs token
|
||||||
P.setEnv "PAGER" "" True
|
P.setEnv "PAGER" "" True
|
||||||
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||||
updateAll (Options pr True token cachix outpaths) updates
|
updateAll (Options pr True token cve cachix outpaths) updates
|
||||||
Update UpdateOptions {pr, cachix} update -> do
|
Update UpdateOptions {pr, cve, cachix} update -> do
|
||||||
token <- getGithubToken
|
token <- getGithubToken
|
||||||
setupNixpkgs token
|
setupNixpkgs token
|
||||||
P.setEnv "PAGER" "" True
|
P.setEnv "PAGER" "" True
|
||||||
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||||
result <- updatePackage (Options pr False token cachix False) update
|
result <- updatePackage (Options pr False token cve cachix False) update
|
||||||
case result of
|
case result of
|
||||||
Left e -> T.putStrLn e
|
Left e -> T.putStrLn e
|
||||||
Right () -> T.putStrLn "Done."
|
Right () -> T.putStrLn "Done."
|
||||||
@ -149,17 +151,17 @@ main = do
|
|||||||
CheckAllVulnerable -> do
|
CheckAllVulnerable -> do
|
||||||
setupNixpkgs undefined
|
setupNixpkgs undefined
|
||||||
updates <- T.readFile "packages-to-update.txt"
|
updates <- T.readFile "packages-to-update.txt"
|
||||||
cveAll (Options undefined undefined undefined undefined undefined) updates
|
cveAll undefined updates
|
||||||
CheckVulnerable productID oldVersion newVersion -> do
|
CheckVulnerable productID oldVersion newVersion -> do
|
||||||
setupNixpkgs undefined
|
setupNixpkgs undefined
|
||||||
report <-
|
report <-
|
||||||
cveReport
|
cveReport
|
||||||
(UpdateEnv productID oldVersion newVersion Nothing (Options False False undefined False False))
|
(UpdateEnv productID oldVersion newVersion Nothing (Options False False undefined False False False))
|
||||||
T.putStrLn report
|
T.putStrLn report
|
||||||
SourceGithub -> do
|
SourceGithub -> do
|
||||||
token <- getGithubToken
|
token <- getGithubToken
|
||||||
updates <- T.readFile "packages-to-update.txt"
|
updates <- T.readFile "packages-to-update.txt"
|
||||||
setupNixpkgs token
|
setupNixpkgs token
|
||||||
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||||
sourceGithubAll (Options False False token False False) updates
|
sourceGithubAll (Options False False token False False False) updates
|
||||||
FetchRepology -> Repology.fetch
|
FetchRepology -> Repology.fetch
|
||||||
|
@ -456,34 +456,36 @@ addPatched attrPath set = do
|
|||||||
|
|
||||||
cveReport :: UpdateEnv -> IO Text
|
cveReport :: UpdateEnv -> IO Text
|
||||||
cveReport updateEnv =
|
cveReport updateEnv =
|
||||||
withVulnDB $ \conn -> do
|
if not (makeCVEReport . options $ updateEnv)
|
||||||
let pname1 = packageName updateEnv
|
then return ""
|
||||||
let pname2 = T.replace "-" "_" pname1
|
else withVulnDB $ \conn -> do
|
||||||
oldCVEs1 <- getCVEs conn pname1 (oldVersion updateEnv)
|
let pname1 = packageName updateEnv
|
||||||
oldCVEs2 <- getCVEs conn pname2 (oldVersion updateEnv)
|
let pname2 = T.replace "-" "_" pname1
|
||||||
let oldCVEs = S.fromList (oldCVEs1 ++ oldCVEs2)
|
oldCVEs1 <- getCVEs conn pname1 (oldVersion updateEnv)
|
||||||
newCVEs1 <- getCVEs conn pname1 (newVersion updateEnv)
|
oldCVEs2 <- getCVEs conn pname2 (oldVersion updateEnv)
|
||||||
newCVEs2 <- getCVEs conn pname2 (newVersion updateEnv)
|
let oldCVEs = S.fromList (oldCVEs1 ++ oldCVEs2)
|
||||||
let newCVEs = S.fromList (newCVEs1 ++ newCVEs2)
|
newCVEs1 <- getCVEs conn pname1 (newVersion updateEnv)
|
||||||
let inOldButNotNew = S.difference oldCVEs newCVEs
|
newCVEs2 <- getCVEs conn pname2 (newVersion updateEnv)
|
||||||
inNewButNotOld = S.difference newCVEs oldCVEs
|
let newCVEs = S.fromList (newCVEs1 ++ newCVEs2)
|
||||||
inBoth = S.intersection oldCVEs newCVEs
|
let inOldButNotNew = S.difference oldCVEs newCVEs
|
||||||
ifEmptyNone t =
|
inNewButNotOld = S.difference newCVEs oldCVEs
|
||||||
if t == T.empty
|
inBoth = S.intersection oldCVEs newCVEs
|
||||||
then "none"
|
ifEmptyNone t =
|
||||||
else t
|
if t == T.empty
|
||||||
inOldButNotNew' <- addPatched (packageName updateEnv) inOldButNotNew
|
then "none"
|
||||||
inNewButNotOld' <- addPatched (packageName updateEnv) inNewButNotOld
|
else t
|
||||||
inBoth' <- addPatched (packageName updateEnv) inBoth
|
inOldButNotNew' <- addPatched (packageName updateEnv) inOldButNotNew
|
||||||
let toMkdownList = fmap (uncurry cveLI) >>> T.unlines >>> ifEmptyNone
|
inNewButNotOld' <- addPatched (packageName updateEnv) inNewButNotOld
|
||||||
fixedList = toMkdownList inOldButNotNew'
|
inBoth' <- addPatched (packageName updateEnv) inBoth
|
||||||
newList = toMkdownList inNewButNotOld'
|
let toMkdownList = fmap (uncurry cveLI) >>> T.unlines >>> ifEmptyNone
|
||||||
unresolvedList = toMkdownList inBoth'
|
fixedList = toMkdownList inOldButNotNew'
|
||||||
if fixedList == "none" && unresolvedList == "none" && newList == "none"
|
newList = toMkdownList inNewButNotOld'
|
||||||
then return ""
|
unresolvedList = toMkdownList inBoth'
|
||||||
else
|
if fixedList == "none" && unresolvedList == "none" && newList == "none"
|
||||||
return
|
then return ""
|
||||||
[interpolate|
|
else
|
||||||
|
return
|
||||||
|
[interpolate|
|
||||||
<details>
|
<details>
|
||||||
<summary>
|
<summary>
|
||||||
Security report (click to expand)
|
Security report (click to expand)
|
||||||
|
@ -107,6 +107,7 @@ data Options
|
|||||||
{ doPR :: Bool,
|
{ doPR :: Bool,
|
||||||
batchUpdate :: Bool,
|
batchUpdate :: Bool,
|
||||||
githubToken :: Text,
|
githubToken :: Text,
|
||||||
|
makeCVEReport :: Bool,
|
||||||
pushToCachix :: Bool,
|
pushToCachix :: Bool,
|
||||||
calculateOutpaths :: Bool
|
calculateOutpaths :: Bool
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user