Skip to content

Log errors in failed user/group name lookup in unix workload attestor#2048

Merged
azdagron merged 3 commits intospiffe:masterfrom
rturner3:unix-attestor-logging
Jan 13, 2021
Merged

Log errors in failed user/group name lookup in unix workload attestor#2048
azdagron merged 3 commits intospiffe:masterfrom
rturner3:unix-attestor-logging

Conversation

@rturner3
Copy link
Collaborator

@rturner3 rturner3 commented Jan 12, 2021

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality
unix Workload Attestor plugin

Description of change
Adding logging in cases where looking up a Unix user name by uid or a Unix group name by gid fails. Currently, the unix attestor swallows these errors without logging or returning them. This makes it difficult to understand workload attestation failures that might be caused by one of the unix:user or unix:group selectors not being properly identified.

Which issue this PR fixes
fixes #2040

Signed-off-by: Ryan Turner <turner@uber.com>
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @rturner3. Other than the nitpicks on the log casing, I was wondering how you felt about throwing together a few test cases to test the logging? Should hopefully be a quick addition to the PR.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log messages should start with uppercase

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log messages should start with uppercase

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @rturner3. Other than the nitpicks on the log casing, I was wondering how you felt about throwing together a few test cases to test the logging? Should hopefully be a quick addition to the PR.

Sure, added some test coverage.

Ryan Turner added 2 commits January 12, 2021 16:19
Signed-off-by: Ryan Turner <turner@uber.com>
Signed-off-by: Ryan Turner <turner@uber.com>
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

@azdagron azdagron merged commit 581fe75 into spiffe:master Jan 13, 2021
@azdagron azdagron added this to the 0.12.2 milestone Mar 23, 2021
@rturner3 rturner3 deleted the unix-attestor-logging branch September 2, 2022 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unix attestation logic should not drop errors on failed group look up

2 participants