Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-14811-transcript-symlink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Refuse symlinked Copilot session logs when archiving kick transcripts and judging busy visibility (#14811)
18 changes: 18 additions & 0 deletions src/crux/agent/busy_visibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,21 @@ func TestScanTranscriptActivityWalksAgentsConcurrently(t *testing.T) {
}
}
}

func TestNewestCopilotTranscriptActivityIgnoresSymlinkedEvents(t *testing.T) {
home := t.TempDir()
target := filepath.Join(t.TempDir(), "events.jsonl")
if err := os.WriteFile(target, []byte("{}\n"), 0o644); err != nil {
t.Fatal(err)
}
dir := filepath.Join(home, ".copilot", "session-state", "linked")
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
if err := os.Symlink(target, filepath.Join(dir, "events.jsonl")); err != nil {
t.Fatal(err)
}
if got, ok := newestCopilotTranscriptActivity(home); ok {
t.Fatalf("symlinked events.jsonl counted as activity: %v", got)
}
}
24 changes: 24 additions & 0 deletions src/crux/agent/kick_transcript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,27 @@ func TestListKickLogs_ReportsHeaderSource(t *testing.T) {
t.Errorf("missing file source = %q", got)
}
}

// A symlink planted at events.jsonl is refused: the archive falls back to the
// scrollback rather than reading through the link.
func TestArchiveKickLog_RefusesSymlinkedTranscript(t *testing.T) {
m, agent, dir, home := transcriptTestManager(t, "copilot", kickLogSourceAuto)
path := writeTestTranscript(t, home, "copilot", "")
target := filepath.Join(t.TempDir(), "secret.jsonl")
if err := os.WriteFile(target, []byte(readTranscriptFixture(t, "copilot_events.jsonl")), 0o600); err != nil {
t.Fatal(err)
}
if err := os.Remove(path); err != nil {
t.Fatal(err)
}
if err := os.Symlink(target, path); err != nil {
t.Fatal(err)
}
if !m.archiveKickLogLocked(agent, "kick") {
t.Fatal("archive not written")
}
body := newestArchiveBody(t, m, dir)
if !strings.Contains(body, "source: scrollback\n") || strings.Contains(body, "fix issue 42") {
t.Errorf("symlinked transcript was read:\n%s", body)
}
}
Loading