Skip to content

Add disableIncludes() support to YaraCompiler - #4

Open
vToMy wants to merge 1 commit into
subreption:mainfrom
vToMy:feature/disable-includes
Open

Add disableIncludes() support to YaraCompiler#4
vToMy wants to merge 1 commit into
subreption:mainfrom
vToMy:feature/disable-includes

Conversation

@vToMy

@vToMy vToMy commented Apr 14, 2026

Copy link
Copy Markdown

Summary

  • Adds disableIncludes() to the YaraCompiler interface, allowing callers to prevent YARA rules from using include directives
  • Implements via yr_compiler_set_include_callback(compiler, NULL, NULL, user_data) in embedded mode
  • External mode logs a warning (CLI does not support this feature)
  • Includes test verifying compilation fails when includes are disabled

This is a security-relevant feature — it prevents rules from using include directives to read arbitrary files from disk.

Changes

File Description
YaraCompiler.java New disableIncludes() interface method
embedded/YaraCompilerImpl.java Implementation calling JNI bridge
embedded/YaraLibrary.java JNI native method + public wrapper
external/YaraCompilerImpl.java Stub with warning log
yara-wrapper.h C function calling yr_compiler_set_include_callback
YaraCompilerImplTest.java Test for include disable behavior

References

Test plan

  • Verify compilation succeeds with includes enabled (existing behavior)
  • Verify compilation fails with "includes are disabled" error when disableIncludes() is called
  • Verify external mode logs a warning without crashing

🤖 Generated with Claude Code

Adds the ability to disable YARA include directives during rule
compilation by calling yr_compiler_set_include_callback with a NULL
callback. This is a security-relevant feature that prevents rules
from using include directives to read arbitrary files from disk.

Changes span all layers:
- YaraCompiler interface: new disableIncludes() method
- Embedded mode: JNI binding to yr_compiler_set_include_callback
- External mode: stub with warning log (not supported in CLI mode)
- Native wrapper: yara_compiler_set_null_include_callback() C function
- Test: verifies compilation fails when includes are disabled

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant