Skip to content

Commit

Permalink
fix: remove cabal.project.freeze panic on last pkg (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
spiffcs committed Nov 23, 2022
1 parent bcfe38c commit b290a44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit b290a44

Please sign in to comment.