Merge pull request #190 from safing/fix/profile-name

Fix exposing the wrong profile name on the connection process context
This commit is contained in:
Daniel 2020-11-05 17:31:33 +01:00 committed by GitHub
commit 224ae219da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,15 +27,19 @@ type FirewallHandler func(conn *Connection, pkt packet.Packet)
// ProcessContext holds additional information about the process
// that iniated a connection.
type ProcessContext struct {
// Name is the name of the process.
Name string
// ProcessName is the name of the process.
ProcessName string
//ProfileName is the name of the profile.
ProfileName string
// BinaryPath is the path to the process binary.
BinaryPath string
// PID i the process identifier.
PID int
// ProfileID is the ID of the main profile that
// Profile is the ID of the main profile that
// is applied to the process.
ProfileID string
Profile string
// Source is the source of the profile.
Source string
}
// Connection describes a distinct physical network connection
@ -163,10 +167,12 @@ type Reason struct {
func getProcessContext(proc *process.Process) ProcessContext {
return ProcessContext{
BinaryPath: proc.Path,
Name: proc.Name,
PID: proc.Pid,
ProfileID: proc.LocalProfileKey,
BinaryPath: proc.Path,
ProcessName: proc.Name,
ProfileName: proc.Profile().LocalProfile().Name,
PID: proc.Pid,
Profile: proc.Profile().LocalProfile().ID,
Source: string(proc.Profile().LocalProfile().Source),
}
}