Merge pull request #1270 from safing/fix/default-query-db

Do not query the history database by default
This commit is contained in:
Daniel Hovie 2023-08-01 16:12:37 +02:00 committed by GitHub
commit 4a6eea4a7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 7 deletions

View file

@ -2,8 +2,6 @@ package netquery
import ( import (
"context" "context"
"crypto/sha256"
"encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"time" "time"
@ -268,7 +266,5 @@ func convertConnection(conn *network.Connection) (*Conn, error) {
} }
func genConnID(conn *network.Connection) string { func genConnID(conn *network.Connection) string {
data := conn.ID + "-" + conn.Process().GetID() return conn.ID + "-" + conn.Process().GetID()
hash := sha256.Sum256([]byte(data))
return hex.EncodeToString(hash[:])
} }

View file

@ -115,8 +115,8 @@ func (m *module) prepare() error {
if err := api.RegisterEndpoint(api.Endpoint{ if err := api.RegisterEndpoint(api.Endpoint{
Path: "netquery/history/clear", Path: "netquery/history/clear",
MimeType: "application/json", MimeType: "application/json",
Read: api.PermitUser,
Write: api.PermitUser, Write: api.PermitUser,
Read: api.PermitUser,
BelongsTo: m.Module, BelongsTo: m.Module,
HandlerFunc: func(w http.ResponseWriter, r *http.Request) { HandlerFunc: func(w http.ResponseWriter, r *http.Request) {
var body struct { var body struct {

View file

@ -189,8 +189,9 @@ func (req *QueryRequestPayload) generateSQL(ctx context.Context, schema *orm.Tab
whereClause = "WHERE " + whereClause whereClause = "WHERE " + whereClause
} }
// if no database is specified we default to LiveDatabase only.
if len(req.Databases) == 0 { if len(req.Databases) == 0 {
req.Databases = []DatabaseName{LiveDatabase, HistoryDatabase} req.Databases = []DatabaseName{LiveDatabase}
} }
sources := make([]string, len(req.Databases)) sources := make([]string, len(req.Databases))