Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

fix(agent): keep LLM connection-test logs on one line

Coff0xca61932c4daab
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5af6fb6..4a47e52 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b
### Fixed
+- **LLM connection-test logs stay one line**: the response body written by a connection test has CR and LF replaced with spaces before it is logged, so the body cannot start a second log record.
- **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
diff --git a/agent/clipbody_test.go b/agent/clipbody_test.go
new file mode 100644
index 0000000..21194ba
--- /dev/null
+++ b/agent/clipbody_test.go
@@ -0,0 +1,16 @@
+package agent
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestClipBodyFlattensNewlines(t *testing.T) {
+ got := clipBody("ok\r\ninjected log line\n")
+ if strings.Contains(got, "\n") || strings.Contains(got, "\r") {
+ t.Fatalf("clipBody kept a line break: %q", got)
+ }
+ if !strings.Contains(got, "injected log line") {
+ t.Fatalf("clipBody dropped the text: %q", got)
+ }
+}
diff --git a/agent/provider.go b/agent/provider.go
index 96d39a6..088fcbb 100644
--- a/agent/provider.go
+++ b/agent/provider.go
@@ -602,6 +602,11 @@ func logTestConnection(c Config, capt *llmrec.Capture) {
// the head of an SSE stream while bounding a runaway response.
func clipBody(s string) string {
s = strings.TrimSpace(s)
+ // One log record per attempt. A body that contains a newline would
+ // otherwise look like a second log line.
+ s = strings.ReplaceAll(s, "\r\n", " ")
+ s = strings.ReplaceAll(s, "\n", " ")
+ s = strings.ReplaceAll(s, "\r", " ")
if s == "" {
return "(empty)"
}