Skip to content

Commit

Permalink
Merge pull request #54 from owenrumney/owenr-some-house-keeping
Browse files Browse the repository at this point in the history
chore: Update version of Docker base image
  • Loading branch information
owenrumney committed Mar 24, 2022
2 parents e4ebc75 + cc1d11a commit 9e2cf3e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine
FROM alpine:3.15.2

# use a non-privileged user
USER nobody
Expand Down
8 changes: 6 additions & 2 deletions internal/app/squealer/scan/directory_scanner.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package scan

import (
"github.com/owenrumney/squealer/internal/app/squealer/match"
"github.com/owenrumney/squealer/internal/app/squealer/mertics"
"io/ioutil"
"os"
"path/filepath"

"github.com/owenrumney/squealer/internal/app/squealer/match"
"github.com/owenrumney/squealer/internal/app/squealer/mertics"
)

type directoryScanner struct {
Expand Down Expand Up @@ -38,6 +39,9 @@ func newDirectoryScanner(sc ScannerConfig) (*directoryScanner, error) {

func (d directoryScanner) Scan() ([]match.Transgression, error) {
return nil, filepath.Walk(d.workingDirectory, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() || shouldIgnore(path, d.ignorePaths, d.ignoreExtensions) {
return nil
}
Expand Down
15 changes: 7 additions & 8 deletions internal/app/squealer/scan/git_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"

"github.com/owenrumney/squealer/internal/app/squealer/match"
Expand Down Expand Up @@ -76,10 +75,10 @@ func (s *gitScanner) Scan() ([]match.Transgression, error) {
var useCommitShaList = false

if s.commitListFile != "" {
logrus.Debug("limiting the commit list check")
log.Debug("limiting the commit list check")
s.commitShas, _ = s.processSpecificCommits()
useCommitShaList = len(s.commitShas) > 0
logrus.Debugf("commit limited to %d commits", len(s.commitShas))
log.Debugf("commit limited to %d commits", len(s.commitShas))
}

commits, err := s.getRelevantCommitIter(client)
Expand Down Expand Up @@ -132,7 +131,7 @@ func (s *gitScanner) Scan() ([]match.Transgression, error) {
s.metrics.IncrementCommitsProcessed()
}
if err != nil && err != io.EOF {
logrus.WithError(err).Error("error was not null or an EOF")
log.WithError(err).Error("error was not null or an EOF")
}

close(ch)
Expand Down Expand Up @@ -262,7 +261,7 @@ func (s *gitScanner) getRelevantCommitIter(client *git.Repository) (object.Commi
var err error

if headRef != plumbing.ZeroHash {
logrus.Infof("starting at hash %s", headRef.String())
log.Infof("starting at hash %s", headRef.String())
commits, err = client.Log(&git.LogOptions{
From: headRef,
All: false,
Expand All @@ -272,7 +271,7 @@ func (s *gitScanner) getRelevantCommitIter(client *git.Repository) (object.Commi
return nil, err
}
} else {
logrus.Info("No head was found, scanning all commits")
log.Info("No head was found, scanning all commits")
commits, err = client.CommitObjects()
if err != nil {
return nil, err
Expand All @@ -299,14 +298,14 @@ func (s *gitScanner) processSpecificCommits() (map[string]bool, error) {
var commitShas = make(map[string]bool)
for r.Scan() {
c := r.Text()
logrus.Debugf("adding commit limit to %s", c)
log.Debugf("adding commit limit to %s", c)
commitShas[c] = true
}
return commitShas, nil
}

func (s *gitScanner) isNotValidCommit(commitSha string) bool {
logrus.Tracef("Checking validity of commit %s", commitSha)
log.Tracef("Checking validity of commit %s", commitSha)
_, ok := s.commitShas[commitSha]
return !ok
}
3 changes: 2 additions & 1 deletion internal/app/squealer/scan/signals_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux || bsd || darwin
// +build linux bsd darwin

package scan
Expand All @@ -14,7 +15,7 @@ func (s *gitScanner) monitorSignals(processes int, wg sync.WaitGroup) {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGTSTP)
go func() {
for _ = range c {
for range c {
log.Info("Shutting down workers and exiting...")
for i := 0; i < processes; i++ {
wg.Done()
Expand Down
3 changes: 2 additions & 1 deletion internal/app/squealer/scan/signals_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package scan
Expand All @@ -14,7 +15,7 @@ func (s *gitScanner) monitorSignals(processes int, wg sync.WaitGroup) {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
for _ = range c {
for range c {
log.Info("Shutting down workers and exiting...")
for i := 0; i < processes; i++ {
wg.Done()
Expand Down

0 comments on commit 9e2cf3e

Please sign in to comment.