Skip to content

Commit

Permalink
Merge pull request #51 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.20.3
  • Loading branch information
andyone authored Nov 1, 2018
2 parents ee53821 + e79b522 commit c9e3f9f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
// App props
const (
APP = "init-exporter"
VER = "0.20.2"
VER = "0.20.3"
DESC = "Utility for exporting services described by Procfile to init system"
)

Expand Down
5 changes: 4 additions & 1 deletion common/init-exporter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

Summary: Utility for exporting services described by Procfile to init system
Name: init-exporter
Version: 0.20.2
Version: 0.20.3
Release: 0%{?dist}
Group: Development/Tools
License: MIT
Expand Down Expand Up @@ -111,6 +111,9 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Mon Oct 29 2018 Anton Novojilov <[email protected]> - 0.20.3-0
- Fixed bug with parsing v1 procfile (found by go-fuzz)

* Wed Jul 25 2018 Anton Novojilov <[email protected]> - 0.20.2-0
- Fixed formatting error in help content

Expand Down
7 changes: 7 additions & 0 deletions procfile/procfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func (s *ProcfileSuite) TestProcV1Parsing(c *C) {
c.Assert(app.Validate(), HasLen, 0)
}

func (s *ProcfileSuite) TestProcV1Fuzz(c *C) {
// Bug #1 found by fuzz testing
_, err := parseV1Line("0:cd")

c.Assert(err, NotNil)
}

func (s *ProcfileSuite) TestProcV2Parsing(c *C) {
app, err := Read("../testdata/procfile_v2", s.Config)

Expand Down
10 changes: 7 additions & 3 deletions procfile/procfile_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,20 @@ func parseV1Line(line string) (*Service, error) {
return nil, fmt.Errorf("Procfile v1 should have format: 'some_label: command'")
}

return parseV1Command(matches[1], matches[2]), nil
return parseV1Command(matches[1], matches[2])
}

// parseV1Command parse command and extract command and working dir
func parseV1Command(name, command string) *Service {
func parseV1Command(name, command string) (*Service, error) {
var service = &Service{Name: name, Options: &ServiceOptions{}}

cmdSlice := splitV1Command(command)

if strings.HasPrefix(cmdSlice[0], "cd") {
if len(cmdSlice) == 1 {
return nil, fmt.Errorf("Procfile v1 command misformatted: %s", command)
}

service.Options.WorkingDir = strings.Replace(cmdSlice[0], "cd ", "", -1)
cmdSlice = cmdSlice[1:]
}
Expand Down Expand Up @@ -129,7 +133,7 @@ func parseV1Command(name, command string) *Service {
service.Options.Env = env
service.Options.LogFile = log

return service
return service, nil
}

// splitV1Cmd split command and format command
Expand Down

0 comments on commit c9e3f9f

Please sign in to comment.