Repository navigation
GTI: fix service account permission check and its error log - #62
Open
Anwesh-Mahapatra wants to merge 1 commit into
Open
Anwesh-Mahapatra wants to merge 1 commit into
Anwesh-Mahapatra wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Anwesh-Mahapatra
force-pushed
the
fix-gti-permission-check
branch
from
November 6, 2026 21:48
5a0f8d2 to
65a9442
Compare
- Request IAM policy version 3 in check_sufficient_permissions_on_service_account. With the default version 1, roles granted with an IAM condition are returned as "<role>_withcond_<hash>", so they never match the required role names and the check fails even though the role is granted. - Fix the "insufficient permissions" log call: the service account email was passed as the `severity` argument of cloud_logging, so the log printed a literal "%s" with an invalid severity. It now logs at ERROR level and lists the missing roles.
Anwesh-Mahapatra
force-pushed
the
fix-gti-permission-check
branch
from
November 6, 2026 22:16
65a9442 to
a299c14
Compare
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.
Summary
Two small fixes to
check_sufficient_permissions_on_service_accountingoogle_threat_intelligence/gti_client.py.1. Roles granted with an IAM condition are never matched
get_iam_policyis called withoutrequested_policy_version. With the default version 1, IAM returns conditional bindings under a modified role name, e.g.roles/storage.admin_withcond_<hash>(docs). The check comparesbinding.role == roleagainstPERMISSION_DETAILS, so a correctly granted conditional role (for example Storage Admin scoped to the GTI bucket only) is reported as missing and the function stops.Fix: request policy version 3, so conditional bindings come back under their real role name.
2. The "insufficient permissions" log is malformed
cloud_logging(message, severity)does not format%s, so the service account email was passed as the severity. In Cloud Logging this shows as a literalService account - %s does not have sufficient permissions.with an empty severity, and the missing roles are never named.Fix: build the message with an f-string, include the missing role names, and log at
ERROR.How this was found
Deploying the GTI ingestion function into a test project with a dedicated service account. Granting Storage Admin with an IAM condition limited to the checkpoint bucket kept failing the permission check, and the error log did not say which role was missing.
Testing
Ran
gti_client_test.pyandmain_test.pylocally (Python 3, requirements.txt + pytest + mock):test__get_last_checkpoint_not_found_exception)mainwithout this change: the same test fails the same way, so it is unrelated to this PR.🤖 Generated with Claude Code