Skip to content

Commit

Permalink
ek package updated to v9 + added templates for github
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed May 25, 2017
1 parent ca40839 commit 71b67ae
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 73 deletions.
21 changes: 21 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing Guidelines

Contributing guidelines for open-source EK projects.

**IMPORTANT! Contribute your code only if you have an excellent understanding of project idea and all existing code base. Otherwise, a nicely formatted issue will be more helpful to us.**

### Issues

1. Provide product version where the problem was found;
2. Provide info about your environment;
3. Provide detailed info about your problem;
4. Provide steps to reproduce the problem;
5. Provide actual and expected results.

### Code

1. Check your code **before** creating pull request;
2. If tests are present in a project, add tests for your code;
3. Add inline documentation for your code;
4. Apply code style used throughout the project;
5. Create your pull request to `develop` branch (_pull requests to other branches are not allowed_).
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ 👍 _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._

### Bug report

**System info:**

* **Version used (`sslcli -v`):**
* **OS (`cat /etc/*-release`):**
* **Kernel (`uname -a`):**
* **Install tools:**

**System info:**

1. [First Step]
2. [Second Step]
3. [and so on...]

**Expected behavior:**

[What you expected to happen]

**Actual behavior:**

[What actually happened]

**Additional info:**

[Include gist of relevant config, logs, etc.]

Please run those if possible and link them from a [gist](http://gist.github.com).

---

### Feature Request

Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them.

**Proposal:**

[Description of the feature]

**Current behavior:**

[What currently happens]

**Desired behavior:**

[What you would like to happen]

**Use case:**

[Why is this important (helps with prioritizing requests)]

24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### What did you implement:

Closes #XXXXX

### How did you implement it:

...

### How can we verify it:

...

### TODO's:

- [ ] Write tests
- [ ] Write documentation
- [ ] Check that there aren't other open pull requests for the same issue/feature
- [ ] Format your source code by `make fmt`
- [ ] Provide verification config / commands
- [ ] Enable "Allow edits from maintainers" for this PR
- [ ] Update the messages below

**Is this ready for review?:** No
**Is it a breaking change?:** No
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
########################################################################################

# This Makefile generated by GoMakeGen 0.5.0 using next command:
# This Makefile generated by GoMakeGen 0.6.0 using next command:
# gomakegen .

########################################################################################
Expand All @@ -16,8 +16,8 @@ sslcli:

deps:
git config --global http.https://pkg.re.followRedirects true
go get -d -v pkg.re/essentialkaos/ek.v8
go get -d -v pkg.re/essentialkaos/sslscan.v6
go get -d -v pkg.re/essentialkaos/ek.v9
go get -d -v pkg.re/essentialkaos/sslscan.v7

fmt:
find . -name "*.go" -exec gofmt -s -w {} \;
Expand Down
128 changes: 64 additions & 64 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ import (
"strings"
"time"

"pkg.re/essentialkaos/ek.v8/arg"
"pkg.re/essentialkaos/ek.v8/fmtc"
"pkg.re/essentialkaos/ek.v8/fmtutil"
"pkg.re/essentialkaos/ek.v8/fsutil"
"pkg.re/essentialkaos/ek.v8/usage"
"pkg.re/essentialkaos/ek.v8/usage/update"

"pkg.re/essentialkaos/sslscan.v6"
"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/usage"
"pkg.re/essentialkaos/ek.v9/usage/update"

"pkg.re/essentialkaos/sslscan.v7"
)

// ////////////////////////////////////////////////////////////////////////////////// //

const (
APP = "SSLScan Client"
VER = "1.5.0"
VER = "1.6.0"
DESC = "Command-line client for the SSL Labs API"
)

const (
ARG_FORMAT = "f:format"
ARG_DETAILED = "d:detailed"
ARG_IGNORE_MISMATCH = "i:ignore-mismatch"
ARG_AVOID_CACHE = "c:avoid-cache"
ARG_PUBLIC = "p:public"
ARG_PERFECT = "P:perfect"
ARG_QUIET = "q:quiet"
ARG_NOTIFY = "n:notify"
ARG_NO_COLOR = "nc:no-color"
ARG_HELP = "h:help"
ARG_VER = "v:version"
OPT_FORMAT = "f:format"
OPT_DETAILED = "d:detailed"
OPT_IGNORE_MISMATCH = "i:ignore-mismatch"
OPT_AVOID_CACHE = "c:avoid-cache"
OPT_PUBLIC = "p:public"
OPT_PERFECT = "P:perfect"
OPT_QUIET = "q:quiet"
OPT_NOTIFY = "n:notify"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "h:help"
OPT_VER = "v:version"
)

const (
Expand Down Expand Up @@ -73,18 +73,18 @@ type EndpointCheckInfo struct {

// ////////////////////////////////////////////////////////////////////////////////// //

var argMap = arg.Map{
ARG_FORMAT: &arg.V{},
ARG_DETAILED: &arg.V{Type: arg.BOOL},
ARG_IGNORE_MISMATCH: &arg.V{Type: arg.BOOL},
ARG_AVOID_CACHE: &arg.V{Type: arg.BOOL},
ARG_PUBLIC: &arg.V{Type: arg.BOOL},
ARG_PERFECT: &arg.V{Type: arg.BOOL},
ARG_QUIET: &arg.V{Type: arg.BOOL},
ARG_NOTIFY: &arg.V{Type: arg.BOOL},
ARG_NO_COLOR: &arg.V{Type: arg.BOOL},
ARG_HELP: &arg.V{Type: arg.BOOL, Alias: "u:usage"},
ARG_VER: &arg.V{Type: arg.BOOL, Alias: "ver"},
var optMap = options.Map{
OPT_FORMAT: {},
OPT_DETAILED: {Type: options.BOOL},
OPT_IGNORE_MISMATCH: {Type: options.BOOL},
OPT_AVOID_CACHE: {Type: options.BOOL},
OPT_PUBLIC: {Type: options.BOOL},
OPT_PERFECT: {Type: options.BOOL},
OPT_QUIET: {Type: options.BOOL},
OPT_NOTIFY: {Type: options.BOOL},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
}

var gradeNumMap = map[string]float64{
Expand All @@ -107,7 +107,7 @@ var api *sslscan.API

// Init starts initialization rutine
func Init() {
args, errs := arg.Parse(argMap)
args, errs := options.Parse(optMap)

if len(errs) != 0 {
fmtc.Println("{r}Arguments parsing errors:{!}")
Expand All @@ -119,16 +119,16 @@ func Init() {
os.Exit(1)
}

if arg.GetB(ARG_NO_COLOR) {
if options.GetB(OPT_NO_COLOR) {
fmtc.DisableColors = true
}

if arg.GetB(ARG_VER) {
if options.GetB(OPT_VER) {
showAbout()
return
}

if arg.GetB(ARG_HELP) || len(args) == 0 {
if options.GetB(OPT_HELP) || len(args) == 0 {
showUsage()
return
}
Expand All @@ -149,7 +149,7 @@ func process(args []string) {
api, err = sslscan.NewAPI("SSLCli", VER)

if err != nil {
if !arg.GetB(ARG_FORMAT) {
if !options.GetB(OPT_FORMAT) {
fmtc.Printf("{r}%v{!}\n", err)
}

Expand All @@ -163,7 +163,7 @@ func process(args []string) {
if fsutil.CheckPerms("FR", hosts[0]) {
hosts, err = readHostList(hosts[0])

if err != nil && arg.GetB(ARG_FORMAT) {
if err != nil && options.GetB(OPT_FORMAT) {
fmtc.Printf("{r}%v{!}\n", err)
os.Exit(1)
}
Expand All @@ -178,25 +178,25 @@ func process(args []string) {
for _, host := range hosts {

switch {
case arg.GetB(ARG_QUIET):
case options.GetB(OPT_QUIET):
grade, _ = quietCheck(host)
case arg.GetB(ARG_FORMAT):
case options.GetB(OPT_FORMAT):
grade, checkInfo = quietCheck(host)
checksInfo = append(checksInfo, checkInfo)
default:
grade = check(host)
}

switch {
case arg.GetB(ARG_PERFECT) && grade != "A+":
case options.GetB(OPT_PERFECT) && grade != "A+":
ok = false
case grade[:1] != "A":
ok = false
}
}

if arg.GetB(ARG_FORMAT) {
switch arg.GetS(ARG_FORMAT) {
if options.GetB(OPT_FORMAT) {
switch options.GetS(OPT_FORMAT) {
case FORMAT_TEXT:
encodeAsText(checksInfo)
case FORMAT_JSON:
Expand All @@ -210,7 +210,7 @@ func process(args []string) {
}
}

if arg.GetB(ARG_NOTIFY) {
if options.GetB(OPT_NOTIFY) {
fmtc.Bell()
}

Expand All @@ -227,10 +227,10 @@ func check(host string) string {
showServerMessage()

params := sslscan.AnalyzeParams{
Public: arg.GetB(ARG_PUBLIC),
StartNew: arg.GetB(ARG_AVOID_CACHE),
FromCache: !arg.GetB(ARG_AVOID_CACHE),
IgnoreMismatch: arg.GetB(ARG_IGNORE_MISMATCH),
Public: options.GetB(OPT_PUBLIC),
StartNew: options.GetB(OPT_AVOID_CACHE),
FromCache: !options.GetB(OPT_AVOID_CACHE),
IgnoreMismatch: options.GetB(OPT_IGNORE_MISMATCH),
}

fmtc.Printf("{*}%s{!} → ", host)
Expand Down Expand Up @@ -280,7 +280,7 @@ func check(host string) string {
t.Println(getColoredGrades(info.Endpoints))
}

if arg.GetB(ARG_DETAILED) {
if options.GetB(OPT_DETAILED) {
printDetailedInfo(ap, info)
}

Expand Down Expand Up @@ -319,10 +319,10 @@ func quietCheck(host string) (string, *HostCheckInfo) {
}

params := sslscan.AnalyzeParams{
Public: arg.GetB(ARG_PUBLIC),
StartNew: arg.GetB(ARG_AVOID_CACHE),
FromCache: !arg.GetB(ARG_AVOID_CACHE),
IgnoreMismatch: arg.GetB(ARG_IGNORE_MISMATCH),
Public: options.GetB(OPT_PUBLIC),
StartNew: options.GetB(OPT_AVOID_CACHE),
FromCache: !options.GetB(OPT_AVOID_CACHE),
IgnoreMismatch: options.GetB(OPT_IGNORE_MISMATCH),
}

ap, err := api.Analyze(host, params)
Expand Down Expand Up @@ -495,17 +495,17 @@ func getNormGrade(grade string) string {
func showUsage() {
info := usage.NewInfo("", "host...")

info.AddOption(ARG_FORMAT, "Output result in different formats", "text|json|yaml|xml")
info.AddOption(ARG_DETAILED, "Show detailed info for each endpoint")
info.AddOption(ARG_IGNORE_MISMATCH, "Proceed with assessments on certificate mismatch")
info.AddOption(ARG_AVOID_CACHE, "Disable cache usage")
info.AddOption(ARG_PUBLIC, "Publish results on sslscan.com")
info.AddOption(ARG_PERFECT, "Return non-zero exit code if not A+")
info.AddOption(ARG_NOTIFY, "Notify when check is done")
info.AddOption(ARG_QUIET, "Don't show any output")
info.AddOption(ARG_NO_COLOR, "Disable colors in output")
info.AddOption(ARG_HELP, "Show this help message")
info.AddOption(ARG_VER, "Show version")
info.AddOption(OPT_FORMAT, "Output result in different formats", "text|json|yaml|xml")
info.AddOption(OPT_DETAILED, "Show detailed info for each endpoint")
info.AddOption(OPT_IGNORE_MISMATCH, "Proceed with assessments on certificate mismatch")
info.AddOption(OPT_AVOID_CACHE, "Disable cache usage")
info.AddOption(OPT_PUBLIC, "Publish results on sslscan.com")
info.AddOption(OPT_PERFECT, "Return non-zero exit code if not A+")
info.AddOption(OPT_NOTIFY, "Notify when check is done")
info.AddOption(OPT_QUIET, "Don't show any output")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
info.AddOption(OPT_VER, "Show version")

info.AddExample("google.com", "Check google.com")
info.AddExample("-P google.com", "Check google.com and return zero exit code only if result is perfect (A+)")
Expand Down
8 changes: 4 additions & 4 deletions cli/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"strings"
"time"

"pkg.re/essentialkaos/ek.v8/fmtc"
"pkg.re/essentialkaos/ek.v8/fmtutil"
"pkg.re/essentialkaos/ek.v8/timeutil"
"pkg.re/essentialkaos/ek.v9/fmtc"
"pkg.re/essentialkaos/ek.v9/fmtutil"
"pkg.re/essentialkaos/ek.v9/timeutil"

"pkg.re/essentialkaos/sslscan.v6"
"pkg.re/essentialkaos/sslscan.v7"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
Loading

0 comments on commit 71b67ae

Please sign in to comment.