module SastBox::SeverityCalculator
Public Instance Methods
add_severity(issue)
click to toggle source
# File lib/sastbox-sdk/severity_calculator.rb, line 4 def add_severity(issue) accepted_levels = [:info, :low, :medium, :high, :critical] if issue.key?(:severity) issue[:severity] = issue[:severity].to_s.downcase.to_sym unless accepted_levels.include?(issue[:severity]) issue[:severity] = attempt_to_determine_severity(issue) end else issue[:severity] = attempt_to_determine_severity(issue) end end
attempt_to_determine_severity(issue)
click to toggle source
# File lib/sastbox-sdk/severity_calculator.rb, line 26 def attempt_to_determine_severity(issue) text = "#{issue[:title]} #{issue[:description]}".downcase.gsub(/[^a-z ]/, ' ') level = :undefined critical = ['command exec', 'cmd exec', 'command inj', 'cmd inj', 'code inj', 'code exec', 'file inclusion', 'dangerous send', 'insecure deserialization'] high = ['xss', 'cross site scripting', 'sqli', 'sql injection', 'insecure url', 'file manipulation', 'file access', 'file disclosure', 'idor', 'xpath inj', 'weak cipher', 'weak crypto', 'insecure cipher', 'insecure crypto', 'insecure encryption', 'broken cipher', 'broken crypto', 'weak hash', 'insecure hash', 'broken hash', 'pathtraversal', 'path traversal', 'xxe', 'xml external entities'] medium = ['mass assignment', 'secret keyword', 'hard coded pass', 'hardcoded pass', 'pass hardcoded', 'password hardcoded', 'password hard coded', 'secret hardcoded', 'session fixation', 'security misconfiguration', 'vulnerable component', 'header injection', 'csrf', 'cross site request forgery', 'toctou', 'session setting', 'response splitting' ] low = ['open redirect', 'resource leak', 'format validation', 'information disclosure', 'logging', 'logger', 'stacktrace', 'stack trace', 'null pointer deref'] info = [] if level == :undefined level = :critical if severity_pattern_found?(critical, text) end if level == :undefined level = :high if severity_pattern_found?(high, text) end if level == :undefined level = :medium if severity_pattern_found?(medium, text) end if level == :undefined level = :low if severity_pattern_found?(low, text) end if level == :undefined level = :info if severity_pattern_found?(info, text) end level end
severity_pattern_found?(patterns, text)
click to toggle source
# File lib/sastbox-sdk/severity_calculator.rb, line 19 def severity_pattern_found?(patterns, text) patterns.each do |pattern| return true if text.include?(pattern) end false end