Class: FiberAudit::Static::Rules::ThreadCurrentState
- Defined in:
- lib/fiber_audit/static/rules/thread_current_state.rb
Overview
FA1004: Detect thread-variable state access.
Detects only thread_variable_get/set operations, not Thread.current index operations. Thread variables are shared across all fibers on the same thread and may leak request-local data.
Constant Summary collapse
- TITLE =
'Thread thread variables in fiber code'- CATEGORY =
:thread_local- MESSAGE =
'Thread thread variables are shared across all fibers on the same thread ' \ 'and may leak request-local data between concurrent requests.'
- REMEDIATION =
'Prefer fiber-local storage (Fiber[:key]) or framework-provided ' \ 'request-local state over thread_variable_get/set.'
- THREAD_VARIABLE_METHODS =
OperationVocabulary::FA1004_THREAD_VARIABLE_METHODS
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
confidence, default_confidence, default_severity, description, id, #initialize, severity
Constructor Details
This class inherits a constructor from FiberAudit::Static::Rules::Base
Instance Method Details
#analyze(call_sites:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fiber_audit/static/rules/thread_current_state.rb', line 32 def analyze(call_sites:) findings = [] call_sites.each do |site| next if skip?(site) finding = match_thread_variable(site) findings << finding if finding end findings rescue StandardError [] end |