Class: FiberAudit::Static::Rules::ThreadCurrentState

Inherits:
Base
  • Object
show all
Defined in:
lib/fiber_audit/static/rules/thread_current_state.rb

Overview

FA1004: Detect thread-variable state access without inferring stored data.

Constant Summary collapse

TITLE =
'Thread-variable access shared across fibers'
CATEGORY =
:thread_local
MESSAGE =
'Thread variables are visible to fibers sharing a thread. This access may expose mutable ' \
'state across concurrent work, but static analysis does not establish request-sensitive leakage.'
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

Base::CONTEXT_CEILING

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



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fiber_audit/static/rules/thread_current_state.rb', line 28

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