mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
ensure whitelist is present before checking
This commit is contained in:
@@ -116,6 +116,8 @@ import Startlude (
|
|||||||
(<$>),
|
(<$>),
|
||||||
(<<$>>),
|
(<<$>>),
|
||||||
(<>),
|
(<>),
|
||||||
|
(>),
|
||||||
|
(&&)
|
||||||
)
|
)
|
||||||
import System.FilePath (
|
import System.FilePath (
|
||||||
(<.>),
|
(<.>),
|
||||||
@@ -144,8 +146,7 @@ import Yesod (
|
|||||||
import Yesod.Auth (YesodAuth (maybeAuthId))
|
import Yesod.Auth (YesodAuth (maybeAuthId))
|
||||||
import Yesod.Core.Types (JSONResponse (JSONResponse))
|
import Yesod.Core.Types (JSONResponse (JSONResponse))
|
||||||
import Database.Persist.Sql (runSqlPool)
|
import Database.Persist.Sql (runSqlPool)
|
||||||
import Data.List (elem)
|
import Data.List (elem, length)
|
||||||
|
|
||||||
|
|
||||||
postPkgUploadR :: Handler ()
|
postPkgUploadR :: Handler ()
|
||||||
postPkgUploadR = do
|
postPkgUploadR = do
|
||||||
@@ -164,7 +165,7 @@ postPkgUploadR = do
|
|||||||
PackageManifest{..} <- do
|
PackageManifest{..} <- do
|
||||||
liftIO (decodeFileStrict (dir </> "manifest.json"))
|
liftIO (decodeFileStrict (dir </> "manifest.json"))
|
||||||
`orThrow` sendResponseText status500 "Failed to parse manifest.json"
|
`orThrow` sendResponseText status500 "Failed to parse manifest.json"
|
||||||
if (not $ elem packageManifestId whitelist)
|
if (not $ elem packageManifestId whitelist && (length whitelist > 0))
|
||||||
then sendResponseText status500 "Package does not belong on this registry."
|
then sendResponseText status500 "Package does not belong on this registry."
|
||||||
else do
|
else do
|
||||||
renameFile path (dir </> (toS . unPkgId) packageManifestId <.> "s9pk")
|
renameFile path (dir </> (toS . unPkgId) packageManifestId <.> "s9pk")
|
||||||
|
|||||||
Reference in New Issue
Block a user