diff --git a/.travis.yml b/.travis.yml index 313dc72..6e9a579 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ -sudo: false - language: go go: - - 1.8.x - - 1.9.x - 1.10.x + - 1.11.x + - 1.12.x - tip branches: diff --git a/Makefile b/Makefile index 749f03d..e2de3f1 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ ################################################################################ -# This Makefile generated by GoMakeGen 0.8.0 using next command: +# This Makefile generated by GoMakeGen 1.1.0 using next command: # gomakegen --race . +# +# More info: https://kaos.sh/gomakegen ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt all clean deps deps-test test help +.PHONY = fmt all clean git-config deps deps-test test gen-fuzz help ################################################################################ @@ -15,23 +17,28 @@ all: shdoc ## Build all binaries shdoc: ## Build shdoc binary go build shdoc.go -install: ## Install binaries +install: ## Install all binaries cp shdoc /usr/bin/shdoc -uninstall: ## Uninstall binaries +uninstall: ## Uninstall all binaries rm -f /usr/bin/shdoc -deps: ## Download dependencies +git-config: ## Configure git redirects for stable import path services git config --global http.https://pkg.re.followRedirects true - go get -d -v pkg.re/essentialkaos/ek.v9 -deps-test: ## Download dependencies for tests - git config --global http.https://pkg.re.followRedirects true +deps: git-config ## Download dependencies + go get -d -v pkg.re/essentialkaos/ek.v10 + +deps-test: git-config ## Download dependencies for tests go get -d -v pkg.re/check.v1 test: ## Run tests - go test -race ./... - go test -covermode=count ./... + go test -race ./parser + go test -covermode=count ./parser + +gen-fuzz: ## Generate archives for fuzz testing + which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build + go-fuzz-build -o parser-fuzz.zip github.com/essentialkaos/shdoc/parser fmt: ## Format source code with gofmt find . -name "*.go" -exec gofmt -s -w {} \; @@ -40,9 +47,10 @@ clean: ## Remove generated files rm -f shdoc help: ## Show this info - @echo -e '\nSupported targets:\n' + @echo -e '\n\033[1mSupported targets:\033[0m\n' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}' @echo -e '' + @echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 12a17d4..df7c79a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@

-

Usage DemoInstallationUsageTest & Coverage StatusContributingLicense

-

@@ -10,6 +8,10 @@

+

Usage DemoInstallationUsageTest & Coverage StatusContributingLicense

+ +
+ `shdoc` is a tool for viewing and exporting documentation for shell scripts. ### Usage Demo @@ -26,7 +28,7 @@ Before the initial install allows git to use redirects for [pkg.re](https://gith git config --global http.https://pkg.re.followRedirects true ``` -Make sure you have a working Go 1.8+ workspace ([instructions](https://golang.org/doc/install)), then: +Make sure you have a working Go 1.10+ workspace ([instructions](https://golang.org/doc/install)), then: ``` go get github.com/essentialkaos/shdoc diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..f42c71e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,36 @@ +# Security Policies and Procedures + +This document outlines security procedures and general policies for all +ESSENTIAL KAOS projects. + + * [Reporting a Bug](#reporting-a-bug) + * [Disclosure Policy](#disclosure-policy) + +## Reporting a Bug + +The ESSENTIAL KAOS team and community take all security bugs in our projects +very seriously. Thank you for improving the security of our project. We +appreciate your efforts and responsible disclosure and will make every effort +to acknowledge your contributions. + +Report security bugs by emailing our security team at security@essentialkaos.com. + +The security team will acknowledge your email within 48 hours and will send a +more detailed response within 48 hours, indicating the next steps in handling +your report. After the initial reply to your report, the security team will +endeavor to keep you informed of the progress towards a fix and full +announcement, and may ask for additional information or guidance. + +Report security bugs in third-party dependencies to the person or team +maintaining the dependencies. + +## Disclosure Policy + +When the security team receives a security bug report, they will assign it to a +primary handler. This person will coordinate the fix and release process, +involving the following steps: + + * Confirm the problem and determine the affected versions; + * Audit code to find any similar potential problems; + * Prepare fixes for all releases still under maintenance. These fixes will be + released as fast as possible. diff --git a/parser/fuzz.go b/parser/fuzz.go index 08348d6..f4fee7a 100644 --- a/parser/fuzz.go +++ b/parser/fuzz.go @@ -4,7 +4,7 @@ package parser // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2009-2018 ESSENTIAL KAOS // +// Copyright (c) 2009-2019 ESSENTIAL KAOS // // Essential Kaos Open Source License // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/parser/parser.go b/parser/parser.go index e56b03d..e4fa9cc 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,7 +2,7 @@ package parser // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2009-2018 ESSENTIAL KAOS // +// Copyright (c) 2009-2019 ESSENTIAL KAOS // // Essential Kaos Open Source License // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -16,10 +16,10 @@ import ( "regexp" "strings" - "pkg.re/essentialkaos/ek.v9/fsutil" - "pkg.re/essentialkaos/ek.v9/mathutil" - "pkg.re/essentialkaos/ek.v9/sliceutil" - "pkg.re/essentialkaos/ek.v9/strutil" + "pkg.re/essentialkaos/ek.v10/fsutil" + "pkg.re/essentialkaos/ek.v10/mathutil" + "pkg.re/essentialkaos/ek.v10/sliceutil" + "pkg.re/essentialkaos/ek.v10/strutil" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -76,7 +76,7 @@ type Variable struct { Line int `json:"line"` // LOC of definition } -// Document contians info about all constants, global variables and methods +// Document contains info about all constants, global variables and methods type Document struct { Title string `json:"title"` About []string `json:"about"` diff --git a/parser/parser_test.go b/parser/parser_test.go index 2526765..b510911 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -2,7 +2,7 @@ package parser // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2009-2018 ESSENTIAL KAOS // +// Copyright (c) 2009-2019 ESSENTIAL KAOS // // Essential Kaos Open Source License // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/shdoc.go b/shdoc.go index dccf72f..d5cf0b6 100644 --- a/shdoc.go +++ b/shdoc.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2009-2018 ESSENTIAL KAOS // +// Copyright (c) 2009-2019 ESSENTIAL KAOS // // Essential Kaos Open Source License // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -13,14 +13,13 @@ import ( "strings" "text/template" - "pkg.re/essentialkaos/ek.v9/env" - "pkg.re/essentialkaos/ek.v9/fmtc" - "pkg.re/essentialkaos/ek.v9/fmtutil" - "pkg.re/essentialkaos/ek.v9/fsutil" - "pkg.re/essentialkaos/ek.v9/options" - "pkg.re/essentialkaos/ek.v9/path" - "pkg.re/essentialkaos/ek.v9/usage" - "pkg.re/essentialkaos/ek.v9/usage/update" + "pkg.re/essentialkaos/ek.v10/fmtc" + "pkg.re/essentialkaos/ek.v10/fmtutil" + "pkg.re/essentialkaos/ek.v10/fsutil" + "pkg.re/essentialkaos/ek.v10/options" + "pkg.re/essentialkaos/ek.v10/path" + "pkg.re/essentialkaos/ek.v10/usage" + "pkg.re/essentialkaos/ek.v10/usage/update" . "github.com/essentialkaos/shdoc/parser" ) @@ -29,7 +28,7 @@ import ( const ( APP = "SHDoc" - VER = "0.5.0" + VER = "0.6.0" DESC = "Tool for viewing and exporting docs for shell scripts" ) @@ -55,6 +54,7 @@ var optMap = options.Map{ // ////////////////////////////////////////////////////////////////////////////////// // +// main is main function func main() { args, errs := options.Parse(optMap) @@ -94,7 +94,7 @@ func main() { // ////////////////////////////////////////////////////////////////////////////////// // -// process start source processing +// process starts source processing func process(file string, pattern string) { if !fsutil.IsExist(file) { printErrorAndExit("File %s does not exist", file) @@ -140,7 +140,7 @@ func process(file string, pattern string) { } } -// findInfo search geven pattern in entities names +// findInfo searches geven pattern in entities names func findInfo(doc *Document, pattern string) { fmtc.NewLine() @@ -172,7 +172,7 @@ func findInfo(doc *Document, pattern string) { } } -// simpleRender print all document info to console +// simpleRender prints all document info to console func simpleRender(doc *Document) { if doc.HasAbout() { fmtutil.Separator(false, "ABOUT") @@ -228,9 +228,9 @@ func simpleRender(doc *Document) { fmtutil.Separator(false) } -// renderTemplate read template and render to file +// renderTemplate reads template and render to file func renderTemplate(doc *Document) { - projectDir := env.Get().GetS("GOPATH") + projectDir := os.Getenv("GOPATH") templateFile := path.Join( projectDir, "src/github.com/essentialkaos/shdoc/templates", options.GetS(OPT_TEMPLATE)+".tpl", @@ -283,19 +283,19 @@ func renderTemplate(doc *Document) { fmtutil.Separator(false) } -// renderConstant print constant info to console +// renderConstant prints constant info to console func renderConstant(c *Variable) { fmtc.Printf("{s-}%4d:{!} {m*}%s{!} {s}={!} %s "+getVarTypeDesc(c.Type)+"\n", c.Line, c.Name, c.Value) fmtc.Printf(" %s\n", c.UnitedDesc()) } -// renderMethod print variable info to console +// renderMethod prints variable info to console func renderVariable(v *Variable) { fmtc.Printf("{s-}%4d:{!} {c*}%s{!} {s}={!} %s "+getVarTypeDesc(v.Type)+"\n", v.Line, v.Name, v.Value) fmtc.Printf(" %s\n", v.UnitedDesc()) } -// renderMethod print method info to console +// renderMethod prints method info to console func renderMethod(m *Method, showExamples bool) { fmtc.Printf("{s-}%4d:{!} {b*}%s{!} {s}-{!} %s\n", m.Line, m.Name, m.UnitedDesc()) @@ -335,7 +335,7 @@ func renderMethod(m *Method, showExamples bool) { } } -// getVarTypeDesc return type description +// getVarTypeDesc returns type description func getVarTypeDesc(t VariableType) string { switch t { case VAR_TYPE_STRING: @@ -359,7 +359,7 @@ func printWarn(f string, a ...interface{}) { fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) } -// printErrorAndExit print error mesage and exit with exit code 1 +// printErrorAndExit prints error mesage and exit with exit code 1 func printErrorAndExit(f string, a ...interface{}) { printError(f, a...) os.Exit(1) @@ -367,6 +367,7 @@ func printErrorAndExit(f string, a ...interface{}) { // ////////////////////////////////////////////////////////////////////////////////// // +// showUsage shows usage info func showUsage() { info := usage.NewInfo("", "file") @@ -395,6 +396,7 @@ func showUsage() { info.Render() } +// showAbout shows info about version func showAbout() { about := &usage.About{ App: APP,