models

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkUploadInput

type BulkUploadInput struct {
	Data   string `json:"data" validate:"required"` // base64-encoded zipfile
	UserID string `json:"userId" validate:"required"`
}

type BulkUploadOutput

type BulkUploadOutput struct {
	TotalPolicies    int `json:"totalPolicies"`
	NewPolicies      int `json:"newPolicies"`
	ModifiedPolicies int `json:"modifiedPolicies"`

	TotalRules    int `json:"totalRules"`
	NewRules      int `json:"newRules"`
	ModifiedRules int `json:"modifiedRules"`

	TotalGlobals    int `json:"totalGlobals"`
	NewGlobals      int `json:"newGlobals"`
	ModifiedGlobals int `json:"modifiedGlobals"`

	TotalDataModels    int `json:"totalDataModels"`
	NewDataModels      int `json:"newDataModels"`
	ModifiedDataModels int `json:"modifiedDataModels"`
}

type CreateDataModelInput

type CreateDataModelInput = UpdateDataModelInput

type CreateGlobalInput

type CreateGlobalInput = UpdateGlobalInput

type CreatePolicyInput

type CreatePolicyInput = UpdatePolicyInput

type CreateRuleInput

type CreateRuleInput = UpdateRuleInput

type DataModel

type DataModel struct {
	Body           string             `json:"body"`
	CreatedAt      time.Time          `json:"createdAt"`
	CreatedBy      string             `json:"createdBy"`
	Description    string             `json:"description"`
	DisplayName    string             `json:"displayName"`
	Enabled        bool               `json:"enabled"`
	ID             string             `json:"id"`
	LastModified   time.Time          `json:"lastModified"`
	LastModifiedBy string             `json:"lastModifiedBy"`
	LogTypes       []string           `json:"logTypes"`
	Mappings       []DataModelMapping `json:"mappings"`
	VersionID      string             `json:"versionId"`
}

type DataModelMapping

type DataModelMapping struct {
	Name   string `json:"name" validate:"required,max=1000"`
	Path   string `json:"path" validate:"required_without=Method,max=1000"`
	Method string `json:"method" validate:"required_without=Path,max=1000"`
}

type DeleteDataModelsInput

type DeleteDataModelsInput = DeletePoliciesInput

type DeleteEntry

type DeleteEntry struct {
	ID string `json:"id" validate:"required,max=1000"`
}

type DeleteGlobalsInput

type DeleteGlobalsInput = DeletePoliciesInput

type DeletePoliciesInput

type DeletePoliciesInput struct {
	Entries []DeleteEntry `json:"entries" validate:"min=1,max=1000,dive"`
}

type DeleteRulesInput

type DeleteRulesInput = DeletePoliciesInput

type DetectionType

type DetectionType string
const (
	TypePolicy    DetectionType = "POLICY"
	TypeRule      DetectionType = "RULE"
	TypeGlobal    DetectionType = "GLOBAL"
	TypeDataModel DetectionType = "DATAMODEL"
)

type GetDataModelInput

type GetDataModelInput struct {
	ID        string `json:"id" validate:"required,max=1000"`
	VersionID string `json:"versionId" validate:"omitempty,len=32"`
}

type GetGlobalInput

type GetGlobalInput struct {
	ID        string `json:"id" validate:"required,max=1000"`
	VersionID string `json:"versionId" validate:"omitempty,len=32"`
}

type GetPolicyInput

type GetPolicyInput struct {
	ID        string `json:"id" validate:"required,max=1000"`
	VersionID string `json:"versionId" validate:"omitempty,len=32"`
}

type GetRuleInput

type GetRuleInput struct {
	ID        string `json:"id" validate:"required,max=1000"`
	VersionID string `json:"versionId" validate:"omitempty,len=32"`
}

type Global

type Global struct {
	Body           string    `json:"body"`
	CreatedAt      time.Time `json:"createdAt"`
	CreatedBy      string    `json:"createdBy"`
	Description    string    `json:"description"`
	ID             string    `json:"id"`
	LastModified   time.Time `json:"lastModified"`
	LastModifiedBy string    `json:"lastModifiedBy"`
	Tags           []string  `json:"tags"`
	VersionID      string    `json:"versionId"`
}

type LambdaInput

type LambdaInput struct {
	// Shared
	BulkUpload *BulkUploadInput `json:"bulkUpload,omitempty"`

	// Globals
	CreateGlobal  *CreateGlobalInput  `json:"createGlobal,omitempty"`
	DeleteGlobals *DeleteGlobalsInput `json:"deleteGlobals,omitempty"`
	GetGlobal     *GetGlobalInput     `json:"getGlobal,omitempty"`
	ListGlobals   *ListGlobalsInput   `json:"listGlobals,omitempty"`
	UpdateGlobal  *UpdateGlobalInput  `json:"updateGlobal,omitempty"`

	// Policies (cloud security)
	CreatePolicy   *CreatePolicyInput   `json:"createPolicy,omitempty"`
	DeletePolicies *DeletePoliciesInput `json:"deletePolicies,omitempty"`
	GetPolicy      *GetPolicyInput      `json:"getPolicy,omitempty"`
	ListPolicies   *ListPoliciesInput   `json:"listPolicies,omitempty"`
	Suppress       *SuppressInput       `json:"suppress,omitempty"`
	TestPolicy     *TestPolicyInput     `json:"testPolicy,omitempty"`
	UpdatePolicy   *UpdatePolicyInput   `json:"updatePolicy,omitempty"`

	// Rules (log analysis)
	CreateRule  *CreateRuleInput  `json:"createRule,omitempty"`
	DeleteRules *DeleteRulesInput `json:"deleteRules,omitempty"`
	GetRule     *GetRuleInput     `json:"getRule,omitempty"`
	ListRules   *ListRulesInput   `json:"listRules,omitempty"`
	TestRule    *TestRuleInput    `json:"testRule,omitempty"`
	UpdateRule  *UpdateRuleInput  `json:"updateRule,omitempty"`

	// Data models (log analysis)
	CreateDataModel  *CreateDataModelInput  `json:"createDataModel,omitempty"`
	DeleteDataModels *DeleteDataModelsInput `json:"deleteDataModels,omitempty"`
	GetDataModel     *GetDataModelInput     `json:"getDataModel,omitempty"`
	ListDataModels   *ListDataModelsInput   `json:"listDataModels,omitempty"`
	UpdateDataModel  *UpdateDataModelInput  `json:"updateDataModel,omitempty"`
}

type ListDataModelsInput

type ListDataModelsInput struct {
	// ----- Filtering -----
	// Only include data models which are enabled or disabled
	Enabled *bool `json:"enabled"`

	// Only include data models whose ID contains this substring (case-insensitive)
	NameContains string `json:"nameContains"`

	// Only include data models which apply to one of these log types
	LogTypes []string `json:"logTypes" validate:"dive,required,max=500"`

	// ----- Sorting -----
	SortBy  string `json:"sortBy" validate:"omitempty,oneof=enabled id lastModified logTypes"`
	SortDir string `json:"sortDir" validate:"omitempty,oneof=ascending descending"`

	// ----- Paging -----
	PageSize int `json:"pageSize" validate:"min=0,max=1000"`
	Page     int `json:"page" validate:"min=0"`
}

type ListDataModelsOutput

type ListDataModelsOutput struct {
	Models []DataModel `json:"models"`
	Paging Paging      `json:"paging"`
}

type ListGlobalsInput

type ListGlobalsInput struct {
	// JSON field names (passed to Dynamo as a projection). For example,
	// ["id", "lastModified", "tags"]
	Fields []string `json:"fields" validate:"max=15,dive,required,max=100"`

	SortDir  string `json:"sortDir" validate:"omitempty,oneof=ascending descending"`
	PageSize int    `json:"pageSize" validate:"min=0,max=1000"`
	Page     int    `json:"page" validate:"min=0"`
}

type ListGlobalsOutput

type ListGlobalsOutput struct {
	Paging  Paging   `json:"paging"`
	Globals []Global `json:"globals"`
}

type ListPoliciesInput

type ListPoliciesInput struct {
	// ----- Filtering -----
	// Only include policies with a specific compliance status
	ComplianceStatus models.ComplianceStatus `json:"complianceStatus" validate:"omitempty,oneof=PASS FAIL ERROR"`

	// Only include policies whose ID or display name contains this case-insensitive substring
	NameContains string `json:"nameContains" validate:"max=1000"`

	// Only include policies which are enabled or disabled
	Enabled *bool `json:"enabled"`

	// Only include policies with or without auto-remediation enabled
	HasRemediation *bool `json:"hasRemediation"`

	// Only include policies which apply to one of these resource types
	ResourceTypes []string `json:"resourceTypes" validate:"max=500,dive,required,max=500"`

	// Only include policies with this severity
	Severity models.Severity `json:"severity" validate:"omitempty,oneof=INFO LOW MEDIUM HIGH CRITICAL"`

	// Only include policies with all of these tags (case-insensitive)
	Tags []string `json:"tags" validate:"max=500,dive,required,max=500"`

	// ----- Projection -----
	// Policy fields to return in the response (default: all)
	Fields []string `json:"fields" validate:"max=20,dive,required,max=100"`

	// ----- Sorting -----
	SortBy  string `json:"sortBy" validate:"omitempty,oneof=complianceStatus enabled id lastModified resourceTypes severity"`
	SortDir string `json:"sortDir" validate:"omitempty,oneof=ascending descending"`

	// ----- Paging -----
	PageSize int `json:"pageSize" validate:"min=0,max=1000"`
	Page     int `json:"page" validate:"min=0"`
}

type ListPoliciesOutput

type ListPoliciesOutput struct {
	Paging   Paging   `json:"paging"`
	Policies []Policy `json:"policies"`
}

type ListRulesInput

type ListRulesInput struct {
	// ----- Filtering -----
	// Only include rules whose ID or display name contains this case-insensitive substring
	NameContains string `json:"nameContains" validate:"max=1000"`

	// Only include rules which are enabled or disabled
	Enabled *bool `json:"enabled"`

	// Only include rules which apply to one of these log types
	LogTypes []string `json:"logTypes" validate:"max=500,dive,required,max=500"`

	// Only include policies with this severity
	Severity models.Severity `json:"severity" validate:"omitempty,oneof=INFO LOW MEDIUM HIGH CRITICAL"`

	// Only include policies with all of these tags (case-insensitive)
	Tags []string `json:"tags" validate:"max=500,dive,required,max=500"`

	// ----- Projection -----
	// Policy fields to return in the response (default: all)
	Fields []string `json:"fields" validate:"max=20,dive,required,max=100"`

	// ----- Sorting -----
	SortBy  string `json:"sortBy" validate:"omitempty,oneof=displayName enabled id lastModified logTypes severity"`
	SortDir string `json:"sortDir" validate:"omitempty,oneof=ascending descending"`

	// ----- Paging -----
	PageSize int `json:"pageSize" validate:"min=0,max=1000"`
	Page     int `json:"page" validate:"min=0"`
}

type ListRulesOutput

type ListRulesOutput struct {
	Paging Paging `json:"paging"`
	Rules  []Rule `json:"rules"`
}

type Paging

type Paging struct {
	ThisPage   int `json:"thisPage"`
	TotalPages int `json:"totalPages"`
	TotalItems int `json:"totalItems"`
}

type Policy

type Policy struct {
	AutoRemediationID         string                  `json:"autoRemediationId" validate:"max=1000"`
	AutoRemediationParameters map[string]string       `json:"autoRemediationParameters" validte:"max=500"`
	Body                      string                  `json:"body" validate:"required,max=100000"`
	ComplianceStatus          models.ComplianceStatus `json:"complianceStatus"`
	CreatedAt                 time.Time               `json:"createdAt"`
	CreatedBy                 string                  `json:"createdBy"`
	Description               string                  `json:"description" validate:"max=10000"`
	DisplayName               string                  `json:"displayName" validate:"max=1000,excludesall='<>&\""`
	Enabled                   bool                    `json:"enabled"`
	ID                        string                  `json:"id" validate:"required,max=1000,excludesall='<>&\""`
	LastModified              time.Time               `json:"lastModified"`
	LastModifiedBy            string                  `json:"lastModifiedBy"`
	OutputIDs                 []string                `json:"outputIds" validate:"max=500,dive,required,max=5000"`
	Reference                 string                  `json:"reference" validate:"max=10000"`
	Reports                   map[string][]string     `json:"reports" validate:"max=500"`
	ResourceTypes             []string                `json:"resourceTypes" validate:"max=500,dive,required,max=500"`
	Runbook                   string                  `json:"runbook" validate:"max=10000"`
	Severity                  models.Severity         `json:"severity" validate:"oneof=INFO LOW MEDIUM HIGH CRITICAL"`
	Suppressions              []string                `json:"suppressions" validate:"max=500,dive,required,max=1000"`
	Tags                      []string                `json:"tags" validate:"max=500,dive,required,max=1000"`
	Tests                     []UnitTest              `json:"tests" validate:"max=500,dive"`
	VersionID                 string                  `json:"versionId"`
}

The validate tags here are used by BulkUpload

type Rule

type Rule struct {
	Body               string              `json:"body"`
	CreatedAt          time.Time           `json:"createdAt"`
	CreatedBy          string              `json:"createdBy"`
	DedupPeriodMinutes int                 `json:"dedupPeriodMinutes"`
	Description        string              `json:"description"`
	DisplayName        string              `json:"displayName"`
	Enabled            bool                `json:"enabled"`
	ID                 string              `json:"id"`
	LastModified       time.Time           `json:"lastModified"`
	LastModifiedBy     string              `json:"lastModifiedBy"`
	LogTypes           []string            `json:"logTypes"`
	OutputIDs          []string            `json:"outputIds"`
	Reference          string              `json:"reference"`
	Reports            map[string][]string `json:"reports"`
	Runbook            string              `json:"runbook"`
	Severity           models.Severity     `json:"severity"`
	Tags               []string            `json:"tags"`
	Tests              []UnitTest          `json:"tests"`
	Threshold          int                 `json:"threshold"`
	VersionID          string              `json:"versionId"`
}

type SuppressInput

type SuppressInput struct {
	PolicyIDs []string `json:"policyIds" validate:"min=1,dive,required,max=1000"`

	// List of resource ID regexes that are excepted from the policy.
	// The policy will still be evaluated, but failures will not trigger alerts nor remediations
	ResourcePatterns []string `json:"resourcePatterns" validate:"min=1,dive,required,max=10000"`
}

type TestDetectionSubRecord

type TestDetectionSubRecord struct {
	Output *string    `json:"output"`
	Error  *TestError `json:"error"`
}

type TestError

type TestError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type TestPolicyInput

type TestPolicyInput struct {
	Body          string     `json:"body" validate:"required,max=100000"`
	ResourceTypes []string   `json:"resourceTypes" validate:"max=500,dive,required,max=500"`
	Tests         []UnitTest `json:"tests" validate:"max=500,dive"`
}

type TestPolicyOutput

type TestPolicyOutput struct {
	Results []TestPolicyRecord `json:"results"`
}

type TestPolicyRecord

type TestPolicyRecord struct {
	ID        string                    `json:"id"`
	Name      string                    `json:"name"`
	Passed    bool                      `json:"passed"`
	Functions TestPolicyRecordFunctions `json:"functions"`
	Error     *TestError                `json:"error"`
}

type TestPolicyRecordFunctions

type TestPolicyRecordFunctions struct {
	Policy TestDetectionSubRecord `json:"policyFunction"`
}

type TestRuleInput

type TestRuleInput struct {
	Body     string     `json:"body" validate:"required,max=100000"`
	LogTypes []string   `json:"logTypes" validate:"max=500,dive,required,max=500"`
	Tests    []UnitTest `json:"tests" validate:"max=500,dive"`
}

type TestRuleOutput

type TestRuleOutput struct {
	Results []TestRuleRecord `json:"results"`
}

type TestRuleRecord

type TestRuleRecord struct {
	ID        string                  `json:"id"`
	Name      string                  `json:"name"`
	Passed    bool                    `json:"passed"`
	Functions TestRuleRecordFunctions `json:"functions"`

	// An error produced before running any of the rule functions, like import or syntax error.
	Error *TestError `json:"error"`
}

type TestRuleRecordFunctions

type TestRuleRecordFunctions struct {
	Rule                *TestDetectionSubRecord `json:"ruleFunction"`
	Title               *TestDetectionSubRecord `json:"titleFunction"`
	Dedup               *TestDetectionSubRecord `json:"dedupFunction"`
	AlertContext        *TestDetectionSubRecord `json:"alertContextFunction"`
	Description         *TestDetectionSubRecord `json:"descriptionFunction"`
	DestinationOverride *TestDetectionSubRecord `json:"destinationOverrideFunction"`
	Reference           *TestDetectionSubRecord `json:"referenceFunction"`
	Runbook             *TestDetectionSubRecord `json:"runbookFunction"`
	Severity            *TestDetectionSubRecord `json:"severityFunction"`
}

type UnitTest

type UnitTest struct {
	ExpectedResult bool   `json:"expectedResult"`
	Name           string `json:"name" validate:"required"`
	Resource       string `json:"resource" validate:"required"`
}

type UpdateDataModelInput

type UpdateDataModelInput struct {
	Body        string             `json:"body" validate:"omitempty,max=100000"` // not required
	Description string             `json:"description" validate:"max=10000"`
	DisplayName string             `json:"displayName" validate:"max=1000,excludesall='<>&\""`
	Enabled     bool               `json:"enabled"`
	ID          string             `json:"id" validate:"required,max=1000,excludesall='<>&\""`
	LogTypes    []string           `json:"logTypes" validate:"len=1,dive,required,max=500"` // for now, only one logtype allowed
	Mappings    []DataModelMapping `json:"mappings" validate:"min=1,max=500,dive"`
	UserID      string             `json:"userId" validate:"required"`
}

type UpdateGlobalInput

type UpdateGlobalInput struct {
	Body        string   `json:"body" validate:"required,max=100000"`
	Description string   `json:"description" validate:"max=10000"`
	ID          string   `json:"id" validate:"required,max=1000,excludesall='<>&\""`
	Tags        []string `json:"tags" validate:"max=500,dive,required,max=1000"`
	UserID      string   `json:"userId" validate:"required"`
}

type UpdatePolicyInput

type UpdatePolicyInput struct {
	AutoRemediationID         string              `json:"autoRemediationId" validate:"max=1000"`
	AutoRemediationParameters map[string]string   `json:"autoRemediationParameters" validate:"max=500"`
	Body                      string              `json:"body" validate:"required,max=100000"`
	Description               string              `json:"description" validate:"max=10000"`
	DisplayName               string              `json:"displayName" validate:"max=1000,excludesall='<>&\""`
	Enabled                   bool                `json:"enabled"`
	ID                        string              `json:"id" validate:"required,max=1000,excludesall='<>&\""`
	OutputIDs                 []string            `json:"outputIds" validate:"max=500,dive,required,max=5000"`
	Reference                 string              `json:"reference" validate:"max=10000"`
	Reports                   map[string][]string `json:"reports" validate:"max=500"`
	ResourceTypes             []string            `json:"resourceTypes" validate:"max=500,dive,required,max=500"`
	Runbook                   string              `json:"runbook" validate:"max=10000"`
	Severity                  models.Severity     `json:"severity" validate:"oneof=INFO LOW MEDIUM HIGH CRITICAL"`
	Suppressions              []string            `json:"suppressions" validate:"max=500,dive,required,max=1000"`
	Tags                      []string            `json:"tags" validate:"max=500,dive,required,max=1000"`
	Tests                     []UnitTest          `json:"tests" validate:"max=500,dive"`
	UserID                    string              `json:"userId" validate:"required"`
}

type UpdateRuleInput

type UpdateRuleInput struct {
	Body               string              `json:"body" validate:"required,max=100000"`
	DedupPeriodMinutes int                 `json:"dedupPeriodMinutes" validate:"min=0"`
	Description        string              `json:"description" validate:"max=10000"`
	DisplayName        string              `json:"displayName" validate:"max=1000,excludesall='<>&\""`
	Enabled            bool                `json:"enabled"`
	ID                 string              `json:"id" validate:"required,max=1000,excludesall='<>&\""`
	LogTypes           []string            `json:"logTypes" validate:"max=500,dive,required,max=500"`
	OutputIDs          []string            `json:"outputIds" validate:"max=500,dive,required,max=5000"`
	Reference          string              `json:"reference" validate:"max=10000"`
	Reports            map[string][]string `json:"reports" validate:"max=500"`
	Runbook            string              `json:"runbook" validate:"max=10000"`
	Severity           models.Severity     `json:"severity" validate:"oneof=INFO LOW MEDIUM HIGH CRITICAL"`
	Tags               []string            `json:"tags" validate:"max=500,dive,required,max=1000"`
	Tests              []UnitTest          `json:"tests" validate:"max=500,dive"`
	Threshold          int                 `json:"threshold" validate:"min=0"`
	UserID             string              `json:"userId" validate:"required"`
}

Jump to

Keyboard shortcuts

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