Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get haskell panic fix into main; remove extra changes #2448

Merged
merged 6 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions syft/pkg/cataloger/haskell/parse_stack_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func parseStackLock(_ file.Resolver, _ *generic.Environment, reader file.Locatio
}

for _, pack := range lockFile.Packages {
if pack.Completed.Hackage == "" {
continue
}
pkgName, pkgVersion, pkgHash := parseStackPackageEncoding(pack.Completed.Hackage)
pkgs = append(
pkgs,
Expand All @@ -80,13 +83,20 @@ func parseStackLock(_ file.Resolver, _ *generic.Environment, reader file.Locatio

return pkgs, nil, nil
}

func parseStackPackageEncoding(pkgEncoding string) (name, version, hash string) {
lastDashIdx := strings.LastIndex(pkgEncoding, "-")
if lastDashIdx == -1 {
name = pkgEncoding
return
}
name = pkgEncoding[:lastDashIdx]
remainingEncoding := pkgEncoding[lastDashIdx+1:]
encodingSplits := strings.Split(remainingEncoding, "@")
version = encodingSplits[0]
startHash, endHash := strings.Index(encodingSplits[1], ":")+1, strings.Index(encodingSplits[1], ",")
hash = encodingSplits[1][startHash:endHash]
if len(encodingSplits) > 1 {
startHash, endHash := strings.Index(encodingSplits[1], ":")+1, strings.Index(encodingSplits[1], ",")
hash = encodingSplits[1][startHash:endHash]
}
return
}
13 changes: 13 additions & 0 deletions syft/pkg/cataloger/haskell/test-fixtures/stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ packages:
sha256: 557c438345de19f82bf01d676100da2a191ef06f624e7a4b90b09ac17cbb52a5
original:
hackage: ptr-0.16.8.2@sha256:708ebb95117f2872d2c5a554eb6804cf1126e86abe793b2673f913f14e5eb1ac,3959
- completed:
commit: a5847301404583e16d55cd4d051b8e605d704fbc
git: https://github.com/runtimeverification/haskell-backend.git
name: kore
pantry-tree:
sha256: 30a502eda589be5af735b1b59760ce3e0235c0cae8961978a46b3564dd8db32b
size: 44685
subdir: kore
version: 0.60.0.0
original:
commit: a5847301404583e16d55cd4d051b8e605d704fbc
git: https://github.com/runtimeverification/haskell-backend.git
subdir: kore
snapshots:
- completed:
size: 618951
Expand Down
Loading