🛡️ 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:
parent
9fb071836b
commit
d98b69dedb
11 changed files with 50 additions and 47 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package tools
|
|||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplitQuoted(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"jane/pkg/tools"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"jane/pkg/tools"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"jane/pkg/tools"
|
||||
"context"
|
||||
"fmt"
|
||||
"jane/pkg/tools"
|
||||
)
|
||||
|
||||
type WebSearchTool struct {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue