Skip to content

feat: Add wildcard support for ignore flags and fix for deletion logic#306

Open
Dakad wants to merge 4 commits into
awslabs:masterfrom
apptweak:fix/gh-305-wildcard-support-and-deletion-logic
Open

feat: Add wildcard support for ignore flags and fix for deletion logic#306
Dakad wants to merge 4 commits into
awslabs:masterfrom
apptweak:fix/gh-305-wildcard-support-and-deletion-logic

Conversation

@Dakad
Copy link
Copy Markdown

@Dakad Dakad commented Mar 14, 2026

Issue #, if available:
Resolves #305

Description of changes:
This PR enhances the user and group "ignore" functionality by introducing wildcard support and strengthening the safety checks during the deletion phase.

  • Wildcard Support: Updated --ignore-users and --ignore-groups to support * wildcards using Go's path.Match. This acts as a "Global Safety Net," allowing administrators to protect patterns of users/groups (e.g., *@internal.com) from being deleted, even if they aren't present in the source directory.
  • Deletion Safety:
    • Integrated the ignore check directly into getUserOperations and getGroupOperations to prevent ignored entities from even entering the "to-delete" queue.
    • Added a secondary "double-check" inside the deletion loops in SyncGroupsUsers as a fail-safe to ensure no ignored user or group is deleted.
  • Input Sanitization: Added whitespace trimming (strings.TrimSpace) for ignore list entries and comparison strings to prevent mismatches caused by leading/trailing spaces in configuration.
  • Better logging: Add more debug logging to provide more context when users or groups are skipped due to ignore rules, including counts of pending deletions.
  • Unit Testing: Added comprehensive tests in internal/sync_test.go covering wildcard matching scenarios and the filtered operation logic.

Why this approach?

By moving the ignore logic into the operation calculation phase (get...Operations), we minimise unnecessary API calls and log noise. The secondary check in the deletion loop serves as a "defense-in-depth" measure, if the sync logic is refactored in the future, the safety net for protected accounts remains intact.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Dakad added 4 commits March 14, 2026 15:39
- Implement glob-style wildcard matching in ignoreUser and ignoreGroup using path.Match.
- Update getGroupOperations and getUserOperations to respect ignore filters, preventing the accidental deletion of manual AWS IAM Identity Center objects that are not present in Google Workspace.
…void mismatches.

- Improved logging to provide detailed information on group and user deletions, including counts and specific actions taken.
- Added safety checks to skip deletions for groups and users listed in the ignore list, ensuring no accidental removals occur.
- Added tests for wildcard matching in ignoreUser and ignoreGroup functions.
- Verified group and user operations with respect to ignore lists, ensuring correct handling of additions, deletions, and matches.
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.

Wildcard support for ignore lists and improved deletion safety

1 participant