utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskConfirmation added in v1.2.0

func AskConfirmation(message string) bool

AskConfirmation will request confirmation from the user

func GetActiveMachineID

func GetActiveMachineID(proxyURL string) string

GetActiveMachineID returns the id of the active machine

func GetHTBToken

func GetHTBToken() string

GetHTBToken checks whether the HTB_TOKEN environment variable exists

func GetMachineType

func GetMachineType(machine_id interface{}, proxyURL string) string

GetMachineType will return the machine type

func GetUserSubscription

func GetUserSubscription(proxyURL string) string

GetUserSubscription returns the user's subscription level

func HtbRequest

func HtbRequest(method string, urlParam string, proxyURL string, jsonData []byte) (*http.Response, error)

HtbRequest makes an HTTP request to the Hackthebox API

func ParseAndFormatDate added in v1.2.0

func ParseAndFormatDate(input string) (string, error)

ParseAndFormatDate takes an input date string, parses it into a time.Time object, and formats it to the "2006-01-02" format.

func ParseJsonMessage

func ParseJsonMessage(resp *http.Response, key string) interface{}

ParseJsonMessage will parse the result of the API request into a JSON

func SearchItemIDByName added in v1.1.0

func SearchItemIDByName(item string, proxyURL string, element_type string) (string, error)

SearchItemIDByName will return the id of an item (machine / challenge) based on its name

func SetOutputTest added in v1.2.0

func SetOutputTest() (*os.File, *os.File)

Function that removes the output from the console for unit tests. TODO: Move into a utils-tests.go file

func SetRetiredStatus added in v1.2.0

func SetRetiredStatus(data map[string]interface{}) string

SetRetiredStatus determines whether an item is retired or not.

func SetStatus added in v1.2.0

func SetStatus(data map[string]interface{}) string

SetStatus determines the status based on user and root flags.

func SetTabWriterData added in v1.2.0

func SetTabWriterData(w *tabwriter.Writer, data string)

SetTabWriterData will write the contents of each array cell

func SetTabWriterHeader added in v1.2.0

func SetTabWriterHeader(header string) *tabwriter.Writer

SetTabWriterHeader will display the information in an array

Types

type Challenge added in v1.1.0

type Challenge struct {
	ID    string `json:"id"`
	Value string `json:"value"`
}

type Machine

type Machine struct {
	ID    string `json:"id"`
	Value string `json:"value"`
}

type Root

type Root struct {
	Machines   interface{} `json:"machines"`
	Challenges interface{} `json:"challenges"`
}

Jump to

Keyboard shortcuts

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