analyzeIamPolicy method

Future<AnalyzeIamPolicyResponse> analyzeIamPolicy(
  1. String scope, {
  2. List<String>? analysisQuery_accessSelector_permissions,
  3. List<String>? analysisQuery_accessSelector_roles,
  4. String? analysisQuery_conditionContext_accessTime,
  5. String? analysisQuery_identitySelector_identity,
  6. bool? analysisQuery_options_analyzeServiceAccountImpersonation,
  7. bool? analysisQuery_options_expandGroups,
  8. bool? analysisQuery_options_expandResources,
  9. bool? analysisQuery_options_expandRoles,
  10. bool? analysisQuery_options_outputGroupEdges,
  11. bool? analysisQuery_options_outputResourceEdges,
  12. String? analysisQuery_resourceSelector_fullResourceName,
  13. String? executionTimeout,
  14. String? savedAnalysisQuery,
  15. String? $fields,
})

Analyzes IAM policies to answer which identities have what accesses on which resources.

Request parameters:

scope - Required. The relative name of the root asset. Only resources and IAM policies within the scope will be analyzed. This can only be an organization number (such as "organizations/123"), a folder number (such as "folders/123"), a project ID (such as "projects/my-project-id"), or a project number (such as "projects/12345"). To know how to get organization ID, visit here . To know how to get folder or project ID, visit here . Value must have pattern ^\[^/\]+/\[^/\]+$.

analysisQuery_accessSelector_permissions - Optional. The permissions to appear in result.

analysisQuery_accessSelector_roles - Optional. The roles to appear in result.

analysisQuery_conditionContext_accessTime - The hypothetical access timestamp to evaluate IAM conditions. Note that this value must not be earlier than the current time; otherwise, an INVALID_ARGUMENT error will be returned.

analysisQuery_identitySelector_identity - Required. The identity appear in the form of principals in IAM policy binding. The examples of supported forms are: "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com". Notice that wildcard characters (such as * and ?) are not supported. You must give a specific identity.

analysisQuery_options_analyzeServiceAccountImpersonation - Optional. If true, the response will include access analysis from identities to resources via service account impersonation. This is a very expensive operation, because many derived queries will be executed. We highly recommend you use AssetService.AnalyzeIamPolicyLongrunning RPC instead. For example, if the request analyzes for which resources user A has permission P, and there's an IAM policy states user A has iam.serviceAccounts.getAccessToken permission to a service account SA, and there's another IAM policy states service account SA has permission P to a Google Cloud folder F, then user A potentially has access to the Google Cloud folder F. And those advanced analysis results will be included in AnalyzeIamPolicyResponse.service_account_impersonation_analysis. Another example, if the request analyzes for who has permission P to a Google Cloud folder F, and there's an IAM policy states user A has iam.serviceAccounts.actAs permission to a service account SA, and there's another IAM policy states service account SA has permission P to the Google Cloud folder F, then user A potentially has access to the Google Cloud folder F. And those advanced analysis results will be included in AnalyzeIamPolicyResponse.service_account_impersonation_analysis. Only the following permissions are considered in this analysis: * iam.serviceAccounts.actAs * iam.serviceAccounts.signBlob * iam.serviceAccounts.signJwt * iam.serviceAccounts.getAccessToken * iam.serviceAccounts.getOpenIdToken * iam.serviceAccounts.implicitDelegation Default is false.

analysisQuery_options_expandGroups - Optional. If true, the identities section of the result will expand any Google groups appearing in an IAM policy binding. If IamPolicyAnalysisQuery.identity_selector is specified, the identity in the result will be determined by the selector, and this flag is not allowed to set. If true, the default max expansion per group is 1000 for AssetService.AnalyzeIamPolicy][]. Default is false.

analysisQuery_options_expandResources - Optional. If true and IamPolicyAnalysisQuery.resource_selector is not specified, the resource section of the result will expand any resource attached to an IAM policy to include resources lower in the resource hierarchy. For example, if the request analyzes for which resources user A has permission P, and the results include an IAM policy with P on a Google Cloud folder, the results will also include resources in that folder with permission P. If true and IamPolicyAnalysisQuery.resource_selector is specified, the resource section of the result will expand the specified resource to include resources lower in the resource hierarchy. Only project or lower resources are supported. Folder and organization resources cannot be used together with this option. For example, if the request analyzes for which users have permission P on a Google Cloud project with this option enabled, the results will include all users who have permission P on that project or any lower resource. If true, the default max expansion per resource is 1000 for AssetService.AnalyzeIamPolicy][] and 100000 for AssetService.AnalyzeIamPolicyLongrunning][]. Default is false.

analysisQuery_options_expandRoles - Optional. If true, the access section of result will expand any roles appearing in IAM policy bindings to include their permissions. If IamPolicyAnalysisQuery.access_selector is specified, the access section of the result will be determined by the selector, and this flag is not allowed to set. Default is false.

analysisQuery_options_outputGroupEdges - Optional. If true, the result will output the relevant membership relationships between groups and other groups, and between groups and principals. Default is false.

analysisQuery_options_outputResourceEdges - Optional. If true, the result will output the relevant parent/child relationships between resources. Default is false.

analysisQuery_resourceSelector_fullResourceName - Required. The full resource name of a resource of supported resource types.

executionTimeout - Optional. Amount of time executable has to complete. See JSON representation of Duration. If this field is set with a value less than the RPC deadline, and the execution of your query hasn't finished in the specified execution timeout, you will get a response with partial result. Otherwise, your query's execution will continue until the RPC deadline. If it's not finished until then, you will get a DEADLINE_EXCEEDED error. Default is empty.

savedAnalysisQuery - Optional. The name of a saved query, which must be in the format of: * projects/project_number/savedQueries/saved_query_id * folders/folder_number/savedQueries/saved_query_id * organizations/organization_number/savedQueries/saved_query_id If both analysis_query and saved_analysis_query are provided, they will be merged together with the saved_analysis_query as base and the analysis_query as overrides. For more details of the merge behavior, refer to the MergeFrom page. Note that you cannot override primitive fields with default value, such as 0 or empty string, etc., because we use proto3, which doesn't support field presence yet.

$fields - Selector specifying which fields to include in a partial response.

Completes with a AnalyzeIamPolicyResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<AnalyzeIamPolicyResponse> analyzeIamPolicy(
  core.String scope, {
  core.List<core.String>? analysisQuery_accessSelector_permissions,
  core.List<core.String>? analysisQuery_accessSelector_roles,
  core.String? analysisQuery_conditionContext_accessTime,
  core.String? analysisQuery_identitySelector_identity,
  core.bool? analysisQuery_options_analyzeServiceAccountImpersonation,
  core.bool? analysisQuery_options_expandGroups,
  core.bool? analysisQuery_options_expandResources,
  core.bool? analysisQuery_options_expandRoles,
  core.bool? analysisQuery_options_outputGroupEdges,
  core.bool? analysisQuery_options_outputResourceEdges,
  core.String? analysisQuery_resourceSelector_fullResourceName,
  core.String? executionTimeout,
  core.String? savedAnalysisQuery,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (analysisQuery_accessSelector_permissions != null)
      'analysisQuery.accessSelector.permissions':
          analysisQuery_accessSelector_permissions,
    if (analysisQuery_accessSelector_roles != null)
      'analysisQuery.accessSelector.roles':
          analysisQuery_accessSelector_roles,
    if (analysisQuery_conditionContext_accessTime != null)
      'analysisQuery.conditionContext.accessTime': [
        analysisQuery_conditionContext_accessTime
      ],
    if (analysisQuery_identitySelector_identity != null)
      'analysisQuery.identitySelector.identity': [
        analysisQuery_identitySelector_identity
      ],
    if (analysisQuery_options_analyzeServiceAccountImpersonation != null)
      'analysisQuery.options.analyzeServiceAccountImpersonation': [
        '${analysisQuery_options_analyzeServiceAccountImpersonation}'
      ],
    if (analysisQuery_options_expandGroups != null)
      'analysisQuery.options.expandGroups': [
        '${analysisQuery_options_expandGroups}'
      ],
    if (analysisQuery_options_expandResources != null)
      'analysisQuery.options.expandResources': [
        '${analysisQuery_options_expandResources}'
      ],
    if (analysisQuery_options_expandRoles != null)
      'analysisQuery.options.expandRoles': [
        '${analysisQuery_options_expandRoles}'
      ],
    if (analysisQuery_options_outputGroupEdges != null)
      'analysisQuery.options.outputGroupEdges': [
        '${analysisQuery_options_outputGroupEdges}'
      ],
    if (analysisQuery_options_outputResourceEdges != null)
      'analysisQuery.options.outputResourceEdges': [
        '${analysisQuery_options_outputResourceEdges}'
      ],
    if (analysisQuery_resourceSelector_fullResourceName != null)
      'analysisQuery.resourceSelector.fullResourceName': [
        analysisQuery_resourceSelector_fullResourceName
      ],
    if (executionTimeout != null) 'executionTimeout': [executionTimeout],
    if (savedAnalysisQuery != null)
      'savedAnalysisQuery': [savedAnalysisQuery],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$scope') + ':analyzeIamPolicy';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return AnalyzeIamPolicyResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}