From a5e1c94157ee2d0d25fb92563330d262f2b5d80b Mon Sep 17 00:00:00 2001 From: akbash Date: Sun, 13 Sep 2026 16:04:22 +0300 Subject: fix: restrict claude session hooks to native sources (#4046) refs #4018 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: JJ Liebig --- src/integration/tests.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/integration/tests.rs') diff --git a/src/integration/tests.rs b/src/integration/tests.rs index e8aad72b..4c2178cc 100644 --- a/src/integration/tests.rs +++ b/src/integration/tests.rs @@ -957,7 +957,10 @@ fn install_claude_writes_hook_and_updates_settings() { ); assert_eq!(hook_content, CLAUDE_HOOK_ASSET); assert!(settings["permissions"]["allow"].is_array()); - assert_eq!(settings["hooks"]["SessionStart"][0]["matcher"], "*"); + assert_eq!( + settings["hooks"]["SessionStart"][0]["matcher"], + "^(startup|resume|clear|compact|fork)$" + ); assert!(settings["hooks"]["SessionStart"][0]["hooks"][0]["command"] .as_str() .unwrap() @@ -1105,7 +1108,7 @@ fn install_claude_removes_deprecated_completion_hooks_and_preserves_user_hooks() } #[test] -fn claude_v1_integration_status_is_outdated() { +fn claude_v9_integration_status_is_outdated_until_reinstalled() { let _lock = integration_env_lock(); let base = unique_base(); let home = base.join("home"); @@ -1114,7 +1117,7 @@ fn claude_v1_integration_status_is_outdated() { let hook_path = claude_hooks_dir.join(CLAUDE_HOOK_INSTALL_NAME); fs::write( &hook_path, - "#!/bin/sh\n# HERDR_INTEGRATION_ID=claude\n# HERDR_INTEGRATION_VERSION=1\n", + "#!/bin/sh\n# HERDR_INTEGRATION_ID=claude\n# HERDR_INTEGRATION_VERSION=9\n", ) .unwrap(); std::env::set_var("HOME", &home); @@ -1126,10 +1129,19 @@ fn claude_v1_integration_status_is_outdated() { .unwrap(); assert_eq!(claude.path, hook_path); - assert_eq!(claude.installed_version, Some(1)); - assert_eq!(claude.expected_version, 9); + assert_eq!(claude.installed_version, Some(9)); + assert_eq!(claude.expected_version, 10); assert_eq!(claude.state, IntegrationStatusKind::Outdated); + install_claude().unwrap(); + let status = integration_status_at( + crate::api::schema::IntegrationTarget::Claude, + hook_path, + CLAUDE_INTEGRATION_VERSION, + ); + assert_eq!(status.installed_version, Some(10)); + assert_eq!(status.state, IntegrationStatusKind::Current); + std::env::remove_var("HOME"); let _ = fs::remove_dir_all(base); } @@ -1157,7 +1169,7 @@ fn claude_v2_integration_status_is_outdated() { assert_eq!(claude.path, hook_path); assert_eq!(claude.installed_version, Some(2)); - assert_eq!(claude.expected_version, 9); + assert_eq!(claude.expected_version, 10); assert_eq!(claude.state, IntegrationStatusKind::Outdated); std::env::remove_var("HOME"); -- cgit v1.2.3