securitycenter

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for the Security Command Center API v1. Wraps the googleapis client.

func NewClient

func NewClient(ctx context.Context, log logr.Logger, googleServiceAccount string, dryRun bool, opts ...option.ClientOption) (*Client, error)

NewClient creates a Client for the Security Command Center API v1. Remember to `defer Close()` to clean up.

Note: All methods creates child contextx (with timeouts) from the provided context.

Optional arguments: - a logr.Logger. Default to stdr, which is a wrapper of Go's system log package. - a Google Service Account to impersonate. Defaults to no impersonation for empty string. - ClientOptions from the google.golang.org/api/option package

func (*Client) Close

func (c *Client) Close() error

Close cleans up

func (*Client) CreateSource

func (c *Client) CreateSource(ctx context.Context, organizationID, displayName, description string) (*securitycenterpb.Source, error)

CreateSource creates a source. Returns an error if a source exists for the organization with the same displayName. Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources/create

func (*Client) GetIamPolicy

func (c *Client) GetIamPolicy(ctx context.Context, source string) (*iampb.Policy, error)

GetIamPolicy for the provided source.

The `source` input argument should be in the format `organizations/[organization_id]/sources/[source_id]`

Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources/getIamPolicy

func (*Client) GetSource

func (c *Client) GetSource(ctx context.Context, source string) (*securitycenterpb.Source, error)

GetSource gets a source by its full name in the format `organizations/[organization_id]/sources/[source_id]` Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources/get

func (*Client) GetSourceNameForDisplayName

func (c *Client) GetSourceNameForDisplayName(ctx context.Context, organizationID, displayName string) (string, error)

GetSourceNameForDisplayName can be used to check if a source with the same display name already exists for the provided organization (case insensitive match). Returns the full source name of the existing source with the provided display name. If no source exists for the provided display name, this method returns the empty string and nil error. Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources

func (*Client) ListSources

func (c *Client) ListSources(ctx context.Context, organizationID string) ([]*securitycenterpb.Source, error)

ListSources retrieves all sources for the provided numeric organization ID. Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources/list

func (*Client) SetIamPolicy

func (c *Client) SetIamPolicy(ctx context.Context, source string, policy *iampb.Policy) (*iampb.Policy, error)

SetIamPolicy for the provided source using the provided policy

The `source` input argument should be in the format `organizations/[organization_id]/sources/[source_id]`

Ref: https://cloud.google.com/security-command-center/docs/reference/rest/v1/organizations.sources/setIamPolicy

func (*Client) SetPageSize

func (c *Client) SetPageSize(pageSize int) error

SetPageSize for list calls to the Security Center API

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration) error

SetTimeout for calls to the Security Center API

func (*Client) SyncFindings

func (c *Client) SyncFindings(ctx context.Context, source string, findingRequests map[string]*securitycenterpb.CreateFindingRequest) error

SyncFindings synchronizes the findings already in Security Command Center (SCC) with the provided finding requests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL