Skip to content

Commit fba751a

Browse files
committed
Disable early returns
1 parent 80f21b5 commit fba751a

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

lib/rex/parser/openvas_nokogiri.rb

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,49 @@ def start_element(name=nil,attrs=[])
3131
def end_element(name=nil)
3232
block = @block
3333
case name
34-
when "name"
35-
return if not in_tag("result")
36-
@state[:has_text] = true
37-
@state[:vuln_name] = @text.strip if @text
38-
when "description"
34+
when 'name'
35+
if in_tag('result')
36+
@state[:has_text] = true
37+
@state[:vuln_name] = @text.strip if @text
38+
end
39+
when 'description'
3940
@state[:has_text] = true
4041
@state[:vuln_desc] = @text.strip if @text
41-
when "bid"
42-
return unless in_tag("result")
43-
return unless in_tag("nvt")
44-
@state[:has_text] = true
45-
@state[:bid] = @text.strip if @text
46-
when "cve"
47-
return unless in_tag("result")
48-
return unless in_tag("nvt")
49-
@state[:has_text] = true
50-
@state[:cves] = @text.strip if @text
51-
when "risk_factor"
52-
return unless in_tag("result")
53-
return unless in_tag("nvt")
54-
#we do this to clean out the buffer so to speak
55-
#if we don't set text to nil now, the text will show up later
56-
@state[:has_text] = true
57-
when "cvss_base"
58-
return unless in_tag("result")
59-
return unless in_tag("nvt")
60-
@state[:has_text] = true
61-
when "subnet"
42+
when 'bid'
43+
if in_tag('result') && in_tag('nvt')
44+
@state[:has_text] = true
45+
@state[:bid] = @text.strip if @text
46+
end
47+
when 'cve'
48+
if in_tag('result') && in_tag('nvt')
49+
@state[:has_text] = true
50+
@state[:cves] = @text.strip if @text
51+
end
52+
when 'risk_factor'
53+
if in_tag('result') && in_tag('nvt')
54+
#we do this to clean out the buffer so to speak
55+
#if we don't set text to nil now, the text will show up later
56+
@state[:has_text] = true
57+
end
58+
when 'cvss_base'
59+
if in_tag('result') && in_tag('nvt')
60+
@state[:has_text] = true
61+
end
62+
when 'subnet'
6263
@state[:has_text] = true
63-
when "result"
64-
record_vuln if in_tag("results")
65-
when "threat"
66-
@state[:has_text] = true if in_tag("ports") && in_tag("port")
67-
when "host"
64+
when 'result'
65+
record_vuln if in_tag('results')
66+
when 'threat'
67+
@state[:has_text] = true if in_tag('ports') && in_tag('port')
68+
when 'host'
6869
if in_tag('result')
6970
@state[:has_text] = true
7071
@state[:host] = @text.strip if @text
7172
elsif in_tag('ports') && in_tag('port')
7273
@state[:has_text] = true
7374
@state[:host] = @text.strip if @text
7475
end
75-
when "port"
76+
when 'port'
7677
if in_tag('result')
7778
@state[:has_text] = true
7879
if @text && @text.index('(')
@@ -102,8 +103,8 @@ def end_element(name=nil)
102103
record_service unless @state[:port] == 'general'
103104
end
104105
end
105-
when "name"
106-
return if not in_tag("result")
106+
when 'name'
107+
return if not in_tag('result')
107108
@state[:has_text] = true
108109
end
109110

0 commit comments

Comments
 (0)