change to whitelist

This commit is contained in:
Lucy Cifferello
2023-04-12 12:10:09 -06:00
parent d599a90e8b
commit b98d3c3d67
5 changed files with 6 additions and 7 deletions

View File

@@ -39,7 +39,7 @@ marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
max-eos-version: "_env:MAX_VERSION:0.3.4.0"
min-eos-version: "_env:MIN_VERSION:0.3.4.0"
run-migration: "_env:RUN_MIGRATION:false"
blacklist: "_env:BLACKLIST:ADD ME"
whitelist: "_env:WHITELIST:ADD ME"
database:
database: "_env:PG_DATABASE:start9_registry"

View File

@@ -150,7 +150,7 @@ import Data.List (elem)
postPkgUploadR :: Handler ()
postPkgUploadR = do
resourcesTemp <- getsYesod $ (</> "temp") . resourcesDir . appSettings
blacklist <- getsYesod $ blacklist . appSettings
whitelist <- getsYesod $ whitelist . appSettings
createDirectoryIfMissing True resourcesTemp
withTempDirectory resourcesTemp "newpkg" $ \dir -> do
let path = dir </> "temp" <.> "s9pk"
@@ -164,7 +164,7 @@ postPkgUploadR = do
PackageManifest{..} <- do
liftIO (decodeFileStrict (dir </> "manifest.json"))
`orThrow` sendResponseText status500 "Failed to parse manifest.json"
if (elem packageManifestId blacklist)
if (not $ elem packageManifestId whitelist)
then sendResponseText status500 "Package does not belong on this registry."
else do
renameFile path (dir </> (toS . unPkgId) packageManifestId <.> "s9pk")

View File

@@ -51,7 +51,6 @@ import Startlude (
Show,
Text,
Traversable (traverse),
catMaybes,
const,
encodeUtf8,
filter,

View File

@@ -25,7 +25,7 @@ import Lib.PkgRepository (
)
import Lib.Types.Core (PkgId, OsArch)
import Lib.Types.Emver (
Version (Version, unVersion),
Version,
VersionRange,
satisfies, parseVersion
)

View File

@@ -89,7 +89,7 @@ data AppSettings = AppSettings
, sslPath :: !FilePath
, staticBinDir :: !FilePath
, torPort :: !AppPort
, blacklist :: ![PkgId]
, whitelist :: ![PkgId]
}
instance Has PkgRepo AppSettings where
extract = liftA2 PkgRepo ((</> "apps") . resourcesDir) staticBinDir
@@ -122,7 +122,7 @@ instance FromJSON AppSettings where
sslPath <- o .: "ssl-path"
staticBinDir <- o .: "static-bin-dir"
torPort <- o .: "tor-port"
blacklist <- o .: "blacklist"
whitelist <- o .: "whitelist"
let sslKeyLocation = sslPath </> "key.pem"
let sslCsrLocation = sslPath </> "certificate.csr"