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

fix: remove cabal.project.freeze panic on last pkg #1363

Merged
merged 1 commit into from
Nov 23, 2022
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
8 changes: 8 additions & 0 deletions syft/pkg/cataloger/haskell/parse_cabal_freeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ func parseCabalFreeze(_ source.FileResolver, _ *generic.Environment, reader sour

line = strings.TrimSpace(line)
startPkgEncoding, endPkgEncoding := strings.Index(line, "any.")+4, strings.Index(line, ",")
// case where comma not found for last package in constraint list
if endPkgEncoding == -1 {
endPkgEncoding = len(line)
}
if startPkgEncoding >= endPkgEncoding || startPkgEncoding < 0 {
continue
}

line = line[startPkgEncoding:endPkgEncoding]
fields := strings.Split(line, " ==")

Expand Down
4 changes: 2 additions & 2 deletions syft/pkg/cataloger/haskell/test-fixtures/cabal.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ constraints: any.Cabal ==3.2.1.0,
any.RSA ==2.4.1,
any.SHA ==1.6.4.4,
void -safe,
any.Spock ==0.14.0.0,
any.Spock ==0.14.0.0

index-state: hackage.haskell.org 2022-07-07T01:01:53Z