발견 항목 그룹화
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
발견 항목을 속성별로 그룹화하는 방법을 보여줍니다.
코드 샘플
Java
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Python
Security Command Center에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to group findings by properties\n\nCode sample \n\nJava\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n static ImmutableList\u003cGroupResult\u003e groupFindings(OrganizationName organizationName) {\n try (SecurityCenterClient client = SecurityCenterClient.create()) {\n // Input parameters for 'SourceName' must be in one of the following formats:\n // * OrganizationName organizationName = OrganizationName.of(\"organization-id\");\n // organizationName.getOrganization();\n // * ProjectName projectName = ProjectName.of(\"project-id\");\n // projectName.getProject();\n // * FolderName folderName = FolderName.of(\"folder-id\");\n // folderName.getFolder();\n SourceName sourceName = SourceName.of(organizationName.getOrganization(), \"-\");\n\n GroupFindingsRequest.Builder request =\n GroupFindingsRequest.newBuilder().setParent(sourceName.toString()).setGroupBy(\"category\");\n\n // Call the API.\n GroupFindingsPagedResponse response = client.groupFindings(request.build());\n\n // This creates one list for all findings. If your organization has a large number of\n // findings\n // this can cause out of memory issues. You can process them batches by returning\n // the Iterable returned response.iterateAll() directly.\n ImmutableList\u003cGroupResult\u003e results = ImmutableList.copyOf(response.iterateAll());\n System.out.println(\"Findings:\");\n System.out.println(results);\n return results;\n } catch (IOException e) {\n throw new RuntimeException(\"Couldn't create client.\", e);\n }\n }\n\nPython\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import securitycenter_v1\n\n # Create a client.\n client = securitycenter_v1.SecurityCenterClient()\n\n # 'parent' must be in one of the following formats:\n # \"organizations/{organization_id}\"\n # \"projects/{project_id}\"\n # \"folders/{folder_id}\"\n parent = f\"organizations/{organization_id}\"\n # The \"sources/-\" suffix lists findings across all sources. You\n # also use a specific source_name instead.\n all_sources = f\"{parent}/sources/-\"\n group_result_iterator = client.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.services.security_center.SecurityCenterClient.html#google_cloud_securitycenter_v1_services_security_center_SecurityCenterClient_group_findings(\n request={\"parent\": all_sources, \"group_by\": \"category\"}\n )\n for i, group_result in enumerate(group_result_iterator):\n print((i + 1), group_result)\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=securitycenter)."]]