Add sync-permissions-by-tags script to share resources across client projects - #1385
Open
TDianaAle wants to merge 2 commits into
Open
Add sync-permissions-by-tags script to share resources across client projects#1385TDianaAle wants to merge 2 commits into
TDianaAle wants to merge 2 commits into
Conversation
greenbonebot
enabled auto-merge (rebase)
August 4, 2026 08:05
Conventional Commits Report
🚀 Conventional commits found. |
… projects Synchronizes group permissions from project:* tags, so analysts only get access to the tasks, scanners and reports of the clients they are assigned to. Supports a dry run, an inventory mode, and an optional cleanup phase that revokes permissions whose tag was removed. Targets Python 3.10 and up, matching the CI matrix.
auto-merge was automatically disabled
August 4, 2026 08:20
Head branch was pushed to by a user without write access
TDianaAle
force-pushed
the
add-sync-permissions-by-tags
branch
from
August 4, 2026 08:20
450aca0 to
22c41e9
Compare
greenbonebot
enabled auto-merge (rebase)
August 4, 2026 08:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This adds
sync-permissions-by-tags.gmp.py, a script that automates sharing scan resources between users, so an analyst can work on several client projects at once while holding only the permissions they actually need.Tags are already how resources get labelled in the web UI, so they become the source of truth. An administrator tags a resource
project:Acme, and the analysts working on that client join theAcmegroup. The script then keeps the permissions in sync with the tags:project:*tagget_scannersget_tasks,start_task,stop_taskget_reportsResources without a
project:*tag are never touched, and re-runs are idempotent: existing permissions are detected and skipped. An analyst in two groups sees both clients' resources, and nothing else.Usage
How the changes were verified
Exercised end to end against a container deployment of Greenbone Community Edition 22.4 (gvmd 26.36.1, DB revision 281): resource discovery, group creation, permission granting, untagged resources left alone, idempotent re-runs,
--dry-runperforming no writes, and garbage collection revoking only the permissions whose tag was removed.Inventory mode shows which resources are in scope, and which are not:
A sync run.
ClientAalready holds its permissions from an earlier run and is left alone;ClientBhas just been tagged and receives exactly what it needs:Garbage collection after the
project:ClientBtag was removed from that task. Only the permissions that lost their tag are revoked;ClientA's five are untouched:Implementation notes
python-gvmruff formatandruff checkclean at 80 columnsscripts/README.mdin the documented formatargs.script_argswith the positional list, following the approach incertbund-report.gmp.py, sincegvm-scriptdeclaresscriptargswithnargs="*"and leaves--prefixed arguments toparse_known_args(). Unsupported arguments are rejected rather than ignored, so a mistyped flag cannot be silently treated as a real runWhy
A security analyst is typically assigned to more than one client at a time. For each of them, the analyst needs to see that client's tasks and reports — start and stop their scans, read their findings — and nothing belonging to anyone else.
Greenbone Community Edition has no built-in way to express this. Setting it up by hand means, for every client: create a group, add the analysts to it, then grant each permission on each resource one at a time —
get_tasks,start_taskandstop_taskon every task,get_scannerson the scanner,get_reportson every report. Adding one task to a client means repeating the grants. Moving an analyst to another project means redoing it from scratch. And when a resource stops belonging to a client, the old permissions stay behind unless someone remembers to remove them, silently leaving access in place.References
None.