Documentation ¶
Overview ¶
Package scanapi defines the Localtoast scan API used to provide access to a local or remote filesystem and database to perform scans.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEntryBeforeNext is the error returned if Entry() is called // and Next() was never called for a DirReader. ErrEntryBeforeNext = errors.New("Entry called before Next") // ErrNoMoreEntries is the error returned if Entry() is called // after Next() returned false for a DirReader. ErrNoMoreEntries = errors.New("Entry called with no more entries") )
Functions ¶
func DirReaderToSlice ¶
func DirReaderToSlice(d DirReader) ([]*apb.DirContent, error)
DirReaderToSlice returns a slice of all the entries left in the given DirReader. The DirReader is automatically disposed of by calling Close() at the end.
Types ¶
type DirReader ¶
type DirReader interface { // Next reads the next entry in the directory which can then be accessed using Entry. // It must be called at least once before calling Entry. // Returns false if there are no more entries in the directory. Next() bool // Entry returns the last entry read using Next or an error if it failed. Entry() (*apb.DirContent, error) // Close must be called to correctly dispose of the underlying reader. Close() error }
DirReader is an interface to iterate the entries inside a directory.
func SliceToDirReader ¶
func SliceToDirReader(entries []*apb.DirContent) DirReader
SliceToDirReader returns a DirReader given a slice of entries.
type Filesystem ¶
type Filesystem interface { // OpenFile opens the specified file for reading. // It should return an os.IsNotExist error if the file doesn't exist. OpenFile(ctx context.Context, path string) (io.ReadCloser, error) // FilePermissions returns unix permission-related data for the specified file or directory. FilePermissions(ctx context.Context, path string) (*apb.PosixPermissions, error) // OpenDir opens the specified directory to list its content. OpenDir(ctx context.Context, path string) (DirReader, error) }
Filesystem is an interface that gives read access to the filesystem of the machine to scan.
type SQLQuerier ¶
type SQLQuerier interface { // SQLQuery executes SQL queries to a target SQL database and returns the number of result rows. SQLQuery(ctx context.Context, query string) (int, error) // SQLQueryWithResponse execute Query and returns the Response as string SQLQueryWithResponse(ctx context.Context, query string) (string, error) // Returns the supported database type SupportedDatabase() (ipb.SQLCheck_SQLDatabase, error) }
SQLQuerier is an interface that supports SQL queries to a target SQL database.
type ScanAPI ¶
type ScanAPI interface { Filesystem SQLQuerier }
ScanAPI is an interface that gives read access to the filesystem of the machine to scan and can execute SQL queries on a single database.