Skip to content

Commit

Permalink
chore: general comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ecshreve committed Mar 4, 2022
1 parent 39ec80f commit 6b5881d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

// pillager is a tool for hunting through filesystems for sensitive information.
// Package pillager is a tool for hunting through filesystems for sensitive information.
//
// Installation
//
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/hunt.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package commands contains the command line logic
// Package commands contains the command line logic.
//
// The commands package is the primary consumer of all packages in the /pkg directory
// The commands package is the primary consumer of all packages in the /pkg directory.
package commands

import (
Expand Down
4 changes: 2 additions & 2 deletions internal/validate/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/afero"
)

// Path checks if a filepath exists and
// returns it if so, otherwise returns a default path.
// Path checks if a file at the given path exists and returns it if so,
// otherwise returns a default path.
func Path(fs afero.Fs, path string) string {
ok, err := afero.Exists(fs, path)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/format/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"gopkg.in/yaml.v2"
)

// Reporter is the interface that each of the canonical output formats implement.
type Reporter interface {
Report(io.Writer, []report.Finding) error
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/hunter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
"github.com/zricethezav/gitleaks/v8/config"
)

// Config takes all of the configurable
// parameters for a Hunter.
// Config takes all of the configurable parameters for a Hunter.
type Config struct {
Filesystem afero.Fs
Reporter format.Reporter
Expand All @@ -32,8 +31,10 @@ type Config struct {
Template string
}

// ConfigOption is a convenient type alias for func(*Config).
type ConfigOption func(*Config)

// NewConfig creates a Config instance.
func NewConfig(opts ...ConfigOption) *Config {
var (
defaultFS = afero.NewOsFs()
Expand Down
2 changes: 1 addition & 1 deletion pkg/hunter/docs.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Package hunter contains secret hunting and file scanning tools
// Package hunter contains secret hunting and file scanning tools.
package hunter
17 changes: 9 additions & 8 deletions pkg/rules/rules.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package rules enables the parsing of Gitleaks rulesets
// Package rules enables the parsing of Gitleaks rulesets.
package rules

import (
Expand All @@ -10,10 +10,11 @@ import (
"github.com/zricethezav/gitleaks/v8/config"
)

const (
ErrReadConfig = "Failed to read config"
)
// ErrReadConfig is the custom error message used if an error is encountered
// reading the gitleaks config.
const ErrReadConfig = "Failed to read gitleaks config"

// These strings contain default configs. They are initialized at compile time via go:embed.
var (
//go:embed rules_simple.toml
RulesDefault string
Expand All @@ -22,14 +23,15 @@ var (
RulesStrict string
)

// Loader represents a gitleaks config loader.
type Loader struct {
loader config.ViperConfig
}

// LoaderOption sets a parameter for the gitleaks config loader.
type LoaderOption func(*Loader)

// NewLoader creates a configuration
// loader.
// NewLoader creates a Loader instance.
func NewLoader(opts ...LoaderOption) *Loader {
var loader Loader
if _, err := toml.Decode(RulesDefault, &loader.loader); err != nil {
Expand Down Expand Up @@ -62,8 +64,7 @@ func (l *Loader) Load() config.Config {
return config
}

// FromFile decodes the configuration
// from a local file.
// FromFile decodes a gitleaks config from a local file.
func FromFile(file string) LoaderOption {
return func(l *Loader) {
if _, err := toml.DecodeFile(file, &l.loader); err != nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/templates/templates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package templates contains a compilation of go templates for rendering secret findings
// Package templates contains a compilation of go templates for rendering secret findings.
package templates

import (
Expand Down Expand Up @@ -29,8 +29,8 @@ var (
HTMLTable string
)

// DefaultTemplate is the base template used to
// format a Finding into the custom output format.
// DefaultTemplate is the base template used to format a Finding into the
// custom output format.
const DefaultTemplate = `{{ with . -}}
{{ range . -}}
Line: {{ quote .StartLine}}
Expand All @@ -39,8 +39,7 @@ Secret: {{ quote .Secret }}
---
{{ end -}}{{- end}}`

// Render renders a finding in a
// custom go template format to the provided writer.
// Render renders a finding in a custom go template format to the provided writer.
func Render(w io.Writer, tpl string, findings []report.Finding) error {
t := template.New("custom")
if tpl == "" {
Expand Down

0 comments on commit 6b5881d

Please sign in to comment.