/
check_rulesets.pl
executable file
·178 lines (136 loc) · 2 KB
/
check_rulesets.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/perl -w
#use strict;
use lib qw(/web/lib/perl);
use warnings;
use strict;
use Cache::Memcached;
use APR::URI ();
use APR::Pool ();
use Kynetx::Parser ;
use Kynetx::Memcached;
use Kynetx::Repository;
use Kynetx::Configure;
use Kynetx::Test;
use JSON::XS;
use Data::Dumper;
use Getopt::Std;
use Log::Log4perl qw(get_logger :levels);
Log::Log4perl->easy_init($INFO);
#Log::Log4perl->easy_init($DEBUG);
# configure KNS
Kynetx::Configure::configure();
Kynetx::Memcached->init();
# global options
use vars qw/ %opt /;
my $opt_string = 'dv:';
getopts( "$opt_string", \%opt ); # or &usage();
&usage() if $opt{'h'};
my @rids = qw/
1024dev
11
996337961
996337965
996337973
996337974
996337977
996337992
996337997
996338000
996338001
996338010
996338020
996338035
996338036
996338044
a143x3
a144x1
a144x2
a144x3
a163x1
a166x1
a166x8
a16x44
a16x45
a16x46
a173x1
a18x10
a18x3
a201x2
a218x3
a22x1
a22x4
a22x5
a25x6
a278x7
a314x3
a314x6
a325x4
a32x1
a32x2
a35x13
a37x6
a38x4
a41x10
a41x73
a41x78
a41x87
a50x3
a58x10
a58x12
a58x17
a58x18
a58x19
a58x2
a58x3
a58x4
a58x6
a58x7
a58x9
a60x16
a60x39
a60x52
a60x53
a60x58
a60x69
a60x9
a64x2
a66x1
a82x2
a8x13
a8x19
a8x20
a8x22
a8x31
a9x13
cs_test
cs_test_1
/;
$Data::Dumper::Indent = 1;
foreach my $rid (@rids) {
my $req_info = Kynetx::Test::gen_req_info($rid);
my $tree = Kynetx::Repository::get_rules_from_repository($rid,$req_info);
foreach my $rule (@{$tree->{'rules'}}) {
my $cond = $rule->{'cond'} || {'type' => undef};
if (ref $cond eq 'ARRAY') {
$cond = $cond->[0];
}
if ($cond->{'type'} && $cond->{'type'} eq 'simple') {
# print Dumper $cond;
print "RID: $rid ", Dumper $cond->{'predicate'} unless $cond->{'predicate'} eq 'truth';
}
}
}
1;
sub getkrl {
}
sub usage {
print STDERR <<EOF;
usage:
krl-parser.pl -f filename [-l] [-j]
krl_check.pl parses a ruleset and returns the errors, if any. If there are no errors
krl_check.pl returns nothing.
Options are:
-f : filename to parse
EOF
exit;
}