Skip to content

Commit

Permalink
Ignore 'No CVE' warning if NOCVE reason was provided in notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebleiweiss-r7 committed Aug 31, 2018
1 parent e5106b5 commit e753edd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tools/dev/msftidy.rb
Expand Up @@ -140,6 +140,7 @@ def check_nokogiri
def check_ref_identifiers
in_super = false
in_refs = false
in_notes = false
cve_assigned = false

@lines.each do |line|
Expand All @@ -153,6 +154,10 @@ def check_ref_identifiers
if in_super and line =~ /["']References["'][[:space:]]*=>/
in_refs = true
elsif in_super and in_refs and line =~ /^[[:space:]]+\],*/m
in_refs = false
elsif in_super and line =~ /["']Notes["'][[:space:]]*=>/
in_notes = true
elsif in_super and in_notes and line =~ /^[[:space:]]+\},*/m
break
elsif in_super and in_refs and line =~ /[^#]+\[[[:space:]]*['"](.+)['"][[:space:]]*,[[:space:]]*['"](.+)['"][[:space:]]*\]/
identifier = $1.strip.upcase
Expand All @@ -178,7 +183,7 @@ def check_ref_identifiers
warn("Invalid WPVDB reference") if value !~ /^\d+$/
when 'PACKETSTORM'
warn("Invalid PACKETSTORM reference") if value !~ /^\d+$/
when 'URL' || 'AKA'
when 'URL'
if value =~ /^https?:\/\/cvedetails\.com\/cve/
warn("Please use 'CVE' for '#{value}'")
elsif value =~ /^https?:\/\/www\.securityfocus\.com\/bid\//
Expand All @@ -194,12 +199,21 @@ def check_ref_identifiers
elsif value =~ /^https?:\/\/(?:[^\.]+\.)?packetstormsecurity\.(?:com|net|org)\//
warn("Please use 'PACKETSTORM' for '#{value}'")
end
when 'AKA'
warn("Please include AKA values in the 'notes' section, rather than in 'references'.")
end
end

# If a NOCVE reason was provided in notes, ignore the fact that the references might lack a CVE
if in_super and in_notes and line =~ /^[[:space:]]+["']NOCVE["'][[:space:]]+=>[[:space:]]+\[*["'](.+)["']\]*/
cve_assigned = true
end
end

# This helps us track when CVEs aren't assigned
info('No CVE references found. Please check before you land!') unless cve_assigned
unless cve_assigned
info('No CVE references found. Please check before you land!')
end
end

def check_self_class
Expand Down

0 comments on commit e753edd

Please sign in to comment.