cli

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTeamNotFound = errors.New("Team not found")
)

Functions

func DereferenceBool

func DereferenceBool(b *bool) bool

func DereferenceString

func DereferenceString(p *string) string

func PtrString

func PtrString(s string) *string

func ReadLines

func ReadLines(path string) ([]string, error)

ReadLines reads a whole file into memory and returns a slice of its lines.

Types

type Asset

type Asset struct {
	ID        string
	Target    string
	AssetType string
	Sensitive bool
	Rolfp     string
	Alias     string
}

func (*Asset) String

func (a *Asset) String() string

type Assets

type Assets []*Asset

func ReadLocalAssets

func ReadLocalAssets(teamDirectory string) (Assets, error)

func (Assets) Find

func (as Assets) Find(ID string) (*Asset, bool)

func (Assets) FindByTarget

func (as Assets) FindByTarget(target string) (*Asset, bool)

func (Assets) IsDupped

func (as Assets) IsDupped(target, assetType, id string) bool

func (Assets) String

func (a Assets) String() string

func (Assets) WriteLocal

func (a Assets) WriteLocal(teamDirectory string) error

type AssetsByType

type AssetsByType struct {
	AssetType string
	Assets    []*Asset
}

func ReadVulcanitoCollections

func ReadVulcanitoCollections(vulcanitoTeamDir string) ([]AssetsByType, error)

type AssociationOp

type AssociationOp struct {
	Asset    *Asset
	NewGroup *Group
	Team     *Team

	Op
}

func (AssociationOp) Apply

func (o AssociationOp) Apply() error

func (AssociationOp) String

func (o AssociationOp) String() string

type CLI

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

func NewCLI

func NewCLI(ctx context.Context, cfg Config, logger *log.Logger) *CLI

func (*CLI) AddProgramsToPolicies

func (cli *CLI) AddProgramsToPolicies(programs Programs, policies Policies)

func (*CLI) AddRecipients

func (cli *CLI) AddRecipients(teamID string, recipients []Recipient) error

func (*CLI) Assets

func (cli *CLI) Assets(teamID string) (Assets, error)

func (*CLI) AssociateAsset

func (cli *CLI) AssociateAsset(teamID, groupID, assetID string) error

func (*CLI) Coverage

func (cli *CLI) Coverage(teamID string) (Coverage, error)

func (*CLI) CreateAsset

func (cli *CLI) CreateAsset(teamID, target, assetType, rolfp, alias string) (Assets, error)

func (*CLI) CreateGroup

func (cli *CLI) CreateGroup(teamID, name string) (string, error)

func (*CLI) CreateMember

func (cli *CLI) CreateMember(teamID, email, role string) (string, error)

func (*CLI) CreateTeam

func (cli *CLI) CreateTeam(t *Team) (string, error)

func (*CLI) DeassociateAsset

func (cli *CLI) DeassociateAsset(teamID, groupID, assetID string) error

func (*CLI) DeleteAsset

func (cli *CLI) DeleteAsset(teamID, assetID string) error

func (*CLI) DeleteMember

func (cli *CLI) DeleteMember(teamID, userID string) error

func (*CLI) DuppedAssets

func (cli *CLI) DuppedAssets(assets Assets) (DuppedAssets, error)

func (*CLI) Findings

func (cli *CLI) Findings(teamID string, minScore float64, status *string) ([]*Finding, error)

func (*CLI) ForeignAssets

func (cli *CLI) ForeignAssets(assets Assets, groups Groups) (ForeignAssets, error)

func (*CLI) Groups

func (cli *CLI) Groups(teamID string) (Groups, error)

func (*CLI) LaunchScan

func (cli *CLI) LaunchScan(t *Team, programID string) (*Scan, error)

func (*CLI) Members

func (cli *CLI) Members(teamID string) (Members, error)

func (*CLI) OrphanAssets

func (cli *CLI) OrphanAssets(assets Assets, groups Groups) (OrphanAssets, error)

func (*CLI) Policies

func (cli *CLI) Policies(teamID string) (Policies, error)

func (*CLI) Program

func (cli *CLI) Program(teamID, programID string) (*Program, error)

func (*CLI) ProgramByName

func (cli *CLI) ProgramByName(teamName, programName string) (*Program, error)

func (*CLI) Programs

func (cli *CLI) Programs(teamID string) (Programs, error)

func (*CLI) Recipients

func (cli *CLI) Recipients(teamID string) (Recipients, error)

func (*CLI) RefreshScan

func (cli *CLI) RefreshScan(s *Scan) (*Scan, error)

func (*CLI) ReportEmail

func (cli *CLI) ReportEmail(teamName string, scanID string) (string, error)

func (*CLI) Scan

func (cli *CLI) Scan(teamID, scanID string) (*Scan, error)

func (*CLI) SendReport

func (cli *CLI) SendReport(teamName string, scanID string) error

func (*CLI) Settings

func (cli *CLI) Settings(teamID, policyID string) (SettingsCollection, error)

func (*CLI) TeamByName

func (cli *CLI) TeamByName(name string) (*Team, error)

func (*CLI) Teams

func (cli *CLI) Teams() ([]*Team, error)

func (*CLI) Unassigned

func (cli *CLI) Unassigned(users Users, teams []*Team) (Unassigned, error)

func (*CLI) UpdateAsset

func (cli *CLI) UpdateAsset(teamID, ID, rolfp string, alias string) error

func (*CLI) UpdateMember

func (cli *CLI) UpdateMember(teamID, userID, role string) error

func (*CLI) UpdateSchedule

func (cli *CLI) UpdateSchedule(teamID, programID, cron string) error

func (*CLI) UpdateTeamInfo

func (cli *CLI) UpdateTeamInfo(t *Team) error

func (*CLI) Users

func (cli *CLI) Users() (Users, error)

type Config

type Config struct {
	Key     string
	Format  string
	Scheme  string
	Host    string
	Timeout time.Duration
	Dump    bool
}

type Coverage

type Coverage float64

func (Coverage) String

func (c Coverage) String() string

func (Coverage) WriteLocal

func (c Coverage) WriteLocal(directory string) error

type CreateAssetOp

type CreateAssetOp struct {
	NewAsset *Asset
	Group    *Group
	Team     *Team

	Op
}

func (CreateAssetOp) Apply

func (o CreateAssetOp) Apply() error

func (CreateAssetOp) String

func (o CreateAssetOp) String() string

type CreateGroupOp

type CreateGroupOp struct {
	NewGroup *Group
	Team     *Team

	Op
}

func (CreateGroupOp) Apply

func (o CreateGroupOp) Apply() error

func (CreateGroupOp) String

func (o CreateGroupOp) String() string

type CreateMemberOp

type CreateMemberOp struct {
	NewMember *Member
	Team      *Team

	Op
}

func (CreateMemberOp) Apply

func (o CreateMemberOp) Apply() error

func (CreateMemberOp) String

func (o CreateMemberOp) String() string

type DeassociationOp

type DeassociationOp struct {
	Asset    *Asset
	OldGroup *Group
	Team     *Team

	Op
}

func (DeassociationOp) Apply

func (o DeassociationOp) Apply() error

func (DeassociationOp) String

func (o DeassociationOp) String() string

type DeleteAssetOp

type DeleteAssetOp struct {
	Asset *Asset
	Team  *Team
	Op
}

func (DeleteAssetOp) Apply

func (o DeleteAssetOp) Apply() error

func (DeleteAssetOp) String

func (o DeleteAssetOp) String() string

type DeleteMemberOp

type DeleteMemberOp struct {
	Member *Member
	Team   *Team

	Op
}

func (DeleteMemberOp) Apply

func (o DeleteMemberOp) Apply() error

func (DeleteMemberOp) String

func (o DeleteMemberOp) String() string

type DuppedAssets

type DuppedAssets struct {
	Assets
}

func ReadLocalDuppedAssets

func ReadLocalDuppedAssets(teamDirectory string) (DuppedAssets, error)

func (DuppedAssets) WriteLocal

func (d DuppedAssets) WriteLocal(teamDirectory string) error

type ErrorVulcanAPI

type ErrorVulcanAPI struct {
	Code int
	Err  string `json:"error"`
	Type string
}

func (ErrorVulcanAPI) Error

func (v ErrorVulcanAPI) Error() string

func (ErrorVulcanAPI) String

func (v ErrorVulcanAPI) String() string

type Finding

type Finding struct {
	Summary   string
	Score     float64
	Target    string
	Checktype string
}

type ForeignAssets

type ForeignAssets struct {
	Assets
}

func ReadLocalForeignAssets

func ReadLocalForeignAssets(teamDirectory string) (ForeignAssets, error)

func (ForeignAssets) WriteLocal

func (o ForeignAssets) WriteLocal(teamDirectory string) error

type Group

type Group struct {
	ID     string
	Name   string
	Assets Assets
}

func ReadLocalGroup

func ReadLocalGroup(path string) (*Group, error)

func (*Group) FindAssetByID

func (g *Group) FindAssetByID(ID string) (*Asset, bool)

func (*Group) WriteLocal

func (g *Group) WriteLocal(groupsDirectory string) error

type Groups

type Groups []*Group

func ReadLocalGroups

func ReadLocalGroups(groupsDirectory string) (Groups, error)

func (Groups) FindByName

func (gs Groups) FindByName(name string) (*Group, bool)

func (Groups) WriteLocal

func (g Groups) WriteLocal(groupsDirectory string) error

type Info

type Info struct {
	Description string
	Tag         string
}

type Journal

type Journal struct {
	LocalTeams  map[string]*Team
	RemoteTeams map[string]*Team

	UpdatedTeams        []UpdateTeamInfoOp
	UpdatedRecipients   []UpdateRecipientsOp
	NewMembers          []CreateMemberOp
	DeletedMembers      []DeleteMemberOp
	UpdatedMembers      []UpdateMemberOp
	NewGroups           []CreateGroupOp
	NewAssets           []CreateAssetOp
	UpdateAssets        []UpdateAssetOp
	NewAssociations     []AssociationOp
	DeletedAssociations []DeassociationOp
	DeleteAssets        []DeleteAssetOp

	UpdatedPrograms []UpdateProgramOp
	// contains filtered or unexported fields
}

func NewJournal

func NewJournal(localTeams []*Team, remoteTeams []*Team, cli *CLI) (*Journal, error)

func (*Journal) Apply

func (j *Journal) Apply() error

func (*Journal) BuildModifications

func (j *Journal) BuildModifications() error

func (*Journal) BuildPruneModifications

func (j *Journal) BuildPruneModifications()

func (*Journal) GuessAssetsToAssociate

func (j *Journal) GuessAssetsToAssociate() ([]AssociationOp, error)

func (*Journal) GuessAssetsToCreate

func (j *Journal) GuessAssetsToCreate() ([]CreateAssetOp, error)

func (*Journal) GuessAssetsToDeassociate

func (j *Journal) GuessAssetsToDeassociate() ([]DeassociationOp, error)

func (*Journal) GuessAssetsToUpdate

func (j *Journal) GuessAssetsToUpdate() ([]UpdateAssetOp, error)

func (*Journal) GuessGroupsToCreate

func (j *Journal) GuessGroupsToCreate() ([]CreateGroupOp, error)

func (*Journal) GuessMembersToCreate

func (j *Journal) GuessMembersToCreate() ([]CreateMemberOp, error)

func (*Journal) GuessMembersToDelete

func (j *Journal) GuessMembersToDelete() ([]DeleteMemberOp, error)

func (*Journal) GuessMembersToUpdate

func (j *Journal) GuessMembersToUpdate() ([]UpdateMemberOp, error)

func (*Journal) GuessProgramsToUpdate

func (j *Journal) GuessProgramsToUpdate() ([]UpdateProgramOp, error)

func (*Journal) GuessRecipientsToUpdate

func (j *Journal) GuessRecipientsToUpdate() ([]UpdateRecipientsOp, error)

func (*Journal) GuessTeamsToUpdate

func (j *Journal) GuessTeamsToUpdate() ([]UpdateTeamInfoOp, error)

func (*Journal) String

func (j *Journal) String() string

type Member

type Member struct {
	User

	Role string
}

func (*Member) String

func (m *Member) String() string

type Members

type Members []*Member

func ReadLocalMembers

func ReadLocalMembers(teamDirectory string) (Members, error)

func (Members) Find

func (ms Members) Find(email string) (*Member, bool)

func (Members) String

func (m Members) String() string

func (Members) WriteLocal

func (m Members) WriteLocal(teamDirectory string) error

type Op

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

type OrphanAssets

type OrphanAssets struct {
	Assets
}

func ReadLocalOrphanAssets

func ReadLocalOrphanAssets(teamDirectory string) (OrphanAssets, error)

func (OrphanAssets) WriteLocal

func (o OrphanAssets) WriteLocal(teamDirectory string) error

type Policies

type Policies []*Policy

func ReadLocalPolicies

func ReadLocalPolicies(policiesDirectory string) (Policies, error)

func (Policies) Find

func (p Policies) Find(ID string) (*Policy, bool)

func (Policies) WriteLocal

func (p Policies) WriteLocal(policiesDirectory string) error

type Policy

type Policy struct {
	ID       string
	Name     string
	Settings SettingsCollection
	Programs Programs
}

func ReadLocalPolicy

func ReadLocalPolicy(path string) (*Policy, error)

func (*Policy) WriteLocal

func (p *Policy) WriteLocal(policiesDirectory string) error

type PolicyGroup

type PolicyGroup struct {
	GroupID  string `json:"group_id,omitempty"`
	PolicyID string `json:"policy_id,omitempty"`
}

type Program

type Program struct {
	ID           string
	Name         string
	Cron         string
	Autosend     bool
	PolicyGroups []PolicyGroup
}

func (*Program) String

func (p *Program) String() string

type Programs

type Programs []*Program

func ReadLocalPrograms

func ReadLocalPrograms(teamDirectory string) (Programs, error)

func (Programs) Find

func (p Programs) Find(ID string) (*Program, bool)

func (Programs) String

func (p Programs) String() string

func (Programs) WriteLocal

func (p Programs) WriteLocal(directory string) error

type Recipient

type Recipient struct {
	Email string
}

type Recipients

type Recipients []Recipient

func ReadLocalRecipients

func ReadLocalRecipients(teamDirectory string) (Recipients, error)

func ReadVulcanitoRecipients

func ReadVulcanitoRecipients(vulcanitoTeamDir string) (Recipients, error)

func (Recipients) String

func (r Recipients) String() string

func (Recipients) WriteLocal

func (r Recipients) WriteLocal(teamDirectory string) error

type Scan

type Scan struct {
	ID      string
	Status  string
	Team    string
	Program string
}

func ParseScan

func ParseScan(s string) (*Scan, error)

func (*Scan) String

func (s *Scan) String() string

type Scans

type Scans []*Scan

func ParseScans

func ParseScans(path string) (Scans, error)

func (Scans) String

func (s Scans) String() string

type Settings

type Settings struct {
	ID      string
	Name    string
	Options string
}

func ReadLocalSettings

func ReadLocalSettings(path string) (*Settings, error)

func (*Settings) WriteLocal

func (s *Settings) WriteLocal(settingsDirectory string) error

type SettingsCollection

type SettingsCollection []*Settings

func ReadLocalSettingsCollection

func ReadLocalSettingsCollection(settingsDirectory string) (SettingsCollection, error)

func (SettingsCollection) WriteLocal

func (s SettingsCollection) WriteLocal(settingsDirectory string) error

type Team

type Team struct {
	Info

	ID            string
	Name          string
	Recipients    Recipients
	Members       Members
	Groups        Groups
	Collections   []AssetsByType
	OrphanAssets  OrphanAssets
	ForeignAssets ForeignAssets
	Assets        Assets
	DuppedAssets  DuppedAssets
	Policies      Policies
	Programs      Programs
	Coverage      Coverage
}

func ReadLocalTeam

func ReadLocalTeam(teamDirectory string) (*Team, error)

func ReadLocalTeams

func ReadLocalTeams(localTeamsRootDir string) ([]*Team, error)

func ReadVulcanitoTeams

func ReadVulcanitoTeams(vulcanitoTeamsRootDir string) ([]*Team, error)

func (*Team) String

func (t *Team) String() string

func (*Team) WriteLocal

func (t *Team) WriteLocal(teamDirectory string) error

type Unassigned

type Unassigned struct {
	Users
}

func (Unassigned) WriteLocal

func (u Unassigned) WriteLocal(teamsDirectory string) error

type UpdateAssetOp

type UpdateAssetOp struct {
	NewAsset *Asset
	OldAsset *Asset
	Team     *Team

	Op
}

func (UpdateAssetOp) Apply

func (o UpdateAssetOp) Apply() error

func (UpdateAssetOp) String

func (o UpdateAssetOp) String() string

type UpdateMemberOp

type UpdateMemberOp struct {
	NewMember *Member
	OldMember *Member
	Team      *Team

	Op
}

func (UpdateMemberOp) Apply

func (o UpdateMemberOp) Apply() error

func (UpdateMemberOp) String

func (o UpdateMemberOp) String() string

type UpdateProgramOp

type UpdateProgramOp struct {
	NewProgram *Program
	OldProgram *Program
	Team       *Team

	Op
}

func (UpdateProgramOp) Apply

func (o UpdateProgramOp) Apply() error

func (UpdateProgramOp) String

func (o UpdateProgramOp) String() string

type UpdateRecipientsOp

type UpdateRecipientsOp struct {
	NewRecipients Recipients
	OldRecipients Recipients
	Team          *Team

	Op
}

func (UpdateRecipientsOp) Apply

func (o UpdateRecipientsOp) Apply() error

func (UpdateRecipientsOp) String

func (o UpdateRecipientsOp) String() string

type UpdateTeamInfoOp

type UpdateTeamInfoOp struct {
	NewInfo Info
	OldInfo Info

	Team *Team

	Op
}

func (UpdateTeamInfoOp) Apply

func (o UpdateTeamInfoOp) Apply() error

func (UpdateTeamInfoOp) String

func (o UpdateTeamInfoOp) String() string

type User

type User struct {
	ID        string
	Firstname string
	Lastname  string
	Email     string
	Admin     bool
	Observer  bool
	Active    bool
}

func (*User) String

func (u *User) String() string

type Users

type Users []*User

func (Users) String

func (u Users) String() string

func (Users) WriteLocal

func (u Users) WriteLocal(teamsDirectory string) error

Jump to

Keyboard shortcuts

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