hashfile

package
v0.0.0-...-aba53e5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 15 Imported by: 0

README

hash file

This filter hashes the content of a file.

{
  "filter": [
    {
      "type": "hashfile",
      "field": "file_name",
      "output": "hash",
      "buf_size": 20000,
      "algos": [
        "crc32",
        "md5",
        "sha256",
        "fnv1a",
        "sha512"
      ]
    }
  ]
}

The file to hash is found in the event specified by "field". Alogs are the list of hashes to use. If blank then all supported hashes will be used. The filter will not load if an unknown filter is specified.

The output hash is in its binary form encoded as base64.

Example output:

{
  "hash": {
    "fnv1a": "OObfHVMzKKqDlPRRHpcI3Q==",
    "crc32": "UNbFkg==",
    "md5": "12UcXohM6INPDmCieDpsaQ==",
    "sha256": "5TU5z8hTPQr2yjPaPbWXcvFF7xsUdCBiv/71SCEbynU=",
    "sha512": "R+W447AH2dO4aADxUG2IdyhE5Vg+u4LDHl7pbimYV62FszO+rqkKND+2jQuvzTT1P9lLoJYJZvwcjnL0m8EMZA=="
  }
}

Documentation

Index

Constants

View Source
const ErrorTag = "gogstash_filter_hashfile_error"

ErrorTag tag added to event when process module failed

View Source
const ModuleName = "hashfile"

ModuleName is the name used in config file

Variables

View Source
var SupportedHashes map[string]func(interface{}) Hash = make(map[string]func(interface{}) Hash)

SupportedHashes the list of supported hashes and their init functions

Functions

func InitHandler

func InitHandler(ctx context.Context, raw config.ConfigRaw, control config.Control) (config.TypeFilterConfig, error)

InitHandler initialize the filter plugin

Types

type FilterConfig

type FilterConfig struct {
	config.FilterConfig

	Field   string   `json:"field" yaml:"field"`       // field name of file to hash
	Output  string   `json:"output" yaml:"output"`     // field name to store output to
	Algos   []string `json:"algos" yaml:"algos"`       // hash algos to hash on
	BufSize int      `json:"buf_size" yaml:"buf_size"` // buffer size for copy
}

FilterConfig holds the configuration json fields and internal objects

func DefaultFilterConfig

func DefaultFilterConfig() FilterConfig

DefaultFilterConfig returns an FilterConfig struct with default values

func (*FilterConfig) Event

Event the main filter event

type Hash

type Hash interface {
	io.Writer
	Sum() []byte
}

Hash is our interface to a hash. Each hash that implements this interface will work with the module.

Jump to

Keyboard shortcuts

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