Skip to content

Commit

Permalink
chore: update packageurl-hs package
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr committed Nov 7, 2024
1 parent d000ace commit 7dc7445
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/Opossum/OpossumDependencyCheckUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ instance A.FromJSON DependencyCheckEvidence where
-}
data DependencyCheckPackage =
DependencyCheckPackage
{ _dcp_id :: Either String PURL
{ _dcp_id :: Either String Purl
, _dcp_url :: Maybe T.Text
, _dcp_description :: Maybe String
, _dcp_confidence :: Maybe DependencyCheckConfidence
Expand All @@ -141,7 +141,7 @@ instance A.FromJSON DependencyCheckPackage where
(\case
Just purl -> Right purl
Nothing -> Left raw)
(parsePURL raw))
(parsePurl raw))
(v A..: "id") <*>
v A..:? "url" <*>
v A..:? "description" <*>
Expand Down Expand Up @@ -438,8 +438,8 @@ dependencyCheckPackageToCoordinates (DependencyCheckPackage {_dcp_id = id}) =
Right purl -> purlToCoordinates purl
Left raw -> Coordinates (Just (T.pack raw)) Nothing Nothing Nothing Nothing

evidenceToPURLs :: Map.Map String [DependencyCheckEvidence] -> [PURL]
evidenceToPURLs evidence =
evidenceToPurls :: Map.Map String [DependencyCheckEvidence] -> [Purl]
evidenceToPurls evidence =
let findBestFromEvidences :: [DependencyCheckEvidence] -> Maybe String
findBestFromEvidences [] = Nothing
findBestFromEvidences (e:_) = Just $ _dce_value e
Expand All @@ -451,14 +451,14 @@ evidenceToPURLs evidence =
in maybeToList $
fmap
(\product' ->
PURL Nothing Nothing vendor product' version Nothing Nothing)
Purl Nothing Nothing vendor product' version Nothing Nothing)
product

evidenceToPackages ::
Map.Map String [DependencyCheckEvidence] -> [DependencyCheckPackage]
evidenceToPackages =
map (\purl -> DependencyCheckPackage (Right purl) Nothing Nothing Nothing) .
evidenceToPURLs
evidenceToPurls

dependencyCheckDependencyToOpossum :: DependencyCheckDependency -> IO Opossum
dependencyCheckDependencyToOpossum (dcd@DependencyCheckDependency { _dcd_isVirtual = isVirtual
Expand Down
8 changes: 4 additions & 4 deletions src/Opossum/OpossumScancodeUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ renderLicense licenses =
-}
data ScancodePackage =
ScancodePackage
{ _scp_purl :: Maybe PURL
{ _scp_purl :: Maybe Purl
, _scp_licenses :: SPDX.MaybeLicenseExpression
, _scp_copyright :: Maybe String
, _scp_dependencies :: [ScancodePackage]
Expand All @@ -156,7 +156,7 @@ instance A.FromJSON ScancodePackage where
purl <-
v A..:? "purl" >>=
(\case
Just purl -> return $ parsePURL purl
Just purl -> return $ parsePurl purl
Nothing -> return Nothing)
dependencies <-
(v A..:? "dependencies" >>=
Expand Down Expand Up @@ -274,12 +274,12 @@ opossumFromScancodePackage scp@(ScancodePackage { _scp_purl = purl
}) providedPath =
let typeFromPurl =
case purl of
Just (PURL {_PURL_type = t}) -> maybe "generic" show t
Just (Purl {_Purl_type = t}) -> maybe "generic" show t
_ -> "generic"
pathFromPurl =
typeFromPurl FP.</>
case purl of
Just (PURL {_PURL_namespace = ns, _PURL_name = n, _PURL_version = v}) ->
Just (Purl {_Purl_namespace = ns, _Purl_name = n, _Purl_version = v}) ->
foldl1 (FP.</>) $
maybeToList ns ++ [intercalate "@" $ n : maybeToList v]
_ -> "UNKNOWN"
Expand Down
4 changes: 2 additions & 2 deletions src/Opossum/OpossumScanossUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ data ScanossFinding =
ScanossFinding
{ _ScanossFinding_id :: String
, _ScanossFinding_matched :: String
, _ScanossFinding_purl :: [PURL]
, _ScanossFinding_purl :: [Purl]
, _ScanossFinding_vendor :: Maybe T.Text
, _ScanossFinding_component :: Maybe T.Text
, _ScanossFinding_version :: Maybe T.Text
Expand Down Expand Up @@ -217,7 +217,7 @@ instance A.FromJSON ScanossFinding where
AKM.filterWithKey (\key -> const (not (key `elem` keysToFilter))))
v
ScanossFinding <$> v A..: "id" <*> v A..: "matched" <*>
(fmap (Maybe.mapMaybe (parsePURL)) $ v A..: "purl") <*>
(fmap (Maybe.mapMaybe (parsePurl)) $ v A..: "purl") <*>
v A..:? "vendor" <*>
v A..:? "component" <*>
v A..:? "version" <*>
Expand Down

0 comments on commit 7dc7445

Please sign in to comment.