Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDocumentNotFound is returned when the doc does not exist in the DB. ErrDocumentNotFound = "document not found" // ErrObjectNotFound is returned when an object does not exist in Obj storage. ErrObjectNotFound = errors.New("object not found") // SamplesPwd represents the pasword used to zip the files during file download. SamplesPwd = "infected" )
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(g *echo.Group, service Service, requireLogin echo.MiddlewareFunc, optionalLogin echo.MiddlewareFunc, logger log.Logger)
Types ¶
type CreateFileRequest ¶
type CreateFileRequest struct {
// contains filtered or unexported fields
}
CreateFileRequest represents a file creation request.
type DynFileScanCfg ¶ added in v0.3.0
type DynFileScanCfg struct {
// Destination path where the sample will be located in the VM.
SampleDestPath string `json:"sample_dest_path,omitempty"`
// Arguments used to run the sample.
Arguments string `json:"arguments,omitempty"`
// Timeout in seconds for how long to keep the VM running.
Timeout int `json:"timeout,omitempty"`
}
DynFileScanCfg represents the dynamic malware analysis configuration.
type FileScanCfg ¶ added in v0.3.0
type FileScanCfg struct {
// SHA256 hash of the file.
SHA256 string `json:"sha256"`
// Dynamic scan configuration.
Dynamic DynFileScanCfg `json:"dynamic"`
}
FileScanCfg represents a file scanning config.
type Repository ¶
type Repository interface {
// Get returns the file with the specified file ID.
Get(ctx context.Context, id string, fields []string) (entity.File, error)
// Count returns the number of files.
Count(ctx context.Context) (int, error)
// Query returns the list of files with the given offset and limit.
Query(ctx context.Context, offset, limit int) ([]entity.File, error)
// Create saves a new file in the storage.
Create(ctx context.Context, id string, file entity.File) error
// Update updates the whole file with given ID in the storage.
Update(ctx context.Context, key string, file entity.File) error
// Patch patches a sub entry in the file with given ID in the storage.
Patch(ctx context.Context, key, path string, val interface{}) error
// Delete removes the file with given ID from the storage.
Delete(ctx context.Context, id string) error
// DeleteActivity removes the activity given its kind and target.
DeleteActivity(ctx context.Context, kind, username, target string) error
// Summary returns a summary of a file scan.
Summary(ctx context.Context, id string) (interface{}, error)
// Comments returns the list of comments over a file.
Comments(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
}
Repository encapsulates the logic to access files from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new file repository.
type Service ¶
type Service interface {
Get(ctx context.Context, id string, fields []string) (File, error)
Count(ctx context.Context) (int, error)
Create(ctx context.Context, input CreateFileRequest) (File, error)
Update(ctx context.Context, id string, input UpdateFileRequest) (File, error)
Delete(ctx context.Context, id string) (File, error)
Query(ctx context.Context, offset, limit int) ([]File, error)
Patch(ctx context.Context, key, path string, val interface{}) error
Summary(ctx context.Context, id string) (interface{}, error)
Like(ctx context.Context, id string) error
Unlike(ctx context.Context, id string) error
Rescan(ctx context.Context, id string) error
Download(ctx context.Context, id string, zipfile *string) error
Comments(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
}
Service encapsulates usecase logic for files.
func NewService ¶
func NewService(repo Repository, logger log.Logger, updown UploadDownloader, producer Producer, topic, bucket string, userSvc user.Service, actSvc activity.Service, arch Archiver) Service
NewService creates a new File service.
type UpdateFileRequest ¶
type UpdateFileRequest struct {
MD5 string `json:"md5,omitempty"`
SHA1 string `json:"sha1,omitempty"`
SHA256 string `json:"sha256,omitempty"`
SHA512 string `json:"sha512,omitempty"`
Ssdeep string `json:"ssdeep,omitempty"`
CRC32 string `json:"crc32,omitempty"`
Magic string `json:"magic,omitempty"`
Size uint64 `json:"size,omitempty"`
Exif map[string]string `json:"exif,omitempty"`
Tags map[string]interface{} `json:"tags,omitempty"`
TriD []string `json:"trid,omitempty"`
Packer []string `json:"packer,omitempty"`
Strings []interface{} `json:"strings,omitempty"`
MultiAV map[string]interface{} `json:"multiav,omitempty"`
PE interface{} `json:"pe,omitempty"`
Histogram []int `json:"histogram,omitempty"`
ByteEntropy []int `json:"byte_entropy,omitempty"`
Ml map[string]interface{} `json:"ml,omitempty"`
FileType string `json:"filetype,omitempty"`
}
UpdateUserRequest represents a File update request.
Click to show internal directories.
Click to hide internal directories.