Skip to content

Commit

Permalink
Added tests for examples (#2216)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RunDevelopment committed Mar 7, 2020
1 parent 26626de commit 1f7a245
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 163 deletions.
10 changes: 5 additions & 5 deletions examples/prism-abap.html
@@ -1,11 +1,11 @@
<h2>Comments</h2>
<pre><code>
* Line Comments
&quot; End of line comment used as line comment.
value = 1. &quot; End of line comment
" End of line comment used as line comment.
value = 1. " End of line comment

DATA:
&quot;! ABAPDoc comment
"! ABAPDoc comment
value TYPE i.
</code></pre>

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

<h2>Numbers and Operators</h2>
Expand Down Expand Up @@ -62,4 +62,4 @@ <h2>Structures and Classes</h2>
CREATE OBJECT lo_instace.

my_structure-component = lo_instace->my_method( ).
</code></pre>
</code></pre>
96 changes: 48 additions & 48 deletions examples/prism-bro.html
Expand Up @@ -55,100 +55,100 @@ <h2>Full example</h2>

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

const activate_priv_port_check = T &redef;
const activate_landmine_check = F &redef;
const landmine_thresh_trigger = 5 &redef;
const activate_priv_port_check = T &amp;redef;
const activate_landmine_check = F &amp;redef;
const landmine_thresh_trigger = 5 &amp;redef;

const landmine_address: set[addr] &redef;
const landmine_address: set[addr] &amp;redef;

const scan_summary_trigger = 25 &redef;
const port_summary_trigger = 20 &redef;
const lowport_summary_trigger = 10 &redef;
const scan_summary_trigger = 25 &amp;redef;
const port_summary_trigger = 20 &amp;redef;
const lowport_summary_trigger = 10 &amp;redef;

# Raise ShutdownThresh after this many failed attempts
const shut_down_thresh = 100 &redef;
const shut_down_thresh = 100 &amp;redef;

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

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

# Ignore address scanners for further scan detection after
# scanning this many hosts.
# 0 disables.
const ignore_scanners_threshold = 0 &redef;
const ignore_scanners_threshold = 0 &amp;redef;

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

const report_outbound_peer_scan: vector of count = {
100, 1000, 10000,
} &redef;
} &amp;redef;

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

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

# Threshold for scanning privileged ports.
const priv_scan_trigger = 5 &redef;
const priv_scan_trigger = 5 &amp;redef;
const troll_skip_service = {
25/tcp, 21/tcp, 22/tcp, 20/tcp, 80/tcp,
} &redef;
} &amp;redef;

const report_accounts_tried: vector of count = {
20, 100, 1000, 10000, 100000, 1000000,
} &redef;
} &amp;redef;

const report_remote_accounts_tried: vector of count = {
100, 500,
} &redef;
} &amp;redef;

# Report a successful password guessing if the source attempted
# at least this many.
const password_guessing_success_threshhold = 20 &redef;
const password_guessing_success_threshhold = 20 &amp;redef;

const skip_accounts_tried: set[addr] &redef;
const skip_accounts_tried: set[addr] &amp;redef;

const addl_web = {
81/tcp, 443/tcp, 8000/tcp, 8001/tcp, 8080/tcp, }
&redef;
&amp;redef;

const skip_services = { 113/tcp, } &redef;
const skip_services = { 113/tcp, } &amp;redef;
const skip_outbound_services = { 21/tcp, addl_web, }
&redef;
&amp;redef;

const skip_scan_sources = {
255.255.255.255, # who knows why we see these, but we do
} &redef;
} &amp;redef;

const skip_scan_nets: set[subnet] = {} &redef;
const skip_scan_nets: set[subnet] = {} &amp;redef;

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

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

const report_backscatter: vector of count = {
20,
} &redef;
} &amp;redef;

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

global distinct_peers: table[addr] of set[addr]
&read_expire = 15 mins &expire_func=scan_summary &redef;
&read_expire = 15 mins &expire_func=scan_summary &amp;redef;
global distinct_ports: table[addr] of set[port]
&read_expire = 15 mins &expire_func=port_summary &redef;
&read_expire = 15 mins &expire_func=port_summary &amp;redef;
global distinct_low_ports: table[addr] of set[port]
&read_expire = 15 mins &expire_func=lowport_summary &redef;
&read_expire = 15 mins &expire_func=lowport_summary &amp;redef;

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

global ignored_scanners: set[addr] &create_expire = 1 day &redef;
global ignored_scanners: set[addr] &create_expire = 1 day &amp;redef;

# These tables track whether a threshold has been reached.
# More precisely, the counter is the next index of threshold vector.
global shut_down_thresh_reached: table[addr] of bool &default=F;
global rb_idx: table[addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
global rps_idx: table[addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
global rops_idx: table[addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
global rpts_idx: table[addr,addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
global rat_idx: table[addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
global rrat_idx: table[addr] of count
&default=1 &read_expire = 1 days &redef;
&default=1 &read_expire = 1 days &amp;redef;
}

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

if ( orig !in distinct_peers )
distinct_peers[orig] = set() &mergeable;
distinct_peers[orig] = set() &amp;mergeable;

if ( resp !in distinct_peers[orig] )
add distinct_peers[orig][resp];
Expand Down Expand Up @@ -448,15 +448,15 @@ <h2>Full example</h2>
if ( orig !in distinct_ports || service !in distinct_ports[orig] )
{
if ( orig !in distinct_ports )
distinct_ports[orig] = set() &mergeable;
distinct_ports[orig] = set() &amp;mergeable;

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

if ( |distinct_ports[orig]| >= possible_port_scan_thresh &&
orig !in scan_triples )
{
scan_triples[orig] = table() &mergeable;
scan_triples[orig] = table() &amp;mergeable;
add possible_scan_sources[orig];
}
}
Expand All @@ -469,7 +469,7 @@ <h2>Full example</h2>
service !in distinct_low_ports[orig] )
{
if ( orig !in distinct_low_ports )
distinct_low_ports[orig] = set() &mergeable;
distinct_low_ports[orig] = set() &amp;mergeable;

add distinct_low_ports[orig][service];

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

if ( resp !in scan_triples[orig] )
scan_triples[orig][resp] = set() &mergeable;
scan_triples[orig][resp] = set() &amp;mergeable;

if ( service !in scan_triples[orig][resp] )
{
Expand Down
6 changes: 3 additions & 3 deletions examples/prism-clojure.html
Expand Up @@ -334,14 +334,14 @@ <h2>Full example</h2>
java.util.Calendar))

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

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

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

; Use doto to make dealing with (mutable) classes more tolerable
(import java.util.Calendar)
Expand Down
8 changes: 4 additions & 4 deletions examples/prism-concurnas.html
Expand Up @@ -65,10 +65,10 @@ <h2>Full example</h2>
thesum = sum(1, 2, 3, 4, 5)

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

//using typedefs...
nm NameMap<String>= new NameMap<String>()
nm NameMap&lt;String>= new NameMap&lt;String>()

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

assert mc1 == mc2//same values!
assert mc1 &<> mc2//different objects!
assert mc1 &&lt;> mc2//different objects!

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

mc4 = mc1@(<a, b>)//copy mc1 but exclude a and b
mc4 = mc1@(&lt;a, b>)//copy mc1 but exclude a and b
assert 'MyClass(0, 0, "hi there")' == mc3.toString()
</code></pre>
2 changes: 1 addition & 1 deletion examples/prism-docker.html
Expand Up @@ -10,7 +10,7 @@ <h2>Full example</h2>
# VERSION 0.0.1

FROM ubuntu
MAINTAINER Victor Vieux <victor@docker.com>
MAINTAINER Victor Vieux &lt;victor@docker.com>

LABEL Description="This image is used to start the foobar executable" Vendor="ACME Products" Version="1.0"
RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server
Expand Down
7 changes: 3 additions & 4 deletions examples/prism-factor.html
Expand Up @@ -55,8 +55,7 @@ <h2>Sequences</h2>

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

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

new last-index + - neg

&lt;array&gt; <=> SYNTAX: x $[ xyz ]
&lt;array&gt; &lt;=> SYNTAX: x $[ xyz ]

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

string>number >hex base> mutater!
</code></pre>
Expand Down
12 changes: 6 additions & 6 deletions examples/prism-liquid.html
Expand Up @@ -3,7 +3,7 @@ <h2>Comments</h2>

<h2>Control Flow</h2>

Liquid provides multiple control flow statements.
<p>Liquid provides multiple control flow statements.</p>

<h3>if</h3>
<pre><code>
Expand All @@ -18,7 +18,7 @@ <h3>if</h3>

<h3>unless</h3>

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

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

<h3>case</h3>

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>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>

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

<h3>for</h3>

Repeatedly executes a block of code.
<p>Repeatedly executes a block of code.</p>

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

<pre><code>
{% for i in (1..10) %}
Expand Down
6 changes: 3 additions & 3 deletions examples/prism-markup.html
Expand Up @@ -72,6 +72,6 @@ <h2>Multi-line attribute values</h2>
baz"></code></pre>

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

0 comments on commit 1f7a245

Please sign in to comment.