Skip to content

listrules.py v2.0#265

Open
tomstarr wants to merge 6 commits into
masterfrom
dev-newlistrules
Open

listrules.py v2.0#265
tomstarr wants to merge 6 commits into
masterfrom
dev-newlistrules

Conversation

@tomstarr
Copy link
Copy Markdown
Collaborator

@tomstarr tomstarr commented May 7, 2026

Complete rewrite of listrules.py to provide greater capabilities for filtering a rule search with integrated error handling.

New capabilities:

  • container filter
  • description filter
  • condition filter
  • media type filter
  • enabled/disabled filter
  • created by filter
  • created after filter
  • created before filter
  • modified by filter
  • modified after filter
  • modified before filter
  • operator - option to use 'eq', 'ne' or 'contains' in the search (where available)
  • raw-filter - option to use open text/custom written filter
  • print-only - option to display the compiled search filter only
  • count-only - option to display a count of the rules found only
  • set a limit for results returned
  • set an item to sort the results by
  • set the order of a sorted return of results

tomstarr added 5 commits May 5, 2026 15:07
Assisted-by: Microsoft Copilot
Trimmed down some of the code that was surplus and added if statement to handle special user (principalTypes) when used in combination with unsupported operator types.
Changes:
Removed the original 'listrules.py' from this branch.
Renamed 'newlistrules.py' to 'listrules.py'.
Changed csv 'csvheader' option to 'headeroff' and set the default to including a header to ensure the same default behaviour as listrules.py v1.0 was persisted.
Changed VALID_PERMISSIONS from being a set to a list to ensure the permissions order returned is consistent.
Renamed columns and results for:
createdTimestamp --> creationTimeStamp
modifiedTimestamp --> modifiedTimeStamp

New features:
Option to print filter and REST call without submitting
Option to filter by createdBy and modifiedBy

Bugfix:
Fixed a bug (through the column and result renamed) affecting the created* and modified* timestamp filters didn't work.
Changes:
Added usage note to -h
Added limit option
Added sort-by option and error handling
Added sort-order option
Added count-only option
Added error message for when no rules are found

Changed:
Changed 'printfilter' option to 'print-filter'
Updated -h file

Signed-off-by: Tom <tom.starr@sas.com>
@tomstarr tomstarr requested a review from gerrynelson63 May 7, 2026 23:09
@tomstarr tomstarr added the enhancement New feature or request label May 7, 2026
I, Tom <tom.starr@sas.com>, hereby add my Signed-off-by to this commit: 509b2a3
I, Tom <tom.starr@sas.com>, hereby add my Signed-off-by to this commit: 7ebce12
I, Tom <tom.starr@sas.com>, hereby add my Signed-off-by to this commit: 3f6bcb6
I, Tom <tom.starr@sas.com>, hereby add my Signed-off-by to this commit: 5029cb8

Signed-off-by: Tom <tom.starr@sas.com>
@tomstarr tomstarr marked this pull request as ready for review May 7, 2026 23:10
@gerrynelson63
Copy link
Copy Markdown
Member

@tomstarr I did some testing, a lot of nice functionality. I did find a change in behavior that might impact existing users. The default query in the current version uses contains on the URI. But the default in the new one is equals. Can we change the default to contains so that we preserver backward compatibility. You can test with:

./listrules.py -u /identities/groups -p SASAdministrators -o csv

It should return the same for new and old.

Thanks.

@tomstarr
Copy link
Copy Markdown
Collaborator Author

@gerrynelson63 thanks for testing and for highlighting the potential for a regression issue. I tried a quick fix on Monday, but found it to be a little more complicated than I'd hoped for.
I'll have a deeper dive next week and post an update once this issue's patched.

@tomstarr tomstarr assigned tomstarr and unassigned gerrynelson63 May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants