Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update version of Docker base image #54

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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