securityattributes

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package securityattributes implements MCP tools for GitLab security attributes.

The package exposes catalog-backed actions for creating, updating, deleting, assigning, and bulk-applying attributes that GitLab uses to classify projects and groups for security workflows. Handlers validate numeric identifiers, security category references, hex color values, and bulk update modes before issuing GraphQL mutations through the GitLab client.

Security attributes are available only on GitLab tiers and deployments that expose the underlying GraphQL security attribute schema. The package keeps the GraphQL payloads local so the MCP action catalog, dynamic search surface, and Markdown formatters all share the same typed input and output structures.

GitLab API docs:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

ActionSpecs returns canonical specs for security attribute actions.

func Delete

Delete deletes a GitLab security attribute.

func FormatBulkUpdateMarkdown

func FormatBulkUpdateMarkdown(out BulkUpdateOutput) string

FormatBulkUpdateMarkdown renders bulk security attribute update results.

func FormatCreateMarkdown

func FormatCreateMarkdown(out CreateOutput) string

FormatCreateMarkdown renders created security attributes as Markdown.

func FormatOutputMarkdown

func FormatOutputMarkdown(out Output) string

FormatOutputMarkdown renders a security attribute as Markdown.

func FormatProjectUpdateMarkdown

func FormatProjectUpdateMarkdown(out ProjectUpdateOutput) string

FormatProjectUpdateMarkdown renders project security attribute update results.

Types

type AttributeInput

type AttributeInput struct {
	Name        string `json:"name"                  jsonschema:"Security attribute name,required"`
	Description string `json:"description"           jsonschema:"Security attribute description,required"`
	Color       string `json:"color"                 jsonschema:"Security attribute color as a hex code (e.g. #FF0000),required"`
}

AttributeInput defines one security attribute to create.

type BulkUpdateInput

type BulkUpdateInput struct {
	GroupIDs     []int64        `json:"group_ids,omitempty"     jsonschema:"Numeric group IDs to update"`
	ProjectIDs   []int64        `json:"project_ids,omitempty"   jsonschema:"Numeric project IDs to update"`
	AttributeIDs []int64        `json:"attribute_ids"           jsonschema:"Security attribute IDs to apply,required"`
	Mode         BulkUpdateMode `json:"mode"                    jsonschema:"Bulk update mode: ADD, REMOVE, or REPLACE,required"`
}

BulkUpdateInput defines parameters for applying attributes to groups and projects in bulk.

type BulkUpdateMode

type BulkUpdateMode string

BulkUpdateMode is the mode used when applying security attributes in bulk.

const (
	// BulkUpdateModeAdd adds attributes while preserving existing assignments.
	BulkUpdateModeAdd BulkUpdateMode = "ADD"
	// BulkUpdateModeRemove removes attributes from the selected items.
	BulkUpdateModeRemove BulkUpdateMode = "REMOVE"
	// BulkUpdateModeReplace replaces existing assignments with the supplied attributes.
	BulkUpdateModeReplace BulkUpdateMode = "REPLACE"
)

type BulkUpdateOutput

type BulkUpdateOutput struct {
	toolutil.HintableOutput
	Status       string         `json:"status"`
	Message      string         `json:"message"`
	Mode         BulkUpdateMode `json:"mode"`
	GroupIDs     []int64        `json:"group_ids,omitempty"`
	ProjectIDs   []int64        `json:"project_ids,omitempty"`
	AttributeIDs []int64        `json:"attribute_ids"`
}

BulkUpdateOutput confirms a bulk security attribute update.

func BulkUpdate

func BulkUpdate(ctx context.Context, client *gitlabclient.Client, input BulkUpdateInput) (BulkUpdateOutput, error)

BulkUpdate adds, removes, or replaces security attributes on groups and projects.

type CategorySummary

type CategorySummary struct {
	ID                int64  `json:"id"`
	Name              string `json:"name"`
	Description       string `json:"description,omitempty"`
	MultipleSelection bool   `json:"multiple_selection"`
	EditableState     string `json:"editable_state,omitempty"`
	TemplateType      string `json:"template_type,omitempty"`
}

CategorySummary represents the security category attached to an attribute.

type CreateInput

type CreateInput struct {
	NamespaceID int64            `json:"namespace_id"          jsonschema:"Numeric namespace ID,required"`
	CategoryID  int64            `json:"category_id"           jsonschema:"Numeric security category ID,required"`
	Attributes  []AttributeInput `json:"attributes"            jsonschema:"Security attributes to create,required"`
}

CreateInput defines parameters for creating security attributes.

type CreateOutput

type CreateOutput struct {
	toolutil.HintableOutput
	Attributes []Output `json:"attributes"`
}

CreateOutput contains security attributes created by one request.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (CreateOutput, error)

Create creates one or more GitLab security attributes.

type DeleteInput

type DeleteInput struct {
	AttributeID int64 `json:"attribute_id" jsonschema:"Numeric security attribute ID,required"`
}

DeleteInput defines parameters for deleting a security attribute.

type Output

type Output struct {
	toolutil.HintableOutput
	ID               int64            `json:"id"`
	Name             string           `json:"name"`
	Color            string           `json:"color"`
	Description      string           `json:"description,omitempty"`
	EditableState    string           `json:"editable_state,omitempty"`
	SecurityCategory *CategorySummary `json:"security_category,omitempty"`
}

Output represents a GitLab security attribute.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update updates a GitLab security attribute.

type ProjectUpdateInput

type ProjectUpdateInput struct {
	ProjectID          int64   `json:"project_id"                    jsonschema:"Numeric project ID,required"`
	AddAttributeIDs    []int64 `json:"add_attribute_ids,omitempty"    jsonschema:"Security attribute IDs to add"`
	RemoveAttributeIDs []int64 `json:"remove_attribute_ids,omitempty" jsonschema:"Security attribute IDs to remove"`
}

ProjectUpdateInput defines parameters for adding or removing attributes on a project.

type ProjectUpdateOutput

type ProjectUpdateOutput struct {
	toolutil.HintableOutput
	AddedCount   int64 `json:"added_count"`
	RemovedCount int64 `json:"removed_count"`
}

ProjectUpdateOutput reports how many security attributes changed on a project.

func ProjectUpdate

func ProjectUpdate(ctx context.Context, client *gitlabclient.Client, input ProjectUpdateInput) (ProjectUpdateOutput, error)

ProjectUpdate adds or removes security attributes on a GitLab project.

type UpdateInput

type UpdateInput struct {
	AttributeID int64   `json:"attribute_id"           jsonschema:"Numeric security attribute ID,required"`
	Name        *string `json:"name,omitempty"         jsonschema:"New security attribute name"`
	Description *string `json:"description,omitempty"  jsonschema:"New security attribute description"`
	Color       *string `json:"color,omitempty"        jsonschema:"New security attribute color as a hex code (e.g. #FF0000)"`
}

UpdateInput defines parameters for updating a security attribute.

Jump to

Keyboard shortcuts

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