cli

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 19 Imported by: 0

README

vulcan-core-cli

This repository contains:

  1. A tool to execute and monitor Vulcan checks using the Vulcan Core API.

  2. A package with a go client to REST vulcan-core api. Import path: github.com/adevinta/vulcan-core-cli/vulcan-core/client

  3. A swagger specification of the vulcan core api. Thar spec can be found in: github.com/adevinta/vulcan-core-cli/_resources/swagger.yaml

Installing the cli.

go get -v github.com/adevinta/vulcan-core-cli

Use the cli.

Execute vulcan-core-cli and check its commands and options.

Commands

Current commands are:

scan

It's similar to cscan, but in this case both the list of targets and checktypes must be provided (using the same format than the targets and checktypes filters from above).

Example:

vulcan-core-cli scan targets.txt checktypes.txt -o /tmp/
monitor

After running cscan or scan commands, the checks are executed by Vulcan Core. The monitor command will poll Vulcan Core for the checks status, until all the checks are in a final state (like FINISHED).

Example:

$ vulcan-core-cli monitor /tmp/37620de0-2484-4304-9724-1278ad837937.gob -i 10

Vulcan-core-api

The rest api it's implemented in the vulcan-scan-engine except for the assettypes and checktypes endpoints that are still implemented in the vulcan-persistence.

API Definition

There's a swagger document that describes it.

API Client

The API client is autogenerated in go using the goa framework.

The API design using the goa DSL language can be found in the design folder.

The current client can be imported in go with this import path:

"github.com/adevinta/vulcan-core-cli/vulcan-core/client"

To generate the client the and swagger definition from the goa design files execute:

cd vulcan-core
source clear.sh
source build.sh

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ScanStatus = map[string]bool{
	"INCONCLUSIVE": true,
	"ABORTED":      true,
	"TIMEOUT":      true,
	"CLEANUP":      false,
	"CREATED":      false,
	"FAILED":       true,
	"FINISHED":     true,
	"KILLED":       true,
	"MALFORMED":    true,
	"QUEUED":       false,
	"RUNNING":      false,
}

ScanStatus contains the list of possible status of a check, and indicates whether the status is a final state or not.

Functions

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 {
	Target    string
	Options   string
	QueueID   string
	AssetType string
}

Asset defines the asset where a concrete checktype will be executed with a set of options and a concrete queue.

type CLI

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

func NewCLI

func NewCLI(scheme, host string, verbose bool) (*CLI, error)

func (*CLI) AbortScan

func (cli *CLI) AbortScan(ID uuid.UUID) error

AbortScan sends an abort scan request to vulcan core for the given id.

func (*CLI) RunScan

func (cli *CLI) RunScan(tg client.ScanTargetsGroup, dryRun string) (*Scan, error)

RunScan starts execution, or simulates, the execution of a scan composed by a set of checks.

func (*CLI) UpdateStats

func (cli *CLI) UpdateStats(scan *Scan) error

type Scan

type Scan struct {
	ID           uuid.UUID
	ExpectedSize int
	StartTime    time.Time
	Stats        *Stats
}

Scan defines a set of checks that have been executed together.

func LoadState

func LoadState(stateFile string) (*Scan, error)

func (*Scan) IsFinished

func (s *Scan) IsFinished() bool

func (*Scan) SaveState

func (s *Scan) SaveState(stateFile string) error

func (*Scan) ToString

func (s *Scan) ToString() string

type Stats

type Stats struct {
	// GroupByStatus keys are different status (e.g. FINISHED), and values
	// are the total number of checks in this state.
	GroupByStatus map[string]int
}

func (*Stats) Print

func (sts *Stats) Print(w io.Writer)

func (*Stats) PrintToFile

func (sts *Stats) PrintToFile(fp string) error

Jump to

Keyboard shortcuts

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