Class: Scryer::Rule
- Inherits:
-
Object
- Object
- Scryer::Rule
- Defined in:
- lib/scryer/rule.rb
Overview
Base class for a single detection rule. Subclasses implement #scan and
return an Array of Finding. Every rule gets the parsed sexp tree (so it
doesn't have to re-parse), the raw source (for snippet extraction), and
the relative file path (for reporting).
Direct Known Subclasses
PerformanceRules::InefficientSaveLoopRule, PerformanceRules::MissingPaginationRule, PerformanceRules::NPlusOneQueryRule, PerformanceRules::UnboundedTableScanRule, Scryer::Rules::ActionCableForgeryProtectionRule, Scryer::Rules::ActiveStorageInlineDispositionRule, Scryer::Rules::ActiveStorageMissingContentTypeValidationRule, Scryer::Rules::AuthenticationBypassRule, Scryer::Rules::CommandInjectionRule, Scryer::Rules::ConsiderAllRequestsLocalRule, Scryer::Rules::CorsMisconfigurationRule, Scryer::Rules::CsrfProtectionRule, Scryer::Rules::ForceSslRule, Scryer::Rules::FrozenStringLiteralRule, Scryer::Rules::GraphqlMissingQueryLimitsRule, Scryer::Rules::HardcodedBasicAuthRule, Scryer::Rules::HardcodedSecretKeyBaseRule, Scryer::Rules::HardcodedSecretRule, Scryer::Rules::HostAuthorizationDisabledRule, Scryer::Rules::IdorRule, Scryer::Rules::InsecureCookieSerializerRule, Scryer::Rules::JobRawParamsRule, Scryer::Rules::JwtInsecureRule, Scryer::Rules::MassAssignmentRule, Scryer::Rules::MissingAuthorizationRule, Scryer::Rules::MissingPolicyScopeRule, Scryer::Rules::OpenRedirectRule, Scryer::Rules::PathTraversalRule, Scryer::Rules::SecurityHeadersRule, Scryer::Rules::SqlInjectionRule, Scryer::Rules::SsrfRule, Scryer::Rules::UnsafeDeserializationRule, Scryer::Rules::VerboseProductionLogLevelRule, Scryer::Rules::WeakCryptoRule, Scryer::Rules::WeakSessionCookieRule, Scryer::Rules::XssUnsafeHtmlRule
Class Attribute Summary collapse
-
.category ⇒ Object
Returns the value of attribute category.
-
.confidence ⇒ Object
"high"/"medium"/"low" — Scryer's own best-effort estimate of how often this specific rule's pattern-match actually reflects a real issue, independent of
severity(how bad it is if real). -
.cwe ⇒ Object
Returns the value of attribute cwe.
-
.default_severity ⇒ Object
Returns the value of attribute default_severity.
-
.owasp_category ⇒ Object
Returns the value of attribute owasp_category.
-
.rule_id ⇒ Object
Returns the value of attribute rule_id.
-
.title ⇒ Object
Returns the value of attribute title.
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#sexp ⇒ Object
readonly
Returns the value of attribute sexp.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file:, source:, sexp:) ⇒ Rule
constructor
A new instance of Rule.
- #scan ⇒ Object
Constructor Details
#initialize(file:, source:, sexp:) ⇒ Rule
Returns a new instance of Rule.
33 34 35 36 37 |
# File 'lib/scryer/rule.rb', line 33 def initialize(file:, source:, sexp:) @file = file @source = source @sexp = sexp end |
Class Attribute Details
.category ⇒ Object
Returns the value of attribute category.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def category @category end |
.confidence ⇒ Object
"high"/"medium"/"low" — Scryer's own best-effort estimate of how
often this specific rule's pattern-match actually reflects a real
issue, independent of severity (how bad it is if real). A rule
can be both high-severity and low-confidence at once (idor is the
clearest example: a real IDOR is serious, but this rule's heuristic
— no visible authorization call anywhere in the controller class —
is the least precise in the gem). Defaults to "medium" so every
rule doesn't have to set it explicitly; only rules with a clearly
different precision (idor's documented false-positive risk, or a
narrow literal-match rule with very little room for ambiguity) set
this themselves. Not derived from anything measured at runtime —
this is a static per-rule estimate, same as default_severity.
22 23 24 |
# File 'lib/scryer/rule.rb', line 22 def confidence @confidence || "medium" end |
.cwe ⇒ Object
Returns the value of attribute cwe.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def cwe @cwe end |
.default_severity ⇒ Object
Returns the value of attribute default_severity.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def default_severity @default_severity end |
.owasp_category ⇒ Object
Returns the value of attribute owasp_category.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def owasp_category @owasp_category end |
.rule_id ⇒ Object
Returns the value of attribute rule_id.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def rule_id @rule_id end |
.title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/scryer/rule.rb', line 8 def title @title end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
39 40 41 |
# File 'lib/scryer/rule.rb', line 39 def file @file end |
#sexp ⇒ Object (readonly)
Returns the value of attribute sexp.
39 40 41 |
# File 'lib/scryer/rule.rb', line 39 def sexp @sexp end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
39 40 41 |
# File 'lib/scryer/rule.rb', line 39 def source @source end |
Class Method Details
Instance Method Details
#scan ⇒ Object
41 42 43 |
# File 'lib/scryer/rule.rb', line 41 def scan raise NotImplementedError, "#{self.class} must implement #scan" end |