mirror of
https://github.com/strongdm/comply
synced 2025-12-16 19:24:01 +00:00
Compare commits
5 Commits
v1.2.6
...
feature/wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e60d7285f4 | ||
|
|
c99d800397 | ||
|
|
0f1badca5b | ||
|
|
00b59ed620 | ||
|
|
749017761d |
@@ -1,4 +1,6 @@
|
|||||||
# Authors in alphabetical order:
|
# Authors in alphabetical order:
|
||||||
|
|
||||||
|
Anthony Oliver
|
||||||
|
Justin Bodeutsch
|
||||||
Justin McCarthy <justin@strongdm.com>
|
Justin McCarthy <justin@strongdm.com>
|
||||||
Manisha Singh <manisha@strongdm.com>
|
Manisha Singh
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -19,10 +19,12 @@ dist: clean
|
|||||||
$(eval LDFLAGS := -ldflags='-X "github.com/strongdm/comply/internal/cli.Version=$(VERSION)"')
|
$(eval LDFLAGS := -ldflags='-X "github.com/strongdm/comply/internal/cli.Version=$(VERSION)"')
|
||||||
mkdir dist
|
mkdir dist
|
||||||
echo $(VERSION)
|
echo $(VERSION)
|
||||||
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -gcflags=-trimpath=$(GOPATH) -asmflags=-trimpath=$(GOPATH) $(LDFLAGS) -o dist/comply-$(VERSION)-darwin-amd64 .
|
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -gcflags=-trimpath=$(GOPATH) -asmflags=-trimpath=$(GOPATH) -ldflags '-extldflags "-static"' $(LDFLAGS) -o dist/comply-$(VERSION)-darwin-amd64 .
|
||||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags=-trimpath=$(GOPATH) -asmflags=-trimpath=$(GOPATH) $(LDFLAGS) -o dist/comply-$(VERSION)-linux-amd64 .
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags=-trimpath=$(GOPATH) -asmflags=-trimpath=$(GOPATH) -ldflags '-extldflags "-static"' $(LDFLAGS) -o dist/comply-$(VERSION)-linux-amd64 .
|
||||||
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -gcflags=-trimpath=$(GOPATH) -asmflags=-trimpath=$(GOPATH) -ldflags '-extldflags "-static"' $(LDFLAGS) -o dist/comply-$(VERSION)-windows-amd64.exe .
|
||||||
cd dist && tar -czvf comply-$(VERSION)-darwin-amd64.tgz comply-$(VERSION)-darwin-amd64
|
cd dist && tar -czvf comply-$(VERSION)-darwin-amd64.tgz comply-$(VERSION)-darwin-amd64
|
||||||
cd dist && tar -czvf comply-$(VERSION)-linux-amd64.tgz comply-$(VERSION)-linux-amd64
|
cd dist && tar -czvf comply-$(VERSION)-linux-amd64.tgz comply-$(VERSION)-linux-amd64
|
||||||
|
cd dist && zip comply-$(VERSION)-windows-amd64.zip comply-$(VERSION)-windows-amd64.exe
|
||||||
|
|
||||||
brew: clean $(GO_SOURCES)
|
brew: clean $(GO_SOURCES)
|
||||||
$(eval VERSION := $(shell cat version))
|
$(eval VERSION := $(shell cat version))
|
||||||
|
|||||||
@@ -133,14 +133,32 @@ func notifyVersion(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pandocMustExist(c *cli.Context) error {
|
func pandocMustExist(c *cli.Context) error {
|
||||||
eitherMustExistErr := fmt.Errorf("Please install either Docker or the pandoc package and re-run `%s`", c.Command.Name)
|
eitherMustExistErr := fmt.Errorf("\n\nPlease install either Docker or the pandoc package and re-run `%s`. Find OS-specific pandoc installation instructions at: [TODO]", c.Command.Name)
|
||||||
|
|
||||||
pandocExistErr := pandocBinaryMustExist(c)
|
pandocExistErr, found, goodVersion, pdfLatex := pandocBinaryMustExist(c)
|
||||||
dockerExistErr := dockerMustExist(c)
|
dockerExistErr, inPath, isRunning := dockerMustExist(c)
|
||||||
|
|
||||||
config.SetPandoc(pandocExistErr == nil, dockerExistErr == nil)
|
config.SetPandoc(pandocExistErr == nil, dockerExistErr == nil)
|
||||||
|
check := func(b bool) string {
|
||||||
|
if b {
|
||||||
|
return "✔"
|
||||||
|
} else {
|
||||||
|
return "✖"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if pandocExistErr != nil && dockerExistErr != nil {
|
if pandocExistErr != nil && dockerExistErr != nil {
|
||||||
|
|
||||||
|
fmt.Printf(`
|
||||||
|
[%s] pandoc binary installed and in PATH
|
||||||
|
[%s] pandoc version compatible
|
||||||
|
[%s] pdflatex binary installed and in PATH
|
||||||
|
[%s] docker binary installed
|
||||||
|
[%s] docker running
|
||||||
|
|
||||||
|
`, check(found), check(goodVersion), check(pdfLatex), check(inPath), check(isRunning))
|
||||||
|
|
||||||
return eitherMustExistErr
|
return eitherMustExistErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,67 +170,89 @@ func pandocMustExist(c *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pandocBinaryMustExist(c *cli.Context) error {
|
func pandocBinaryMustExist(c *cli.Context) (e error, found, goodVersion, pdfLatex bool) {
|
||||||
cmd := exec.Command("pandoc", "-v")
|
cmd := exec.Command("pandoc", "-v")
|
||||||
outputRaw, err := cmd.Output()
|
outputRaw, err := cmd.Output()
|
||||||
|
|
||||||
|
e = nil
|
||||||
|
found = false
|
||||||
|
goodVersion = false
|
||||||
|
pdfLatex = false
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error calling pandoc")
|
e = errors.Wrap(err, "error calling pandoc")
|
||||||
}
|
} else {
|
||||||
|
found = true
|
||||||
output := strings.TrimSpace((string(outputRaw)))
|
goodVersion = true
|
||||||
versionErr := errors.New("cannot determine pandoc version")
|
output := strings.TrimSpace((string(outputRaw)))
|
||||||
if !strings.HasPrefix(output, "pandoc") {
|
versionErr := errors.New("cannot determine pandoc version")
|
||||||
return versionErr
|
if !strings.HasPrefix(output, "pandoc") {
|
||||||
}
|
e = versionErr
|
||||||
|
goodVersion = false
|
||||||
re := regexp.MustCompile(`pandoc (\d+)\.(\d+)`)
|
} else {
|
||||||
result := re.FindStringSubmatch(output)
|
re := regexp.MustCompile(`pandoc (\d+)\.(\d+)`)
|
||||||
if len(result) != 3 {
|
result := re.FindStringSubmatch(output)
|
||||||
return versionErr
|
if len(result) != 3 {
|
||||||
}
|
e = versionErr
|
||||||
|
goodVersion = false
|
||||||
major, err := strconv.Atoi(result[1])
|
} else {
|
||||||
if err != nil {
|
major, err := strconv.Atoi(result[1])
|
||||||
return versionErr
|
if err != nil {
|
||||||
}
|
e = versionErr
|
||||||
minor, err := strconv.Atoi(result[2])
|
goodVersion = false
|
||||||
if err != nil {
|
}
|
||||||
return versionErr
|
minor, err := strconv.Atoi(result[2])
|
||||||
}
|
if err != nil {
|
||||||
|
e = versionErr
|
||||||
if major < 2 || minor < 1 {
|
goodVersion = false
|
||||||
return errors.New("pandoc 2.1 or greater required")
|
}
|
||||||
|
if major < 2 || minor < 1 {
|
||||||
|
e = errors.New("pandoc 2.1 or greater required")
|
||||||
|
goodVersion = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pdflatex must also be present
|
// pdflatex must also be present
|
||||||
cmd = exec.Command("pdflatex", "-v")
|
cmd = exec.Command("pdflatex", "--version")
|
||||||
outputRaw, err = cmd.Output()
|
outputRaw, err = cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error calling pdflatex")
|
e = errors.Wrap(err, "error calling pdflatex")
|
||||||
|
} else if !strings.Contains(string(outputRaw), "TeX") {
|
||||||
|
e = errors.New("pdflatex is required")
|
||||||
|
} else {
|
||||||
|
pdfLatex = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(string(outputRaw), "TeX") {
|
return e, found, goodVersion, pdfLatex
|
||||||
return errors.New("pdflatex is required")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dockerMustExist(c *cli.Context) error {
|
func dockerMustExist(c *cli.Context) (e error, inPath, isRunning bool) {
|
||||||
dockerErr := fmt.Errorf("Docker must be available in order to run `%s`", c.Command.Name)
|
dockerErr := fmt.Errorf("Docker must be available in order to run `%s`", c.Command.Name)
|
||||||
|
|
||||||
|
inPath = true
|
||||||
|
cmd := exec.Command("docker", "--version")
|
||||||
|
_, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
inPath = false
|
||||||
|
}
|
||||||
|
|
||||||
|
isRunning = true
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
cli, err := client.NewEnvClient()
|
cli, err := client.NewEnvClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dockerErr
|
isRunning = false
|
||||||
|
return dockerErr, inPath, isRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = cli.Ping(ctx)
|
_, err = cli.Ping(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dockerErr
|
isRunning = false
|
||||||
|
return dockerErr, inPath, isRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil, inPath, isRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
func dockerPull(c *cli.Context) error {
|
func dockerPull(c *cli.Context) error {
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ func (g *githubPlugin) Configured() bool {
|
|||||||
|
|
||||||
func (g *githubPlugin) Links() model.TicketLinks {
|
func (g *githubPlugin) Links() model.TicketLinks {
|
||||||
links := model.TicketLinks{}
|
links := model.TicketLinks{}
|
||||||
links.AuditAll = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%3Aissue+is%3Aopen+label%3Acomply+label%3Aaudit", g.username, g.reponame)
|
links.AuditAll = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%%3Aissue+is%%3Aopen+label%%3Acomply+label%%3Aaudit", g.username, g.reponame)
|
||||||
links.AuditOpen = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%3Aissue+is%3Aopen+label%3Acomply+label%3Aaudit", g.username, g.reponame)
|
links.AuditOpen = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%%3Aissue+is%%3Aopen+label%%3Acomply+label%%3Aaudit", g.username, g.reponame)
|
||||||
links.ProcedureAll = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%3Aissue+label%3Acomply+label%3Aprocedure", g.username, g.reponame)
|
links.ProcedureAll = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%%3Aissue+label%%3Acomply+label%%3Aprocedure", g.username, g.reponame)
|
||||||
links.ProcedureOpen = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%3Aissue+is%3Aopen+label%3Acomply+label%3Aprocedure", g.username, g.reponame)
|
links.ProcedureOpen = fmt.Sprintf("https://github.com/%s/%s/issues?q=is%%3Aissue+is%%3Aopen+label%%3Acomply+label%%3Aprocedure", g.username, g.reponame)
|
||||||
return links
|
return links
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func html(output string, live bool, errCh chan error, wg *sync.WaitGroup) {
|
|||||||
if live {
|
if live {
|
||||||
if !opened {
|
if !opened {
|
||||||
opened = true
|
opened = true
|
||||||
open.Run("output/index.html")
|
open.Run(filepath.Join(".", "output", "index.html"))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
|||||||
Reference in New Issue
Block a user