fixing all golint and adding some more tests

This commit is contained in:
zach rice committed 2019-11-11 21:50:50 -05:00
1 parent 2ccd40677d
commit e446ba0738
19 files changed
+161 -91

No files matched your search

+14
View File
@@ -34,6 +34,8 @@ type Manager struct {
metadata Metadata
}
// Leak is a struct that contains information about some line of code that contains
// sensitive information as determined by the rules set in a gitleaks config
type Leak struct {
Line string `json:"line"`
Offender string `json:"offender"`
@@ -49,14 +51,24 @@ type Leak struct {
Severity string `json:"severity"`
}
// AuditTime is a type used to determine total audit time
type AuditTime int64
// PatchTime is a type used to determine total patch time during an audit
type PatchTime int64
// CloneTime is a type used to determine total clone time
type CloneTime int64
// RegexTime is a type used to determine the time each rules' regex takes. This is especially useful
// if you notice that gitleaks is taking a long time. You can use --debug to see the output of the regexTime
// so you can determine which regex is not performing well.
type RegexTime struct {
Time int64
Regex string
}
// Metadata is a struct used to communicate metadata about an audit like timings and total commit counts.
type Metadata struct {
mux sync.Mutex
data map[string]interface{}
@@ -110,6 +122,7 @@ func (manager *Manager) receiveLeaks() {
}
}
// GetMetadata returns the metadata. TODO this may not need to be private
func (manager *Manager) GetMetadata() Metadata {
return manager.metadata
}
@@ -132,6 +145,7 @@ func (manager *Manager) receiveMetadata() {
}
}
// IncrementCommits increments total commits during an audit by i.
func (manager *Manager) IncrementCommits(i int) {
manager.metadata.mux.Lock()
manager.metadata.Commits += i
+6 -7
View File
@@ -6,7 +6,6 @@ import (
"testing"
)
// TODO
// add more substantial tests... but since literally every pkg uses manager
// these tests are kind of redundant
@@ -73,17 +72,17 @@ func TestSendReceiveMeta(t *testing.T) {
})
}
md := m.GetMetadata()
if md.cloneTime != test.cloneTime * int64(test.iterations) {
if md.cloneTime != test.cloneTime*int64(test.iterations) {
t.Errorf("clone time mismatch, got %d, wanted %d",
md.cloneTime, test.cloneTime * int64(test.iterations))
md.cloneTime, test.cloneTime*int64(test.iterations))
}
if md.AuditTime != test.auditTime * int64(test.iterations) {
if md.AuditTime != test.auditTime*int64(test.iterations) {
t.Errorf("audit time mismatch, got %d, wanted %d",
md.AuditTime, test.auditTime * int64(test.iterations))
md.AuditTime, test.auditTime*int64(test.iterations))
}
if md.patchTime != test.patchTime * int64(test.iterations) {
if md.patchTime != test.patchTime*int64(test.iterations) {
t.Errorf("clone time mismatch, got %d, wanted %d",
md.patchTime, test.patchTime * int64(test.iterations))
md.patchTime, test.patchTime*int64(test.iterations))
}
}
}