A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/security-command-center/docs/custom-modules-sha-test below:

Test custom modules for Security Health Analytics | Security Command Center

Test custom modules for Security Health Analytics

Stay organized with collections Save and categorize content based on your preferences.

Premium and Enterprise service tiers

This page explains how to test Security Health Analytics custom modules in the Google Cloud console by uploading a YAML file that contains test data.

Before you begin

Before you can test custom modules, you need to satisfy the following prerequisites:

Create test resources in a YAML file

To test a custom module, you define fake resource definitions, fake policy definitions, or both in a YAML file.

The definitions do not correspond to real resource or policy instances, but the definitions must conform to the schemas of the resource or policy types that are specified in your custom modules.

In your test definitions, the only properties that you need to specify are the properties that your custom modules evaluate. You don't need to include resource properties that the custom module doesn't reference.

To test your CEL expressions in the custom module, specify property values in the test file that cause the CEL expressions to resolve to true.

Format of the test data

Start the file with testData: on the first line, followed by one or more - asset definitions.

testData:
- asset:
    resource: ARBITRARY_ASSET_NAME_1
    assetType: RESOURCE_TYPE_1
    resourceData:
      PROPERTIES_TO_TEST_1: PROPERTY_VALUE_1
        SUB_PROPERTY: SUB_PROPERTY_VALUE
      PROPERTIES_TO_TEST_2: PROPERTY_VALUE_2
- asset:
    resource: ARBITRARY_ASSET_NAME_2
    assetType: RESOURCE_TYPE_2
    iamPolicyData:
      PROPERTIES_TO_TEST_3: PROPERTY_VALUE_3
      PROPERTIES_TO_TEST_4: PROPERTY_VALUE_4

Replace the following:

Example test definitions

This section contains an example of a test resource definition and a test policy definition. Although the two examples are shown as being defined in separate files, asset definitions for resources and policies can be combined in a single testData file.

Example resource definition

The following example of a test resource definition, tests a custom module that checks whether the rotationPeriod property of CryptoKey resources exceeds 2592000 seconds (30 days). The other properties in the definition are not used in the custom module, but still conform to the schema of the resource. For the full definition of the custom module that this example tests, see Example custom module definition.

testData:
- asset:
    resource: THE CRYPTOKEY TEST WAS SUCCESSFUL!
    assetType: cloudkms.googleapis.com/CryptoKey
    resourceData:
      nextRotationTime:  '2020-02-05T12:00:55.192645Z'
      primary:
        state: 'ENABLED'
      purpose: 'ENCRYPT_DECRYPT'
      rotationPeriod: '2592001s'
Example policy definition

The following is an example of a test definition for an IAM policy:

testData:
- asset:
    resource: //cloudresourcemanager.googleapis.com/projects/fake-project
    assetType: cloudresourcemanager.googleapis.com/Project
    iamPolicyData:
      bindings:
      - role: "roles/viewer"
        members:
        - "serviceAccount:fake-service-account@compute-system.iam.gserviceaccount.com"
        - "user:fake-email-account"
Test a custom module

You can test new custom modules or existing custom modules in the Google Cloud console.

To test a custom module, follow these steps:

  1. Go to the Security Health Analytics Modules page in Security Command Center settings.

    Go to Modules

  2. Open or create a custom module for testing:

  3. Select the Test module tab.

  4. Under Upload the YAML file, click Browse to upload a file that contains sample asset data. The test runs as soon as the YAML file is uploaded.

  5. Under Test results preview, check the results.

    Test results are not stored or written to Security Command Center.

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4