mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
minor fixes to prevent go vet from complaining
This commit is contained in:
parent
5e1a398bc6
commit
41172b65e5
8 changed files with 26 additions and 26 deletions
|
@ -69,7 +69,7 @@ func newConnectionImpl(nfp *netfilter.Packet, c *Connection, protoType string) (
|
|||
if c.parseDirection(protoType) == false {
|
||||
return nil, nil
|
||||
}
|
||||
log.Debug("new connection %s => %d:%v -> %v:%d uid: ", c.Protocol, c.SrcPort, c.SrcIP, c.DstIP, c.DstPort, nfp.UID)
|
||||
log.Debug("new connection %s => %d:%v -> %v:%d uid: %d", c.Protocol, c.SrcPort, c.SrcIP, c.DstIP, c.DstPort, nfp.UID)
|
||||
|
||||
c.Entry = &netstat.Entry{
|
||||
Proto: c.Protocol,
|
||||
|
|
|
@ -83,7 +83,7 @@ func loadConfiguration(rawConfig []byte) bool {
|
|||
func saveConfiguration(rawConfig string) error {
|
||||
conf, err := json.Marshal([]byte(rawConfig))
|
||||
if err != nil {
|
||||
log.Error("saving json firewall configuration: ", err, conf)
|
||||
log.Error("saving json firewall configuration: %s %s", err, conf)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func saveConfiguration(rawConfig string) error {
|
|||
}
|
||||
|
||||
if err = ioutil.WriteFile(configFile, []byte(rawConfig), 0644); err != nil {
|
||||
log.Error("writing firewall configuration to disk: ", err)
|
||||
log.Error("writing firewall configuration to disk: %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -249,9 +249,9 @@ func CleanRules(logErrors bool) {
|
|||
|
||||
func insertRules() {
|
||||
if err4, err6 := QueueDNSResponses(true, true, queueNum); err4 != nil || err6 != nil {
|
||||
log.Error("Error while running DNS firewall rule: %s", err4, err6)
|
||||
log.Error("Error while running DNS firewall rule: %s %s", err4, err6)
|
||||
} else if err4, err6 = QueueConnections(true, true, queueNum); err4 != nil || err6 != nil {
|
||||
log.Fatal("Error while running conntrack firewall rule: %s", err4, err6)
|
||||
log.Fatal("Error while running conntrack firewall rule: %s %s", err4, err6)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ func Init(qNum *int) {
|
|||
|
||||
var err error
|
||||
if configWatcher, err = fsnotify.NewWatcher(); err != nil {
|
||||
log.Warning("Error creating firewall config watcher:", err)
|
||||
log.Warning("Error creating firewall config watcher: %s", err)
|
||||
}
|
||||
loadDiskConfiguration(false)
|
||||
|
||||
|
|
|
@ -164,11 +164,11 @@ func OpenFile(logFile string) (err error) {
|
|||
}
|
||||
|
||||
if Output, err = os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err != nil {
|
||||
Error("Error opening log: ", logFile, err)
|
||||
Error("Error opening log: %s %s", logFile, err)
|
||||
//fallback to stdout
|
||||
setDefaultLogOutput()
|
||||
}
|
||||
Important("Start writing logs to ", logFile)
|
||||
Important("Start writing logs to %s", logFile)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ func setupLogging() {
|
|||
if logFile != "" {
|
||||
log.Close()
|
||||
if err := log.OpenFile(logFile); err != nil {
|
||||
log.Error("Error opening user defined log: ", logFile, err)
|
||||
log.Error("Error opening user defined log: %s %s", logFile, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func worker(id int) {
|
|||
default:
|
||||
pkt, ok := <-wrkChan
|
||||
if !ok {
|
||||
log.Debug("worker channel closed", id)
|
||||
log.Debug("worker channel closed %d", id)
|
||||
goto Exit
|
||||
}
|
||||
onPacket(pkt)
|
||||
|
|
|
@ -275,14 +275,14 @@ func Reader(r io.Reader, eventChan chan<- Event) {
|
|||
buf, _, err := reader.ReadLine()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
log.Error("AuditReader: auditd stopped, reconnecting in 30s", err)
|
||||
log.Error("AuditReader: auditd stopped, reconnecting in 30s %s", err)
|
||||
if newReader, err := reconnect(); err == nil {
|
||||
reader = bufio.NewReader(newReader)
|
||||
log.Important("Auditd reconnected, continue reading")
|
||||
}
|
||||
continue
|
||||
}
|
||||
log.Warning("AuditReader: auditd error", err)
|
||||
log.Warning("AuditReader: auditd error %s", err)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ func (c *Client) saveConfiguration(rawConfig string) (err error) {
|
|||
}
|
||||
|
||||
if err = ioutil.WriteFile(configFile, []byte(rawConfig), 0644); err != nil {
|
||||
log.Error("writing configuration to disk: ", err)
|
||||
log.Error("writing configuration to disk: %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -101,7 +101,7 @@ func (c *Client) handleActionChangeConfig(stream protocol.UI_NotificationsClient
|
|||
// this save operation triggers a re-loadConfiguration()
|
||||
err = c.saveConfiguration(notification.Data)
|
||||
if err != nil {
|
||||
log.Warning("[notification] CHANGE_CONFIG not applied", err)
|
||||
log.Warning("[notification] CHANGE_CONFIG not applied %s", err)
|
||||
} else if err == nil && procMonitorEqual == false {
|
||||
procmon.Init()
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ func (c *Client) handleActionChangeConfig(stream protocol.UI_NotificationsClient
|
|||
func (c *Client) handleActionEnableRule(stream protocol.UI_NotificationsClient, notification *protocol.Notification) {
|
||||
var err error
|
||||
for _, rul := range notification.Rules {
|
||||
log.Info("[notification] enable rule: ", rul.Name)
|
||||
log.Info("[notification] enable rule: %s", rul.Name)
|
||||
// protocol.Rule(protobuf) != rule.Rule(json)
|
||||
r, _ := rule.Deserialize(rul)
|
||||
r.Enabled = true
|
||||
|
@ -125,7 +125,7 @@ func (c *Client) handleActionEnableRule(stream protocol.UI_NotificationsClient,
|
|||
func (c *Client) handleActionDisableRule(stream protocol.UI_NotificationsClient, notification *protocol.Notification) {
|
||||
var err error
|
||||
for _, rul := range notification.Rules {
|
||||
log.Info("[notification] disable rule: ", rul)
|
||||
log.Info("[notification] disable rule: %s", rul)
|
||||
r, _ := rule.Deserialize(rul)
|
||||
r.Enabled = false
|
||||
err = c.rules.Replace(r, r.Duration == rule.Always)
|
||||
|
@ -141,9 +141,9 @@ func (c *Client) handleActionChangeRule(stream protocol.UI_NotificationsClient,
|
|||
rErr = fmt.Errorf("Invalid rule, %s", err)
|
||||
continue
|
||||
}
|
||||
log.Info("[notification] change rule: ", r, notification.Id)
|
||||
log.Info("[notification] change rule: %s %d", r, notification.Id)
|
||||
if err := c.rules.Replace(r, r.Duration == rule.Always); err != nil {
|
||||
log.Warning("[notification] Error changing rule: ", err, r)
|
||||
log.Warning("[notification] Error changing rule: %s %s", err, r)
|
||||
rErr = err
|
||||
}
|
||||
}
|
||||
|
@ -153,10 +153,10 @@ func (c *Client) handleActionChangeRule(stream protocol.UI_NotificationsClient,
|
|||
func (c *Client) handleActionDeleteRule(stream protocol.UI_NotificationsClient, notification *protocol.Notification) {
|
||||
var err error
|
||||
for _, rul := range notification.Rules {
|
||||
log.Info("[notification] delete rule: ", rul.Name, notification.Id)
|
||||
log.Info("[notification] delete rule: %s %d", rul.Name, notification.Id)
|
||||
err = c.rules.Delete(rul.Name)
|
||||
if err != nil {
|
||||
log.Error("[notification] Error deleting rule: ", err, rul)
|
||||
log.Error("[notification] Error deleting rule: %s %s", err, rul)
|
||||
}
|
||||
}
|
||||
c.sendNotificationReply(stream, notification.Id, "", err)
|
||||
|
@ -179,7 +179,7 @@ func (c *Client) handleActionStopMonitorProcess(stream protocol.UI_Notifications
|
|||
pid, err := strconv.Atoi(notification.Data)
|
||||
if err != nil {
|
||||
log.Error("parsing PID to stop monitor")
|
||||
c.sendNotificationReply(stream, notification.Id, "", fmt.Errorf("Error stopping monitor: ", notification.Data))
|
||||
c.sendNotificationReply(stream, notification.Id, "", fmt.Errorf("Error stopping monitor: %s", notification.Data))
|
||||
return
|
||||
}
|
||||
stopMonitoringProcess <- pid
|
||||
|
@ -230,7 +230,7 @@ func (c *Client) sendNotificationReply(stream protocol.UI_NotificationsClient, n
|
|||
reply.Data = fmt.Sprint(err)
|
||||
}
|
||||
if err := stream.Send(reply); err != nil {
|
||||
log.Error("Error replying to notification:", err, reply.Id)
|
||||
log.Error("Error replying to notification: %s %d", err, reply.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ func (c *Client) Subscribe() {
|
|||
defer cancel()
|
||||
|
||||
if _, err := c.client.Subscribe(ctx, c.getClientConfig()); err != nil {
|
||||
log.Error("Subscribing to GUI", err)
|
||||
log.Error("Subscribing to GUI %s", err)
|
||||
return
|
||||
}
|
||||
c.listenForNotifications()
|
||||
|
@ -263,12 +263,12 @@ func (c *Client) listenForNotifications() {
|
|||
streamReply := &protocol.NotificationReply{Id: 0, Code: protocol.NotificationReplyCode_OK}
|
||||
notisStream, err := c.client.Notifications(ctx)
|
||||
if err != nil {
|
||||
log.Error("establishing notifications channel", err)
|
||||
log.Error("establishing notifications channel %s", err)
|
||||
return
|
||||
}
|
||||
// send the first notification
|
||||
if err := notisStream.Send(streamReply); err != nil {
|
||||
log.Error("sending notification HELLO", err)
|
||||
log.Error("sending notification HELLO %s", err)
|
||||
return
|
||||
}
|
||||
log.Info("Start receiving notifications")
|
||||
|
@ -283,7 +283,7 @@ func (c *Client) listenForNotifications() {
|
|||
goto Exit
|
||||
}
|
||||
if err != nil {
|
||||
log.Error("getting notifications: ", err, noti)
|
||||
log.Error("getting notifications: %s %s", err, noti)
|
||||
goto Exit
|
||||
}
|
||||
c.handleNotification(notisStream, noti)
|
||||
|
|
Loading…
Add table
Reference in a new issue