Skip to content

Commit 550d062

Browse files
committed
fix(security): address vulnerabilities + fix all errcheck lint errors
Includes all changes from PR #13 (by RinZ27) plus: - Added error checking (errcheck) across 16 files - Removed unused field broker.running - Removed unused func computeChallengeResponse
1 parent 5b56a93 commit 550d062

17 files changed

Lines changed: 38 additions & 43 deletions

File tree

cmd/eipc-cli/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func cmdSend(args []string) {
7171
payload := fs.String("payload", `{}`, "JSON payload")
7272
source := fs.String("source", "eipc-cli", "source service ID")
7373
capability := fs.String("cap", "", "capability header")
74-
fs.Parse(args)
74+
_ = fs.Parse(args)
7575

7676
hmacKey, err := config.LoadHMACKey()
7777
if err != nil {
@@ -118,7 +118,7 @@ func cmdListen(args []string) {
118118
fs := flag.NewFlagSet("listen", flag.ExitOnError)
119119
addr := fs.String("addr", config.LoadListenAddr(), "server address")
120120
count := fs.Int("count", 0, "max messages to receive (0=unlimited)")
121-
fs.Parse(args)
121+
_ = fs.Parse(args)
122122

123123
hmacKey, err := config.LoadHMACKey()
124124
if err != nil {
@@ -153,7 +153,7 @@ func cmdListen(args []string) {
153153
func cmdPing(args []string) {
154154
fs := flag.NewFlagSet("ping", flag.ExitOnError)
155155
addr := fs.String("addr", config.LoadListenAddr(), "server address")
156-
fs.Parse(args)
156+
_ = fs.Parse(args)
157157

158158
hmacKey, err := config.LoadHMACKey()
159159
if err != nil {

cmd/eipc-server/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,3 @@ func handleConnection(
671671
}
672672

673673
// computeChallengeResponse computes HMAC-SHA256(secret, nonce) for client-side auth.
674-
func computeChallengeResponse(secret, nonce []byte) []byte {
675-
mac := hmac.New(sha256.New, secret)
676-
mac.Write(nonce)
677-
return mac.Sum(nil)
678-
}

config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestLoadHMACKey_File(t *testing.T) {
2828
os.Unsetenv("EIPC_HMAC_KEY")
2929

3030
tmpFile := filepath.Join(t.TempDir(), "hmac.key")
31-
os.WriteFile(tmpFile, []byte("file-based-key"), 0600)
31+
_ = os.WriteFile(tmpFile, []byte("file-based-key"), 0600)
3232

3333
os.Setenv("EIPC_KEY_FILE", tmpFile)
3434
defer os.Unsetenv("EIPC_KEY_FILE")

core/benchmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func BenchmarkRouterDispatch(b *testing.B) {
3333

3434
b.ResetTimer()
3535
for i := 0; i < b.N; i++ {
36-
router.Dispatch(msg)
36+
_ = router.Dispatch(msg)
3737
}
3838
}
3939

core/router_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func TestRouterMultipleHandlers(t *testing.T) {
9393
return nil, nil
9494
})
9595

96-
r.Dispatch(NewMessage(TypeIntent, "test", nil))
97-
r.Dispatch(NewMessage(TypeAck, "test", nil))
96+
_ = r.Dispatch(NewMessage(TypeIntent, "test", nil))
97+
_ = r.Dispatch(NewMessage(TypeAck, "test", nil))
9898

9999
if !intentCalled {
100100
t.Error("intent handler not called")

protocol/benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func BenchmarkFrameEncode(b *testing.B) {
2121
b.ResetTimer()
2222
for i := 0; i < b.N; i++ {
2323
var buf bytes.Buffer
24-
frame.Encode(&buf)
24+
_ = frame.Encode(&buf)
2525
}
2626
}
2727

@@ -36,7 +36,7 @@ func BenchmarkFrameDecode(b *testing.B) {
3636
}
3737

3838
var buf bytes.Buffer
39-
frame.Encode(&buf)
39+
_ = frame.Encode(&buf)
4040
encoded := buf.Bytes()
4141

4242
b.ResetTimer()

protocol/fuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func FuzzFrameDecode(f *testing.F) {
1919
Header: []byte(`{"service_id":"test"}`),
2020
Payload: []byte(`{"intent":"move"}`),
2121
}
22-
frame.Encode(&validFrame)
22+
_ = frame.Encode(&validFrame)
2323
f.Add(validFrame.Bytes())
2424

2525
// Seed with minimal valid preamble

security/keyring/keyring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ func (kr *Keyring) Cleanup() int {
159159

160160
func randomBytes(n int) []byte {
161161
b := make([]byte, n)
162-
rand.Read(b)
162+
_ = rand.Read(b)
163163
return b
164164
}

services/audit/audit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestFileLogger_TimestampAutoFill(t *testing.T) {
9393
t.Fatalf("NewFileLogger: %v", err)
9494
}
9595

96-
logger.Log(Entry{Source: "test", Action: "check"})
96+
_ = logger.Log(Entry{Source: "test", Action: "check"})
9797
logger.Close()
9898

9999
data, err := os.ReadFile(tmpFile)
@@ -117,7 +117,7 @@ func TestFileLogger_PresetTimestamp(t *testing.T) {
117117
}
118118

119119
customTS := "2026-01-01T00:00:00Z"
120-
logger.Log(Entry{Timestamp: customTS, Source: "test", Action: "check"})
120+
_ = logger.Log(Entry{Timestamp: customTS, Source: "test", Action: "check"})
121121
logger.Close()
122122

123123
data, err := os.ReadFile(tmpFile)

services/broker/broker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (b *Broker) Route(msg core.Message) []RouteResult {
112112
decision = "failed"
113113
result = err.Error()
114114
}
115-
b.audit.Log(audit.Entry{
115+
_ = b.audit.Log(audit.Entry{
116116
RequestID: msg.RequestID, Source: msg.Source,
117117
Target: sub.ServiceID, Action: string(msg.Type),
118118
Decision: decision, Result: result,

0 commit comments

Comments
 (0)