Skip to content

Commit

Permalink
fixed windows agent sqlite dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pygrum committed Oct 6, 2023
1 parent 9bc328d commit 368aa15
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
13 changes: 7 additions & 6 deletions internal/agent/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ func (s *Scout) Add(file string) error {
Model: gorm.Model{
CreatedAt: fi.ModTime(),
},
Name: filepath.Base(file),
Path: file,
FileType: filepath.Ext(file)[1:], // Skip the leading '.'
FileSize: uint(fi.Size()),
Source: s.Agent.ID,
Hash: fileHash(file),
Name: filepath.Base(file),
Path: file,
FileType: filepath.Ext(file)[1:], // Skip the leading '.'
FileSize: uint(fi.Size()),
Source: s.Agent.ID,
Hash: fileHash(file),
UploadTime: fi.ModTime(),
}
return conn.Add(sample)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/commands/samples/samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/pygrum/siphon/internal/logger"
"strconv"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -71,7 +72,7 @@ func RenderTable(samples []db.Sample, v bool) {
s.Hash,
s.FileSize,
s.Source,
s.UploadTime.String(),
s.UploadTime.Format(time.DateTime),
}
t.AppendRow(row)
}
Expand Down
7 changes: 6 additions & 1 deletion internal/integrations/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func (f *Fetcher) BasicRequest(a *db.Agent, endpoint, query, form string) (*http

func (f *Fetcher) mTLSClient(agent *db.Agent) (*http.Client, error) {
serverCertFile := agent.CertPath
// Refresh viper configuration
if err := viper.ReadInConfig(); err != nil {
return nil, err
}
certFile, keyFile := viper.GetString("cert_file"), viper.GetString("key_file")
// Read server certificate file and add it to trusted certificate store (certPool). Right now I'm reading my cert instead of the servers
caCert, err := os.ReadFile(serverCertFile)
Expand Down Expand Up @@ -149,7 +153,8 @@ func (f *Fetcher) Download(agent *db.Agent, sha256Hash string) (io.ReadCloser, e
if err != nil {
return nil, err
}
if resp.Header.Get("Content-Type") == "application/json" {
// if not application/zip, then its json, meaning request failed
if !strings.EqualFold(resp.Header.Get("content-type"), "application/zip") {
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions internal/integrations/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ func Refresh() {
logger.Silentf("invalid configuration: refresh rate must be 1 minute or more")
}
ticker := time.NewTicker(time.Duration(r) * time.Minute)
mbFetcher := malwarebazaar.NewFetcher()
agFetcher := agent.NewFetcher()
for range ticker.C {
mbFetcher := malwarebazaar.NewFetcher()
if mbFetcher != nil {
go mbFetcher.GetRecent()
}
agFetcher := agent.NewFetcher()
go agFetcher.GetRecent()
}
}

0 comments on commit 368aa15

Please sign in to comment.