nasl 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f7f194e85bfffd0d60eeba8e2e0c9731fefb8efd
4
- data.tar.gz: d1ae8dbd9a8f4cfa6bdea898acb19c6e07715e28
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWMwMTc1ZTg3N2ZmZDJjYzBkN2U3NDljZWM0MGMxNDUxNzc4ZmI2Yg==
5
+ data.tar.gz: !binary |-
6
+ MGZmMWYyMmVkOTA3ZjhlZTUwNGY4YWI3OGJmYzA0YzlmNThlMjg0NQ==
5
7
  SHA512:
6
- metadata.gz: 127f28c3d561498967aedd5de3ae092eec8327b1781a8a7321934fb40c617f2aab5940b6ff1f6bdfeb90b1122f1489f2b83a42273a4a8dcbdeb54ddddb28aeba
7
- data.tar.gz: 25f4fc9e456ad37df32f2fe6999ec3fa62089511d2d71a6703772ef454da6bbde0ba80b140051dc007a0b792693d4d358d21e13c585e6bd7f85215425236a29c
8
+ metadata.gz: !binary |-
9
+ Nzc0ZjcyMTk5ZjZkNzgxZmYxMTVhNzRmNjE0ZDJhOWNlNTEwMTllMzk1NjYz
10
+ ODBhNTc1NjIxYzhkNmJjZTVmMDJkMGMzMDg5YzViYzBiMjZkZTA1ZmFjM2Q1
11
+ ZjRhMDFkZDg0ZDFkY2MwYTYwOGM3YWU3MzFiZjMxMmU1NWVhMWM=
12
+ data.tar.gz: !binary |-
13
+ MWRhZDY3MjQ4NDg5ZjQ5ZTExOTk3MjIyODJlN2IzNGZhNTliOTAwODA1ZmM4
14
+ MWM5OWRkNzdmNzgyZDM3Y2JkOTMyNGY0ZTI1YzdlMWUxMTgzMWZmNjAxNzJj
15
+ NWE2ZDNjZDQzMTI0MWE4M2M5ODY1YzQ2MDhhOTM3M2MyYzIwZjQ=
data/Rakefile CHANGED
@@ -59,7 +59,7 @@ task :tag_and_bag do
59
59
  end
60
60
 
61
61
  task :release => [:tag_and_bag, :build] do
62
- system "gem push #{Nasl::APP_NAME}-#{Nasl::VERSION}.gem"
62
+ system "gem push nasl-#{Nasl::VERSION}.gem"
63
63
  end
64
64
 
65
65
  task :default => :compile
@@ -221,9 +221,9 @@ rule
221
221
  ;
222
222
 
223
223
  foreach : FOREACH ident LPAREN expr RPAREN statement
224
- { n(:Foreach, val[1], val[3], val[5]) }
224
+ { n(:Foreach, val[0], val[1], val[3], val[5]) }
225
225
  | FOREACH LPAREN ident IN expr RPAREN statement
226
- { n(:Foreach, val[2], val[4], val[6]) }
226
+ { n(:Foreach, val[0], val[2], val[4], val[6]) }
227
227
  ;
228
228
 
229
229
  if : IF LPAREN expr RPAREN statement
@@ -382,10 +382,14 @@ rule
382
382
  { n(:KeyValuePair, *val) }
383
383
  | int COLON expr
384
384
  { n(:KeyValuePair, *val) }
385
+ | ident COLON expr
386
+ { n(:KeyValuePair, *val) }
385
387
  | string COLON ref
386
388
  { n(:KeyValuePair, *val) }
387
389
  | int COLON ref
388
390
  { n(:KeyValuePair, *val) }
391
+ | ident COLON ref
392
+ { n(:KeyValuePair, *val) }
389
393
  ;
390
394
 
391
395
  kv_pairs : kv_pair COMMA kv_pairs
@@ -38,6 +38,8 @@ module Nasl
38
38
  @keys = Hash[@pairs.map do |p|
39
39
  if p.key.is_a? String
40
40
  k = p.key.text
41
+ elsif p.key.is_a? Identifier
42
+ k = p.key.name
41
43
  else
42
44
  k = p.key.value
43
45
  end
@@ -33,9 +33,9 @@ module Nasl
33
33
  def initialize(tree, *tokens)
34
34
  super
35
35
 
36
- @iter = @tokens[0]
37
- @expr = @tokens[1]
38
- @body = @tokens[2]
36
+ @iter = @tokens[1]
37
+ @expr = @tokens[2]
38
+ @body = @tokens[3]
39
39
 
40
40
  @children << :iter
41
41
  @children << :expr
@@ -25,5 +25,5 @@
25
25
  ################################################################################
26
26
 
27
27
  module Nasl
28
- VERSION = '0.2.0'
28
+ VERSION = '0.3.0'
29
29
  end
@@ -171,4 +171,8 @@ class TestArray < Test::Unit::TestCase
171
171
  def test_empty_array_with_comma
172
172
  fail_parse(%q|return {,};|)
173
173
  end
174
+
175
+ def test_array_with_unquoted_key
176
+ parse(%q|return {a:@foo, b:"hello", c:3};|)
177
+ end
174
178
  end
@@ -40,4 +40,13 @@ class TestForeach < Test::Unit::TestCase
40
40
  '<tree><foreach><identifier name="foo"/><lvalue><identifier name="bar"/></lvalue><empty/></foreach></tree>'
41
41
  )
42
42
  end
43
+
44
+ # Check that the 'foreach' itself is in the tokens list
45
+ def test_foreach_in_tokens
46
+ tree = parse(%q|foreach foo (bar);|)
47
+ assert_equal(
48
+ tree.all(:Foreach).first.tokens.first.to_s,
49
+ "foreach"
50
+ )
51
+ end
43
52
  end
@@ -82,4 +82,13 @@ class TestIf < Test::Unit::TestCase
82
82
  '<tree><if><integer value="1"/><if><integer value="1"/><call><lvalue><identifier name="foo"/></lvalue></call></if><call><identifier name="bar"/></call></if></tree>'
83
83
  )
84
84
  end
85
+
86
+ # Check that the 'if' itself is in the tokens list
87
+ def test_if_in_tokens
88
+ tree = parse(%q|if (foo) {};|)
89
+ assert_equal(
90
+ tree.all(:If).first.tokens.first.to_s,
91
+ "if"
92
+ )
93
+ end
85
94
  end
@@ -0,0 +1,38 @@
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
+ class TestWhile < Test::Unit::TestCase
28
+ include Nasl::Test
29
+
30
+ # Check that the 'while' itself is in the tokens list
31
+ def test_while_in_tokens
32
+ tree = parse(%q|while (foo) {}|)
33
+ assert_equal(
34
+ tree.all(:While).first.tokens.first.to_s,
35
+ "while"
36
+ )
37
+ end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nasl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mak Kolybabi
@@ -10,62 +10,62 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-28 00:00:00.000000000 Z
13
+ date: 2015-09-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: racc
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.4'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.4'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ~>
34
34
  - !ruby/object:Gem::Version
35
35
  version: '10.1'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ~>
41
41
  - !ruby/object:Gem::Version
42
42
  version: '10.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: builder
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ~>
48
48
  - !ruby/object:Gem::Version
49
49
  version: '3.1'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ~>
55
55
  - !ruby/object:Gem::Version
56
56
  version: '3.1'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rainbow
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - ~>
62
62
  - !ruby/object:Gem::Version
63
63
  version: '2.0'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
70
  version: '2.0'
71
71
  description: A language parser for the Nessus Attack Scripting Language. Supporting
@@ -79,8 +79,8 @@ executables:
79
79
  extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
- - ".gitignore"
83
- - ".travis.yml"
82
+ - .gitignore
83
+ - .travis.yml
84
84
  - Gemfile
85
85
  - Gemfile.ci
86
86
  - README.md
@@ -162,6 +162,7 @@ files:
162
162
  - test/unit/parser/test_repetition.rb
163
163
  - test/unit/parser/test_return.rb
164
164
  - test/unit/parser/test_string.rb
165
+ - test/unit/parser/test_while.rb
165
166
  - test/unit/parser/test_whitespace.rb
166
167
  - test/unit/test_context.rb
167
168
  - test/unit/tokenizer/test_comment.rb
@@ -179,17 +180,17 @@ require_paths:
179
180
  - lib
180
181
  required_ruby_version: !ruby/object:Gem::Requirement
181
182
  requirements:
182
- - - ">="
183
+ - - ! '>='
183
184
  - !ruby/object:Gem::Version
184
185
  version: '0'
185
186
  required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  requirements:
187
- - - ">="
188
+ - - ! '>='
188
189
  - !ruby/object:Gem::Version
189
190
  version: '0'
190
191
  requirements: []
191
192
  rubyforge_project: nasl
192
- rubygems_version: 2.2.0
193
+ rubygems_version: 2.4.6
193
194
  signing_key:
194
195
  specification_version: 4
195
196
  summary: A language parser for the Nessus Attack Scripting Language.
@@ -216,6 +217,7 @@ test_files:
216
217
  - test/unit/parser/test_repetition.rb
217
218
  - test/unit/parser/test_return.rb
218
219
  - test/unit/parser/test_string.rb
220
+ - test/unit/parser/test_while.rb
219
221
  - test/unit/parser/test_whitespace.rb
220
222
  - test/unit/test_context.rb
221
223
  - test/unit/tokenizer/test_comment.rb