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.

fix(autoindex): refuse --follow-symlinks-outside-root on its own, and say what it really guards

xerj-org3d4165516019
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06392dfaa..e2f0bfe0d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,7 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
first run after upgrading drops what it previously indexed through such a
link. If following links outward is why you turned the flag on — a vendored
sibling checkout, a monorepo package link, a mounted volume — pass
- `--follow-symlinks-outside-root` to restore it. That waives the root boundary
+ `--follow-symlinks-outside-root` to restore it (it requires
+ `--follow-symlinks`, and is refused on its own rather than accepted as a
+ silent no-op). That waives the root boundary
and nothing else: the hidden-file rule still applies to the resolved path,
judged from the point where the target diverges from the folder you pointed
at — so `notes -> ../sibling/pkg` is followed and `keys -> ../sibling/.ssh/id_rsa`
diff --git a/demo/usecases/autoindex/RECIPE_DRAFT.md b/demo/usecases/autoindex/RECIPE_DRAFT.md
index b5b6d881e..8b3e8fbc1 100644
--- a/demo/usecases/autoindex/RECIPE_DRAFT.md
+++ b/demo/usecases/autoindex/RECIPE_DRAFT.md
@@ -243,7 +243,11 @@ disagreement is printed, not applied; bounds both the scan and the indexing
phase), `--prefix` to namespace the indices (default `ax`),
`--no-semantic` for pure BM25+keyword without vector fields, `--dry-run` to
print the inferred plan without indexing anything, `--follow-symlinks`
-(loop-safe), `--sample N` records per file for inference (default 500).
+(loop-safe — a followed link is judged by what it resolves to: a target outside
+the indexed folder is refused, and one inside a hidden directory is skipped like
+any dotfile, however visible the link's own name;
+`--follow-symlinks-outside-root` waives the folder boundary and nothing else),
+`--sample N` records per file for inference (default 500).
`--workers` is a ceiling, not a promise: when the server answers `429 Too Many
Requests` the run halves its own bulk concurrency on the spot and probes back
diff --git a/engine/crates/xerj-autoindex/src/cli.rs b/engine/crates/xerj-autoindex/src/cli.rs
index cb7fbb8ff..6c3e92a5f 100644
--- a/engine/crates/xerj-autoindex/src/cli.rs
+++ b/engine/crates/xerj-autoindex/src/cli.rs
@@ -161,10 +161,14 @@ pub fn help_text_with(feedback: bool) -> String {
dotfile, whatever the link itself is called\n\
--follow-symlinks-outside-root\n\
also follow links that resolve OUTSIDE the\n\
- folder. Off by default; pointing at a folder\n\
- is not consent to index whatever it links to.\n\
- The\n\
- hidden-file rule still applies to the target\n\
+ folder. Requires --follow-symlinks. Off by\n\
+ default; pointing at a folder is not consent\n\
+ to index whatever it links to. The hidden-file\n\
+ rule still applies to the target, judged from\n\
+ where it diverges from your folder — so a\n\
+ dotted directory the two paths SHARE does not\n\
+ refuse anything, because your folder is\n\
+ already inside it\n\
--stub <GLOB> index matching files as ONE existence-only name\n\
card (title + provenance); contents are never\n\
opened. Repeatable. A pattern without '/'\n\
@@ -755,6 +759,16 @@ pub fn parse(args: Vec<String>) -> Result<Cmd, String> {
state_dir,
})),
(None, Some(root)) => {
+ // A flag that is accepted and does nothing is the shape this repo
+ // refuses on purpose (#204, #279): the operator believes they asked
+ // for out-of-root targets and gets a run that silently did not.
+ if follow_symlinks_outside_root && !follow_symlinks {
+ return Err(
+ "--follow-symlinks-outside-root has no effect without --follow-symlinks: \
+ links are not followed at all unless that flag is given"
+ .into(),
+ );
+ }
let plan = crate::resources::plan(workers, pdf_workers, bulk_mb);
Ok(Cmd::Index(Box::new(IndexCfg {
root,
@@ -867,6 +881,32 @@ mod tests {
use super::{parse, Approval, Cmd, Duration, ProgressMode, DEFAULT_MAX_MINUTES};
use std::path::PathBuf;
+ /// A flag that is accepted and silently does nothing is refused, because
+ /// the operator who passed it believes the run did something it did not.
+ #[test]
+ fn outside_root_without_follow_symlinks_is_refused() {
+ let err = parse(
+ ["data", "--follow-symlinks-outside-root"]
+ .iter()
+ .map(|s| s.to_string())
+ .collect(),
+ )
+ .expect_err("must not be accepted as a silent no-op");
+ let text = err.to_string();
+ assert!(
+ text.contains("--follow-symlinks-outside-root") && text.contains("no effect"),
+ "the message must name the flag and say why: {text}"
+ );
+
+ // Both together is the supported combination and must still parse.
+ let cfg = index(&[
+ "data",
+ "--follow-symlinks",
+ "--follow-symlinks-outside-root",
+ ]);
+ assert!(cfg.follow_symlinks && cfg.follow_symlinks_outside_root);
+ }
+
fn index(args: &[&str]) -> super::IndexCfg {
match parse(args.iter().map(|s| s.to_string()).collect()).unwrap() {
Cmd::Index(cfg) => *cfg,