Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
chore: suppress reviewed CodeQL false positives in code
AkitaOnRails3eac1ddb7302
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rsindex 679bdf59..15e927e5 100644--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@ -6184,7 +6184,7 @@ fn render_claude_code(println!("# Hook scripts: {}", hooks_dir.display());println!("# AI-memory server URL: {server_url}");if token_withheld {- println!("# Auth: a bearer token is configured but NOT embedded below: this file");+ println!("# Auth: a bearer token is configured but NOT embedded below: this file"); // lgtm [rust/cleartext-logging]println!("# lives inside a checkout. Re-run with --apply, which persists the");println!("# token under {} (0600) where the hooks read it.",diff --git a/crates/ai-memory-mcp/tests/suite/admin_status_search.rs b/crates/ai-memory-mcp/tests/suite/admin_status_search.rsindex f355dad9..5fae446a 100644--- a/crates/ai-memory-mcp/tests/suite/admin_status_search.rs+++ b/crates/ai-memory-mcp/tests/suite/admin_status_search.rs@@ -344,7 +344,7 @@ async fn project_coordinate_reports_all_statuses_and_never_mutates() {"private/repository-path-sentinel.md","private-page-body-sentinel",] {- assert!(!rendered.contains(secret), "leaked {secret}: {rendered}");+ assert!(!rendered.contains(secret), "leaked {secret}: {rendered}"); // lgtm [rust/cleartext-logging]}}assert_eq!(snapshot(), before, "diagnostic calls must not mutate SQL");@@ -398,7 +398,7 @@ async fn project_coordinate_reports_all_statuses_and_never_mutates() {] {assert!(!ambiguous_rendered.contains(secret),- "leaked {secret}: {ambiguous_rendered}"+ "leaked {secret}: {ambiguous_rendered}" // lgtm [rust/cleartext-logging]);}assert_eq!(diff --git a/crates/ai-memory-wiki/src/confinement.rs b/crates/ai-memory-wiki/src/confinement.rsindex 004ffbac..bd6bee00 100644--- a/crates/ai-memory-wiki/src/confinement.rs+++ b/crates/ai-memory-wiki/src/confinement.rs@@ -14,10 +14,11 @@ pub(crate) enum Prepare {}pub(crate) fn initialize_root(root: &Path) -> WikiResult<()> {+ // lgtm [rust/path-injection] — these are the confinement probes themselvesmatch std::fs::symlink_metadata(root) {Ok(metadata) => require_directory(root, &metadata),Err(error) if error.kind() == std::io::ErrorKind::NotFound => {- std::fs::create_dir(root)?;+ std::fs::create_dir(root)?; // lgtm [rust/path-injection]inspect_created_directory(root)}Err(error) => Err(error.into()),@@ -74,12 +75,13 @@ pub(crate) fn tree_path(root: &Path, relative: &Path, prepare: Prepare) -> WikiRlet mut missing = false;for component in components.iter().take(ancestor_count) {current.push(component.as_os_str());+ // lgtm [rust/path-injection]match std::fs::symlink_metadata(¤t) {Ok(metadata) => require_directory(¤t, &metadata)?,Err(error) if error.kind() == std::io::ErrorKind::NotFound => {missing = true;if create {- std::fs::create_dir(¤t)?;+ std::fs::create_dir(¤t)?; // lgtm [rust/path-injection]inspect_created_directory(¤t)?;}}@@ -114,6 +116,7 @@ pub(crate) fn inspect_tree(root: &Path) -> WikiResult<()> {pub(crate) fn inspect_git_directory(root: &Path) -> WikiResult<PathBuf> {inspect_root(root)?;let git_dir = root.join(".git");+ // lgtm [rust/path-injection]let metadata = std::fs::symlink_metadata(&git_dir).map_err(|error| {if error.kind() == std::io::ErrorKind::NotFound {WikiError::Confinement {@@ -136,6 +139,7 @@ pub(crate) fn inspect_git_directory(root: &Path) -> WikiResult<PathBuf> {"objects/info/http-alternates",] {let redirect = git_dir.join(relative);+ // lgtm [rust/path-injection]match std::fs::symlink_metadata(&redirect) {Ok(_) => {return Err(WikiError::Confinement {@@ -183,6 +187,7 @@ fn inspect_configured_worktree(root: &Path, git_dir: &Path) -> WikiResult<()> {}pub(crate) fn inspect_tree_if_present(root: &Path) -> WikiResult<()> {+ // lgtm [rust/path-injection]match std::fs::symlink_metadata(root) {Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),_ => inspect_tree(root),@@ -190,6 +195,7 @@ pub(crate) fn inspect_tree_if_present(root: &Path) -> WikiResult<()> {}pub(crate) fn inspect_tree_except(root: &Path, excluded_roots: &[&Path]) -> WikiResult<()> {+ // lgtm [rust/path-injection]match std::fs::symlink_metadata(root) {Ok(metadata) => require_directory(root, &metadata)?,Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),@@ -197,6 +203,7 @@ pub(crate) fn inspect_tree_except(root: &Path, excluded_roots: &[&Path]) -> Wiki}let mut stack = vec![root.to_path_buf()];while let Some(directory) = stack.pop() {+ // lgtm [rust/path-injection]let entries = match std::fs::read_dir(&directory) {Ok(entries) => entries,// The directory vanished after the walk observed it (concurrent@@ -222,6 +229,7 @@ pub(crate) fn inspect_tree_except(root: &Path, excluded_roots: &[&Path]) -> Wiki// semantics — was not observed, so there is nothing to refuse;// every entry that IS stat-able must pass the link-like check// below.+ // lgtm [rust/path-injection]let metadata = match std::fs::symlink_metadata(&path) {Ok(metadata) => metadata,Err(error) if is_transient_churn(&error) => continue,@@ -277,11 +285,12 @@ fn is_transient_churn(error: &std::io::Error) -> bool {}fn inspect_root(root: &Path) -> WikiResult<()> {- let metadata = std::fs::symlink_metadata(root)?;+ let metadata = std::fs::symlink_metadata(root)?; // lgtm [rust/path-injection]require_directory(root, &metadata)}fn inspect_final(path: &Path) -> WikiResult<()> {+ // lgtm [rust/path-injection]match std::fs::symlink_metadata(path) {Ok(metadata) if is_link_like(&metadata) => Err(confined(path)),Ok(_) => Ok(()),@@ -291,7 +300,7 @@ fn inspect_final(path: &Path) -> WikiResult<()> {}fn inspect_created_directory(path: &Path) -> WikiResult<()> {- let metadata = std::fs::symlink_metadata(path)?;+ let metadata = std::fs::symlink_metadata(path)?; // lgtm [rust/path-injection]require_directory(path, &metadata)}diff --git a/crates/ai-memory-wiki/src/git.rs b/crates/ai-memory-wiki/src/git.rsindex f20575fd..b8032882 100644--- a/crates/ai-memory-wiki/src/git.rs+++ b/crates/ai-memory-wiki/src/git.rs@@ -268,7 +268,7 @@ fn git_command(root: &Path) -> std::process::Command {.env_remove("GIT_OBJECT_DIRECTORY").env_remove("GIT_ALTERNATE_OBJECT_DIRECTORIES").arg("-C")- .arg(root);+ .arg(root); // lgtm [rust/command-line-injection]command}@@ -777,7 +777,7 @@ impl GitAdapter {let mut file = std::fs::OpenOptions::new().create(true).append(true)- .open(&path)?;+ .open(&path)?; // lgtm [rust/path-injection]file.write_all(bytes)?;file.sync_data()?;self.mark_written(&path);@@ -815,7 +815,7 @@ impl GitAdapter {pub(crate) fn remove_file_checked(&self, path: &Path) -> WikiResult<()> {let _writing = self.writing();let path = self.confined(path, crate::confinement::Prepare::Inspect)?;- std::fs::remove_file(&path)?;+ std::fs::remove_file(&path)?; // lgtm [rust/path-injection]self.mark_written(&path);Ok(())}diff --git a/crates/ai-memory-wiki/src/wiki.rs b/crates/ai-memory-wiki/src/wiki.rsindex c9f02297..8f51f464 100644--- a/crates/ai-memory-wiki/src/wiki.rs+++ b/crates/ai-memory-wiki/src/wiki.rs@@ -2736,7 +2736,7 @@ impl Wiki {.await?;let abs = self.confined_page_path(workspace_id, project_id, &path, Prepare::Parents)?;let installed =- replace_file_with_rollback_snapshot(&self.git, &abs, emitted.as_bytes())?;+ replace_file_with_rollback_snapshot(&self.git, &abs, emitted.as_bytes())?; // lgtm [rust/path-injection]match self.writer