Skip to content

feat: add created_by filter to ReadAllFlowObjects#1164

Merged
Tati1701 merged 2 commits intogoogle:masterfrom
TristanInSec:feat/readallflows-created-by-filter
Apr 16, 2026
Merged

feat: add created_by filter to ReadAllFlowObjects#1164
Tati1701 merged 2 commits intogoogle:masterfrom
TristanInSec:feat/readallflows-created-by-filter

Conversation

@TristanInSec
Copy link
Copy Markdown
Contributor

Summary

  • Add optional created_by parameter to ReadAllFlowObjects for filtering flows by creator at the database level
  • Implemented in both MySQL and in-memory backends, with input validation in ValidatingDB
  • Allows callers to efficiently query flows for a specific user without fetching all flows first

Companion to #1162, which currently iterates all flows in Python to find one owned by the requesting user.

Test plan

  • testReadAllFlowObjectsWithCreatedBy covers match, single-match, and no-match cases
  • Existing testReadAllFlowObjectsWithNotCreatedBy and testReadAllFlowObjectsWithAllConditions unaffected

Extend ReadAllFlowObjects with an optional created_by parameter that
filters flows at the database level instead of requiring callers to
fetch all flows and filter in Python.

Implemented in both MySQL and in-memory backends, with input validation
in the ValidatingDB wrapper. Includes dedicated test coverage.
Copy link
Copy Markdown
Collaborator

@Tati1701 Tati1701 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 the quick turnaround!

max_create_time: Optional[rdfvalue.RDFDatetime] = None,
include_child_flows: bool = True,
not_created_by: Optional[Iterable[str]] = None,
created_by: Optional[str] = None,
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.

Let's make this one Iterable too, like in other methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Changed to Optional[Iterable[str]] across all four files, with IN %s in MySQL and list() membership in the in-memory backend. Test updated to cover multi-user filtering.

Match the convention used by not_created_by: accept an iterable of
usernames so callers can filter by multiple creators in a single query.
Uses IN/NOT IN symmetry in the MySQL backend and list membership checks
in the in-memory backend. Test updated to cover multi-user filtering.
@Tati1701 Tati1701 merged commit acea2f8 into google:master Apr 16, 2026
1 check passed
TristanInSec pushed a commit to TristanInSec/grr that referenced this pull request Apr 16, 2026
Now that ReadAllFlowObjects supports a created_by parameter (google#1164),
use it to filter flows at the database level instead of fetching all
flows and iterating in Python.
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.

3 participants