utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLogger = NewLogger()
)
View Source
var GitHubDownloadURL = func(version, osName, arch string) string {
	var ext string
	if osName == "windows" {
		ext = ".exe"
	}
	return fmt.Sprintf(
		"https://github.com/%s/releases/download/%s/wpprobe_%s_%s_%s%s",
		githubRepo,
		version,
		version,
		osName,
		arch,
		ext,
	)
}
View Source
var GitHubLatestReleaseURL = func() string {
	return fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", githubRepo)
}
View Source
var Version = "dev"

Functions

func AutoUpdate added in v0.3.0

func AutoUpdate(currentVersion string) error

func CheckLatestVersion added in v0.3.0

func CheckLatestVersion(currentVersion string) (string, bool)

func DetectOutputFormat added in v0.2.0

func DetectOutputFormat(outputFile string) string

func GetEmbeddedFile

func GetEmbeddedFile(filename string) ([]byte, error)

func GetPluginVersion

func GetPluginVersion(target, plugin string, _ int, headers []string) string

func GetStoragePath

func GetStoragePath(filename string) (string, error)

func IsVersionVulnerable

func IsVersionVulnerable(version, fromVersion, toVersion string) bool

func NormalizeURL added in v0.6.0

func NormalizeURL(url string) string

func ReadLines

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

func SplitLines added in v0.6.0

func SplitLines(data []byte) []string

Types

type AuthGroup added in v0.6.0

type AuthGroup struct {
	AuthType        string          `json:"auth_type"`
	Vulnerabilities []Vulnerability `json:"vulnerabilities"`
}

type CSVWriter

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

func NewCSVWriter

func NewCSVWriter(filename string) *CSVWriter

func (*CSVWriter) Close

func (c *CSVWriter) Close()

func (*CSVWriter) WriteResults

func (c *CSVWriter) WriteResults(url string, results []PluginEntry)

type HTTPClientManager

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

func NewHTTPClient

func NewHTTPClient(timeout time.Duration, headers []string) *HTTPClientManager

func (*HTTPClientManager) Get

func (h *HTTPClientManager) Get(url string) (string, error)

type JSONWriter added in v0.2.0

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

func NewJSONWriter added in v0.2.0

func NewJSONWriter(output string) *JSONWriter

func (*JSONWriter) Close added in v0.2.0

func (j *JSONWriter) Close()

func (*JSONWriter) WriteResults added in v0.2.0

func (j *JSONWriter) WriteResults(url string, results []PluginEntry)

type Logger added in v0.3.0

type Logger struct {
	Logger *log.Logger
}

func NewLogger added in v0.3.0

func NewLogger() *Logger

func (*Logger) Error added in v0.3.0

func (l *Logger) Error(msg string)

func (*Logger) Info added in v0.3.0

func (l *Logger) Info(msg string)

func (*Logger) PrintBanner added in v0.3.0

func (l *Logger) PrintBanner(version string, isLatest bool)

func (*Logger) Success added in v0.3.0

func (l *Logger) Success(msg string)

func (*Logger) Warning added in v0.3.0

func (l *Logger) Warning(msg string)

type OutputResults added in v0.6.0

type OutputResults struct {
	URL     string            `json:"url"`
	Plugins PluginsCollection `json:"plugins"`
}

type PluginEntry added in v0.2.0

type PluginEntry struct {
	Plugin     string   `json:"plugin"`
	Version    string   `json:"version"`
	Severity   string   `json:"severity"`
	CVEs       []string `json:"cves"`
	CVELinks   []string `json:"cve_link"`
	Title      string   `json:"title"`
	AuthType   string   `json:"auth_type"`
	CVSSScore  float64  `json:"cvss_score"`
	CVSSVector string   `json:"cvss_vector"`
}

type PluginResult added in v0.6.0

type PluginResult struct {
	Name     string         `json:"-"`
	Versions []VersionGroup `json:"versions"`
}

type PluginsCollection added in v0.6.0

type PluginsCollection []PluginResult

func (PluginsCollection) MarshalJSON added in v0.6.0

func (p PluginsCollection) MarshalJSON() ([]byte, error)

type ProgressManager

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

func NewProgressBar

func NewProgressBar(total int, description string) *ProgressManager

NewProgressBar creates a progress bar with a fixed width and padded/truncated description

func (*ProgressManager) Bprintf

func (p *ProgressManager) Bprintf(format string, a ...interface{}) (int, error)

Bprintf prints a formatted message above the bar.

func (*ProgressManager) Bprintln

func (p *ProgressManager) Bprintln(a ...interface{}) (int, error)

Bprintln prints a message on a new line above the bar.

func (*ProgressManager) ClearLine added in v0.5.3

func (p *ProgressManager) ClearLine()

ClearLine clears the current console line.

func (*ProgressManager) Finish

func (p *ProgressManager) Finish()

Finish completes the bar and prints a newline.

func (*ProgressManager) Increment

func (p *ProgressManager) Increment()

Increment increases the current progress by one.

func (*ProgressManager) RenderBlank

func (p *ProgressManager) RenderBlank()

RenderBlank renders an empty bar state.

func (*ProgressManager) SetMessage added in v0.6.0

func (p *ProgressManager) SetMessage(description string)

SetMessage updates the bar's description, padded/truncated to fixed width.

func (*ProgressManager) SetTotal added in v0.5.2

func (p *ProgressManager) SetTotal(total int)

SetTotal updates the maximum count of the progress bar.

func (*ProgressManager) Write added in v0.3.1

func (p *ProgressManager) Write(data []byte) (int, error)

Write adds the length of data to the bar.

type SeverityEntry added in v0.6.0

type SeverityEntry struct {
	Severity string
	Auths    []AuthGroup
}

func (SeverityEntry) MarshalJSON added in v0.6.0

func (s SeverityEntry) MarshalJSON() ([]byte, error)

type VersionGroup added in v0.6.0

type VersionGroup struct {
	Version    string          `json:"version"`
	Severities []SeverityEntry `json:"severities"`
}

type Vulnerability added in v0.6.0

type Vulnerability struct {
	CVE        string  `json:"cve"`
	CVELink    string  `json:"cve_link"`
	Title      string  `json:"title"`
	CVSSScore  float64 `json:"cvss_score"`
	CVSSVector string  `json:"cvss_vector"`
}

type WriterInterface added in v0.2.0

type WriterInterface interface {
	WriteResults(url string, results []PluginEntry)
	Close()
}

func GetWriter added in v0.2.0

func GetWriter(outputFile string) WriterInterface

Jump to

Keyboard shortcuts

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