Skip to content

sudoreplay: don't reuse the previous result for a missing log field - #590

Open
Ar-maan05 wants to merge 1 commit into
sudo-project:mainfrom
Ar-maan05:sudoreplay-missing-field
Open

Ar-maan05 wants to merge 1 commit into
sudo-project:mainfrom
Ar-maan05:sudoreplay-missing-field

Conversation

@Ar-maan05

Copy link
Copy Markdown
Contributor

sudoreplay -l can list sessions that don't match the search when a field is missing from the log. a run group is only logged when it differs from the run user's primary group, so plenty of logs don't have it. for a session by alice with no run group:

$ sudoreplay -l user alice group wheel
before: lists the session
after:  nothing

$ sudoreplay -l user alice ! group wheel
before: nothing
after:  lists the session

res was only set when the field was there, so a missing field reused the result of the previus term. the fix resets it for each term.

tested with a small hand-written log.json before and after. plain searches like user alice and user alice host h give the same results as before. there's no sudoreplay regress dir so i didn't add a test.

match_expr() only sets res for cwd, host, tty, group and similar terms when that field is in the log. if it is missing, res keeps the value from the previus term, so "user alice group wheel" lists alice's sessions that have no run group logged. reset res for each term so that a missing field doesn't match.

@millert millert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, thanks.

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.

2 participants