Fix linter errors

This commit is contained in:
Patrick Pacher
2022-10-10 18:08:09 +02:00
committed by Daniel
parent 77c0d954a9
commit 0810eee7bb
3 changed files with 16 additions and 8 deletions

6
package-lock.json generated
View File

@@ -1,6 +0,0 @@
{
"name": "workspace",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

View File

@@ -68,6 +68,7 @@ type Process struct {
ExecHashes map[string]string
}
// GetTag returns the process tag with the given ID.
func (p *Process) GetTag(tagID string) (profile.Tag, bool) {
for _, t := range p.Tags {
if t.Key == tagID {
@@ -239,7 +240,7 @@ func loadProcess(ctx context.Context, pid int) (*Process, error) {
if runtime.GOOS != "windows" {
process.Cwd, err = pInfo.Cwd()
if err != nil {
log.Warningf("process: failed to get Cwd: %w", err)
log.Warningf("process: failed to get Cwd: %s", err)
}
}

View File

@@ -86,7 +86,9 @@ func fileMustBeUTF8(path string) bool {
return false
}
defer f.Close()
defer func() {
_ = f.Close()
}()
// read the first chunk of bytes
buf := new(bytes.Buffer)
@@ -108,12 +110,15 @@ func fileMustBeUTF8(path string) bool {
return true
}
// InterpHandler supports adding process tags based on well-known interpreter binaries.
type InterpHandler struct{}
// Name returns "Interpreter"
func (h *InterpHandler) Name() string {
return "Interpreter"
}
// TagDescriptions returns a set of tag descriptions that InterpHandler provides.
func (h *InterpHandler) TagDescriptions() []process.TagDescription {
l := make([]process.TagDescription, len(knownInterperters))
for idx, it := range knownInterperters {
@@ -123,6 +128,8 @@ func (h *InterpHandler) TagDescriptions() []process.TagDescription {
return l
}
// CreateProfile creates a new profile for any process that has a tag created
// by InterpHandler.
func (h *InterpHandler) CreateProfile(p *process.Process) *profile.Profile {
for _, it := range knownInterperters {
if tag, ok := p.GetTag(it.ID); ok {
@@ -159,6 +166,8 @@ func (h *InterpHandler) CreateProfile(p *process.Process) *profile.Profile {
return nil
}
// AddTags inspects the process p and adds any interpreter tags that InterpHandler
// detects.
func (h *InterpHandler) AddTags(p *process.Process) {
// check if we have a matching interpreter
var matched interpType
@@ -208,6 +217,8 @@ func (h *InterpHandler) AddTags(p *process.Process) {
Value: filePath,
})
p.MatchingPath = filePath
return
}
@@ -217,4 +228,6 @@ func (h *InterpHandler) AddTags(p *process.Process) {
Key: matched.ID,
Value: args[0],
})
p.MatchingPath = args[0]
}