nasl 0.0.8 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/README.md +11 -16
- data/Rakefile +38 -0
- data/bin/nasl-parse +1 -1
- data/lib/nasl.rb +1 -1
- data/lib/nasl/cli.rb +1 -1
- data/lib/nasl/command.rb +1 -1
- data/lib/nasl/commands/benchmark.rb +1 -1
- data/lib/nasl/commands/parse.rb +1 -1
- data/lib/nasl/commands/test.rb +1 -1
- data/lib/nasl/commands/tokenize.rb +1 -1
- data/lib/nasl/commands/xml.rb +1 -1
- data/lib/nasl/context.rb +5 -5
- data/lib/nasl/grammar.racc +104 -16
- data/lib/nasl/parser.rb +1 -1
- data/lib/nasl/parser/argument.rb +1 -1
- data/lib/nasl/parser/array.rb +51 -0
- data/lib/nasl/parser/assigment.rb +1 -1
- data/lib/nasl/parser/block.rb +7 -1
- data/lib/nasl/parser/break.rb +2 -2
- data/lib/nasl/parser/call.rb +3 -2
- data/lib/nasl/parser/comment.rb +2 -2
- data/lib/nasl/parser/continue.rb +2 -2
- data/lib/nasl/parser/decrement.rb +1 -1
- data/lib/nasl/parser/empty.rb +2 -2
- data/lib/nasl/parser/export.rb +1 -1
- data/lib/nasl/parser/expression.rb +1 -1
- data/lib/nasl/parser/for.rb +2 -2
- data/lib/nasl/parser/foreach.rb +4 -4
- data/lib/nasl/parser/function.rb +1 -1
- data/lib/nasl/parser/global.rb +1 -1
- data/lib/nasl/parser/identifier.rb +7 -2
- data/lib/nasl/parser/if.rb +2 -2
- data/lib/nasl/parser/import.rb +1 -1
- data/lib/nasl/parser/include.rb +2 -2
- data/lib/nasl/parser/increment.rb +1 -1
- data/lib/nasl/parser/integer.rb +7 -2
- data/lib/nasl/parser/ip.rb +2 -2
- data/lib/nasl/parser/key_value_pair.rb +43 -0
- data/lib/nasl/parser/list.rb +41 -0
- data/lib/nasl/parser/local.rb +1 -1
- data/lib/nasl/parser/lvalue.rb +1 -1
- data/lib/nasl/parser/node.rb +2 -2
- data/lib/nasl/parser/parameter.rb +43 -0
- data/lib/nasl/parser/reference.rb +41 -0
- data/lib/nasl/parser/repeat.rb +1 -1
- data/lib/nasl/parser/repetition.rb +1 -1
- data/lib/nasl/parser/return.rb +2 -2
- data/lib/nasl/parser/string.rb +7 -2
- data/lib/nasl/parser/tree.rb +2 -2
- data/lib/nasl/parser/undefined.rb +2 -2
- data/lib/nasl/parser/while.rb +1 -1
- data/lib/nasl/test.rb +1 -1
- data/lib/nasl/token.rb +2 -2
- data/lib/nasl/tokenizer.rb +7 -4
- data/lib/nasl/version.rb +27 -1
- data/nasl.gemspec +35 -8
- data/test/unit/parser/test_array.rb +174 -0
- data/test/unit/parser/test_assignment.rb +75 -4
- data/test/unit/parser/test_blank.rb +1 -1
- data/test/unit/parser/test_block.rb +29 -1
- data/test/unit/parser/test_call.rb +57 -5
- data/test/unit/parser/test_comment.rb +1 -1
- data/test/unit/parser/test_constant.rb +1 -1
- data/test/unit/parser/test_empty.rb +1 -1
- data/test/unit/parser/test_expressions.rb +8 -1
- data/test/unit/parser/test_foreach.rb +43 -0
- data/test/unit/parser/test_function.rb +147 -51
- data/test/unit/parser/test_global.rb +49 -0
- data/test/unit/parser/test_if.rb +3 -3
- data/test/unit/parser/test_include.rb +1 -1
- data/test/unit/parser/test_incr_decr.rb +1 -1
- data/test/unit/parser/test_ip.rb +1 -1
- data/test/unit/parser/test_list.rb +42 -0
- data/test/unit/parser/test_local.rb +49 -0
- data/test/unit/parser/test_return.rb +7 -3
- data/test/unit/parser/test_string.rb +1 -1
- data/test/unit/parser/test_whitespace.rb +1 -1
- data/test/unit/test_context.rb +1 -1
- data/test/unit/tokenizer/test_comment.rb +1 -1
- data/test/unit/tokenizer/test_empty.rb +1 -1
- data/test/unit/tokenizer/test_integer.rb +1 -1
- data/test/unit/tokenizer/test_references.rb +41 -0
- data/test/unit/tokenizer/test_string.rb +2 -1
- metadata +49 -86
data/lib/nasl/parser.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/argument.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -0,0 +1,51 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
################################################################################
|
26
|
+
|
27
|
+
require 'nasl/parser/node'
|
28
|
+
|
29
|
+
module Nasl
|
30
|
+
class Array < Node
|
31
|
+
attr_reader :keys, :pairs
|
32
|
+
|
33
|
+
def initialize(tree, *tokens)
|
34
|
+
super
|
35
|
+
|
36
|
+
@pairs = if @tokens[1].is_a? ::Array then @tokens[1] else [] end
|
37
|
+
|
38
|
+
@keys = Hash[@pairs.map do |p|
|
39
|
+
if p.key.is_a? String
|
40
|
+
k = p.key.text
|
41
|
+
else
|
42
|
+
k = p.key.value
|
43
|
+
end
|
44
|
+
|
45
|
+
[k, p.value]
|
46
|
+
end]
|
47
|
+
|
48
|
+
@children << :pairs
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/block.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -30,6 +30,8 @@ module Nasl
|
|
30
30
|
class Block < Node
|
31
31
|
attr_reader :body
|
32
32
|
|
33
|
+
include Enumerable
|
34
|
+
|
33
35
|
def initialize(tree, *tokens)
|
34
36
|
super
|
35
37
|
|
@@ -37,5 +39,9 @@ module Nasl
|
|
37
39
|
|
38
40
|
@children << :body
|
39
41
|
end
|
42
|
+
|
43
|
+
def each
|
44
|
+
@body.each{ |stmt| yield stmt }
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
data/lib/nasl/parser/break.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/call.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -34,7 +34,8 @@ module Nasl
|
|
34
34
|
super
|
35
35
|
|
36
36
|
@name = @tokens[0]
|
37
|
-
|
37
|
+
|
38
|
+
@args = if @tokens[2].is_a? ::Array then @tokens[2] else [] end
|
38
39
|
|
39
40
|
@arg = {}
|
40
41
|
@args.select { |a| a.type == :named }.each do |a|
|
data/lib/nasl/parser/comment.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/continue.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/empty.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/export.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/for.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/foreach.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -33,9 +33,9 @@ module Nasl
|
|
33
33
|
def initialize(tree, *tokens)
|
34
34
|
super
|
35
35
|
|
36
|
-
@iter = @tokens[
|
37
|
-
@expr = @tokens[
|
38
|
-
@body = @tokens[
|
36
|
+
@iter = @tokens[0]
|
37
|
+
@expr = @tokens[1]
|
38
|
+
@body = @tokens[2]
|
39
39
|
|
40
40
|
@children << :iter
|
41
41
|
@children << :expr
|
data/lib/nasl/parser/function.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/global.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -28,6 +28,7 @@ require 'nasl/parser/node'
|
|
28
28
|
|
29
29
|
module Nasl
|
30
30
|
class Identifier < Node
|
31
|
+
include Comparable
|
31
32
|
attr_reader :name
|
32
33
|
|
33
34
|
def initialize(tree, *tokens)
|
@@ -36,6 +37,10 @@ module Nasl
|
|
36
37
|
@name = @tokens.first.body
|
37
38
|
end
|
38
39
|
|
40
|
+
def <=>(other)
|
41
|
+
self.name <=> other.name
|
42
|
+
end
|
43
|
+
|
39
44
|
def to_xml(xml)
|
40
45
|
xml.identifier(:name=>@name)
|
41
46
|
end
|
data/lib/nasl/parser/if.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/import.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/include.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/integer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -28,6 +28,7 @@ require 'nasl/parser/node'
|
|
28
28
|
|
29
29
|
module Nasl
|
30
30
|
class Integer < Node
|
31
|
+
include Comparable
|
31
32
|
attr_reader :base, :value
|
32
33
|
|
33
34
|
def initialize(tree, *tokens)
|
@@ -56,6 +57,10 @@ module Nasl
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
60
|
+
def <=>(other)
|
61
|
+
self.value <=> other.value
|
62
|
+
end
|
63
|
+
|
59
64
|
def to_xml(xml)
|
60
65
|
case @tokens.first.type
|
61
66
|
when :FALSE
|
data/lib/nasl/parser/ip.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Copyright (c) 2011-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -0,0 +1,43 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
################################################################################
|
26
|
+
|
27
|
+
require 'nasl/parser/node'
|
28
|
+
|
29
|
+
module Nasl
|
30
|
+
class KeyValuePair < Node
|
31
|
+
attr_reader :key, :value
|
32
|
+
|
33
|
+
def initialize(tree, *tokens)
|
34
|
+
super
|
35
|
+
|
36
|
+
@key = tokens[0]
|
37
|
+
@value = tokens[2]
|
38
|
+
|
39
|
+
@children << :key
|
40
|
+
@children << :value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
################################################################################
|
26
|
+
|
27
|
+
require 'nasl/parser/node'
|
28
|
+
|
29
|
+
module Nasl
|
30
|
+
class List < Node
|
31
|
+
attr_reader :elems
|
32
|
+
|
33
|
+
def initialize(tree, *tokens)
|
34
|
+
super
|
35
|
+
|
36
|
+
@elems = if @tokens[1].is_a? ::Array then @tokens[1] else [] end
|
37
|
+
|
38
|
+
@children << :elems
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/nasl/parser/local.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/lvalue.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
data/lib/nasl/parser/node.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
################################################################################
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -73,7 +73,7 @@ module Nasl
|
|
73
73
|
|
74
74
|
# Handle objects that are arrays holding nodes, or basic types that
|
75
75
|
# aren't nodes.
|
76
|
-
if obj.is_a? Array
|
76
|
+
if obj.is_a? ::Array
|
77
77
|
obj.each { |el| el.to_xml(xml) }
|
78
78
|
elsif obj.is_a? Node
|
79
79
|
obj.to_xml(xml)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
################################################################################
|
26
|
+
|
27
|
+
require 'nasl/parser/node'
|
28
|
+
|
29
|
+
module Nasl
|
30
|
+
class Parameter < Node
|
31
|
+
attr_reader :name, :pass_by
|
32
|
+
|
33
|
+
def initialize(tree, *tokens)
|
34
|
+
super
|
35
|
+
|
36
|
+
@name = @tokens[0]
|
37
|
+
@pass_by = @tokens[1]
|
38
|
+
|
39
|
+
@children << :name
|
40
|
+
@children << :pass_by
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|