forked from hillu/go-yara
-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.go
42 lines (36 loc) · 1.16 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright © 2015-2020 Hilko Bengen <bengen@hilluzination.de>
// All rights reserved.
//
// Use of this source code is governed by the license that can be
// found in the LICENSE file.
package yara
// #include <yara.h>
import "C"
import "unsafe"
type ConfigName uint32
const (
ConfigStackSize ConfigName = C.YR_CONFIG_STACK_SIZE
ConfigMaxMatchData = C.YR_CONFIG_MAX_MATCH_DATA
ConfigMaxStringsPerRule = C.YR_CONFIG_MAX_STRINGS_PER_RULE
ConfigMaxProcessMemoryChunk = C.YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK
)
// SetConfiguration sets a global YARA configuration option.
func SetConfiguration(name ConfigName, src interface{}) error {
i, ok := src.(int)
if !ok {
return newError(C.ERROR_INTERNAL_FATAL_ERROR)
}
u := C.uint32_t(i)
return newError(
C.yr_set_configuration(C.YR_CONFIG_NAME(name), unsafe.Pointer(&u)))
}
// GetConfiguration gets a global YARA configuration option.
func GetConfiguration(name ConfigName) (interface{}, error) {
var u C.uint32_t
if err := newError(C.yr_get_configuration(
C.YR_CONFIG_NAME(name), unsafe.Pointer(&u)),
); err != nil {
return nil, err
}
return int(u), nil
}