Class: Dawn::Kb::DependencyCheck
- Inherits:
-
Object
- Object
- Dawn::Kb::DependencyCheck
- Includes:
- BasicCheck
- Defined in:
- lib/dawn/kb/dependency_check.rb
Constant Summary
Constants included from BasicCheck
Instance Attribute Summary collapse
-
#aux_mitigation_gem ⇒ Object
Returns the value of attribute aux_mitigation_gem.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#not_affected ⇒ Object
Returns the value of attribute not_affected.
-
#safe_dependencies ⇒ Object
This attribute replaces fixed_dependency in 20130521.
-
#save_major ⇒ Object
Returns the value of attribute save_major.
-
#save_minor ⇒ Object
Tells a version is not vulnerable even if in the fixes array that has a minor version number higher than the current.
Attributes included from BasicCheck
#applies, #aux_links, #check_family, #cve, #cvss, #cwe, #debug, #evidences, #fixes_version, #kind, #message, #mitigated, #name, #osvdb, #owasp, #please_ignore_dep_version, #priority, #release_date, #remediation, #ruby_version, #ruby_vulnerable_versions, #severity, #status, #target_version, #title
Instance Method Summary collapse
-
#initialize(options) ⇒ DependencyCheck
constructor
deprecated
Deprecated.
Please use UnsafeDependencyCheck instead. This class is no
- #vuln? ⇒ Boolean
Methods included from BasicCheck
#applies_to?, #cve_link, #cvss_score, families, #family, #family=, #lint, #mitigated?, #nvd_link, #osvdb_link, #rubysec_advisories_link
Constructor Details
#initialize(options) ⇒ DependencyCheck
Please use UnsafeDependencyCheck instead. This class is no
longer supperted and it will be removed really soon.
30 31 32 33 34 35 36 |
# File 'lib/dawn/kb/dependency_check.rb', line 30 def initialize() super() @save_minor ||= [:save_minor] @save_major ||= [:save_major] warn "This class is deprecated. Please use UnsafeDependencyCheck instead" end |
Instance Attribute Details
#aux_mitigation_gem ⇒ Object
Returns the value of attribute aux_mitigation_gem.
15 16 17 |
# File 'lib/dawn/kb/dependency_check.rb', line 15 def aux_mitigation_gem @aux_mitigation_gem end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
6 7 8 |
# File 'lib/dawn/kb/dependency_check.rb', line 6 def dependencies @dependencies end |
#not_affected ⇒ Object
Returns the value of attribute not_affected.
17 18 19 |
# File 'lib/dawn/kb/dependency_check.rb', line 17 def not_affected @not_affected end |
#safe_dependencies ⇒ Object
This attribute replaces fixed_dependency in 20130521. There are cve checks like web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-0175 that addresses two different gems firing up the vulnerability. You can read this like, “if you use gem A version A1 or if you use gem B version B1 you can occur in this issue”.
14 15 16 |
# File 'lib/dawn/kb/dependency_check.rb', line 14 def safe_dependencies @safe_dependencies end |
#save_major ⇒ Object
Returns the value of attribute save_major.
26 27 28 |
# File 'lib/dawn/kb/dependency_check.rb', line 26 def save_major @save_major end |
#save_minor ⇒ Object
Tells a version is not vulnerable even if in the fixes array that has a minor version number higher than the current. This is useful especially for rails version where 3.0.x, 3.1.y, 3.2.z are separated branches and the patch is provided for all of those. So if version 3.1.10 is safe and you have it, you don’t be prompted about 3.2.x.
25 26 27 |
# File 'lib/dawn/kb/dependency_check.rb', line 25 def save_minor @save_minor end |
Instance Method Details
#vuln? ⇒ Boolean
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dawn/kb/dependency_check.rb', line 38 def vuln? ret = false @mitigated = false = "" @dependencies.each do |dep| # don't care about gem version when it mitigates a vulnerability... this can be risky, maybe I would reconsider in the future. @mitigated = true if dep[:name] == @aux_mitigation_gem[:name] unless @aux_mitigation_gem.nil? @safe_dependencies.each do |safe_dep| if dep[:name] == safe_dep[:name] v = Dawn::Kb::VersionCheck.new( { :safe=>safe_dep[:version], :detected=>dep[:version], :save_minor => self.save_minor, :save_major => self.save_major, } ) v.debug = self.debug v.excluded = self.not_affected[:version] unless self.not_affected.nil? vuln = v.vuln? if vuln && @ruby_vulnerable_versions.empty? = "Vulnerable #{dep[:name]} gem version found: #{dep[:version]}" ret = vuln end end end end if ret && @mitigated ret = false += "Vulnerability has been mitigated by gem #{@aux_mitigation_gem[:name]}. Don't remove it from your Gemfile" end self.evidences << unless .empty? @status = ret ret end |