Skip to content

Commit cfdc063

Browse files
committed
lint updates
1 parent c9a0456 commit cfdc063

9 files changed

Lines changed: 19 additions & 21 deletions

File tree

certgraph.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import (
2525
"github.com/lanrat/certgraph/web"
2626
)
2727

28-
// version vars
2928
var (
30-
gitDate = "none"
31-
gitHash = "master"
29+
version = "dev"
3230
certGraph = graph.NewCertGraph()
3331
)
3432

@@ -101,7 +99,7 @@ func main() {
10199

102100
// check for version flag
103101
if config.printVersion {
104-
fmt.Println(version())
102+
fmt.Println(showVersion())
105103
return
106104
}
107105

@@ -411,15 +409,15 @@ func visit(domainNode *graph.DomainNode) {
411409

412410
func printNode(domainNode *graph.DomainNode) {
413411
if config.details {
414-
fmt.Fprintln(os.Stdout, domainNode)
412+
_, _ = fmt.Fprintln(os.Stdout, domainNode)
415413
} else {
416-
fmt.Fprintln(os.Stdout, domainNode.Domain)
414+
_, _ = fmt.Fprintln(os.Stdout, domainNode.Domain)
417415
}
418416
if config.checkDNS && !domainNode.HasDNS {
419417
// TODO print this in a better way
420418
// TODO for debugging
421419
realDomain, _ := dns.ApexDomain(domainNode.Domain)
422-
fmt.Fprintf(os.Stdout, "* Missing DNS for: %s\n", realDomain)
420+
_, _ = fmt.Fprintf(os.Stdout, "* Missing DNS for: %s\n", realDomain)
423421

424422
}
425423
}
@@ -437,7 +435,7 @@ func certNodeFromCertResult(certResult *driver.CertResult) *graph.CertNode {
437435
// TODO map all config json
438436
func generateGraphMetadata() map[string]interface{} {
439437
data := make(map[string]interface{})
440-
data["version"] = version()
438+
data["version"] = version
441439
data["website"] = "https://lanrat.github.io/certgraph/"
442440
data["scan_date"] = time.Now().UTC()
443441
data["command"] = strings.Join(os.Args, " ")
@@ -455,8 +453,8 @@ func generateGraphMetadata() map[string]interface{} {
455453
}
456454

457455
// returns the version string
458-
func version() string {
459-
return fmt.Sprintf("Git commit: %s [%s]", gitDate, gitHash)
456+
func showVersion() string {
457+
return fmt.Sprintf("Version: %s", version)
460458
}
461459

462460
// cleanInput attempts to parse the input string as a url to extract the hostname

dns/publicsuffix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func UpdatePublicSuffixList(timeout time.Duration) error {
2828
if err != nil {
2929
return err
3030
}
31-
defer resp.Body.Close()
31+
defer func() { _ = resp.Body.Close() }()
3232
newSuffixList := publicsuffix.NewList()
3333
_, err = newSuffixList.Load(resp.Body, suffixListParseOptions)
3434
suffixList = newSuffixList

driver/censys/censys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (d *censys) jsonRequest(method, url string, request, response interface{})
161161
if err != nil {
162162
return err
163163
}
164-
defer resp.Body.Close()
164+
defer func() { _ = resp.Body.Close() }()
165165

166166
// got an error, decode it
167167
if resp.StatusCode != http.StatusOK {

driver/crtsh/crtsh.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// As the API is unofficial and has been reverse engineered it may stop working
66
// at any time and comes with no guarantees.
77
// view SQL excample: https://crt.sh/?showSQL=Y&exclude=expired&q=
8-
//
98
package crtsh
109

1110
import (

driver/http/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (d *httpDriver) QueryDomain(host string) (driver.Result, error) {
108108
if fullStatus != status.GOOD {
109109
return results, err // in some rare cases this error can be ignored
110110
}
111-
defer resp.Body.Close()
111+
defer func() { _ = resp.Body.Close() }()
112112

113113
// set final domain status
114114
results.status.Set(resp.Request.URL.Hostname(), status.New(status.GOOD))

driver/save.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func CertsToPEMFile(certs []*x509.Certificate, file string) error {
1515
if err != nil {
1616
return err
1717
}
18-
defer f.Close()
18+
defer func() { _ = f.Close() }()
1919
for _, cert := range certs {
2020
err = pem.Encode(f, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw})
2121
if err != nil {
@@ -34,7 +34,7 @@ func RawCertToPEMFile(cert []byte, file string) error {
3434
if err != nil {
3535
return err
3636
}
37-
defer f.Close()
37+
defer func() { _ = f.Close() }()
3838
err = pem.Encode(f, &pem.Block{Type: "CERTIFICATE", Bytes: cert})
3939
return err
4040
}

driver/smtp/smtp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (d *smtpDriver) smtpGetCerts(host string) ([]*x509.Certificate, error) {
8888
if err != nil {
8989
return certs, err
9090
}
91-
defer conn.Close()
91+
defer func() { _ = conn.Close() }()
9292
smtp, err := smtp.NewClient(conn, host)
9393
if err != nil {
9494
return certs, err

graph/graph.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func (graph *CertGraph) AddDomain(domainNode *DomainNode) {
4242
graph.domains.Store(domainNode.Domain, domainNode)
4343
}
4444

45-
//NumDomains returns the number of domains in the graph
45+
// NumDomains returns the number of domains in the graph
4646
func (graph *CertGraph) NumDomains() int {
4747
return graph.numDomains
4848
}
4949

50-
//DomainDepth returns the maximum depth of the graph from the initial root domains
50+
// DomainDepth returns the maximum depth of the graph from the initial root domains
5151
func (graph *CertGraph) DomainDepth() uint {
5252
return graph.depth
5353
}

status/status.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ func CheckNetErr(err error) DomainStatus {
100100
} else {
101101
switch t := err.(type) {
102102
case *net.OpError:
103-
if t.Op == "dial" {
103+
switch t.Op {
104+
case "dial":
104105
return NOHOST
105-
} else if t.Op == "read" {
106+
case "read":
106107
return REFUSED
107108
}
108109
case syscall.Errno:

0 commit comments

Comments
 (0)