<commit_before>module Suites.Parser ( tests ) where

import Data.Functor
import Network.IPTables.Ruleset
import Network.IPTables.Parser
import Network.IPTables.IpassmtParser
import qualified Network.IPTables.Generated as Isabelle
import Network.IPTables.Analysis as Analysis
import Test.Tasty
import Test.Tasty.HUnit as HU


expected_result = "*filter\n\
    \:DOS~Pro-t_ect - [0:0]\n\
    \:FORWARD DROP [0:0]\n\
    \:INPUT ACCEPT [1101:228112]\n\
    \:IPSEC_42 - [0:0]\n\
    \:LOGDROP - [0:0]\n\
    \:OUTPUT ACCEPT [70:23175]\n\
    \:Terminal - [0:0]\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p tcp' `ParsedMatch --dpts [22]' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p tcp' `ParsedMatch -m state --state NEW' \
        \`ParsedMatch --dpts [1:65535]' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p udp' `ParsedAction -j RETURN'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~icmp~~' \
        \`ParsedMatch ~~--icmp-type~~' \
        \`ParsedMatch ~~3/4~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' \
        \`ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' \
        \`ParsedMatch ~~\"!\"~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' \
        \`ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' \
        \`ParsedMatch ~~\"has space\"~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedNegatedMatch -p icmp'\n\
    \-A DOS~Pro-t_ect `ParsedNegatedMatch -p tcp' `ParsedNegatedMatch -s 172.16.31.10/16'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -i vocb' `ParsedMatch -p udp' `ParsedMatch --spts [67:68]' `ParsedMatch --dpts [67:68]' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -i vocb' `ParsedMatch -p udp' `ParsedNegatedMatch --spts [67:68]' `ParsedNegatedMatch --dpts [67:68]' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedAction -j LOG' `ParsedMatch ~~--log-prefix~~' `ParsedMatch ~~\"!#*~%&/()=?\"~~' `ParsedMatch ~~--log-level~~' `ParsedMatch ~~6~~'\n\
    \-A FORWARD `ParsedMatch -s 127.0.0.0/8' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -i wlan0' \
        \`ParsedMatch -p tcp' \
        \`ParsedNegatedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedMatch -m state --state NEW' \
        \`ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -p tcp' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedMatch --dpts [80, 443]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -p tcp' \
        \`ParsedMatch -m state --state NEW' \
        \`ParsedMatch --dpts [1:65535]' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state NEW,INVALID' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -i wlan0' \
        \`ParsedMatch -p icmp' \
        \`ParsedMatch -m state --state NEW,ESTABLISHED,RELATED,UNTRACKED' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state NEW,UNTRACKED' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state ESTABLISHED,RELATED' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedNegatedMatch -i eth+' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -s 192.168.127.12/24' `ParsedMatch -p tcp' `ParsedAction -j DOS~Pro-t_ect (call)'\n\
    \-A FORWARD `ParsedNegatedMatch -s 172.16.31.10/16' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -p tcp' `ParsedMatch --spts [80, 443]' `ParsedAction -j DROP'\n\<commit_msg>this is how it SHOULD look like<commit_after>module Suites.Parser ( tests ) where

import Data.Functor
import Network.IPTables.Ruleset
import Network.IPTables.Parser
import Network.IPTables.IpassmtParser
import qualified Network.IPTables.Generated as Isabelle
import Network.IPTables.Analysis as Analysis
import Test.Tasty
import Test.Tasty.HUnit as HU


expected_result = "*filter\n\
    \:DOS~Pro-t_ect - [0:0]\n\
    \:FORWARD DROP [0:0]\n\
    \:INPUT ACCEPT [1101:228112]\n\
    \:IPSEC_42 - [0:0]\n\
    \:LOGDROP - [0:0]\n\
    \:OUTPUT ACCEPT [70:23175]\n\
    \:Terminal - [0:0]\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p tcp' `ParsedMatch --dpts [22]' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p tcp' `ParsedMatch -m state --state NEW' \
        \`ParsedMatch --dpts [1:65535]' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p udp' `ParsedAction -j RETURN'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~icmp~~' \
        \`ParsedMatch ~~--icmp-type~~' \
        \`ParsedMatch ~~3/4~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' \
        \`ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' \
        \`ParsedMatch ~~\"!\"~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' \
        \`ParsedMatch ~~-m~~' \
        \`ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' \
        \`ParsedMatch ~~\"has space\"~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p icmp' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p ipv6-icmp' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~icmp6~~' \
        \`ParsedMatch ~~--icmpv6-type~~' `ParsedMatch ~~133~~' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' `ParsedMatch ~~\"this module only works for ip6tables but -p icmpv6 is fine\"~~' \
        \`ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -p ipv6-icmp' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~icmp6~~' \
        \`ParsedMatch ~~--icmpv6-type~~' `ParsedMatch ~~133~~' \
        \`ParsedMatch ~~-m~~' `ParsedMatch ~~comment~~' \
        \`ParsedMatch ~~--comment~~' `ParsedMatch ~~\"\\\"\"~~' \
        \`ParsedMatch -s 127.0.0.0/8' \
        `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedNegatedMatch -p icmp'\n\
    \-A DOS~Pro-t_ect `ParsedNegatedMatch -p tcp' `ParsedNegatedMatch -s 172.16.31.10/16'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -i vocb' `ParsedMatch -p udp' `ParsedMatch --spts [67:68]' `ParsedMatch --dpts [67:68]' `ParsedAction -j ACCEPT'\n\
    \-A DOS~Pro-t_ect `ParsedMatch -i vocb' `ParsedMatch -p udp' `ParsedNegatedMatch --spts [67:68]' `ParsedNegatedMatch --dpts [67:68]' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedAction -j LOG' `ParsedMatch ~~--log-prefix~~' `ParsedMatch ~~\"!#*~%&/()=?\"~~' `ParsedMatch ~~--log-level~~' `ParsedMatch ~~6~~'\n\
    \-A FORWARD `ParsedMatch -s 127.0.0.0/8' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -i wlan0' \
        \`ParsedMatch -p tcp' \
        \`ParsedNegatedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedMatch -m state --state NEW' \
        \`ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -p tcp' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedMatch --dpts [80, 443]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -p tcp' \
        \`ParsedMatch -m state --state NEW' \
        \`ParsedMatch --dpts [1:65535]' \
        \`ParsedMatch --tcp-flags [TCP_SYN, TCP_ACK, TCP_FIN, TCP_RST] [TCP_SYN]' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state NEW,INVALID' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -i wlan0' \
        \`ParsedMatch -p icmp' \
        \`ParsedMatch -m state --state NEW,ESTABLISHED,RELATED,UNTRACKED' \
        \`ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state NEW,UNTRACKED' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedMatch -m state --state ESTABLISHED,RELATED' `ParsedAction -j ACCEPT'\n\
    \-A FORWARD `ParsedNegatedMatch -i eth+' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -s 192.168.127.12/24' `ParsedMatch -p tcp' `ParsedAction -j DOS~Pro-t_ect (call)'\n\
    \-A FORWARD `ParsedNegatedMatch -s 172.16.31.10/16' `ParsedAction -j DROP'\n\
    \-A FORWARD `ParsedMatch -p tcp' `ParsedMatch --spts [80, 443]' `ParsedAction -j DROP'\n\
{'fraction_non_alphanumeric': 0.18563983786913724, 'fraction_numerical': 0.02929936305732484, 'mean_word_length': 2.461322645290581, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1060876', 'n_tokens_mistral': 3707, 'n_tokens_neox': 3516, 'n_words': 789}