avast

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

README

avast

Golang Avast Client

Ci codecov Go Report Card Go Reference MPLv2 License

Description

avast is a Golang library and cmdline tool that implements the Avast client protocol.

Requirements

  • Golang 1.10.x or higher

Getting started

Avast client

The avast client can be installed as follows

$ go get github.com/baruwa-enterprise/avast/cmd/avastscan

Or by cloning the repo and then running

$ make build
$ ./bin/avastscan
Avast library

To install the library

go get github.com/baruwa-enterprise/avast

You can then import it in your code

import "github.com/baruwa-enterprise/avast"
Testing

Set the env variable AVAST_ADDRESS to point to your avast socket

$ export AVAST_ADDRESS="/var/run/avast/scan.sock"
$ make test

License

MPL-2.0

Documentation

Overview

Package avast Golang Avast client Avast - Golang Avast client

Index

Constants

View Source
const (

	// DefaultTimeout is the default connection timeout
	DefaultTimeout = 15 * time.Second
	// DefaultCmdTimeout is the default IO timeout
	DefaultCmdTimeout = 1 * time.Minute
	// DefaultSleep is the default sleep period
	DefaultSleep = 1 * time.Second
	// AvastSock is the default socket location
	AvastSock = "/var/run/avast/scan.sock"
)

Variables

View Source
var (
	// ZeroTime holds the zero value of time
	ZeroTime time.Time
)

Functions

This section is empty.

Types

type Client

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

A Client represents an Avast client.

func NewClient

func NewClient(ctx context.Context, address string, connTimeOut, ioTimeOut time.Duration) (c *Client, err error)

NewClient creates and returns a new instance of Client

func (*Client) CheckURL

func (c *Client) CheckURL(u string) (r bool, err error)

CheckURL checks whether a given URL is malicious

func (*Client) Close

func (c *Client) Close() (err error)

Close closes the server connection

func (*Client) GetExclude

func (c *Client) GetExclude() (r string, err error)

GetExclude returns excluded path from scans

func (*Client) GetFlags

func (c *Client) GetFlags() (f string, err error)

GetFlags returns scan flags

func (*Client) GetPack

func (c *Client) GetPack() (p string, err error)

GetPack returns packer options

func (*Client) GetSensitivity

func (c *Client) GetSensitivity() (f string, err error)

GetSensitivity returns scan sensitivity options

func (*Client) Scan

func (c *Client) Scan(p string) (r []*Response, err error)

Scan submits a path for scanning

func (*Client) SetCmdTimeout

func (c *Client) SetCmdTimeout(t time.Duration)

SetCmdTimeout sets the cmd timeout

func (*Client) SetConnRetries

func (c *Client) SetConnRetries(s int)

SetConnRetries sets the number of times connection is retried

func (*Client) SetConnSleep

func (c *Client) SetConnSleep(s time.Duration)

SetConnSleep sets the connection retry sleep duration in seconds

func (*Client) SetConnTimeout

func (c *Client) SetConnTimeout(t time.Duration)

SetConnTimeout sets the connection timeout

func (*Client) SetExclude

func (c *Client) SetExclude(p string) (err error)

SetExclude returns excluded path from scans

func (*Client) SetFlags

func (c *Client) SetFlags(o Flag, v bool) (err error)

SetFlags sets scan flags

func (*Client) SetPack

func (c *Client) SetPack(o PackOption, v bool) (err error)

SetPack sets packer options

func (*Client) SetSensitivity

func (c *Client) SetSensitivity(o SensiOption, v bool) (err error)

SetSensitivity sets scan sensitivity

func (*Client) Vps

func (c *Client) Vps() (v int, err error)

Vps returns the virus definitions (VPS) version

type Command

type Command int

A Command represents an Avast Command

const (
	// Scan sends the SCAN request
	Scan Command = iota + 1
	// Vps sends the VPS request
	Vps
	// Pack sends the PACK request
	Pack
	// Flags sends the FLAGS request
	Flags
	// Sensitivity sends the SENSITIVITY request
	Sensitivity
	// Exclude sends the EXCLUDE request
	Exclude
	// CheckURL sends the CHECKURL request
	CheckURL
	// Quit sends the QUIT request
	Quit
)

func (Command) Len

func (c Command) Len() (l int)

Len returns the length of the string

func (Command) String

func (c Command) String() (s string)

type Flag

type Flag int

A Flag represents Avast flags

const (
	// FullFiles is fullfiles
	FullFiles Flag = iota + 1
	// AllFiles is allfiles
	AllFiles
	// ScanDevices is scandevices
	ScanDevices
)

func (Flag) Disable

func (f Flag) Disable() (s string)

Disable returns disabled option string

func (Flag) Enable

func (f Flag) Enable() (s string)

Enable returns enabled option string

func (Flag) String

func (f Flag) String() (s string)

type PackOption

type PackOption int

A PackOption represents Avast PACK options

const (
	// Mime represents mime option
	Mime PackOption = iota + 1
	// Zip represents zip pack option
	Zip
	// Arj represents arj pack option
	Arj
	// Rar represents rar pack option
	Rar
	// Cab represents cab pack option
	Cab
	// Tar represents tar pack option
	Tar
	// Gz represents gz pack option
	Gz
	// Bzip2 represents bzip2 pack option
	Bzip2
	// Ace represents ace pack option
	Ace
	// Arc represents arc pack option
	Arc
	// Zoo represents zoo pack option
	Zoo
	// Lharc represents lharc pack option
	Lharc
	// Chm represents chm pack option
	Chm
	// Cpio represents cpio pack option
	Cpio
	// Rpm represents rpm pack option
	Rpm
	// Szip represents 7zip pack option
	Szip
	// Iso represents iso pack option
	Iso
	// Tnef represents tnef pack option
	Tnef
	// Dbx represents dbx pack option
	Dbx
	// Sys represents sys pack option
	Sys
	// Ole represents ole pack option
	Ole
	// Exec represents exec pack option
	Exec
	// WinExec represents winexec pack option
	WinExec
	// Install represents install option
	Install
	// Dmg represents dmg pack option
	Dmg
)

func (PackOption) Disable

func (p PackOption) Disable() (s string)

Disable returns disabled option string

func (PackOption) Enable

func (p PackOption) Enable() (s string)

Enable returns enabled option string

func (PackOption) String

func (p PackOption) String() (s string)

type Response

type Response struct {
	Filename    string
	ArchiveItem string
	Signature   string
	Status      string
	Infected    bool
	Raw         string
}

Response represents the response from the server

type SensiOption

type SensiOption int

SensiOption represents Avast Sensitivity options

const (
	// Worm represents worm
	Worm SensiOption = iota + 1
	// Trojan represents trojan
	Trojan
	// Adware represents adware
	Adware
	// Spyware represents spyware
	Spyware
	// Dropper represents dropper
	Dropper
	// Kit represents kit
	Kit
	// Joke represents joke
	Joke
	// Dangerous represents dangerous
	Dangerous
	// Dialer represents dialer
	Dialer
	// Rootkit represents rootkit
	Rootkit
	// Exploit represents exploit
	Exploit
	// Pup represents pup
	Pup
	// Suspicious represents suspicious
	Suspicious
	// Pube represents pube
	Pube
)

func (SensiOption) Disable

func (so SensiOption) Disable() (s string)

Disable returns disabled option string

func (SensiOption) Enable

func (so SensiOption) Enable() (s string)

Enable returns enabled option string

func (SensiOption) String

func (so SensiOption) String() (s string)

Directories

Path Synopsis
cmd
avastscan
Package main Golang Avast client Avast - Golang Avast cmdline client Package main Golang Avast client Avast - Golang Avast cmdline client
Package main Golang Avast client Avast - Golang Avast cmdline client Package main Golang Avast client Avast - Golang Avast cmdline client
Package main Golang Avast client Avast - Golang Avast test program
Package main Golang Avast client Avast - Golang Avast test program

Jump to

Keyboard shortcuts

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