🛡️ Sentinel: [MEDIUM] Fix missing HTTP client timeout in jules API client

Added a 15-second timeout to the http.Client in cmd/picoclaw/internal/jules/jules.go to prevent potential resource exhaustion or indefinite hangs if the external service is slow or unresponsive.

Co-authored-by: hobbyistlabs-coder <267281733+hobbyistlabs-coder@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-03-17 17:25:23 +00:00
parent 9fb071836b
commit d98b69dedb
11 changed files with 50 additions and 47 deletions

View file

@ -7,6 +7,7 @@ import (
"io"
"net/http"
"os"
"time"
"github.com/spf13/cobra"
@ -43,7 +44,9 @@ func doRequest(method, url string, body []byte) error {
req.Header.Set("x-goog-api-key", apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
client := &http.Client{
Timeout: 15 * time.Second,
}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("error making request: %w", err)

View file

@ -844,15 +844,15 @@ func TestTargetReasoningChannelID_AllChannels(t *testing.T) {
t.Fatalf("Failed to create channel manager: %v", err)
}
for name, id := range map[string]string{
"whatsapp": "rid-whatsapp",
"telegram": "rid-telegram",
"discord": "rid-discord",
"maixcam": "rid-maixcam",
"qq": "rid-qq",
"dingtalk": "rid-dingtalk",
"slack": "rid-slack",
"line": "rid-line",
"onebot": "rid-onebot",
"whatsapp": "rid-whatsapp",
"telegram": "rid-telegram",
"discord": "rid-discord",
"maixcam": "rid-maixcam",
"qq": "rid-qq",
"dingtalk": "rid-dingtalk",
"slack": "rid-slack",
"line": "rid-line",
"onebot": "rid-onebot",
} {
chManager.RegisterChannel(name, &fakeChannel{id: id})
}

View file

@ -1,18 +1,18 @@
package config
type ChannelsConfig struct {
WhatsApp WhatsAppConfig `json:"whatsapp"`
Telegram TelegramConfig `json:"telegram"`
Discord DiscordConfig `json:"discord"`
MaixCam MaixCamConfig `json:"maixcam"`
QQ QQConfig `json:"qq"`
DingTalk DingTalkConfig `json:"dingtalk"`
Slack SlackConfig `json:"slack"`
Matrix MatrixConfig `json:"matrix"`
LINE LINEConfig `json:"line"`
OneBot OneBotConfig `json:"onebot"`
Pico PicoConfig `json:"pico"`
IRC IRCConfig `json:"irc"`
WhatsApp WhatsAppConfig `json:"whatsapp"`
Telegram TelegramConfig `json:"telegram"`
Discord DiscordConfig `json:"discord"`
MaixCam MaixCamConfig `json:"maixcam"`
QQ QQConfig `json:"qq"`
DingTalk DingTalkConfig `json:"dingtalk"`
Slack SlackConfig `json:"slack"`
Matrix MatrixConfig `json:"matrix"`
LINE LINEConfig `json:"line"`
OneBot OneBotConfig `json:"onebot"`
Pico PicoConfig `json:"pico"`
IRC IRCConfig `json:"irc"`
}
// GroupTriggerConfig controls when the bot responds in group chats.

View file

@ -66,12 +66,12 @@ func (rt *ResourceTracker) logResources() {
sysMB := float64(m.Sys) / 1024 / 1024
logger.InfoCF("SystemHealth", "Resource tracking telemetry", map[string]any{
"goroutines": goroutines,
"memory_alloc_mb": allocMB,
"memory_total_mb": totalAllocMB,
"memory_sys_mb": sysMB,
"num_gc": m.NumGC,
"gc_pause_ns": m.PauseNs[(m.NumGC+255)%256], // Latest GC pause time
"goroutines": goroutines,
"memory_alloc_mb": allocMB,
"memory_total_mb": totalAllocMB,
"memory_sys_mb": sysMB,
"num_gc": m.NumGC,
"gc_pause_ns": m.PauseNs[(m.NumGC+255)%256], // Latest GC pause time
"gc_pause_total_ns": m.PauseTotalNs,
})
}

View file

@ -34,9 +34,9 @@ var (
currentTimeFormat = "15:04:05"
logger zerolog.Logger
fileLogger zerolog.Logger
logFile *os.File
once sync.Once
mu sync.RWMutex
logFile *os.File
once sync.Once
mu sync.RWMutex
)
func init() {

View file

@ -13,14 +13,14 @@ var migrateableDirs = []string{
}
var supportedChannels = map[string]bool{
"whatsapp": true,
"telegram": true,
"discord": true,
"maixcam": true,
"qq": true,
"dingtalk": true,
"slack": true,
"matrix": true,
"line": true,
"onebot": true,
"whatsapp": true,
"telegram": true,
"discord": true,
"maixcam": true,
"qq": true,
"dingtalk": true,
"slack": true,
"matrix": true,
"line": true,
"onebot": true,
}

View file

@ -107,8 +107,8 @@ func (t *AlpacaTool) getPrice(symbol string) *tools.ToolResult {
func (t *AlpacaTool) getSMA(symbol string) *tools.ToolResult {
req := marketdata.GetBarsRequest{
TimeFrame: marketdata.OneDay,
TotalLimit: 10, // 10-day simple moving average
TimeFrame: marketdata.OneDay,
TotalLimit: 10, // 10-day simple moving average
}
bars, err := t.marketData.GetBars(symbol, req)
if err != nil {

View file

@ -259,7 +259,7 @@ func splitQuoted(s string) []string {
var quoteChar rune
for _, r := range s {
if (r == '"' || r == '\'') {
if r == '"' || r == '\'' {
if inQuotes && quoteChar == r {
inQuotes = false
} else if !inQuotes {

View file

@ -2,8 +2,8 @@ package tools
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSplitQuoted(t *testing.T) {

View file

@ -1,12 +1,12 @@
package web
import (
"jane/pkg/tools"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"jane/pkg/tools"
"net"
"net/http"
"net/url"

View file

@ -1,9 +1,9 @@
package web
import (
"jane/pkg/tools"
"context"
"fmt"
"jane/pkg/tools"
)
type WebSearchTool struct {