Class: FiberAudit::Static::Rules::Base
- Inherits:
-
Object
- Object
- FiberAudit::Static::Rules::Base
- Defined in:
- lib/fiber_audit/static/rules/base.rb
Overview
Base class for all static analysis rules.
Subclasses use the class-level DSL to declare metadata:
class BlockingSubprocess < Base
id 'FA1001'
severity :high
confidence :high
description 'Blocking subprocess call in the fiber scheduler path'
def analyze(call_sites:)
# ...
end
end
Severity resolution flow (monotonic):
1. Start with the rule's default_severity
2. Apply configuration.severity_override (replaces default if present)
3. Apply context ceiling: if the resulting severity is less severe
than the ceiling for the execution context, raise to the ceiling.
Never lower a severity that is already more severe than the ceiling.
Direct Known Subclasses
BlockingSubprocess, DirectSocket, IOSelect, NetHTTPInRequest, Synchronization, ThreadCurrentState, ThreadJoin
Constant Summary collapse
- CONTEXT_CEILING =
Context severity ceiling table.
For each execution context, the ceiling is the minimum severity (maximum urgency) that a finding must reach. If the rule's base severity is already at or above the ceiling, it is left unchanged. A nil ceiling (unknown context) means no upgrade is applied.
{ request: :critical, middleware: :critical, websocket: :critical, callback: :high, view: :high, job: :high, boot: :medium, console: :info, test: :info, rake_task: :low, unknown: nil }.freeze
Class Method Summary collapse
-
.confidence(value = nil) ⇒ Object
Get or set the default confidence.
-
.default_confidence(value = nil) ⇒ Object
Alias: getter for the default confidence.
-
.default_severity(value = nil) ⇒ Object
Alias: getter for the default severity.
-
.description(value = nil) ⇒ Object
Get or set the human-readable description.
-
.id(value = nil) ⇒ Object
Get or set the rule identifier.
-
.severity(value = nil) ⇒ Object
Get or set the default severity.
Instance Method Summary collapse
-
#analyze(call_sites:) ⇒ Array<FiberAudit::Finding>
Analyze call sites and return an array of findings.
-
#initialize(workspace:, context_resolver:, configuration:) ⇒ Base
constructor
Construct a rule instance with its dependencies.
Constructor Details
#initialize(workspace:, context_resolver:, configuration:) ⇒ Base
Construct a rule instance with its dependencies.
111 112 113 114 115 |
# File 'lib/fiber_audit/static/rules/base.rb', line 111 def initialize(workspace:, context_resolver:, configuration:) @workspace = workspace @context_resolver = context_resolver @configuration = configuration end |
Class Method Details
.confidence(value = nil) ⇒ Object
Get or set the default confidence. When setting, validates via Confidence.coerce. Accepts Symbol or String values; Strings are normalized to Symbols.
83 84 85 86 87 88 |
# File 'lib/fiber_audit/static/rules/base.rb', line 83 def confidence(value = nil) return @default_confidence unless value normalized = value.is_a?(String) ? value.to_sym : value @default_confidence = Confidence.coerce(normalized) end |
.default_confidence(value = nil) ⇒ Object
Alias: getter for the default confidence. Also accepts a value for DSL symmetry (delegates to confidence).
92 93 94 95 96 |
# File 'lib/fiber_audit/static/rules/base.rb', line 92 def default_confidence(value = nil) return @default_confidence unless value confidence(value) end |
.default_severity(value = nil) ⇒ Object
Alias: getter for the default severity. Also accepts a value for DSL symmetry (delegates to severity).
74 75 76 77 78 |
# File 'lib/fiber_audit/static/rules/base.rb', line 74 def default_severity(value = nil) return @default_severity unless value severity(value) end |
.description(value = nil) ⇒ Object
Get or set the human-readable description.
99 100 101 102 103 |
# File 'lib/fiber_audit/static/rules/base.rb', line 99 def description(value = nil) return @description unless value @description = value.to_s.freeze end |
.id(value = nil) ⇒ Object
Get or set the rule identifier. Coerces the value to a frozen String.
56 57 58 59 60 |
# File 'lib/fiber_audit/static/rules/base.rb', line 56 def id(value = nil) return @rule_id unless value @rule_id = value.to_s.freeze end |
.severity(value = nil) ⇒ Object
Get or set the default severity. When setting, validates via Severity.coerce. Accepts Symbol or String values; Strings are normalized to Symbols.
65 66 67 68 69 70 |
# File 'lib/fiber_audit/static/rules/base.rb', line 65 def severity(value = nil) return @default_severity unless value normalized = value.is_a?(String) ? value.to_sym : value @default_severity = Severity.coerce(normalized) end |
Instance Method Details
#analyze(call_sites:) ⇒ Array<FiberAudit::Finding>
Analyze call sites and return an array of findings. Subclasses MUST override this method.
123 124 125 126 |
# File 'lib/fiber_audit/static/rules/base.rb', line 123 def analyze(call_sites:) raise NotImplementedError, "#{self.class.name}#analyze must be implemented by the subclass" end |