Skip to content

Commit

Permalink
Do not log anymore failures to look up user/group name (spiffe#4906)
Browse files Browse the repository at this point in the history
Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
  • Loading branch information
amartinezfayo authored Feb 28, 2024
1 parent 31b3cb1 commit 61bf130
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
2 changes: 0 additions & 2 deletions pkg/agent/plugin/workloadattestor/unix/unix_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func (p *Plugin) getUID(proc processInfo) (string, error) {
func (p *Plugin) getUserName(uid string) (string, bool) {
u, err := p.hooks.lookupUserByID(uid)
if err != nil {
p.log.Warn("Failed to lookup user name by uid", "uid", uid, "error", err)
return "", false
}
return u.Username, true
Expand All @@ -260,7 +259,6 @@ func (p *Plugin) getGID(proc processInfo) (string, error) {
func (p *Plugin) getGroupName(gid string) (string, bool) {
g, err := p.hooks.lookupGroupByID(gid)
if err != nil {
p.log.Warn("Failed to lookup group name by gid", "gid", gid, "error", err)
return "", false
}
return g.Name, true
Expand Down
22 changes: 0 additions & 22 deletions pkg/agent/plugin/workloadattestor/unix/unix_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (s *Suite) TestAttest() {
config string
expectCode codes.Code
expectMsg string
expectLogs []spiretest.LogEntry
}{
{
name: "pid with no uids",
Expand All @@ -75,16 +74,6 @@ func (s *Suite) TestAttest() {
"group:g2000",
},
expectCode: codes.OK,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.WarnLevel,
Message: "Failed to lookup user name by uid",
Data: logrus.Fields{
"uid": "1999",
logrus.ErrorKey: "no user with UID 1999",
},
},
},
},
{
name: "pid with no gids",
Expand All @@ -107,16 +96,6 @@ func (s *Suite) TestAttest() {
"gid:2999",
},
expectCode: codes.OK,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.WarnLevel,
Message: "Failed to lookup group name by gid",
Data: logrus.Fields{
"gid": "2999",
logrus.ErrorKey: "no group with GID 2999",
},
},
},
},
{
name: "primary user and gid",
Expand Down Expand Up @@ -253,7 +232,6 @@ func (s *Suite) TestAttest() {
}

require.Equal(t, testCase.selectorValues, selectorValues)
spiretest.AssertLogs(t, s.logHook.AllEntries(), testCase.expectLogs)
})
}
}
Expand Down

0 comments on commit 61bf130

Please sign in to comment.