Building 70 Projects ranging from beginner to advanced so anyone can β learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company π
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
fix: close audit-pass-1 remaining MAJOR + quick MINOR (Findings 14, 19, 20, 28, 29)
CarterPerez-devd9dd59db2a42
diff --git a/PROJECTS/advanced/haskell-reverse-proxy/aenebris.cabal b/PROJECTS/advanced/haskell-reverse-proxy/aenebris.cabalindex a95ad7bd..eac26e1f 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/aenebris.cabal+++ b/PROJECTS/advanced/haskell-reverse-proxy/aenebris.cabal@@ -9,7 +9,7 @@ license: MITlicense-file: LICENSEauthor: Carter Perezmaintainer: [email protected]-copyright: 2025 Carter Perez+copyright: 2026 AngelaMoscategory: Network, Security, Webbuild-type: Simpleextra-source-files: README.mddiff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Geo.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Geo.hsindex 93567003..774af8fe 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Geo.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Geo.hs@@ -60,9 +60,11 @@ import qualified Data.ByteString.Char8 as BCimport qualified Data.ByteString.Lazy as LBSimport Data.GeoIP2 (GeoDB, GeoResult(..), AS(..), findGeoData, openGeoDB)import Data.IP (IP(..), fromHostAddress, fromHostAddress6)+import Data.List (minimumBy)import Data.Map.Strict (Map)import qualified Data.Map.Strict as Mapimport Data.Maybe (fromMaybe, isJust)+import Data.Ord (comparing)import Data.Text (Text)import qualified Data.Text as Timport qualified Data.Text.Encoding as TE@@ -95,6 +97,9 @@ defaultGeoSweepIntervalMicros = 60_000_000defaultGeoFlaggedAsns :: [Int]defaultGeoFlaggedAsns = []+defaultGeoAsnCountCap :: Int+defaultGeoAsnCountCap = 200_000+geoResponseHeaderName :: HeaderNamegeoResponseHeaderName = "x-aenebris-geo"@@ -262,9 +267,20 @@ bumpAsnCounter Geo{..} n now = do| now - awWindowStart w < window ->w { awCount = awCount w + 1 }_ -> AsnWindow { awCount = 1, awWindowStart = now }- writeTVar geoAsnCounts $! Map.insert n entry m+ inserted = Map.insert n entry m+ bounded = capAsnCounts inserted+ writeTVar geoAsnCounts $! boundedpure (awCount entry)+capAsnCounts :: Map Int AsnWindow -> Map Int AsnWindow+capAsnCounts m+ | Map.size m <= defaultGeoAsnCountCap = m+ | otherwise =+ let oldestKey = fst $ minimumBy+ (comparing (awWindowStart . snd))+ (Map.toList m)+ in Map.delete oldestKey m+asnConcentrationScore :: Geo -> Int -> DoubleasnConcentrationScore Geo{..} count =let threshold = max 1 (gcConcentrationThreshold geoConfig)diff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Honeypot.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Honeypot.hsindex 0e819b4f..6e0fbabb 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Honeypot.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/Honeypot.hs@@ -274,7 +274,7 @@ robotsResponse cfg =robotsTxtBody :: HoneypotConfig -> ByteStringrobotsTxtBody HoneypotConfig{..} = BS.concat $[ "User-agent: *\n"- , "# Honeypot trap paths β Disallow per RFC 9309. Visiting these\n"+ , "# Honeypot trap paths. Disallow per RFC 9309. Visiting these\n", "# paths is treated as a violation signal regardless of declared UA.\n"] <> map disallowLine hpPatternswherediff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/IForest.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/IForest.hsindex 8515c15a..188884bd 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/IForest.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/IForest.hs@@ -16,6 +16,7 @@ module Aenebris.ML.IForest, minSubsampleForNormalization, defaultIForestNumTrees, defaultIForestSubsampleSize+ , maxIForestDepth) whereimport Data.Vector (Vector)@@ -44,6 +45,12 @@ defaultIForestNumTrees = 100defaultIForestSubsampleSize :: IntdefaultIForestSubsampleSize = 256+maxIForestDepth :: Int+maxIForestDepth = 64++depthBoundLeafSize :: Int+depthBoundLeafSize = 1+data ITree= ITreeLeaf !Int| ITreeSplit !Int !Double !ITree !ITree@@ -77,14 +84,17 @@ averagePathLength !trees !fv =addPath !acc !tree = acc + pathLength tree fv initialDepthpathLength :: ITree -> VU.Vector Double -> Int -> Double-pathLength !tree !fv !currentDepth = case tree of- ITreeLeaf !size ->- fromIntegral currentDepth + normalizationConstant size- ITreeSplit !featIdx !thr !left !right ->- let !fval = fv VU.! featIdx- in if fval <= thr- then pathLength left fv (currentDepth + 1)- else pathLength right fv (currentDepth + 1)+pathLength !tree !fv !currentDepth+ | currentDepth >= maxIForestDepth =+ fromIntegral currentDepth + normalizationConstant depthBoundLeafSize+ | otherwise = case tree of+ ITreeLeaf !size ->+ fromIntegral currentDepth + normalizationConstant size+ ITreeSplit !featIdx !thr !left !right ->+ let !fval = fv VU.! featIdx+ in if fval <= thr+ then pathLength left fv (currentDepth + 1)+ else pathLength right fv (currentDepth + 1)normalizationConstant :: Int -> DoublenormalizationConstant ndiff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Middleware.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Middleware.hsindex 1433542f..eb99af13 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Middleware.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Middleware.hs@@ -54,7 +54,7 @@ challengeWireText :: ByteStringchallengeWireText = "challenge"botBlockBody :: LBS.ByteString-botBlockBody = "403 Forbidden \x2014 request blocked by Aenebris ML"+botBlockBody = "403 Forbidden - request blocked by Aenebris ML"challengePageBody :: LBS.ByteStringchallengePageBody =diff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Model.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Model.hsindex b2faa917..b9f90837 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Model.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/ML/Model.hs@@ -329,15 +329,19 @@ validateCategoricalNode:: Int -> Int -> Tree -> Int -> Int -> Int -> Int -> Either String ()validateCategoricalNode featureCount nodeCount t i fIdx lIdx rIdx = dovalidateSplitNode featureCount nodeCount i fIdx lIdx rIdx- let catIdx = floor (treeThreshold t VU.! i) :: Int- nBound = VU.length (treeCatBoundaries t)- if nBound < 2+ let rawThreshold = treeThreshold t VU.! i+ catIdx = floor rawThreshold :: Int+ nBound = VU.length (treeCatBoundaries t)+ if fromIntegral catIdx /= rawThresholdthen Left ("Categorical node " <> show i- <> " requires non-empty cat_boundaries")- else if catIdx < 0 || catIdx >= nBound - 1+ <> " has non-integer threshold " <> show rawThreshold)+ else if nBound < 2then Left ("Categorical node " <> show i- <> " has out-of-range bitmap slice index " <> show catIdx)- else Right ()+ <> " requires non-empty cat_boundaries")+ else if catIdx < 0 || catIdx >= nBound - 1+ then Left ("Categorical node " <> show i+ <> " has out-of-range bitmap slice index " <> show catIdx)+ else Right ()validateEnsemble :: Int -> Ensemble -> Either String ()validateEnsemble expectedFeatures ens = dodiff --git a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/WAF/Engine.hs b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/WAF/Engine.hsindex 17eff80b..301f8c07 100644--- a/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/WAF/Engine.hs+++ b/PROJECTS/advanced/haskell-reverse-proxy/src/Aenebris/WAF/Engine.hs@@ -170,4 +170,4 @@ wafMiddleware rsVar app req respond = do[ ("Content-Type", "text/plain; charset=utf-8"), (wafResponseHeader, "blocked score=" <> BC.pack (show score))]- "403 Forbidden β request blocked by Aenebris WAF"+ "403 Forbidden - request blocked by Aenebris WAF"