Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thorlog/v3/hostinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HostInfo struct {
Platform PlatformInfo `json:"platform" textlog:",expand"`
Uptime time.Duration `json:"uptime" textlog:"uptime"`
Cpus int `json:"cpu_count" textlog:"cpu_count"`
Memory uint64 `json:"memory" textlog:"memory"`
Memory Memory `json:"memory" textlog:"memory"`
Timezone string `json:"timezone" textlog:"timezone"`
Language string `json:"language" textlog:"language"`
Interfaces []InterfaceInfo `json:"interfaces" textlog:",expand"`
Expand Down
44 changes: 42 additions & 2 deletions thorlog/v3/scaninfo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package thorlog

import (
"fmt"
"strings"
"time"

"github.com/NextronSystems/jsonlog"
)
Expand All @@ -24,8 +26,15 @@ type ScanInfo struct {

Outputs []ScannerOutput `json:"outputs"`

ActiveModules []string `json:"active_modules"`
ActiveFeatures []string `json:"active_features"`
ActiveModules StringList `json:"active_modules" textlog:"active_modules"`
ActiveFeatures StringList `json:"active_features" textlog:"active_features"`

Threads int `json:"threads" textlog:"threads"`

Timeout time.Duration `json:"timeout" textlog:"timeout"`
CPULimit int `json:"cpu_limit" textlog:"cpu_limit"`
FreeMemoryLimit Memory `json:"free_memory_limit" textlog:"free_memory_limit"`
FileSizeLimit Memory `json:"file_size_limit" textlog:"file_size_limit"`

License LicenseInfo `json:"license" textlog:"license,expand"`

Expand Down Expand Up @@ -64,3 +73,34 @@ type VersionInfo struct {
Signatures string `json:"signatures" textlog:"signature_version"`
Sigma string `json:"sigma_rules" textlog:"sigma_version"`
}

type Memory uint64

func (m Memory) String() string {
var usedSuffix = "B"
var divisor uint64 = 1
bytes := uint64(m)
for suffix, multiplier := range multipliers {
if multiplier < bytes && multiplier > divisor {
divisor = multiplier
usedSuffix = suffix + "B"
}
}
return fmt.Sprintf("%d%s", int64(float64(bytes)/float64(divisor)), usedSuffix)
}

const (
kb = 1024
mb = 1024 * kb
gb = 1024 * mb
tb = 1024 * gb
pb = 1024 * tb
)

var multipliers = map[string]uint64{
"K": kb,
"M": mb,
"G": gb,
"T": tb,
"P": pb,
}