Skip to content

Commit 1f7a245

Browse files
Added tests for examples (#2216)
This adds a new test to validate the structure and syntax of all examples and moves the existing example test into the mocha test suite.
1 parent 26626de commit 1f7a245

20 files changed

+352
-163
lines changed

examples/prism-abap.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<h2>Comments</h2>
22
<pre><code>
33
* Line Comments
4-
&quot; End of line comment used as line comment.
5-
value = 1. &quot; End of line comment
4+
" End of line comment used as line comment.
5+
value = 1. " End of line comment
66

77
DATA:
8-
&quot;! ABAPDoc comment
8+
"! ABAPDoc comment
99
value TYPE i.
1010
</code></pre>
1111

@@ -16,7 +16,7 @@ <h2>Strings</h2>
1616
my_string = 'String with an escaped '' inside'.
1717
my_string = |A string template: { nvalue } times|.
1818
my_string = |A string template: { nvalue } times|.
19-
my_string = |Characters \|, \{, and \} have to be escaped by \\ in literal text.|.
19+
my_string = |Characters \|, \{, and \} have to be escaped by \\ in literal text.|.
2020
</code></pre>
2121

2222
<h2>Numbers and Operators</h2>
@@ -62,4 +62,4 @@ <h2>Structures and Classes</h2>
6262
CREATE OBJECT lo_instace.
6363

6464
my_structure-component = lo_instace->my_method( ).
65-
</code></pre>
65+
</code></pre>

examples/prism-bro.html

+48-48
Original file line numberDiff line numberDiff line change
@@ -55,100 +55,100 @@ <h2>Full example</h2>
5555

5656
# Whether to consider UDP "connections" for scan detection.
5757
# Can lead to false positives due to UDP fanout from some P2P apps.
58-
const suppress_UDP_scan_checks = F &redef;
58+
const suppress_UDP_scan_checks = F &amp;redef;
5959

60-
const activate_priv_port_check = T &redef;
61-
const activate_landmine_check = F &redef;
62-
const landmine_thresh_trigger = 5 &redef;
60+
const activate_priv_port_check = T &amp;redef;
61+
const activate_landmine_check = F &amp;redef;
62+
const landmine_thresh_trigger = 5 &amp;redef;
6363

64-
const landmine_address: set[addr] &redef;
64+
const landmine_address: set[addr] &amp;redef;
6565

66-
const scan_summary_trigger = 25 &redef;
67-
const port_summary_trigger = 20 &redef;
68-
const lowport_summary_trigger = 10 &redef;
66+
const scan_summary_trigger = 25 &amp;redef;
67+
const port_summary_trigger = 20 &amp;redef;
68+
const lowport_summary_trigger = 10 &amp;redef;
6969

7070
# Raise ShutdownThresh after this many failed attempts
71-
const shut_down_thresh = 100 &redef;
71+
const shut_down_thresh = 100 &amp;redef;
7272

7373
# Which services should be analyzed when detecting scanning
7474
# (not consulted if analyze_all_services is set).
75-
const analyze_services: set[port] &redef;
76-
const analyze_all_services = T &redef;
75+
const analyze_services: set[port] &amp;redef;
76+
const analyze_all_services = T &amp;redef;
7777

7878
# Track address scaners only if at least these many hosts contacted.
79-
const addr_scan_trigger = 0 &redef;
79+
const addr_scan_trigger = 0 &amp;redef;
8080

8181
# Ignore address scanners for further scan detection after
8282
# scanning this many hosts.
8383
# 0 disables.
84-
const ignore_scanners_threshold = 0 &redef;
84+
const ignore_scanners_threshold = 0 &amp;redef;
8585

8686
# Report a scan of peers at each of these points.
8787
const report_peer_scan: vector of count = {
8888
20, 100, 1000, 10000, 50000, 100000, 250000, 500000, 1000000,
89-
} &redef;
89+
} &amp;redef;
9090

9191
const report_outbound_peer_scan: vector of count = {
9292
100, 1000, 10000,
93-
} &redef;
93+
} &amp;redef;
9494

9595
# Report a scan of ports at each of these points.
9696
const report_port_scan: vector of count = {
9797
50, 250, 1000, 5000, 10000, 25000, 65000,
98-
} &redef;
98+
} &amp;redef;
9999

100100
# Once a source has scanned this many different ports (to however many
101101
# different remote hosts), start tracking its per-destination access.
102-
const possible_port_scan_thresh = 20 &redef;
102+
const possible_port_scan_thresh = 20 &amp;redef;
103103

104104
# Threshold for scanning privileged ports.
105-
const priv_scan_trigger = 5 &redef;
105+
const priv_scan_trigger = 5 &amp;redef;
106106
const troll_skip_service = {
107107
25/tcp, 21/tcp, 22/tcp, 20/tcp, 80/tcp,
108-
} &redef;
108+
} &amp;redef;
109109

110110
const report_accounts_tried: vector of count = {
111111
20, 100, 1000, 10000, 100000, 1000000,
112-
} &redef;
112+
} &amp;redef;
113113

114114
const report_remote_accounts_tried: vector of count = {
115115
100, 500,
116-
} &redef;
116+
} &amp;redef;
117117

118118
# Report a successful password guessing if the source attempted
119119
# at least this many.
120-
const password_guessing_success_threshhold = 20 &redef;
120+
const password_guessing_success_threshhold = 20 &amp;redef;
121121

122-
const skip_accounts_tried: set[addr] &redef;
122+
const skip_accounts_tried: set[addr] &amp;redef;
123123

124124
const addl_web = {
125125
81/tcp, 443/tcp, 8000/tcp, 8001/tcp, 8080/tcp, }
126-
&redef;
126+
&amp;redef;
127127

128-
const skip_services = { 113/tcp, } &redef;
128+
const skip_services = { 113/tcp, } &amp;redef;
129129
const skip_outbound_services = { 21/tcp, addl_web, }
130-
&redef;
130+
&amp;redef;
131131

132132
const skip_scan_sources = {
133133
255.255.255.255, # who knows why we see these, but we do
134-
} &redef;
134+
} &amp;redef;
135135

136-
const skip_scan_nets: set[subnet] = {} &redef;
136+
const skip_scan_nets: set[subnet] = {} &amp;redef;
137137

138138
# List of well known local server/ports to exclude for scanning
139139
# purposes.
140-
const skip_dest_server_ports: set[addr, port] = {} &redef;
140+
const skip_dest_server_ports: set[addr, port] = {} &amp;redef;
141141

142142
# Reverse (SYN-ack) scans seen from these ports are considered
143143
# to reflect possible SYN-flooding backscatter, and not true
144144
# (stealth) scans.
145145
const backscatter_ports = {
146146
80/tcp, 8080/tcp, 53/tcp, 53/udp, 179/tcp, 6666/tcp, 6667/tcp,
147-
} &redef;
147+
} &amp;redef;
148148

149149
const report_backscatter: vector of count = {
150150
20,
151-
} &redef;
151+
} &amp;redef;
152152

153153
global check_scan:
154154
function(c: connection, established: bool, reverse: bool): bool;
@@ -174,14 +174,14 @@ <h2>Full example</h2>
174174
# Indexed by scanner address, yields # distinct peers scanned.
175175
# pre_distinct_peers tracks until addr_scan_trigger hosts first.
176176
global pre_distinct_peers: table[addr] of set[addr]
177-
&read_expire = 15 mins &redef;
177+
&read_expire = 15 mins &amp;redef;
178178

179179
global distinct_peers: table[addr] of set[addr]
180-
&read_expire = 15 mins &expire_func=scan_summary &redef;
180+
&read_expire = 15 mins &expire_func=scan_summary &amp;redef;
181181
global distinct_ports: table[addr] of set[port]
182-
&read_expire = 15 mins &expire_func=port_summary &redef;
182+
&read_expire = 15 mins &expire_func=port_summary &amp;redef;
183183
global distinct_low_ports: table[addr] of set[port]
184-
&read_expire = 15 mins &expire_func=lowport_summary &redef;
184+
&read_expire = 15 mins &expire_func=lowport_summary &amp;redef;
185185

186186
# Indexed by scanner address, yields a table with scanned hosts
187187
# (and ports).
@@ -196,23 +196,23 @@ <h2>Full example</h2>
196196
global accounts_tried: table[addr] of set[string, string]
197197
&read_expire = 1 days;
198198

199-
global ignored_scanners: set[addr] &create_expire = 1 day &redef;
199+
global ignored_scanners: set[addr] &create_expire = 1 day &amp;redef;
200200

201201
# These tables track whether a threshold has been reached.
202202
# More precisely, the counter is the next index of threshold vector.
203203
global shut_down_thresh_reached: table[addr] of bool &default=F;
204204
global rb_idx: table[addr] of count
205-
&default=1 &read_expire = 1 days &redef;
205+
&default=1 &read_expire = 1 days &amp;redef;
206206
global rps_idx: table[addr] of count
207-
&default=1 &read_expire = 1 days &redef;
207+
&default=1 &read_expire = 1 days &amp;redef;
208208
global rops_idx: table[addr] of count
209-
&default=1 &read_expire = 1 days &redef;
209+
&default=1 &read_expire = 1 days &amp;redef;
210210
global rpts_idx: table[addr,addr] of count
211-
&default=1 &read_expire = 1 days &redef;
211+
&default=1 &read_expire = 1 days &amp;redef;
212212
global rat_idx: table[addr] of count
213-
&default=1 &read_expire = 1 days &redef;
213+
&default=1 &read_expire = 1 days &amp;redef;
214214
global rrat_idx: table[addr] of count
215-
&default=1 &read_expire = 1 days &redef;
215+
&default=1 &read_expire = 1 days &amp;redef;
216216
}
217217

218218
global thresh_check: function(v: vector of count, idx: table[addr] of count,
@@ -388,7 +388,7 @@ <h2>Full example</h2>
388388
{ # XXXXX
389389

390390
if ( orig !in distinct_peers )
391-
distinct_peers[orig] = set() &mergeable;
391+
distinct_peers[orig] = set() &amp;mergeable;
392392

393393
if ( resp !in distinct_peers[orig] )
394394
add distinct_peers[orig][resp];
@@ -448,15 +448,15 @@ <h2>Full example</h2>
448448
if ( orig !in distinct_ports || service !in distinct_ports[orig] )
449449
{
450450
if ( orig !in distinct_ports )
451-
distinct_ports[orig] = set() &mergeable;
451+
distinct_ports[orig] = set() &amp;mergeable;
452452

453453
if ( service !in distinct_ports[orig] )
454454
add distinct_ports[orig][service];
455455

456456
if ( |distinct_ports[orig]| >= possible_port_scan_thresh &&
457457
orig !in scan_triples )
458458
{
459-
scan_triples[orig] = table() &mergeable;
459+
scan_triples[orig] = table() &amp;mergeable;
460460
add possible_scan_sources[orig];
461461
}
462462
}
@@ -469,7 +469,7 @@ <h2>Full example</h2>
469469
service !in distinct_low_ports[orig] )
470470
{
471471
if ( orig !in distinct_low_ports )
472-
distinct_low_ports[orig] = set() &mergeable;
472+
distinct_low_ports[orig] = set() &amp;mergeable;
473473

474474
add distinct_low_ports[orig][service];
475475

@@ -494,10 +494,10 @@ <h2>Full example</h2>
494494
if ( orig in possible_scan_sources )
495495
{
496496
if ( orig !in scan_triples )
497-
scan_triples[orig] = table() &mergeable;
497+
scan_triples[orig] = table() &amp;mergeable;
498498

499499
if ( resp !in scan_triples[orig] )
500-
scan_triples[orig][resp] = set() &mergeable;
500+
scan_triples[orig][resp] = set() &amp;mergeable;
501501

502502
if ( service !in scan_triples[orig][resp] )
503503
{

examples/prism-clojure.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ <h2>Full example</h2>
334334
java.util.Calendar))
335335

336336
; Use the class name with a "." at the end to make a new instance
337-
(Date.) ; <a date object>
337+
(Date.) ; &lt;a date object>
338338

339339
; Use . to call methods. Or, use the ".method" shortcut
340-
(. (Date.) getTime) ; <a timestamp>
340+
(. (Date.) getTime) ; &lt;a timestamp>
341341
(.getTime (Date.)) ; exactly the same thing.
342342

343343
; Use / to call static methods
344-
(System/currentTimeMillis) ; <a timestamp> (system is always present)
344+
(System/currentTimeMillis) ; &lt;a timestamp> (system is always present)
345345

346346
; Use doto to make dealing with (mutable) classes more tolerable
347347
(import java.util.Calendar)

examples/prism-concurnas.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ <h2>Full example</h2>
6565
thesum = sum(1, 2, 3, 4, 5)
6666

6767
//partially defined typedef
68-
typedef NameMap<X> = java.util.ArrayList<java.util.HashMap<String, java.util.HashSet<X>>>
68+
typedef NameMap&lt;X> = java.util.ArrayList&lt;java.util.HashMap&lt;String, java.util.HashSet&lt;X>>>
6969

7070
//using typedefs...
71-
nm NameMap<String>= new NameMap<String>()
71+
nm NameMap&lt;String>= new NameMap&lt;String>()
7272

7373
@Annotation
7474
class MyClass(a int, b int, c String){
@@ -79,11 +79,11 @@ <h2>Full example</h2>
7979
mc2 = mc1@ //copy mc1
8080

8181
assert mc1 == mc2//same values!
82-
assert mc1 &<> mc2//different objects!
82+
assert mc1 &&lt;> mc2//different objects!
8383

8484
mc3 = mc1@(a = 100)//copy mc1 but overwrite value of a
8585
assert 'MyClass(100, 14, "hi there")' == mc3.toString()
8686

87-
mc4 = mc1@(<a, b>)//copy mc1 but exclude a and b
87+
mc4 = mc1@(&lt;a, b>)//copy mc1 but exclude a and b
8888
assert 'MyClass(0, 0, "hi there")' == mc3.toString()
8989
</code></pre>

examples/prism-docker.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2>Full example</h2>
1010
# VERSION 0.0.1
1111

1212
FROM ubuntu
13-
MAINTAINER Victor Vieux <victor@docker.com>
13+
MAINTAINER Victor Vieux &lt;victor@docker.com>
1414

1515
LABEL Description="This image is used to start the foobar executable" Vendor="ACME Products" Version="1.0"
1616
RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server

examples/prism-factor.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ <h2>Sequences</h2>
5555

5656
<h2>Regular Expressions</h2>
5757
<pre><code>USE: regexp
58-
R/ abcde?.*+\?\.\*\+\/\\\/idmsr-idmsr/idmsr-idmsr</code>
59-
</pre>
58+
R/ abcde?.*+\?\.\*\+\/\\\/idmsr-idmsr/idmsr-idmsr</code></pre>
6059

6160
<h2>Colon parsing words</h2>
6261
<pre><code>: a ( -- ) ;
@@ -73,9 +72,9 @@ <h2>Special words (builtins, conventions)</h2>
7372

7473
new last-index + - neg
7574

76-
&lt;array&gt; <=> SYNTAX: x $[ xyz ]
75+
&lt;array&gt; &lt;=> SYNTAX: x $[ xyz ]
7776

78-
set-x change-x with-variable ?of if* (gensym) hex. $description reader>> >>setter writer<<
77+
set-x change-x with-variable ?of if* (gensym) hex. $description reader>> >>setter writer&lt;&lt;
7978

8079
string>number >hex base> mutater!
8180
</code></pre>

examples/prism-liquid.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ <h2>Comments</h2>
33

44
<h2>Control Flow</h2>
55

6-
Liquid provides multiple control flow statements.
6+
<p>Liquid provides multiple control flow statements.</p>
77

88
<h3>if</h3>
99
<pre><code>
@@ -18,7 +18,7 @@ <h3>if</h3>
1818

1919
<h3>unless</h3>
2020

21-
The opposite of <code>if</code> – executes a block of code only if a certain condition is not met.
21+
<p>The opposite of <code>if</code> – executes a block of code only if a certain condition is not met.</p>
2222

2323
<pre><code>
2424
{% unless product.title == 'Awesome Shoes' %}
@@ -28,7 +28,7 @@ <h3>unless</h3>
2828

2929
<h3>case</h3>
3030

31-
Creates a switch statement to compare a variable with different values. <code>case</code> initializes the switch statement, and <code>when</code> compares its values.
31+
<p>Creates a switch statement to compare a variable with different values. <code>case</code> initializes the switch statement, and <code>when</code> compares its values.</p>
3232

3333
<pre><code>
3434
{% assign handle = 'cake' %}
@@ -44,10 +44,10 @@ <h3>case</h3>
4444

4545
<h3>for</h3>
4646

47-
Repeatedly executes a block of code.
47+
<p>Repeatedly executes a block of code.</p>
4848

49-
break = Causes the loop to stop iterating when it encounters the break tag.
50-
continue = Causes the loop to skip the current iteration when it encounters the continue tag.
49+
<p>break = Causes the loop to stop iterating when it encounters the break tag. <br>
50+
continue = Causes the loop to skip the current iteration when it encounters the continue tag.</p>
5151

5252
<pre><code>
5353
{% for i in (1..10) %}

examples/prism-markup.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ <h2>Multi-line attribute values</h2>
7272
baz"></code></pre>
7373

7474
<h2>XML tags with non-ASCII characters</h2>
75-
<pre><code>&lt;L&auml;ufer&gt;foo&lt;/L&auml;ufer&gt;
76-
&lt;tag l&auml;ufer="l&auml;ufer"&gt;bar&lt;/tag&gt;
77-
&lt;l&auml;ufer:tag&gt;baz&lt;/l&auml;ufer:tag&gt;</code></pre>
75+
<pre><code>&lt;Läufer&gt;foo&lt;/Läufer&gt;
76+
&lt;tag läufer="läufer"&gt;bar&lt;/tag&gt;
77+
&lt;läufer:tag&gt;baz&lt;/läufer:tag&gt;</code></pre>

0 commit comments

Comments
 (0)