Compare commits

..
Author SHA1 Message Date
BaaRai 449065aaaa Merge pull request #465 from Coff0xc/fix/upload-no-symlink
fix(server): refuse to upload through a symlink
2026-11-22 09:09:47 +01:00
BaaRai 5df46e22c1 Merge remote-tracking branch 'origin/main' into pr465
# Conflicts:
#	CHANGELOG.md
#	server/chatupload.go
2026-11-22 08:55:15 +01:00
BaaRai 83b35f844b Merge pull request #459 from Coff0xc/fix/upload-name-loop
fix(server): stop the chat upload name search when the path cannot be created
2026-11-22 08:54:03 +01:00
BaaRai 9d7983f1a2 Merge remote-tracking branch 'origin/main' into pr459
# Conflicts:
#	CHANGELOG.md
2026-11-22 08:40:44 +01:00
BaaRai 3ca8f217a3 Merge pull request #464 from Coff0xc/fix/hook-range-budget
fix(hookvm): charge range iterations against the memory budget
2026-11-22 08:40:24 +01:00
BaaRai 132af98029 Merge remote-tracking branch 'origin/main' into pr464
# Conflicts:
#	CHANGELOG.md
2026-11-22 08:30:16 +01:00
BaaRai 6ef01d4f24 Merge pull request #463 from Coff0xc/fix/asset-url-userinfo
fix(db): drop userinfo from an asset URL that cannot be parsed
2026-11-22 08:29:58 +01:00
BaaRai f72311994e Merge remote-tracking branch 'origin/main' into pr463
# Conflicts:
#	CHANGELOG.md
2026-11-22 08:17:20 +01:00
BaaRai 4171a041e6 Merge pull request #462 from Coff0xc/fix/traffic-blob-mode
fix(traffic): keep spilled capture blobs owner-only
2026-11-22 08:17:02 +01:00
BaaRai db867f63a4 Merge remote-tracking branch 'origin/main' into pr462
# Conflicts:
#	CHANGELOG.md
2026-11-22 08:06:58 +01:00
BaaRai d59227c5d4 Merge pull request #461 from Coff0xc/fix/notify-direct
fix(notify): dial notification targets directly
2026-11-22 08:06:32 +01:00
BaaRai f37d09e365 Merge remote-tracking branch 'origin/main' into pr461
# Conflicts:
#	CHANGELOG.md
2026-11-22 07:56:10 +01:00
BaaRai 5ce7ae6006 Merge pull request #458 from Coff0xc/fix/logsink-closed-subscriber
fix(server): do not send a log line to a closed subscriber
2026-11-22 07:55:33 +01:00
BaaRai 7b8be967cc Merge pull request #469 from cyberd4ch/fix/factprovenance-doc-comment
agent: attach the factProvenance doc comment to its function
2026-11-22 07:55:23 +01:00
BaaRai 09eb73c547 Merge pull request #455 from NikolayGusev-astra/fix/remove-dead-traffic-guidance
agent: remove the unused finding traffic guidance constant
2026-11-22 07:55:18 +01:00
BaaRai 43ace17ad7 Merge pull request #472 from BaaRai/feat/ghcr-compose-preset
docs(deploy): GHCR Compose preset for no-git updates
2026-11-22 07:05:17 +01:00
dach-a 1e7696c572 agent: move the factProvenance doc comment off the closing brace
The comment sat on the closing brace of factEvidenceLines, so Go attached it
to no declaration and godoc showed it nowhere. Noted in the review of #441.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 01:02:23 +00:00
Coff0xc f4c7184dcc fix(server): refuse to upload through a symlink
os.Create follows a symlink, and Stat treats a dangling link as missing, so a
name planted in the uploads directory could redirect the server's write.
Destinations are now Lstat'd, a symlink is rejected, and the chat name search
treats a link as taken.
2026-11-21 19:53:50 +00:00
Coff0xc 0c55774613 fix(hookvm): charge range iterations against the memory budget
Ranging over a body or collection built the iteration list without calling
alloc, so a large body bypassed MaxMemory. The length is charged before the
loop, and the run stops with ErrMemoryLimit when it does not fit.
2026-11-21 19:53:08 +00:00
Coff0xc a133b79a0e fix(db): drop userinfo from an asset URL that cannot be parsed
normalizeURL returned the raw string when url.Parse failed, so a password in
scheme://user:password@ survived into the asset row. The authority's userinfo
is removed before that fallback.
2026-11-21 19:52:37 +00:00
Coff0xc 19110a4727 fix(traffic): keep spilled capture blobs owner-only
HTTP and raw-stream bodies written under _blobs were 0644 in a 0755
directory, so any local user could read captured traffic. New blobs are
0600 and the bucket directory is 0700. An existing blob is tightened when
it is seen again.
2026-11-21 19:52:13 +00:00
Coff0xc c8b771881e fix(notify): dial notification targets directly
Cloning the default transport kept ProxyFromEnvironment. The loopback guard
then saw the proxy address, so a link-local URL could still be fetched
through that proxy. Notifications now set Proxy to nil and connect directly.
2026-11-21 19:51:15 +00:00
Coff0xc 0eb66f4c44 fix(server): stop the chat upload name search when the path cannot be created
uniqueUploadPath treated every Stat error except "not exist" as "try the next
suffix". A name the filesystem rejects never becomes "not exist", so the
handler looped. The search now returns that error, and it also stops after
10000 existing suffixes.
2026-11-21 19:33:22 +00:00
Coff0xc 9a8f366574 fix(server): do not send a log line to a closed subscriber
Unsubscribing closes the channel after dropping it from the map. The fan-out
copied the channel and sent after releasing the lock, so the close could land
first and panic the process. The send now happens while the lock is still held.
2026-11-21 19:32:38 +00:00
Николай Гусев 25217afdce refactor(agent): remove unused finding traffic guidance 2026-11-21 21:30:58 +03:00
19 changed files with 293 additions and 28 deletions
+7
View File
@@ -6,6 +6,13 @@ All notable changes to this project are documented in this file. The format is b
### Fixed
- **Live log subscribers can no longer crash the process**: a client disconnect closes its log channel. The sink now delivers a line while it still holds the subscriber lock, so that close cannot land in the middle of the send.
- **Notification delivery ignores HTTP_PROXY**: the dial guard checks the address it connects to. An environment proxy made that address the proxy, so a link-local target could still be reached. Notification HTTP now connects directly.
- **Captured traffic blobs are owner-only**: HTTP and raw-stream bodies spilled out of the database are written `0600`, and their bucket directory is `0700`. An existing blob is tightened when it is seen again.
- **Asset URLs drop userinfo when parsing fails**: a URL `url.Parse` rejects is no longer stored unchanged. The `scheme://userinfo@` prefix is removed first, so a password in that prefix does not land in the asset row.
- **Hook `range` counts against the memory budget**: ranging over a body, slice, string, or map charges the iteration before the loop. A body larger than the hook budget now stops with the memory limit instead of allocating one element at a time with no check.
- **Chat upload name search stops**: choosing `name`, `name-1`, `name-2`, … now returns an error when the filesystem rejects the path or after 10000 collisions, instead of looping while `Stat` keeps failing.
- **Uploads do not follow a symlink**: chat and workspace uploads `Lstat` the destination and refuse to write when it is already a symlink. A dangling link is no longer treated as a free name.
- **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450).
## [0.7.0] - 2026-11-21
-4
View File
@@ -20,10 +20,6 @@ type TrafficCaptureChecker interface {
TrafficExists(ctx context.Context, trafficID string) (bool, error)
}
// Tool-use guidance is appended without replacing the user's editable prompt.
// It does not require capture or claim that unavailable traffic tools exist.
const findingTrafficGuidance = "\n\n**Vulnerability traffic evidence**: when reporting a vulnerability via report_finding, bind real HTTP request/response IDs via traffic_refs in reproduction order; domains and times are only candidate filters and do not imply association. A finding without bound traffic stays recorded and visible, but cannot close a goal via prove_goal until verified traffic matching its asset host is bound (via report_finding or bind_finding_traffic). For TCP and other non-HTTP vulnerabilities, when nothing was captured, or when there is no exact match, omit traffic_refs or pass [], keep verifiable command output and logs in evidence, and close non-HTTP goals with an observed tool_output fact. Do not guess IDs, and do not re-probe just to capture packets."
func (t *ToolSet) SetFindingRecorder(r FindingRecorder) { t.findingRecorder = r }
func (w *Worker) SetFindingRecorder(r FindingRecorder) { w.findingRecorder = r }
func (p *Planner) SetFindingRecorder(r FindingRecorder) { p.findingRecorder = r }
+26
View File
@@ -0,0 +1,26 @@
package agent
import (
"go/ast"
"go/parser"
"go/token"
"testing"
)
func TestFindingRecorderHasNoLegacyTrafficGuidance(t *testing.T) {
// Check the declaration directly: an unused constant cannot affect prompt output.
f, err := parser.ParseFile(token.NewFileSet(), "finding_recorder.go", nil, parser.SkipObjectResolution)
if err != nil {
t.Fatal(err)
}
ast.Inspect(f, func(n ast.Node) bool {
if spec, ok := n.(*ast.ValueSpec); ok {
for _, name := range spec.Names {
if name.Name == "findingTrafficGuidance" {
t.Fatal("finding_recorder.go declares the obsolete findingTrafficGuidance constant")
}
}
}
return true
})
}
+3 -1
View File
@@ -1692,7 +1692,9 @@ func factEvidenceLines(evidence string) []string {
}
}
return out
} // factProvenance classifies one fact against the intent's recorded activity.
}
// factProvenance classifies one fact against the intent's recorded activity.
// Beyond the activity tie it checks whether the quoted bytes were captured
// coming back from the target through the proxy, in which case the target
// authored them and the fact is classified target_response even when the model
+20 -1
View File
@@ -165,7 +165,7 @@ func calcCSegment(ipStr string) string {
func normalizeURL(raw string) string {
u, err := url.Parse(raw)
if err != nil {
return raw
return stripURLUserinfo(raw)
}
u.Scheme = strings.ToLower(u.Scheme)
u.Host = strings.ToLower(u.Host)
@@ -177,6 +177,25 @@ func normalizeURL(raw string) string {
return s
}
// stripURLUserinfo removes scheme://userinfo@ when url.Parse cannot. The
// userinfo is the span before the last @ that still sits in the authority.
func stripURLUserinfo(raw string) string {
i := strings.Index(raw, "://")
if i < 0 {
return raw
}
rest := raw[i+3:]
authEnd := len(rest)
if j := strings.IndexAny(rest, "/?#"); j >= 0 {
authEnd = j
}
at := strings.LastIndex(rest[:authEnd], "@")
if at < 0 {
return raw
}
return raw[:i+3] + rest[at+1:]
}
// parseURL extracts domain, port, service_name from a URL.
func parseURL(raw string) (domain string, port int, serviceName string) {
u, err := url.Parse(raw)
+1
View File
@@ -908,6 +908,7 @@ func TestNormalizeURL(t *testing.T) {
{"https://user@example.com/", "https://example.com"},
{"https://u:p@example.com:8443/users/@alice?x=1", "https://example.com:8443/users/@alice?x=1"},
{"https://example.com/@me?r=http://a:b@x/", "https://example.com/@me?r=http://a:b@x/"},
{"http://user:secret@ex ample.com/a", "http://ex ample.com/a"},
}
for _, tc := range tests {
got := normalizeURL(tc.raw)
+4
View File
@@ -104,6 +104,10 @@ var notifyTransport = func() *http.Transport {
return &http.Transport{}
}
clone := t.Clone()
// Clone keeps ProxyFromEnvironment. The dial would then be to the proxy, so
// blockInternalDial would see the proxy address and a link-local target
// could still be reached through it. Notifications go direct.
clone.Proxy = nil
clone.DialContext = (&net.Dialer{Timeout: 10 * time.Second, Control: blockInternalDial}).DialContext
return clone
}()
+9
View File
@@ -0,0 +1,9 @@
package notify
import "testing"
func TestNotifyTransportIgnoresEnvironmentProxy(t *testing.T) {
if notifyTransport.Proxy != nil {
t.Fatal("notification transport must dial the target, not an environment proxy")
}
}
+31 -8
View File
@@ -21,6 +21,10 @@ const (
// Allow multipart headers and boundaries in addition to the file data.
chatUploadMultipartOverhead = 1 << 20 // 1 MiB
chatUploadLimitMessage = "files exceed the 512 MiB upload limit"
// maxUploadNameTries bounds the name-1, name-2, … search. A Stat error that
// is not "not exist" (a component the filesystem rejects) must stop the
// search instead of spinning.
maxUploadNameTries = 10000
)
// safeChatID guards the {id} path segment against traversal — task ids are numeric,
@@ -123,7 +127,11 @@ func (s *Server) chatUpload(w http.ResponseWriter, r *http.Request) {
if name == "" || name == "." || name == ".." || strings.ContainsAny(name, `/\`) {
continue
}
dest := uniqueUploadPath(dir, name)
dest, err := uniqueUploadPath(dir, name)
if err != nil {
writeErr(w, 500, "Save failed: "+err.Error())
return
}
if err := saveUpload(hdr, dest); err != nil {
writeErr(w, 500, "Save failed: "+err.Error())
return
@@ -136,19 +144,34 @@ func (s *Server) chatUpload(w http.ResponseWriter, r *http.Request) {
// uniqueUploadPath returns dir/name, or dir/name-1, dir/name-2… when it already exists,
// so re-uploading the same filename never clobbers a prior attachment.
func uniqueUploadPath(dir, name string) string {
dest := filepath.Join(dir, name)
if _, err := os.Stat(dest); os.IsNotExist(err) {
return dest
func uniqueUploadPath(dir, name string) (string, error) {
if dest, ok, err := uploadPathFree(filepath.Join(dir, name)); err != nil || ok {
return dest, err
}
ext := filepath.Ext(name)
stem := strings.TrimSuffix(name, ext)
for i := 1; ; i++ {
for i := 1; i <= maxUploadNameTries; i++ {
cand := filepath.Join(dir, fmt.Sprintf("%s-%d%s", stem, i, ext))
if _, err := os.Stat(cand); os.IsNotExist(err) {
return cand
dest, ok, err := uploadPathFree(cand)
if err != nil || ok {
return dest, err
}
}
return "", fmt.Errorf("no free name for upload %q", name)
}
// uploadPathFree reports whether path can be created. ok is false when a file
// or a symlink (including a dangling one) is already there. Any other Lstat
// error is returned so the caller stops.
func uploadPathFree(path string) (dest string, ok bool, err error) {
_, err = os.Lstat(path)
if errors.Is(err, os.ErrNotExist) {
return path, true, nil
}
if err != nil {
return "", false, err
}
return "", false, nil
}
// composeAgentMessage appends an attachment manifest to the user's message so the agent
+33
View File
@@ -0,0 +1,33 @@
package server
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestUniqueUploadPathSuffixesCollisions(t *testing.T) {
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "note.txt"), []byte("a"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, "note-1.txt"), []byte("b"), 0o644); err != nil {
t.Fatal(err)
}
got, err := uniqueUploadPath(dir, "note.txt")
if err != nil {
t.Fatal(err)
}
if filepath.Base(got) != "note-2.txt" {
t.Fatalf("got %s", got)
}
}
func TestUniqueUploadPathStopsOnUnstorableName(t *testing.T) {
dir := t.TempDir()
name := strings.Repeat("a", 300) + ".txt"
if _, err := uniqueUploadPath(dir, name); err == nil {
t.Fatal("an overlong file name must not be searched forever")
}
}
+8 -9
View File
@@ -152,9 +152,15 @@ func (s *logSinkT) add(l LogLine) {
s.ring = s.ring[len(s.ring)-s.cap:]
}
ch := s.dbCh
subs := make([]chan LogLine, 0, len(s.subs))
// Fan-out stays under the lock. subscribe's cancel removes the channel and
// then closes it; a send on a closed channel panics even inside select, so
// the send and the close must not interleave. The send does not block: a
// full buffer drops the line.
for sub := range s.subs {
subs = append(subs, sub)
select {
case sub <- l:
default:
}
}
s.mu.Unlock()
@@ -165,13 +171,6 @@ func (s *logSinkT) add(l LogLine) {
default:
}
}
for _, sub := range subs {
select {
case sub <- l:
default:
}
}
}
// recent returns ring lines with Seq > since (capped to limit), and the latest seq.
+23
View File
@@ -0,0 +1,23 @@
package server
import (
"io"
"sync"
"testing"
)
func TestLogSinkUnsubscribeDuringAddDoesNotPanic(t *testing.T) {
s := &logSinkT{cap: 8, subs: map[chan LogLine]struct{}{}, out: io.Discard}
var wg sync.WaitGroup
for i := 0; i < 32; i++ {
_, unsub := s.subscribe()
wg.Add(1)
go func() {
defer wg.Done()
unsub()
}()
s.add(LogLine{Text: "line"})
}
wg.Wait()
s.add(LogLine{Text: "after"})
}
+33
View File
@@ -0,0 +1,33 @@
package server
import (
"os"
"path/filepath"
"testing"
)
func TestRefuseUploadSymlink(t *testing.T) {
dir := t.TempDir()
target := filepath.Join(dir, "secret")
if err := os.WriteFile(target, []byte("keep"), 0o644); err != nil {
t.Fatal(err)
}
link := filepath.Join(dir, "upload")
if err := os.Symlink(target, link); err != nil {
t.Skipf("symlink: %v", err)
}
if err := refuseUploadSymlink(link); err == nil {
t.Fatal("symlink destination was accepted")
}
body, err := os.ReadFile(target)
if err != nil {
t.Fatal(err)
}
if string(body) != "keep" {
t.Fatalf("target changed to %q", body)
}
missing := filepath.Join(dir, "fresh")
if err := refuseUploadSymlink(missing); err != nil {
t.Fatal(err)
}
}
+23 -1
View File
@@ -2,6 +2,7 @@ package server
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
@@ -340,12 +341,15 @@ func (s *Server) wsUpload(w http.ResponseWriter, r *http.Request) {
}
func saveUpload(hdr *multipart.FileHeader, dest string) error {
if err := refuseUploadSymlink(dest); err != nil {
return err
}
src, err := hdr.Open()
if err != nil {
return err
}
defer src.Close()
out, err := os.Create(dest)
out, err := os.OpenFile(dest, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return err
}
@@ -354,6 +358,24 @@ func saveUpload(hdr *multipart.FileHeader, dest string) error {
return err
}
// refuseUploadSymlink rejects a destination that is already a symlink. os.Create
// follows one, including a dangling link that Stat reports as missing, so an
// agent that can write the uploads directory could aim the server's write at
// another path. Lstat sees the link itself.
func refuseUploadSymlink(dest string) error {
fi, err := os.Lstat(dest)
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
if fi.Mode()&os.ModeSymlink != 0 {
return fmt.Errorf("refusing to write through a symlink")
}
return nil
}
// sanitizeFilename strips characters unsafe for a Content-Disposition filename token.
func sanitizeFilename(name string) string {
name = strings.ReplaceAll(name, "\"", "")
+38
View File
@@ -0,0 +1,38 @@
package traffic
import (
"bytes"
"os"
"path/filepath"
"runtime"
"testing"
)
func TestSpillBlobIsOwnerOnly(t *testing.T) {
dir := t.TempDir()
tr := &Traffic{dir: dir}
body := bytes.Repeat([]byte("a"), maxInlineBody+1)
got := tr.spill(body, "text/plain")
if got.hash == "" {
t.Fatal("expected a spilled blob")
}
blobDir := filepath.Join(dir, "_blobs", "sha256", got.hash[:2])
blobPath := filepath.Join(blobDir, got.hash+".bin")
info, err := os.Stat(blobPath)
if err != nil {
t.Fatal(err)
}
dirInfo, err := os.Stat(blobDir)
if err != nil {
t.Fatal(err)
}
if runtime.GOOS == "windows" {
return
}
if info.Mode().Perm() != 0o600 {
t.Fatalf("blob mode %o, want 0600", info.Mode().Perm())
}
if dirInfo.Mode().Perm() != 0o700 {
t.Fatalf("blob dir mode %o, want 0700", dirInfo.Mode().Perm())
}
}
+6
View File
@@ -330,24 +330,30 @@ func (e *vm) execRange(s *ast.RangeStmt, sc *env) (flowSignal, any) {
var items []kvPair
switch x := e.eval(s.X, sc).(type) {
case []byte:
e.alloc(int64(len(x)) * 16)
for i, v := range x {
items = append(items, kvPair{int64(i), int64(v)})
}
case []any:
e.alloc(int64(len(x)) * 16)
for i, v := range x {
items = append(items, kvPair{int64(i), v})
}
case []string:
e.alloc(int64(len(x)) * 16)
for i, v := range x {
items = append(items, kvPair{int64(i), v})
}
case string:
e.alloc(int64(len(x)) * 16)
for i, r := range x {
items = append(items, kvPair{int64(i), int64(r)})
}
case map[string]any:
e.alloc(int64(len(x)) * 16)
items = sortedMapPairs(x)
case map[string][]string:
e.alloc(int64(len(x)) * 16)
items = sortedMapPairs(x)
case nil:
return flowNone, nil
+19
View File
@@ -204,6 +204,25 @@ func OnResponse(req *Request, resp *Response) error {
}
func TestResourceBoundsMemoryStepTimeoutPanicAndRegexp(t *testing.T) {
t.Run("range_over_body_stopped_by_memory_budget", func(t *testing.T) {
src := `package hook
func OnRequest(req *Request) error {
for _, b := range req.Body {
_ = b
}
return nil
}`
prog, err := Compile("request", src)
if err != nil {
t.Fatal(err)
}
body := make([]byte, 256<<10)
err = prog.RunRequest(context.Background(), &Request{Body: body}, RunOptions{MaxMemory: 64 << 10})
if !errors.Is(err, ErrMemoryLimit) {
t.Fatalf("err = %v, want ErrMemoryLimit", err)
}
})
t.Run("make_100MiB_stopped_by_memory_budget", func(t *testing.T) {
src := `package hook
func OnRequest(req *Request) error {
+2 -2
View File
@@ -63,7 +63,7 @@ func (t *Traffic) spillRawDir(data []byte, previewCap int) (preview []byte, blob
sum := sha256.Sum256(data)
h := hex.EncodeToString(sum[:])
blobDir := filepath.Join(t.dir, "_blobs", "sha256", h[:2])
if err := os.MkdirAll(blobDir, 0o755); err != nil {
if err := os.MkdirAll(blobDir, 0o700); err != nil {
log.Printf("[traffic/socks5] failed to create blob directory: %v", err)
return append([]byte(nil), data[:previewCap]...), ""
}
@@ -96,7 +96,7 @@ func writeBlobAtomic(blobDir, blobPath, hash string, data []byte) error {
_ = tmp.Close()
return err
}
if err := tmp.Chmod(0o644); err != nil {
if err := tmp.Chmod(0o600); err != nil {
_ = tmp.Close()
return err
}
+7 -2
View File
@@ -873,16 +873,21 @@ func (t *Traffic) spillAt(body []byte, contentType string, maxInline int) stored
// One bucket level (256 buckets) is enough to keep any single directory small;
// the store only ever holds bodies above maxInlineBody, deduplicated by hash.
blobDir := filepath.Join(t.dir, "_blobs", "sha256", h[:2])
if err := os.MkdirAll(blobDir, 0o755); err != nil {
if err := os.MkdirAll(blobDir, 0o700); err != nil {
log.Printf("[traffic] failed to create blob directory: %v", err)
return storedBody{inline: clipBytes(body, blobPreview), index: indexText()}
}
if err := os.Chmod(blobDir, 0o700); err != nil {
log.Printf("[traffic] failed to restrict blob directory: %v", err)
}
blobPath := filepath.Join(blobDir, h+".bin")
if _, err := os.Stat(blobPath); os.IsNotExist(err) {
if err := os.WriteFile(blobPath, body, 0o644); err != nil {
if err := os.WriteFile(blobPath, body, 0o600); err != nil {
log.Printf("[traffic] failed to write blob %s: %v", h, err)
return storedBody{inline: clipBytes(body, blobPreview), index: indexText()}
}
} else if err := os.Chmod(blobPath, 0o600); err != nil {
log.Printf("[traffic] failed to restrict blob %s: %v", h, err)
}
sb := storedBody{hash: h, index: indexText()}
if text {