google-github-actions / analyze-code-security-scc

A GitHub Action to analyze Terraform and IaC configurations in Security Command Center.
https://cloud.google.com/security-command-center
Apache License 2.0
2 stars 9 forks source link
actions cloud-security cloud-security-command-center gcp github-actions google-cloud google-cloud-platform scc security security-command-center

analyze-code-security-scc

Description

This GitHub action identifies insecure configurations in Infrastructure as Code (IaC) files for Google Cloud resources. This action requires Terraform plan files in JSON format for scanning.

Use this action to detect and remediate issues in IaC files for Google Cloud before you deploy the resources.

This action lets you:

This is not an officially supported Google product, and it is not covered by a Google Cloud support contract. To report bugs or request features in a Google Cloud product, please contact Google Cloud support.

[!IMPORTANT] This action requires the Security Command Center Premium tier or Enterprise tier. In the Premium tier, you must be a subscription customer to use this action. You must activate Security Command Center at the organization level to use this feature.

[!CAUTION] Don’t enter any sensitive information such as passwords and other personal identifiable information in the Terraform plan files.

Prerequisites

Usage

jobs:
  job_id:
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
      - uses: 'actions/checkout@v4'
      - id: 'auth'
        uses: 'google-github-actions/auth@v2'
        with:
          workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
          service_account: 'my-service-account@my-project.iam.gserviceaccount.com'

      - id: 'analyze-code-security-scc'
        uses: 'google-github-actions/analyze-code-security-scc@v0'
        with:
          organization_id: '123456789'
          scan_file_ref: './tf_plan.json'
          iac_type: 'terraform'
          scan_timeout: '1m'
          ignore_violations: false
          failure_criteria: 'High:1,Medium:1,Low:1,Operator:or'
          fail_silently: false

      - if: |-
          ${{ !cancelled() && steps.analyze-code-security-scc.outputs.iac_scan_result_sarif_path != '' }}
        uses: 'actions/upload-artifact@v4'
        with:
          name: 'sarif'
          path: '${{ steps.analyze-code-security-scc.outputs.iac_scan_result_sarif_path }}'

Inputs

Outputs

Authorization

Use google-github-actions/auth to authenticate the action. You can use Workload Identity Federation or Service account key JSON for authentication.

jobs:
  job_id:
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v2'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: 'my-service-account@my-project.iam.gserviceaccount.com'

    - id: 'analyze-code-security-scc'
      uses: 'google-github-actions/analyze-code-security-scc@v0'

Supported asset types and policies

For information about supported asset types and policies, see IaC Validation - Supported assets and policies.