nasldoc 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/Gemfile +5 -0
- data/Gemfile.ci +5 -0
- data/Gemfile.lock +17 -0
- data/LICENSE +1 -1
- data/NEWS.markdown +16 -1
- data/Rakefile +19 -19
- data/TODO.markdown +6 -8
- data/bin/nasldoc +20 -19
- data/lib/nasldoc.rb +21 -20
- data/lib/nasldoc/cli.rb +19 -19
- data/lib/nasldoc/cli/application.rb +43 -21
- data/lib/nasldoc/cli/application.rb.orig +290 -0
- data/lib/nasldoc/cli/application.rb.rej +16 -0
- data/lib/nasldoc/cli/comment.rb +19 -19
- data/lib/nasldoc/templates/file.erb +8 -6
- data/lib/nasldoc/templates/index.erb +1 -1
- data/nasldoc.gemspec +25 -22
- metadata +68 -22
- data/lib/nasldoc/templates/old/file.erb +0 -332
- data/lib/nasldoc/templates/old/xfile.erb +0 -267
- data/lib/nasldoc/templates/old/xindex.erb +0 -16
- data/lib/nasldoc/templates/old/xoverview.erb +0 -26
- data/lib/nasldoc/templates/old/xsidebar.erb +0 -21
- data/lib/nasldoc/templates/xindex.erb +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjFhNmI2Y2VmNjQ0YTdiN2I2NjY4YTg5MTYwZDlkOWUxZTkzZmI5Nw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2ZkYzUzMGZjZDFlYWE1NDEzODg3NDM5NWEwNWY2ZDU1MDlkMTM0Nw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTE4YzhlYzA5MGI0Y2IzYWQ5YWU4MTQ0ZWNkMWE1MjAxYzYxNDA2NWFjNWQz
|
10
|
+
NzgxMjhjYTRkMTk0MzM4MjkzY2IwNmEwNTcxNWU5OTUzYWM0MTVhYzY3NTM3
|
11
|
+
MWNlYTA5YmZlMDM0NDFhYmNjNzdhY2EyODcwMzQ1YzVkNjI5MWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2Q5NGE5N2NlMzRjN2VjNGRhOGVhNTJlYTlmNWRmZmQxZDRjY2I1MDMzNWQx
|
14
|
+
MGJkYmViYTQwZDYyYTRjZjNhOGFjYTQ3NmEyMzk2NGVkY2E1MmM3NGEwMjA4
|
15
|
+
ZGM5NWIzMzg5ODJkZDRmMWZiMjc5NmVlMWE2MGViZDE5NWEwNDk=
|
data/Gemfile
ADDED
data/Gemfile.ci
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.2.2)
|
5
|
+
nasl (0.2.0)
|
6
|
+
builder (~> 3.1)
|
7
|
+
rainbow (~> 2.0)
|
8
|
+
rainbow (2.0.0)
|
9
|
+
rake (10.3.2)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
nasl (= 0.2.0)
|
16
|
+
rainbow (= 2.0.0)
|
17
|
+
rake (= 10.3.2)
|
data/LICENSE
CHANGED
data/NEWS.markdown
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
#0.2.0 (August 27, 2014)
|
4
|
+
- Updated to support NASL v5.2.
|
5
|
+
- Minor bug fixes
|
6
|
+
- Added travis.ci support
|
7
|
+
|
8
|
+
#0.1.1 (January 29, 2013)
|
9
|
+
- Fixed bug caused by target attribute in anchor tags (Mak)
|
10
|
+
- Fixed linkages, these files don't exist, they're minified (Mak)
|
11
|
+
- Add syntax highlighting (Mak)
|
12
|
+
- Add source code to function hash (Mak)
|
13
|
+
- Fixed whitespace and removed trailing whitespace (Mak)
|
14
|
+
- Fixed parsing bug caused by bad formatting of tags (Mak)
|
15
|
+
- Fixed sorting for directories. (Mak)
|
16
|
+
- Fixed minor inconsistencies. (Mak)
|
17
|
+
- Support nested directories. (Mak)
|
18
|
+
|
3
19
|
#0.1.0 (November 2012)
|
4
20
|
- Integrated the nasl gem's language parsing for acquiring comments (Mak)
|
5
|
-
- Added
|
6
21
|
|
7
22
|
#0.0.9 (March 2012)
|
8
23
|
- Fixed a show stopper
|
data/Rakefile
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
2
3
|
# All rights reserved.
|
3
4
|
#
|
4
5
|
# Redistribution and use in source and binary forms, with or without
|
5
6
|
# modification, are permitted provided that the following conditions are met:
|
6
7
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# * Redistributions in binary form must reproduce the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer in the
|
11
|
-
# documentation and/or other materials provided with the distribution.
|
12
|
-
# * Neither the name of the Tenable Network Security nor the names of its contributors
|
13
|
-
# may be used to endorse or promote products derived from this software
|
14
|
-
# without specific prior written permission.
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
15
10
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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
26
|
|
27
27
|
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
28
28
|
|
data/TODO.markdown
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Todo
|
2
|
-
- create a github page for the project
|
3
2
|
|
3
|
+
- tags nasldoc tag for assisting in searching, possibly auto generated from the description
|
4
|
+
- javascript searching
|
5
|
+
- create a github page for the project
|
4
6
|
- hyper links open in new tab in firefox
|
5
7
|
- fix the formatting for the function summaries
|
6
8
|
- [hyperlink] syntax is broken
|
@@ -8,15 +10,11 @@
|
|
8
10
|
- fix whitespace around all blocks
|
9
11
|
- add code div
|
10
12
|
- http://code.google.com/p/syntaxhighlighter/source/browse/trunk/Scripts/shBrushPhp.js
|
11
|
-
|
12
13
|
- Break up the Application class
|
13
|
-
|
14
|
-
- Compileatron <-- Takes in list of files to compile
|
14
|
+
- Compilation <-- Takes in list of files to compile
|
15
15
|
- Creates index
|
16
16
|
- Copies Assets
|
17
17
|
- Compiles each .inc file into a .html file
|
18
|
-
|
19
18
|
- TemplateHelper
|
20
|
-
|
21
|
-
|
22
|
-
- Anchor tags css issue not seeing the top
|
19
|
+
- Anchor tags css issue not seeing the top
|
20
|
+
- nasldoc coverage checker
|
data/bin/nasldoc
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
3
5
|
# All rights reserved.
|
4
6
|
#
|
5
7
|
# Redistribution and use in source and binary forms, with or without
|
6
8
|
# modification, are permitted provided that the following conditions are met:
|
7
9
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# may be used to endorse or promote products derived from this software
|
15
|
-
# without specific prior written permission.
|
10
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
11
|
+
# list of conditions and the following disclaimer.
|
12
|
+
#
|
13
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
15
|
+
# and/or other materials provided with the distribution.
|
16
16
|
#
|
17
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
-
# DISCLAIMED. IN NO EVENT SHALL
|
21
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
-
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
-
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
################################################################################
|
27
28
|
|
28
29
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../lib'))
|
29
30
|
|
data/lib/nasldoc.rb
CHANGED
@@ -1,36 +1,37 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
2
3
|
# All rights reserved.
|
3
4
|
#
|
4
5
|
# Redistribution and use in source and binary forms, with or without
|
5
6
|
# modification, are permitted provided that the following conditions are met:
|
6
7
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# * Redistributions in binary form must reproduce the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer in the
|
11
|
-
# documentation and/or other materials provided with the distribution.
|
12
|
-
# * Neither the name of the Tenable Network Security nor the names of its contributors
|
13
|
-
# may be used to endorse or promote products derived from this software
|
14
|
-
# without specific prior written permission.
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
15
10
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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
26
|
|
27
27
|
module NaslDoc
|
28
28
|
APP_NAME = "nasldoc"
|
29
|
-
VERSION = "0.
|
29
|
+
VERSION = "0.2.1"
|
30
30
|
end
|
31
31
|
|
32
32
|
require 'erb'
|
33
33
|
require 'pathname'
|
34
34
|
require 'optparse'
|
35
|
+
require 'rainbow/ext/string'
|
35
36
|
|
36
37
|
require 'nasldoc/cli'
|
data/lib/nasldoc/cli.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
2
3
|
# All rights reserved.
|
3
4
|
#
|
4
5
|
# Redistribution and use in source and binary forms, with or without
|
5
6
|
# modification, are permitted provided that the following conditions are met:
|
6
7
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# * Redistributions in binary form must reproduce the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer in the
|
11
|
-
# documentation and/or other materials provided with the distribution.
|
12
|
-
# * Neither the name of the Tenable Network Security nor the names of its contributors
|
13
|
-
# may be used to endorse or promote products derived from this software
|
14
|
-
# without specific prior written permission.
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
15
10
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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
26
|
|
27
27
|
module NaslDoc
|
28
28
|
module CLI
|
@@ -1,28 +1,28 @@
|
|
1
|
-
|
1
|
+
################################################################################
|
2
|
+
# Copyright (c) 2011-2014, Tenable Network Security
|
2
3
|
# All rights reserved.
|
3
4
|
#
|
4
5
|
# Redistribution and use in source and binary forms, with or without
|
5
6
|
# modification, are permitted provided that the following conditions are met:
|
6
7
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# * Redistributions in binary form must reproduce the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer in the
|
11
|
-
# documentation and/or other materials provided with the distribution.
|
12
|
-
# * Neither the name of the Tenable Network Security nor the names of its contributors
|
13
|
-
# may be used to endorse or promote products derived from this software
|
14
|
-
# without specific prior written permission.
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
15
10
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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
26
|
|
27
27
|
require 'nasldoc/cli/comment'
|
28
28
|
|
@@ -98,7 +98,12 @@ module NaslDoc
|
|
98
98
|
contents = File.open(path, "rb") { |f| f.read }
|
99
99
|
|
100
100
|
# Parse the input file.
|
101
|
-
|
101
|
+
begin
|
102
|
+
tree = Nasl::Parser.new.parse(contents, path)
|
103
|
+
rescue Nasl::ParseException, Nasl::TokenException
|
104
|
+
puts "[!!!] File '#{path}' couldn't be parsed. It should be added to the blacklist."
|
105
|
+
return nil
|
106
|
+
end
|
102
107
|
|
103
108
|
# Collect the functions.
|
104
109
|
@functions = Hash.new()
|
@@ -114,7 +119,13 @@ module NaslDoc
|
|
114
119
|
@funcs_pub = @functions.reject { |n, p| @funcs_prv.key? n }
|
115
120
|
|
116
121
|
# Collect the globals.
|
117
|
-
@globals = tree.all(:Global).map(&:idents).flatten.map
|
122
|
+
@globals = tree.all(:Global).map(&:idents).flatten.map do |id|
|
123
|
+
if id.is_a? Nasl::Assignment
|
124
|
+
id.lval.name
|
125
|
+
else
|
126
|
+
id.name
|
127
|
+
end
|
128
|
+
end.sort
|
118
129
|
|
119
130
|
@globs_prv = @globals.select { |n| n =~ /^_/ }
|
120
131
|
@globs_pub = @globals.reject { |n| @globs_prv.include? n }
|
@@ -173,6 +184,7 @@ module NaslDoc
|
|
173
184
|
# Removes blacklisted files from the file list
|
174
185
|
def remove_blacklist file_list
|
175
186
|
blacklist = [
|
187
|
+
"apple_device_model_list.inc",
|
176
188
|
"blacklist_dss.inc",
|
177
189
|
"blacklist_rsa.inc",
|
178
190
|
"blacklist_ssl_rsa1024.inc",
|
@@ -183,8 +195,18 @@ module NaslDoc
|
|
183
195
|
"daily_badurl.inc",
|
184
196
|
"known_CA.inc",
|
185
197
|
"oui.inc",
|
198
|
+
"oval-definitions-schematron.inc",
|
199
|
+
"ovaldi32-rhel5.inc",
|
200
|
+
"ovaldi32-win-dyn-v100.inc",
|
201
|
+
"ovaldi32-win-dyn-v90.inc",
|
202
|
+
"ovaldi32-win-static.inc",
|
203
|
+
"ovaldi64-rhel5.inc",
|
204
|
+
"ovaldi64-win-dyn-v100.inc",
|
205
|
+
"ovaldi64-win-dyn-v90.inc",
|
206
|
+
"ovaldi64-win-static.inc",
|
186
207
|
"plugin_feed_info.inc",
|
187
208
|
"sc_families.inc",
|
209
|
+
"scap_schema.inc",
|
188
210
|
"ssl_known_cert.inc"
|
189
211
|
]
|
190
212
|
|
@@ -0,0 +1,290 @@
|
|
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 'nasldoc/cli/comment'
|
28
|
+
|
29
|
+
module NaslDoc
|
30
|
+
module CLI
|
31
|
+
class Application
|
32
|
+
attr_accessor :error_count
|
33
|
+
|
34
|
+
# Initializes the Application class
|
35
|
+
#
|
36
|
+
# - Sets the default output directory to nasldoc_output/
|
37
|
+
# - Sets the template directory to lib/templates
|
38
|
+
# - Sets the assets directory to lib/assets
|
39
|
+
#
|
40
|
+
def initialize
|
41
|
+
@file_list = Array.new
|
42
|
+
@function_count = 0
|
43
|
+
@error_count = 0
|
44
|
+
@options = Hash.new
|
45
|
+
|
46
|
+
@options[:output_directory] = "nasldoc_ouput/"
|
47
|
+
|
48
|
+
@functions = Array.new
|
49
|
+
@globals = Array.new
|
50
|
+
@includes = Array.new
|
51
|
+
|
52
|
+
@overview = nil
|
53
|
+
|
54
|
+
@template_dir = Pathname.new(__FILE__).realpath.to_s.gsub('cli/application.rb', 'templates')
|
55
|
+
@asset_dir = Pathname.new(__FILE__).realpath.to_s.gsub('cli/application.rb', 'assets')
|
56
|
+
@current_file = "(unknown)"
|
57
|
+
end
|
58
|
+
|
59
|
+
# For ERB Support
|
60
|
+
#
|
61
|
+
# @return ERB Binding for access to instance variables in templates
|
62
|
+
def get_binding
|
63
|
+
binding
|
64
|
+
end
|
65
|
+
|
66
|
+
# Generates the base name for a path
|
67
|
+
#
|
68
|
+
# @return htmlized file name for .inc file
|
69
|
+
def base path
|
70
|
+
File.basename(path, '.inc')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Generates the HTML base name for a path
|
74
|
+
#
|
75
|
+
# @return htmlized file name for .inc file
|
76
|
+
def url path
|
77
|
+
base(path).gsub('.', '_') + '.html'
|
78
|
+
end
|
79
|
+
|
80
|
+
# Compiles a template for each file
|
81
|
+
def build_template name, path=nil
|
82
|
+
path ||= name
|
83
|
+
|
84
|
+
dest = url(path)
|
85
|
+
puts "[**] Creating #{dest}"
|
86
|
+
@erb = ERB.new File.new("#{@template_dir}/#{name}.erb").read, nil, "%"
|
87
|
+
html = @erb.result(get_binding)
|
88
|
+
|
89
|
+
File.open("#{@options[:output_directory]}/#{dest}", 'w+') do |f|
|
90
|
+
f.puts html
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Processes each .inc file and sets instance variables for each template
|
95
|
+
def build_file_page path
|
96
|
+
puts "[*] Processing file: #{path}"
|
97
|
+
@current_file = File.basename(path)
|
98
|
+
contents = File.open(path, "rb") { |f| f.read }
|
99
|
+
|
100
|
+
# Parse the input file.
|
101
|
+
tree = Nasl::Parser.new.parse(contents, path)
|
102
|
+
|
103
|
+
# Collect the functions.
|
104
|
+
@functions = Hash.new()
|
105
|
+
tree.all(:Function).map do |fn|
|
106
|
+
@functions[fn.name.name] = {
|
107
|
+
:code => fn.context(nil, false, false),
|
108
|
+
:params => fn.params.map(&:name)
|
109
|
+
}
|
110
|
+
@function_count += 1
|
111
|
+
end
|
112
|
+
|
113
|
+
@funcs_prv = @functions.select { |n, p| n =~ /^_/ }
|
114
|
+
@funcs_pub = @functions.reject { |n, p| @funcs_prv.key? n }
|
115
|
+
|
116
|
+
# Collect the globals.
|
117
|
+
@globals = tree.all(:Global).map(&:idents).flatten.map do |id|
|
118
|
+
if id.is_a? Nasl::Assignment
|
119
|
+
id.lval.name
|
120
|
+
else
|
121
|
+
id.name
|
122
|
+
end
|
123
|
+
end.sort
|
124
|
+
|
125
|
+
@globs_prv = @globals.select { |n| n =~ /^_/ }
|
126
|
+
@globs_pub = @globals.reject { |n| @globs_prv.include? n }
|
127
|
+
|
128
|
+
# Collect the includes.
|
129
|
+
@includes = tree.all(:Include).map(&:filename).map(&:text).sort
|
130
|
+
|
131
|
+
# Parse the comments.
|
132
|
+
@comments = tree.all(:Comment)
|
133
|
+
puts "[**] #{@comments.size} comment(s) were found"
|
134
|
+
@comments.map! do |comm|
|
135
|
+
begin
|
136
|
+
NaslDoc::CLI::Comment.new(comm, path)
|
137
|
+
rescue CommentException => e
|
138
|
+
# A short message is okay for format errors.
|
139
|
+
puts "[!!!] #{e.class.name} #{e.message}"
|
140
|
+
@error_count += 1
|
141
|
+
nil
|
142
|
+
rescue Exception => e
|
143
|
+
# A detailed message is given for programming errors.
|
144
|
+
puts "[!!!] #{e.class.name} #{e.message}"
|
145
|
+
puts e.backtrace.map{ |l| l.prepend "[!!!!] " }.join("\n")
|
146
|
+
nil
|
147
|
+
end
|
148
|
+
end
|
149
|
+
@comments.compact!
|
150
|
+
@comments.keep_if &:valid
|
151
|
+
puts "[**] #{@comments.size} nasldoc comment(s) were parsed"
|
152
|
+
|
153
|
+
# Find the overview comment.
|
154
|
+
@overview = @comments.select{ |c| c.type == :file }.shift
|
155
|
+
|
156
|
+
build_template "file", path
|
157
|
+
end
|
158
|
+
|
159
|
+
# Builds each page from the file_list
|
160
|
+
def build_file_pages
|
161
|
+
@file_list.each do |f|
|
162
|
+
build_file_page(f)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Copies required assets to the final build directory
|
167
|
+
def copy_assets
|
168
|
+
puts `cp -vr #{@asset_dir}/* #{@options[:output_directory]}/`
|
169
|
+
end
|
170
|
+
|
171
|
+
# Prints documentation stats to stdout
|
172
|
+
def print_documentation_stats
|
173
|
+
puts "\n\nDocumentation Statistics"
|
174
|
+
puts "Files: #{@file_list.size}"
|
175
|
+
puts "Functions: #{@function_count}"
|
176
|
+
puts "Errors: #{@error_count}"
|
177
|
+
end
|
178
|
+
|
179
|
+
# Removes blacklisted files from the file list
|
180
|
+
def remove_blacklist file_list
|
181
|
+
blacklist = [
|
182
|
+
"apple_device_model_list.inc",
|
183
|
+
"blacklist_dss.inc",
|
184
|
+
"blacklist_rsa.inc",
|
185
|
+
"blacklist_ssl_rsa1024.inc",
|
186
|
+
"blacklist_ssl_rsa2048.inc",
|
187
|
+
"custom_CA.inc",
|
188
|
+
"daily_badip.inc",
|
189
|
+
"daily_badip2.inc",
|
190
|
+
"daily_badurl.inc",
|
191
|
+
"known_CA.inc",
|
192
|
+
"oui.inc",
|
193
|
+
"oval-definitions-schematron.inc",
|
194
|
+
"ovaldi32-rhel5.inc",
|
195
|
+
"ovaldi32-win-dyn-v100.inc",
|
196
|
+
"ovaldi32-win-dyn-v90.inc",
|
197
|
+
"ovaldi32-win-static.inc",
|
198
|
+
"ovaldi64-rhel5.inc",
|
199
|
+
"ovaldi64-win-dyn-v100.inc",
|
200
|
+
"ovaldi64-win-dyn-v90.inc",
|
201
|
+
"ovaldi64-win-static.inc",
|
202
|
+
"plugin_feed_info.inc",
|
203
|
+
"sc_families.inc",
|
204
|
+
"scap_schema.inc",
|
205
|
+
"ssl_known_cert.inc"
|
206
|
+
]
|
207
|
+
|
208
|
+
new_file_list = file_list.dup
|
209
|
+
|
210
|
+
file_list.each_with_index do |file, index|
|
211
|
+
blacklist.each do |bf|
|
212
|
+
if file =~ /#{bf}/
|
213
|
+
new_file_list.delete(file)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
return new_file_list
|
219
|
+
end
|
220
|
+
|
221
|
+
# Parses the command line arguments
|
222
|
+
def parse_args
|
223
|
+
opts = OptionParser.new do |opt|
|
224
|
+
opt.banner = "#{APP_NAME} v#{VERSION}\nTenable Network Security.\njhammack@tenable.com\n\n"
|
225
|
+
opt.banner << "Usage: #{APP_NAME} [options] [file|directory]"
|
226
|
+
|
227
|
+
opt.separator ''
|
228
|
+
opt.separator 'Options'
|
229
|
+
|
230
|
+
opt.on('-o', '--output DIRECTORY', "Directory to output results to, created if it doesn't exit") do |option|
|
231
|
+
@options[:output_directory] = option
|
232
|
+
end
|
233
|
+
|
234
|
+
opt.separator ''
|
235
|
+
opt.separator 'Other Options'
|
236
|
+
|
237
|
+
opt.on_tail('-v', '--version', "Shows application version information") do
|
238
|
+
puts "#{APP_NAME} - #{VERSION}"
|
239
|
+
exit
|
240
|
+
end
|
241
|
+
|
242
|
+
opt.on_tail('-?', '--help', 'Show this message') do
|
243
|
+
puts opt.to_s + "\n"
|
244
|
+
exit
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
if ARGV.length != 0
|
249
|
+
opts.parse!
|
250
|
+
else
|
251
|
+
puts opts.to_s + "\n"
|
252
|
+
exit
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# Main function for running nasldoc
|
257
|
+
def run
|
258
|
+
parse_args
|
259
|
+
|
260
|
+
if File.directory?(ARGV.first) == true
|
261
|
+
pattern = File.join(ARGV.first, '**', '*.inc')
|
262
|
+
@file_list = Dir.glob pattern
|
263
|
+
else
|
264
|
+
@file_list << ARGV.first
|
265
|
+
end
|
266
|
+
|
267
|
+
# Ensure the output directory exists.
|
268
|
+
if File.directory?(@options[:output_directory]) == false
|
269
|
+
Dir.mkdir @options[:output_directory]
|
270
|
+
end
|
271
|
+
|
272
|
+
# Get rid of non-NASL files.
|
273
|
+
@file_list = remove_blacklist(@file_list)
|
274
|
+
|
275
|
+
# Ensure we process files in a consistent order.
|
276
|
+
@file_list.sort! do |a, b|
|
277
|
+
base(a) <=> base(b)
|
278
|
+
end
|
279
|
+
|
280
|
+
puts "[*] Building documentation..."
|
281
|
+
|
282
|
+
build_template "index"
|
283
|
+
build_file_pages
|
284
|
+
copy_assets
|
285
|
+
|
286
|
+
print_documentation_stats
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|