commandargs

package
v14.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package commandargs defines structures and methods for handling command-line arguments related to authorized key checks in the GitLab shell.

Package commandargs provides functionality for handling and parsing command-line arguments related to authorized principals for GitLab shell commands.

Package commandargs defines types and interfaces for handling command-line arguments in GitLab shell commands.

Package commandargs provides functionality to handle and parse command-line arguments for various GitLab shell commands, including SSH arguments and command types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOnlySSHAllowed - represents the error returned when the
	// a non ssh connection is passed.
	ErrOnlySSHAllowed = errors.New("Only SSH allowed") //nolint:staticcheck // message is customer facing
)
View Source
var (

	// List of Git commands that are handled in a special way
	GitCommands = []CommandType{LfsAuthenticate, UploadPack, ReceivePack, UploadArchive}
)

Regular expressions for parsing key IDs and usernames from arguments

Functions

This section is empty.

Types

type AuthorizedKeys

type AuthorizedKeys struct {
	Arguments    []string
	ExpectedUser string
	ActualUser   string
	Key          string
}

AuthorizedKeys holds the arguments and user information for key authorization checks.

func (*AuthorizedKeys) GetArguments

func (ak *AuthorizedKeys) GetArguments() []string

GetArguments returns the list of command-line arguments.

func (*AuthorizedKeys) Parse

func (ak *AuthorizedKeys) Parse() error

Parse parses and validates the arguments, setting ExpectedUser, ActualUser, and Key.

type AuthorizedPrincipals

type AuthorizedPrincipals struct {
	Arguments  []string
	KeyID      string
	Principals []string
}

AuthorizedPrincipals holds the arguments for checking authorized principals and the key ID.

func (*AuthorizedPrincipals) GetArguments

func (ap *AuthorizedPrincipals) GetArguments() []string

GetArguments returns the list of command-line arguments provided.

func (*AuthorizedPrincipals) Parse

func (ap *AuthorizedPrincipals) Parse() error

Parse validates and extracts the key ID and principals from the Arguments slice. Returns an error if validation fails.

type CommandArgs

type CommandArgs interface {
	Parse() error
	GetArguments() []string
}

CommandArgs is an interface for parsing and accessing command-line arguments.

type CommandType

type CommandType string

CommandType represents a type of command identified by a string.

const (
	Discover            CommandType = "discover"
	TwoFactorRecover    CommandType = "2fa_recovery_codes"
	TwoFactorVerify     CommandType = "2fa_verify"
	LfsAuthenticate     CommandType = "git-lfs-authenticate"
	LfsTransfer         CommandType = "git-lfs-transfer"
	ReceivePack         CommandType = "git-receive-pack"
	UploadPack          CommandType = "git-upload-pack"
	UploadArchive       CommandType = "git-upload-archive"
	PersonalAccessToken CommandType = "personal_access_token"
)

Define supported command types

type Shell

type Shell struct {
	Arguments           []string
	GitlabUsername      string
	GitlabKeyID         string
	GitlabKrb5Principal string
	SSHArgs             []string
	CommandType         CommandType
	Env                 sshenv.Env
}

Shell represents a parsed shell command with its arguments and related information.

func (*Shell) GetArguments

func (s *Shell) GetArguments() []string

GetArguments returns the list of command-line arguments.

func (*Shell) Parse

func (s *Shell) Parse() error

Parse validates and parses the command-line arguments and SSH environment.

func (*Shell) ParseCommand

func (s *Shell) ParseCommand(commandString string) error

ParseCommand parses the command string into a slice of arguments.

func (*Shell) UserArgs added in v14.51.0

func (s *Shell) UserArgs() topology.UserArgs

UserArgs returns the topology.UserArgs for this shell session's identity fields. This centralizes the mapping from Shell identity fields to the topology resolution parameters, so callers don't need to construct UserArgs inline.

Jump to

Keyboard shortcuts

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