Skip to content

Sudo group gid#35

Closed
shridhargadekar wants to merge 2 commits into
RedHat-SP-Security:masterfrom
shridhargadekar:sudo-group-gid
Closed

Sudo group gid#35
shridhargadekar wants to merge 2 commits into
RedHat-SP-Security:masterfrom
shridhargadekar:sudo-group-gid

Conversation

@shridhargadekar

@shridhargadekar shridhargadekar commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Extend sudo responder test coverage for LDAP sudoUser handling, including group GID support and multiple users per rule.

New Features:

  • Add LDAP sudo responder tests verifying sudoUser entries specified by group GID (%#GID) are honored.
  • Add tests for sudoUser rules combining multiple group GIDs and mixing group GID and group name entries in a single rule.

Tests:

  • Broaden existing sudo duplicate-user test to cover multiple users in a single sudo rule and validate all can list and run commands.

jakub-vavra-cz and others added 2 commits May 25, 2026 19:49
Tests sudoUser with group GID notation (%#GID) which currently doesn't
work via SSSD sudo provider but works with direct LDAP lookup.

Test cases:
- test_sudo__sudouser_with_group_gid: Basic %#GID notation
- test_sudo__sudouser_with_multiple_group_gids: Multiple GID entries
- test_sudo__sudouser_group_gid_with_group_name_mixed: Mixed %#GID and %group

Signed-off-by: shridhargadekar <shridhar.always@gmail.com>
@sourcery-ai

sourcery-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Extends sudo responder test coverage to group GID-based sudoUser matching and improves an existing duplicate sudo user test to verify behavior with multiple users.

File-Level Changes

Change Details Files
Broaden duplicate sudo user test to cover multiple local and domain users and verify sudo list/run for each.
  • Add creation of two additional users for the duplicate sudo user scenario.
  • Update sudo rule to include multiple users, including a domain-qualified entry for a different user.
  • Replace single-user list/run assertions with a loop that asserts sudo list and sudo command success for all configured users.
pytest/tests/test_sudo.py
Add new test module validating sudoUser matching using group GID syntax, multiple GIDs, and mixed GID/group-name entries with the LDAP provider.
  • Introduce test validating that a sudo rule with sudoUser specified as a single group GID (%#GID) allows only users whose primary GID matches.
  • Add test that a sudo rule with multiple sudoUser GID entries permits users from any listed GID but blocks users from other GIDs.
  • Add test that a sudo rule mixing group GID (%#GID) and group name (%group) sudoUser entries correctly authorizes users matched by either notation while denying others.
  • Use explicit group/user creation, sudo defaults (!authenticate), and SSSD sudo responder startup in each test to exercise behavior via SSSD against a BareLDAP topology.
pytest/tests/test_sudo_group_gid.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The three new sudo group GID tests repeat very similar setup logic for creating groups/users and the defaults sudo rule; consider extracting common helper(s) or using parametrization to reduce duplication and make the intent clearer.
  • The hard-coded UID/GID values (e.g., 20001/20002/30001/etc.) could be defined as named constants at the top of the file to improve readability and make it easier to avoid accidental reuse or conflicts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The three new sudo group GID tests repeat very similar setup logic for creating groups/users and the `defaults` sudo rule; consider extracting common helper(s) or using parametrization to reduce duplication and make the intent clearer.
- The hard-coded UID/GID values (e.g., 20001/20002/30001/etc.) could be defined as named constants at the top of the file to improve readability and make it easier to avoid accidental reuse or conflicts.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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