Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

feat(autoindex): index journalctl/ISO syslog and vsftpd xferlog as per-line log records (#1504) (#1508)

ordinary beingf3b38a87a662
diff --git a/engine/crates/xerj-autoindex/src/extract/logs.rs b/engine/crates/xerj-autoindex/src/extract/logs.rs
index 97a8ff80a..307cf3def 100644
--- a/engine/crates/xerj-autoindex/src/extract/logs.rs
+++ b/engine/crates/xerj-autoindex/src/extract/logs.rs
@@ -1,5 +1,8 @@
//! Server-log families: CLF/combined access logs, app logs
-//! (`YYYY-MM-DD HH:MM:SS,ms LEVEL [thread] message`), RFC3164 syslog.
+//! (`YYYY-MM-DD HH:MM:SS,ms LEVEL [thread] message`), RFC3164 syslog, and —
+//! since #1504 — ISO-prefixed syslog (`journalctl -o short-iso` and friends:
+//! `TS host prog[pid]: message`, with an optional `<PRI>` whose severity is
+//! decoded) and `xferlog` (`vsftpd`/wu-ftpd transfer records, 14 fields).
//! One template is elected per file from the first 200 lines; unmatched
//! lines under an elected template are treated as continuations (multiline
//! stack traces) and appended to the previous record's message.
@@ -17,6 +20,8 @@ struct Templates {
clf: Regex,
applog: Regex,
syslog: Regex,
+ isosyslog: Regex,
+ xferlog: Regex,
kv: Regex,
}
@@ -35,6 +40,40 @@ fn templates() -> &'static Templates {
r"^([A-Z][a-z]{2} +\d+ \d{2}:\d{2}:\d{2}) (\S+) ([\w./-]+)(?:\[(\d+)\])?: (.*)$",
)
.unwrap(),
+ // #1504: `journalctl -o short-iso` / rsyslog ISO templates —
+ // `TS host TAG[pid]: message`, ISO-8601 timestamp (offset optional),
+ // an optional leading `<PRI>` (facility*8 + severity) decoded into
+ // `severity`/`facility`.
+ //
+ // Deliberately strict, because the Logs probe runs before CSV and
+ // prose detection and an ISO timestamp opens half the log lines in
+ // the world (#1504 review):
+ // * inter-field separators are single literal spaces, so
+ // tab-separated TSV and zap dev logs do not match;
+ // * the tag starts with a letter or `(` — an `IPv4:port` token
+ // (ELB access logs) starts with a digit and does not match;
+ // * a tag is either bracketed with a numeric pid, or a bare tag
+ // from the small set syslog(3) writers emit without LOG_PID
+ // (`kernel`, `sudo`, `su`, `audit`) or a parenthesised systemd
+ // unit/executable name (`(sd-pam)`). A bare English word —
+ // `2026-10-16T09:06:58 retro notes: we shipped` — is prose.
+ isosyslog: Regex::new(
+ r"^(?:<(\d{1,3})>)?(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:[.,]\d{1,9})?(?:Z|[+-]\d{2}:?\d{2})?) (\S+) (?:([A-Za-z(][^\s\[\]:]*)\[(\d+)\]|(kernel|sudo|su|audit|\([^)]*\))): ?(.*)$",
+ )
+ .unwrap(),
+ // #1504: vsftpd/wu-ftpd `xferlog` — fixed 14-field transfer records,
+ // weekday-first date. Field order: date, transfer-time(s), remote
+ // host, bytes, path, transfer type (a|b), special action flag
+ // (_|C|U|T), direction (o|i|d), access mode (a|r|g), user, service,
+ // auth method (0|1), authenticated user id (*|name), status (c|i).
+ // vsftpd writes only a|r and o|i; `g` (guest, wu-ftpd) and `d`
+ // (delete, ProFTPD) are accepted because the PR covers wu-ftpd too.
+ // The path is lazy, not `\S+`: vsftpd writes the filename verbatim,
+ // spaces included, and the nine fixed fields after it anchor the end.
+ xferlog: Regex::new(
+ r"^([A-Z][a-z]{2} [A-Z][a-z]{2} +\d+ \d{2}:\d{2}:\d{2} \d{4}) (\d+) (\S+) (\d+) (\S.*?) ([ab]) ([_CUT*]) ([oid]) ([agr]) (\S+) (\S+) ([01]) (\S+) ([ci])\s*$",
+ )
+ .unwrap(),
kv: Regex::new(r#"\b([A-Za-z_][A-Za-z0-9_.]*)=("(?:[^"\\]|\\.)*"|\S+)"#).unwrap(),
})
}
@@ -44,6 +83,8 @@ enum Kind {
Clf,
App,
Syslog,
+ IsoSyslog,
+ Xferlog,
}
impl Kind {
@@ -51,15 +92,19 @@ impl Kind {
/// the order `parse_kind` tries the templates in, so an ambiguous FILE
/// resolves the way an ambiguous LINE does — most specific first. The app
/// template demands an ISO timestamp *and* a level keyword; CLF demands a
- /// quoted request line *and* a 3-digit status; the syslog pattern is by
- /// far the loosest (`Mon dd HH:MM:SS host prog: rest`) and will claim
- /// lines the other two describe better. Every variant has a distinct
- /// rank, which is what makes the ordering total.
+ /// quoted request line *and* a 3-digit status; xferlog demands the fixed
+ /// 14-field record shape; the ISO-syslog template demands an ISO timestamp
+ /// *and* the `prog[pid]:` colon form; the RFC3164 pattern is by far the
+ /// loosest (`Mon dd HH:MM:SS host prog: rest`) and will claim lines the
+ /// others describe better. Every variant has a distinct rank, which is
+ /// what makes the ordering total.
fn specificity(self) -> u8 {
match self {
Kind::App => 0,
Kind::Clf => 1,
- Kind::Syslog => 2,
+ Kind::Xferlog => 2,
+ Kind::IsoSyslog => 3,
+ Kind::Syslog => 4,
}
}
}
@@ -96,6 +141,10 @@ fn parse_kind(line: &str) -> Option<Kind> {
Some(Kind::App)
} else if t.clf.is_match(line) {
Some(Kind::Clf)
+ } else if t.xferlog.is_match(line) {
+ Some(Kind::Xferlog)
+ } else if t.isosyslog.is_match(line) {
+ Some(Kind::IsoSyslog)
} else if t.syslog.is_match(line) {
Some(Kind::Syslog)
} else {
@@ -169,6 +218,128 @@ fn parse_line(line: &str, kind: Kind) -> Option<Map<String, Value>> {
let msg = c.get(5)?.as_str().to_string();
lift_kv(&msg, &mut m);
}
+ Kind::IsoSyslog => {
+ let c = t.isosyslog.captures(line)?;
+ // Optional `<PRI>`: facility*8 + severity (RFC 5424 §6.2.1). Only
+ // recorded when the writer actually emitted one — `journalctl -o
+ // short-iso` has no priority field, and inventing one would be a
+ // lie about the data. PRI's domain is 0..=191 (facility 0..=23 × 8
+ // + severity 0..=7); `<999>` is not a priority, so it stays
+ // unrecorded rather than decoding into a facility of 124.
+ if let Some(pri) = c
+ .get(1)
+ .and_then(|p| p.as_str().parse::<u16>().ok())
+ .filter(|p| *p <= 191)
+ {
+ const SEVERITY: [&str; 8] = [
+ "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug",
+ ];
+ m.insert(
+ "severity".into(),
+ Value::String(SEVERITY[(pri & 7) as usize].to_string()),
+ );
+ m.insert("facility".into(), Value::Number((pri >> 3).into()));
+ }
+ m.insert("ts".into(), Value::String(c.get(2)?.as_str().to_string()));
+ m.insert("host".into(), Value::String(c.get(3)?.as_str().to_string()));
+ // Group 4 is a tagged pid, group 6 a bare no-pid tag.
+ let program = c.get(4).or_else(|| c.get(6))?;
+ m.insert(
+ "program".into(),
+ Value::String(program.as_str().to_string()),
+ );
+ if let Some(pid) = c.get(5) {
+ if let Ok(n) = pid.as_str().parse::<i64>() {
+ m.insert("pid".into(), Value::Number(n.into()));
+ }
+ }
+ let msg = c.get(7)?.as_str().to_string();
+ lift_kv(&msg, &mut m);
+ }
+ Kind::Xferlog => {
+ let c = t.xferlog.captures(line)?;
+ let g = |i: usize| c.get(i).map(|x| x.as_str().to_string());
+ m.insert("ts".into(), Value::String(g(1)?));
+ if let Ok(n) = g(2)?.parse::<i64>() {
+ m.insert("duration_s".into(), Value::Number(n.into()));
+ }
+ m.insert("host".into(), Value::String(g(3)?));
+ if let Ok(n) = g(4)?.parse::<i64>() {
+ m.insert("bytes".into(), Value::Number(n.into()));
+ }
+ m.insert("path".into(), Value::String(g(5)?));
+ // The single-letter xferlog fields are spelled out: `b`/`a`,
+ // `o`/`i`, `r`/`a` and `c`/`i` collide as raw letters (the same
+ // `a` means ascii in one column and anonymous in the next), and a
+ // callers-first reader is what this index is for.
+ m.insert(
+ "transfer_type".into(),
+ Value::String(match g(6)?.as_str() {
+ "a" => "ascii".into(),
+ _ => "binary".into(),
+ }),
+ );
+ let action = g(7)?;
+ if action != "_" {
+ m.insert(
+ "action".into(),
+ Value::String(
+ match action.as_str() {
+ "C" => "compressed",
+ "U" => "uncompressed",
+ "T" => "tar",
+ other => other,
+ }
+ .into(),
+ ),
+ );
+ }
+ m.insert(
+ "direction".into(),
+ Value::String(
+ match g(8)?.as_str() {
+ "i" => "incoming",
+ // ProFTPD writes `d` for deletes; vsftpd never does.
+ "d" => "delete",
+ _ => "outgoing",
+ }
+ .into(),
+ ),
+ );
+ m.insert(
+ "access".into(),
+ Value::String(
+ match g(9)?.as_str() {
+ "a" => "anonymous",
+ // `g` is wu-ftpd's guest access; vsftpd writes a|r only.
+ "g" => "guest",
+ _ => "real",
+ }
+ .into(),
+ ),
+ );
+ m.insert("user".into(), Value::String(g(10)?));
+ m.insert("service".into(), Value::String(g(11)?));
+ m.insert(
+ "auth_method".into(),
+ Value::String(if g(12)? == "1" { "rfc931" } else { "none" }.into()),
+ );
+ let auth_user = g(13)?;
+ if auth_user != "*" {
+ m.insert("auth_user".into(), Value::String(auth_user));
+ }
+ m.insert(
+ "status".into(),
+ Value::String(
+ if g(14)? == "i" {
+ "incomplete"
+ } else {
+ "complete"
+ }
+ .into(),
+ ),
+ );
+ }
}
Some(m)
}
@@ -316,6 +487,230 @@ mod tests {
assert_eq!(m["message"], serde_json::json!("Segment merge."));
}
+ /// #1504: `journalctl -o short-iso` / ISO-prefixed syslog —
+ /// `TS host prog[pid]: message`, with an optional `<PRI>`.
+ #[test]
+ fn iso_syslog_lines_parse_to_fields() {
+ let j = "2026-10-16T09:06:59+0200 pbx vsftpd[1234]: CONNECT: Client \"10.0.0.7\"";
+ assert_eq!(parse_kind(j), Some(Kind::IsoSyslog));
+ let m = parse_line(j, Kind::IsoSyslog).unwrap();
+ assert_eq!(m["ts"], serde_json::json!("2026-10-16T09:06:59+0200"));
+ assert_eq!(m["host"], serde_json::json!("pbx"));
+ assert_eq!(m["program"], serde_json::json!("vsftpd"));
+ assert_eq!(m["pid"], serde_json::json!(1234));
+ assert_eq!(
+ m["message"],
+ serde_json::json!("CONNECT: Client \"10.0.0.7\"")
+ );
+
+ // Kernel line: no pid bracket, `Z`-suffixed stamp, colon-separated msg.
+ let k = "2026-10-16T09:06:58Z pbx kernel: eth0: link up";
+ let m = parse_line(k, Kind::IsoSyslog).unwrap();
+ assert_eq!(m["ts"], serde_json::json!("2026-10-16T09:06:58Z"));
+ assert_eq!(m["program"], serde_json::json!("kernel"));
+ assert!(m.get("pid").is_none(), "no bracket means no pid field");
+ assert_eq!(m["message"], serde_json::json!("eth0: link up"));
+
+ // `<PRI>` = facility*8 + severity; 50 = facility 6, severity 2 (crit).
+ let p = "<50>2026-10-16T09:06:58Z pbx app[7]: message";
+ let m = parse_line(p, Kind::IsoSyslog).unwrap();
+ assert_eq!(m["severity"], serde_json::json!("crit"));
+ assert_eq!(m["facility"], serde_json::json!(6));
+ assert_eq!(m["message"], serde_json::json!("message"));
+
+ // PRI's domain ends at 191; `<999>` is not a priority and must not
+ // decode into a facility of 124.
+ let over = "<999>2026-10-16T09:06:58Z pbx app[7]: message";
+ let m = parse_line(over, Kind::IsoSyslog).unwrap();
+ assert!(m.get("severity").is_none());
+ assert!(m.get("facility").is_none());
+ assert_eq!(m["message"], serde_json::json!("message"));
+
+ // systemd logs a unit's pre-exec process as `(unit)[pid]:`. The parens
+ // are part of the tag: real journals carry `(ogon-ops)`, `(sd-pam)`,
+ // `(udev-worker)`, and these exec errors are exactly what people grep
+ // for.
+ let unit = "2026-10-16T17:41:16-05:00 drai (ogon-ops)[2357880]: \
+ ogon-ops.service: Unable to locate executable";
+ assert_eq!(parse_kind(unit), Some(Kind::IsoSyslog));
+ let m = parse_line(unit, Kind::IsoSyslog).unwrap();
+ assert_eq!(m["program"], serde_json::json!("(ogon-ops)"));
+ assert_eq!(m["pid"], serde_json::json!(2357880));
+
+ // A parenthesised tag may also appear without a pid.
+ let sd_pam = "2026-10-16T17:41:17-05:00 drai (sd-pam): pam_unix session";
+ let m = parse_line(sd_pam, Kind::IsoSyslog).unwrap();
+ assert_eq!(m["program"], serde_json::json!("(sd-pam)"));
+ assert!(m.get("pid").is_none());
+
+ // Through the real extractor: the four-line systemd repro is four
+ // records, not two with the failures glued onto "Starting".
+ let dir = tempfile::tempdir().unwrap();
+ let p = dir.path().join("journal");
+ std::fs::write(
+ &p,
+ "2026-10-16T17:41:15-05:00 drai systemd[1]: Starting ogon-ops.service\n\
+ 2026-10-16T17:41:16-05:00 drai (ogon-ops)[2357880]: ogon-ops.service: Unable to locate executable\n\
+ 2026-10-16T17:41:16-05:00 drai (ogon-ops)[2357880]: ogon-ops.service: Failed at step EXEC\n\
+ 2026-10-16T17:41:17-05:00 drai systemd[1]: ogon-ops.service: Main process exited\n",
+ )
+ .unwrap();
+ let mut recs = Vec::new();
+ extract(&p, false, None, &mut |r| {
+ recs.push(r);
+ true
+ })
+ .unwrap();
+ assert_eq!(recs.len(), 4, "every journal line is a record");
+ assert!(recs.iter().all(|r| r.fields.get("message").is_some()));
+ assert_eq!(
+ recs[1].fields["program"],
+ serde_json::json!("(ogon-ops)"),
+ "the exec failure stays its own record, attributed to its unit"
+ );
+ }
+
+ /// #1504: vsftpd/wu-ftpd `xferlog` — 14 fields, single letters spelled out.
+ #[test]
+ fn xferlog_lines_parse_to_fields() {
+ let out =
+ "Fri Oct 16 09:06:58 2026 1 10.0.0.7 4242 /uploads/fw.bin b _ o r admin ftp 0 * c";
+ assert_eq!(parse_kind(out), Some(Kind::Xferlog));
+ let m = parse_line(out, Kind::Xferlog).unwrap();
+ assert_eq!(m["ts"], serde_json::json!("Fri Oct 16 09:06:58 2026"));
+ assert_eq!(m["duration_s"], serde_json::json!(1));
+ assert_eq!(m["host"], serde_json::json!("10.0.0.7"));
+ assert_eq!(m["bytes"], serde_json::json!(4242));
+ assert_eq!(m["path"], serde_json::json!("/uploads/fw.bin"));
+ assert_eq!(m["transfer_type"], serde_json::json!("binary"));
+ assert!(m.get("action").is_none(), "`_` is the no-action sentinel");
+ assert_eq!(m["direction"], serde_json::json!("outgoing"));
+ assert_eq!(m["access"], serde_json::json!("real"));
+ assert_eq!(m["user"], serde_json::json!("admin"));
+ assert_eq!(m["service"], serde_json::json!("ftp"));
+ assert_eq!(m["auth_method"], serde_json::json!("none"));
+ assert!(
+ m.get("auth_user").is_none(),
+ "`*` is the no-rfc931 sentinel"
+ );
+ assert_eq!(m["status"], serde_json::json!("complete"));
+
+ let anon_in =
+ "Sat Oct 17 11:00:00 2026 0 10.0.0.9 0 /pub/README a C i a guest ftp 1 guest c";
+ assert_eq!(parse_kind(anon_in), Some(Kind::Xferlog));
+ let m = parse_line(anon_in, Kind::Xferlog).unwrap();
+ assert_eq!(m["transfer_type"], serde_json::json!("ascii"));
+ assert_eq!(m["action"], serde_json::json!("compressed"));
+ assert_eq!(m["direction"], serde_json::json!("incoming"));
+ assert_eq!(m["access"], serde_json::json!("anonymous"));
+ assert_eq!(m["auth_method"], serde_json::json!("rfc931"));
+ assert_eq!(m["auth_user"], serde_json::json!("guest"));
+
+ // wu-ftpd writes `g` for guest access; ProFTPD writes `d` for delete.
+ let guest_delete =
+ "Sun Oct 18 08:30:00 2026 0 10.0.0.9 0 /pub/upload b _ d g guest ftp 0 * c";
+ assert_eq!(parse_kind(guest_delete), Some(Kind::Xferlog));
+ let m = parse_line(guest_delete, Kind::Xferlog).unwrap();
+ assert_eq!(m["access"], serde_json::json!("guest"));
+ assert_eq!(m["direction"], serde_json::json!("delete"));
+ assert_eq!(m["user"], serde_json::json!("guest"));
+ }
+
+ /// vsftpd writes the transferred filename verbatim, spaces included, so
+ /// the path is not one whitespace-delimited token. A `\S+` path made such
+ /// a line miss the template, and under an elected `Xferlog` it was glued
+ /// onto the previous transfer as a `message`: the transfer vanished as a
+ /// record of its own.
+ #[test]
+ fn xferlog_path_with_spaces_is_its_own_record() {
+ let spaced =
+ "Fri Oct 16 09:07:12 2026 3 10.0.0.7 2048 /uploads/phone config v2.xml b _ i r admin ftp 0 * c";
+ assert_eq!(parse_kind(spaced), Some(Kind::Xferlog));
+ let m = parse_line(spaced, Kind::Xferlog).unwrap();
+ assert_eq!(m["path"], serde_json::json!("/uploads/phone config v2.xml"));
+ assert_eq!(m["bytes"], serde_json::json!(2048));
+ assert_eq!(m["direction"], serde_json::json!("incoming"));
+ assert_eq!(m["user"], serde_json::json!("admin"));
+ assert_eq!(m["status"], serde_json::json!("complete"));
+
+ // Through the real extractor: three transfers, three records.
+ let dir = tempfile::tempdir().unwrap();
+ let p = dir.path().join("xferlog");
+ std::fs::write(
+ &p,
+ "Fri Oct 16 09:06:58 2026 1 10.0.0.7 4242 /uploads/fw.bin b _ o r admin ftp 0 * c\n\
+ Fri Oct 16 09:07:12 2026 3 10.0.0.7 2048 /uploads/phone config v2.xml b _ i r admin ftp 0 * c\n\
+ Sat Oct 17 11:00:00 2026 0 10.0.0.9 0 /pub/README b _ i a guest ftp 0 * c\n",
+ )
+ .unwrap();
+ let mut recs = Vec::new();
+ extract(&p, false, None, &mut |r| {
+ recs.push(r);
+ true
+ })
+ .unwrap();
+ assert_eq!(recs.len(), 3, "every transfer is a record");
+ assert!(recs.iter().all(|r| r.fields.get("message").is_none()));
+ assert_eq!(
+ recs[1].fields["path"],
+ serde_json::json!("/uploads/phone config v2.xml")
+ );
+ }
+
+ /// The detection side must not claim ISO-stamped prose. Each line below
+ /// was a false positive found in the #1504 review; the chosen rule is
+ /// stated in the `isosyslog` template comment (single spaces, tag starts
+ /// with a letter or paren, pid bracket or a bare kernel/security tag).
+ #[test]
+ fn iso_stamped_prose_is_not_a_log_line() {
+ // One-token prose: no host AND tag.
+ assert!(!probe_line("2026-10-16T09:06:58 notes from the retro"));
+ assert!(!probe_line("2026-10-16T09:06:58 update: we shipped rc.96"));
+ // Two-word prose: host=`retro`, tag=`notes` — an English word is not
+ // a syslog tag unless it is one of the pidless kernel/security tags.
+ assert!(!probe_line(
+ "2026-10-16T09:06:58 retro notes: we shipped rc.96"
+ ));
+ // TSV: tabs are not the syslog field separator.
+ assert!(!probe_line(
+ "2026-10-16T09:06:58Z\tGET\thttps://example.com/a\t200"
+ ));
+ // zap dev log, tab-separated: `INFO`/`app/main.go` are not host/tag.
+ assert!(!probe_line(
+ "2026-10-16T09:06:58.123+0200\tINFO\tapp/main.go:42\tstarted"
+ ));
+ // ELB access log: the token after the timestamp is `IPv4:port`, which
+ // starts with a digit and is not a tag.
+ assert!(!probe_line(
+ "2015-05-13T23:39:43.945958Z my-lb 192.168.131.39:2817 10.0.0.1:80 0.000022 0.086224"
+ ));
+ // `git log --format='%aI %h %s'`: host=sha, tag=`feat`, no pid.
+ assert!(!probe_line("2026-10-16T09:06:58+02:00 a1b2c3d feat: add x"));
+ // RFC3164 lines still probe true (no regression).
+ assert!(probe_line("Oct 16 09:06:58 pbx syslogd: restart."));
+ // Bare tags syslog(3) writes without LOG_PID still probe true.
+ assert!(probe_line("2026-10-16T09:06:58Z pbx kernel: link up"));
+ assert!(probe_line(
+ "2026-10-16T09:06:58Z pbx sudo: pam_unix(sudo:session): opened"
+ ));
+ }
+
+ /// Both #1504 templates outrank the loose RFC3164 pattern on a tie, so a
+ /// file carrying both kinds parses the tighter one.
+ #[test]
+ fn iso_syslog_and_xferlog_outrank_rfc3164_on_a_tie() {
+ let votes: std::collections::HashMap<Kind, usize> =
+ [(Kind::Syslog, 5), (Kind::IsoSyslog, 5)]
+ .into_iter()
+ .collect();
+ assert_eq!(elect_kind(&votes), Some(Kind::IsoSyslog));
+ let votes: std::collections::HashMap<Kind, usize> =
+ [(Kind::IsoSyslog, 5), (Kind::Xferlog, 5)]
+ .into_iter()
+ .collect();
+ assert_eq!(elect_kind(&votes), Some(Kind::Xferlog));
+ }
+
const APP_LINE: &str = r#"2026-03-17 00:00:13,529 INFO [ingest-svc] tenant=t-n user=u-1153 latency_ms=221 msg="Segment merge.""#;
const CLF_LINE: &str = r#"198.192.155.112 - - [01/Mar/2026:00:00:03 +0000] "GET /api/v1/x HTTP/1.1" 200 20854 "-" "Mozilla/5.0""#;
diff --git a/engine/crates/xerj-autoindex/src/sniff.rs b/engine/crates/xerj-autoindex/src/sniff.rs
index 56c93a958..6fafa396d 100644
--- a/engine/crates/xerj-autoindex/src/sniff.rs
+++ b/engine/crates/xerj-autoindex/src/sniff.rs
@@ -3839,6 +3839,83 @@ mod text_family_tests {
classify_text(text, &nonblank)
}
+ /// #1504: `journalctl -o short-iso` output and vsftpd `xferlog` transfer
+ /// records are line-oriented logs. Both used to fall through to
+ /// `TxtProse`: the field report's syslog and transfer files were shredded
+ /// into prose chunks with no timestamp/host/program fields to filter on.
+ /// Asserted through the full classifier — `classify_text` claims the
+ /// `Logs` family before `txt_kind` is consulted.
+ #[test]
+ fn iso_syslog_and_xferlog_files_classify_as_logs() {
+ let iso = "2026-10-16T09:06:58+0200 pbx systemd[1]: Started vsftpd service\n\
+ 2026-10-16T09:06:59+0200 pbx vsftpd[1234]: CONNECT: Client \"10.0.0.7\"\n\
+ 2026-10-16T09:07:01+0200 pbx sshd[1235]: Accepted publickey for admin\n\
+ 2026-10-16T09:07:02+0200 pbx (ogon-ops)[2357880]: Unable to locate executable\n";
+ assert_eq!(classify_full(iso), Family::Logs);
+
+ let xfer = "Fri Oct 16 09:06:58 2026 1 10.0.0.7 4242 /uploads/fw.bin b _ o r admin ftp 0 * c\n\
+ Fri Oct 16 09:07:10 2026 2 10.0.0.7 10 /uploads/invalid.bin b _ o r admin ftp 0 * i\n\
+ Sat Oct 17 11:00:00 2026 0 10.0.0.9 0 /pub/README b _ i a guest ftp 0 * c\n";
+ assert_eq!(classify_full(xfer), Family::Logs);
+
+ // The RFC3164 control keeps classifying (no regression).
+ let rfc = "Oct 16 09:06:58 pbx vsftpd[1234]: CONNECT: Client \"10.0.0.7\"\n\
+ Oct 16 09:07:01 pbx sshd[1235]: Accepted publickey for admin\n\
+ Oct 16 09:07:02 pbx pbx-phone[990]: SIP engine not registered\n";
+ assert_eq!(classify_full(rfc), Family::Logs);
+ }
+
+ /// #1504 review: the ISO-syslog template must not steal files from Csv or
+ /// TxtProse. Each shape below matched a looser draft of the template
+ /// (`\s+` separators, any `word:` tag) and changed family; they are CSV
+ /// or prose, never logs. The chosen rule is stated in the `isosyslog`
+ /// template comment: single spaces, a tag starting with a letter or `(`,
+ /// and either a numeric `[pid]` bracket or a bare `kernel`/`sudo`/`su`/
+ /// `audit`/`(unit)` tag.
+ #[test]
+ fn iso_stamped_non_syslog_files_do_not_classify_as_logs() {
+ let tsv = "2026-10-16T09:06:58Z\tGET\thttps://example.com/a\t200\n\
+ 2026-10-16T09:06:59Z\tPOST\thttps://example.com/b\t201\n\
+ 2026-10-16T09:07:00Z\tGET\thttps://example.com/c\t404\n";
+ assert_ne!(classify_full(tsv), Family::Logs, "TSV is Csv, not Logs");
+
+ let zap = "2026-10-16T09:06:58.123+0200\tINFO\tapp/main.go:42\tstarted\n\
+ 2026-10-16T09:06:59.456+0200\tWARN\tapp/db.go:17\tslow query\n\
+ 2026-10-16T09:07:00.789+0200\tERROR\tapp/api.go:88\tpanic\n";
+ assert_ne!(
+ classify_full(zap),
+ Family::Logs,
+ "zap dev log is Csv, not Logs"
+ );
+
+ let elb = "2015-05-13T23:39:43.945958Z my-lb 192.168.131.39:2817 10.0.0.1:80 0.000022 0.086224 0.000021 200 200 0 57 \"GET http://www.example.com:80/ HTTP/1.1\" \"curl/7.38.0\" - -\n\
+ 2015-05-13T23:39:44.945958Z my-lb 192.168.131.39:2817 10.0.0.1:80 0.000022 0.086224 0.000021 200 200 0 57 \"GET http://www.example.com:80/ HTTP/1.1\" \"curl/7.38.0\" - -\n\
+ 2015-05-13T23:39:45.945958Z my-lb 192.168.131.39:2817 10.0.0.1:80 0.000022 0.086224 0.000021 200 200 0 57 \"GET http://www.example.com:80/ HTTP/1.1\" \"curl/7.38.0\" - -\n";
+ assert_ne!(
+ classify_full(elb),
+ Family::Logs,
+ "ELB access log is prose, not Logs"
+ );
+
+ let git = "2026-10-16T09:06:58+02:00 a1b2c3d feat: add x\n\
+ 2026-10-16T09:06:59+02:00 b2c3d4e fix: correct y\n\
+ 2026-10-16T09:07:00+02:00 c3d4e5f docs: describe z\n";
+ assert_ne!(
+ classify_full(git),
+ Family::Logs,
+ "git log is prose, not Logs"
+ );
+
+ let notes = "2026-10-16T09:06:58 retro notes: we shipped rc.96\n\
+ 2026-10-16T09:07:00 retro notes: the bench held\n\
+ 2026-10-16T09:07:05 retro notes: next is review\n";
+ assert_ne!(
+ classify_full(notes),
+ Family::Logs,
+ "timestamped notes are prose, not Logs"
+ );
+ }
+
/// Regression: a markdown document with `## Headings` averages ~50 chars
/// over 7 lines, which the length-only rule classified as TxtLines — the
/// same corpus's 5-line runbook (avg 59) went to TxtProse. Same content