nasldoc 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +64 -45
- data/lib/nasldoc.rb +1 -1
- data/lib/nasldoc/assets/js/shBrushNasl.js +2 -1
- data/lib/nasldoc/cli/application.rb +12 -16
- data/lib/nasldoc/cli/comment.rb +27 -9
- data/lib/nasldoc/templates/file.erb +9 -7
- data/lib/nasldoc/templates/index.erb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d6100856f636cd28f60d6936bb5d056fe021393
|
4
|
+
data.tar.gz: 1398be4dbab1473a82289a47f4cb2b172cb42486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ad2cd3ec765ce4b26f1afa5f4a0c8891e7e12398e8c01186cc3fe544e9966b4ad65039b5a3ddd6ce8b71801b197f1fef1efef1df140ddb45f5fb993ea2160a2
|
7
|
+
data.tar.gz: 4f2eaf16e55f9b1ba6442e8611a642723d15d882d679500d0b4cac74f3920e238047f89fb63c759803549f90577af92c2a86a1af4e1d9c8c5a41c059bb7d5f2a
|
data/README.markdown
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
#nasldoc
|
1
|
+
# nasldoc
|
2
2
|
|
3
|
-
|
3
|
+
### Installation
|
4
4
|
|
5
5
|
Installation is really easy, all you need to do is gem install!
|
6
6
|
|
7
|
-
|
7
|
+
% gem install nasldoc
|
8
8
|
|
9
|
-
|
9
|
+
#### Usage
|
10
10
|
|
11
11
|
Using `nasldoc` is fairly simple; just pass it a directory or a single file that you want to generate the documentation for. `nasldoc` is designed to only parse .inc files which special comment markup.
|
12
12
|
|
13
|
-
|
13
|
+
% nasldoc /opt/nessus/lib/nessus/plugins/
|
14
14
|
|
15
15
|
This will cause a directory called `nasldoc/` to be created in your current directory. This directory will contain all of the generated HTML documents. After running `nasldoc`, open `index.html` inside of `nasldoc/` and view the documentation.
|
16
16
|
|
17
|
-
|
17
|
+
#### Comment Markup
|
18
18
|
|
19
19
|
`nasldoc` comments are inclosed in ## blocks and use special tags to mark items. Currently, there are only 3 tags. Tags can be added in a matter of minutes to the parser.
|
20
20
|
|
@@ -28,48 +28,67 @@ nasldoc supports several markup tags:
|
|
28
28
|
- @category - type of category for the function
|
29
29
|
- @remark - special notes or remarks
|
30
30
|
|
31
|
-
|
31
|
+
### Function Description Block
|
32
32
|
|
33
33
|
The function description block is free form text from the first ## block to the first @tag in the `nasldoc` body. The lines are split on the # and rejoined with spaces.
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
Example:
|
36
|
+
|
37
|
+
##
|
38
|
+
# An example addition function in NASL
|
39
|
+
#
|
40
|
+
# @param arg1 first number to add
|
41
|
+
# @param arg2 second number to add
|
42
|
+
#
|
43
|
+
# @return the sum of arg1 and arg2
|
44
|
+
##
|
45
|
+
function add(arg1, arg2)
|
46
|
+
{
|
47
|
+
return (arg1 + arg2);
|
48
|
+
}
|
49
|
+
|
50
|
+
### Variable types
|
51
|
+
|
52
|
+
If you'd like, you can provide variable type descriptions. The syntax is as follows:
|
53
|
+
|
54
|
+
##
|
55
|
+
# An example addition function in NASL
|
56
|
+
#
|
57
|
+
# @param <arg1:int> first number to add
|
58
|
+
# @param [arg2:int] second number to add
|
59
|
+
#
|
60
|
+
# @return the sum of arg1 and arg2
|
61
|
+
##
|
62
|
+
function add(arg1, arg2)
|
63
|
+
{
|
64
|
+
return (arg1 + arg2);
|
65
|
+
}
|
66
|
+
|
67
|
+
You can wrap the name:type tuple using either '[]' or '<>'.
|
68
|
+
|
69
|
+
### Templates
|
51
70
|
|
52
71
|
`nasldoc` uses the ERB templating engine to make generating the output HTML trivial. Attached is an example of the sidebar; ruby code can be injected to help generate the layout.
|
53
72
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
Example:
|
74
|
+
|
75
|
+
<html>
|
76
|
+
<head>
|
77
|
+
<title>nasldoc</title>
|
78
|
+
<link rel = 'stylesheet' type= 'text/css' href='stylesheet.css'>
|
79
|
+
</head>
|
80
|
+
<body>
|
81
|
+
<img src='nessus.jpg' />
|
82
|
+
<br><br><br>
|
83
|
+
<ul>
|
84
|
+
<% @file_list.each_with_index do |file, i| %>
|
85
|
+
<% row_class = i % 2 == 0 ? "even" : "odd" %>
|
86
|
+
<% output_file = file.gsub(".", "_") %>
|
87
|
+
<% output_file = File.basename(file).gsub(".", "_") %>
|
88
|
+
<li class="<%= row_class %>"><a href='<%= output_file %>.html' target='content'><%= File.basename(file) %></a></li>
|
89
|
+
<% end %>
|
90
|
+
</ul>
|
91
|
+
<br><br><br>
|
92
|
+
<ul><a href='overview.html' target='content'>Home</a></ul>
|
93
|
+
</body>
|
94
|
+
</html>
|
data/lib/nasldoc.rb
CHANGED
@@ -7,7 +7,8 @@
|
|
7
7
|
var constants = 'FALSE NULL TRUE';
|
8
8
|
|
9
9
|
var keywords = 'break continue else export for foreach function global_var if ' +
|
10
|
-
'import include local_var repeat return until while'
|
10
|
+
'import include local_var repeat return until while namespace object ' +
|
11
|
+
'var public private case switch default do';
|
11
12
|
|
12
13
|
this.regexList = [
|
13
14
|
{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comment' },
|
@@ -43,7 +43,7 @@ module NaslDoc
|
|
43
43
|
@error_count = 0
|
44
44
|
@options = Hash.new
|
45
45
|
|
46
|
-
@options[:output_directory] = "
|
46
|
+
@options[:output_directory] = "nasldoc_output/"
|
47
47
|
|
48
48
|
@functions = Array.new
|
49
49
|
@globals = Array.new
|
@@ -253,29 +253,25 @@ module NaslDoc
|
|
253
253
|
def remove_blacklist file_list
|
254
254
|
blacklist = [
|
255
255
|
"apple_device_model_list.inc",
|
256
|
-
"
|
257
|
-
"blacklist_rsa.inc",
|
258
|
-
"blacklist_ssl_rsa1024.inc",
|
259
|
-
"blacklist_ssl_rsa2048.inc",
|
256
|
+
"blacklist_",
|
260
257
|
"custom_CA.inc",
|
261
|
-
"daily_badip
|
262
|
-
"daily_badip2.inc",
|
258
|
+
"daily_badip",
|
263
259
|
"daily_badurl.inc",
|
264
260
|
"known_CA.inc",
|
265
261
|
"oui.inc",
|
266
262
|
"oval-definitions-schematron.inc",
|
267
|
-
"ovaldi32-rhel5.inc",
|
268
|
-
"ovaldi32-win-dyn-v100.inc",
|
269
|
-
"ovaldi32-win-dyn-v90.inc",
|
270
|
-
"ovaldi32-win-static.inc",
|
271
|
-
"ovaldi64-rhel5.inc",
|
272
|
-
"ovaldi64-win-dyn-v100.inc",
|
273
|
-
"ovaldi64-win-dyn-v90.inc",
|
274
|
-
"ovaldi64-win-static.inc",
|
275
263
|
"plugin_feed_info.inc",
|
276
264
|
"sc_families.inc",
|
277
265
|
"scap_schema.inc",
|
278
|
-
"ssl_known_cert.inc"
|
266
|
+
"ssl_known_cert.inc",
|
267
|
+
"ssh_get_info2",
|
268
|
+
"torture_cgi",
|
269
|
+
"daily_badip3.inc",
|
270
|
+
"cisco_ios.inc",
|
271
|
+
"ovaldi32",
|
272
|
+
"ovaldi64",
|
273
|
+
"os_cves.inc",
|
274
|
+
"kernel_cves.inc"
|
279
275
|
]
|
280
276
|
|
281
277
|
new_file_list = file_list.dup
|
data/lib/nasldoc/cli/comment.rb
CHANGED
@@ -52,8 +52,8 @@ module NaslDoc
|
|
52
52
|
attr_accessor :description, :summary
|
53
53
|
|
54
54
|
# Tag attributes.
|
55
|
-
attr_accessor :anonparams, :categories, :deprecated, :includes, :nessus
|
56
|
-
attr_accessor :params, :remarks, :return
|
55
|
+
attr_accessor :anonparams, :anonparams_type, :categories, :deprecated, :includes, :nessus
|
56
|
+
attr_accessor :params, :params_type, :remarks, :return
|
57
57
|
|
58
58
|
# Export and function attributes.
|
59
59
|
attr_accessor :function
|
@@ -87,11 +87,13 @@ module NaslDoc
|
|
87
87
|
|
88
88
|
# Create tag attributes.
|
89
89
|
@anonparams = {}
|
90
|
+
@anonparams_type = {}
|
90
91
|
@categories = []
|
91
92
|
@deprecated = nil
|
92
93
|
@includes = []
|
93
94
|
@nessus = nil
|
94
95
|
@params = {}
|
96
|
+
@params_type = {}
|
95
97
|
@remarks = []
|
96
98
|
@return = nil
|
97
99
|
|
@@ -193,7 +195,7 @@ module NaslDoc
|
|
193
195
|
end
|
194
196
|
|
195
197
|
def parse_tags(text)
|
196
|
-
re_name = Regexp.new("[
|
198
|
+
re_name = Regexp.new("(<|\\[)?[_a-zA-Z0-9:]*(\\]|>)?")
|
197
199
|
re_tags = Regexp.new(tags_regex)
|
198
200
|
|
199
201
|
# Tags start a line which continues until the next tag or blank line.
|
@@ -232,17 +234,29 @@ module NaslDoc
|
|
232
234
|
case tag
|
233
235
|
when '@anonparam', '@param'
|
234
236
|
# Parse the argument name.
|
235
|
-
|
236
|
-
if
|
237
|
+
parts_str = block[re_name]
|
238
|
+
if parts_str.nil?
|
237
239
|
raise TagFormatException, "Failed to parse the #{tag}'s name for #@name."
|
238
240
|
end
|
239
241
|
|
240
|
-
|
242
|
+
parts = parts_str.split(':')
|
243
|
+
|
244
|
+
name = parts[0]
|
245
|
+
name = name.gsub(/[\[\]<>]/, '')
|
246
|
+
|
247
|
+
block = block[parts_str.length..-1]
|
248
|
+
|
241
249
|
if block.nil?
|
242
250
|
raise TagFormatException, "Failed to parse the #{tag}'s block for #@name."
|
243
251
|
end
|
252
|
+
|
244
253
|
block.lstrip!
|
245
|
-
|
254
|
+
|
255
|
+
type = nil
|
256
|
+
if(parts.length > 1)
|
257
|
+
type = parts[1]
|
258
|
+
type = type.gsub(/[\[\]<>]/, '')
|
259
|
+
end
|
246
260
|
|
247
261
|
# Check for previous declarations of this name.
|
248
262
|
if @anonparams.key?(name)
|
@@ -252,10 +266,14 @@ module NaslDoc
|
|
252
266
|
if @params.key?(name) and not @params[name].nil?
|
253
267
|
raise DuplicateTagException, "The param '#{name}' was previously declared as a @param for #@name."
|
254
268
|
end
|
255
|
-
|
256
269
|
hash = self.send(attr + 's')
|
257
270
|
hash[name] = block
|
258
|
-
|
271
|
+
|
272
|
+
if(!type.nil?)
|
273
|
+
hash1 = self.send(attr + 's_type')
|
274
|
+
hash1[name] = type
|
275
|
+
end
|
276
|
+
|
259
277
|
when '@category'
|
260
278
|
unless @categories.empty?
|
261
279
|
raise DuplicateTagException, "The #{tag} tag appears more than once for #@name."
|
@@ -14,7 +14,6 @@
|
|
14
14
|
@comments.select(&filter1).select(&filter2).shift
|
15
15
|
end
|
16
16
|
%>
|
17
|
-
|
18
17
|
<%
|
19
18
|
def safe(obj, default, *attrs)
|
20
19
|
attrs.each do |attr|
|
@@ -344,7 +343,8 @@
|
|
344
343
|
<h3>Anonymous Parameters</h3>
|
345
344
|
<dl>
|
346
345
|
<% comm.anonparams.sort.each do |name, block| %>
|
347
|
-
<dt><%= name
|
346
|
+
<dt><%= name %><% unless !comm.anonparams_type.has_key?(name) %><font color="#d14"> (<%= comm.anonparams_type[name] %>)</font>
|
347
|
+
<% end %></dt>
|
348
348
|
<dd><%= block %></dd>
|
349
349
|
<% end %>
|
350
350
|
</dl>
|
@@ -356,7 +356,9 @@
|
|
356
356
|
<dl>
|
357
357
|
|
358
358
|
<% @functions[name][:params].sort.each do |param| %>
|
359
|
-
<dt><%= param.name
|
359
|
+
<dt><%= param.name %>
|
360
|
+
<% unless comm.nil? || !comm.params_type.has_key?(param.name) %><font color="#d14"> (<%= comm.params_type[param.name] %>)</font>
|
361
|
+
<% end %></dt>
|
360
362
|
<% unless comm.nil? || !comm.params.has_key?(param.name) %>
|
361
363
|
<dd><%= comm.params[param.name] %></dd>
|
362
364
|
<% end %>
|
@@ -371,11 +373,11 @@
|
|
371
373
|
|
372
374
|
<h3>Code</h3>
|
373
375
|
<!-- The contents must not have indentation, else formatting is off. -->
|
374
|
-
|
376
|
+
<script type="syntaxhighlighter" class="brush: nasl"><![CDATA[
|
375
377
|
<% unless @functions[name][:code].nil? %>
|
376
|
-
<%=
|
378
|
+
<%= @functions[name][:code] %>
|
377
379
|
<% end %>
|
378
|
-
|
380
|
+
]]></script>
|
379
381
|
<a href="#top">top</a>
|
380
382
|
<hr>
|
381
383
|
<% end %>
|
@@ -388,7 +390,7 @@
|
|
388
390
|
<hr>
|
389
391
|
|
390
392
|
<footer>
|
391
|
-
<p>© Tenable Network Security
|
393
|
+
<p>© Tenable Network Security <%= Time.new.year %></p>
|
392
394
|
</footer>
|
393
395
|
|
394
396
|
</div><!--/.fluid-container-->
|
@@ -71,8 +71,9 @@
|
|
71
71
|
<div class="span9">
|
72
72
|
<div class="hero-unit">
|
73
73
|
<h1>Welcome to nasldoc!</h1>
|
74
|
+
<h3> Generated <%= Time.now.inspect %></h3>
|
74
75
|
<p>Select a file to view the docs!</p>
|
75
|
-
<p><a class="btn btn-primary btn-large">Learn more »</a></p>
|
76
|
+
<p><a class="btn btn-primary btn-large" href="https://github.com/tenable/nasldoc">Learn more »</a></p>
|
76
77
|
</div>
|
77
78
|
<div class="row-fluid">
|
78
79
|
</div><!--/row-->
|
@@ -82,7 +83,7 @@
|
|
82
83
|
<hr>
|
83
84
|
|
84
85
|
<footer>
|
85
|
-
<p>© Tenable Network Security
|
86
|
+
<p>© Tenable Network Security <%= Time.new.year %></p>
|
86
87
|
</footer>
|
87
88
|
|
88
89
|
</div><!--/.fluid-container-->
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nasldoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Hammack
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-06-
|
13
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|