Skip to content

Commit 6ac4ae1

Browse files
author
GomoR
committed
- update: version: 3.05
- new: -version argument to onyphe program - new: certcleaner, fieldcount & filter functions - update: print JSON output with ordered field names - update: fields function accepts a new argument to set a default value for missing fields
1 parent a567cd4 commit 6ac4ae1

File tree

15 files changed

+307
-20
lines changed

15 files changed

+307
-20
lines changed

Build.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ my $builder = Module::Build->new(
1515
'perl' => '5.6.1',
1616
'Metabrik' => '1.40',
1717
'Metabrik::Repository' => '1.40',
18+
'Tie::IxHash' => 0,
1819
},
1920
configure_requires => {
2021
'Module::Build' => 0,

Changes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
Revision history for Perl extension Metabrik::Client::Onyphe.
22

3+
3.05 Wed 1 Mar 07:24:05 CET 2023
4+
- new: -version argument to onyphe program
5+
- new: certcleaner, fieldcount & filter functions
6+
- update: print JSON output with ordered field names
7+
- update: fields function accepts a new argument to set a default value for missing fields
8+
39
3.04 Mon 12 Dec 11:37:01 CET 2022
410
- BUGFIX: correctly handle UTF-8 from all API endpoints (bugfix against Export API, for instance)
11+
- bugfix: stop CLI on SIGINT (Ctrl+C)
512

613
3.03 Wed 7 Dec 07:49:50 CET 2022
714
- new: support for API Basic authorizations

MANIFEST

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ lib/Metabrik/Client/Onyphe/Function/Addcount.pm
66
lib/Metabrik/Client/Onyphe/Function/Allowlist.pm
77
lib/Metabrik/Client/Onyphe/Function/Blacklist.pm
88
lib/Metabrik/Client/Onyphe/Function/Blocklist.pm
9+
lib/Metabrik/Client/Onyphe/Function/Certcleaner.pm
910
lib/Metabrik/Client/Onyphe/Function/Count.pm
1011
lib/Metabrik/Client/Onyphe/Function/Dedup.pm
1112
lib/Metabrik/Client/Onyphe/Function/Exec.pm
1213
lib/Metabrik/Client/Onyphe/Function/Expand.pm
1314
lib/Metabrik/Client/Onyphe/Function/Export.pm
15+
lib/Metabrik/Client/Onyphe/Function/Fieldcount.pm
1416
lib/Metabrik/Client/Onyphe/Function/Fields.pm
17+
lib/Metabrik/Client/Onyphe/Function/Filter.pm
1518
lib/Metabrik/Client/Onyphe/Function/Flat.pm
1619
lib/Metabrik/Client/Onyphe/Function/Httpshot.pm
1720
lib/Metabrik/Client/Onyphe/Function/Lookup.pm

META.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@
2323
"requires" : {
2424
"Metabrik" : "1.40",
2525
"Metabrik::Repository" : "1.40",
26+
"Tie::IxHash" : "0",
2627
"perl" : "v5.6.1"
2728
}
2829
}
2930
},
3031
"provides" : {
3132
"Metabrik::Api::Onyphe" : {
3233
"file" : "lib/Metabrik/Api/Onyphe.pm",
33-
"version" : "3.04"
34+
"version" : "3.05"
3435
},
3536
"Metabrik::Client::Onyphe" : {
3637
"file" : "lib/Metabrik/Client/Onyphe.pm",
37-
"version" : "3.04"
38+
"version" : "3.05"
3839
},
3940
"Metabrik::Client::Onyphe::Function" : {
4041
"file" : "lib/Metabrik/Client/Onyphe/Function.pm",
41-
"version" : "3.04"
42+
"version" : "3.05"
4243
},
4344
"Metabrik::Client::Onyphe::Function::Addcount" : {
4445
"file" : "lib/Metabrik/Client/Onyphe/Function/Addcount.pm"
@@ -52,6 +53,9 @@
5253
"Metabrik::Client::Onyphe::Function::Blocklist" : {
5354
"file" : "lib/Metabrik/Client/Onyphe/Function/Blocklist.pm"
5455
},
56+
"Metabrik::Client::Onyphe::Function::Certcleaner" : {
57+
"file" : "lib/Metabrik/Client/Onyphe/Function/Certcleaner.pm"
58+
},
5559
"Metabrik::Client::Onyphe::Function::Count" : {
5660
"file" : "lib/Metabrik/Client/Onyphe/Function/Count.pm"
5761
},
@@ -67,9 +71,15 @@
6771
"Metabrik::Client::Onyphe::Function::Export" : {
6872
"file" : "lib/Metabrik/Client/Onyphe/Function/Export.pm"
6973
},
74+
"Metabrik::Client::Onyphe::Function::Fieldcount" : {
75+
"file" : "lib/Metabrik/Client/Onyphe/Function/Fieldcount.pm"
76+
},
7077
"Metabrik::Client::Onyphe::Function::Fields" : {
7178
"file" : "lib/Metabrik/Client/Onyphe/Function/Fields.pm"
7279
},
80+
"Metabrik::Client::Onyphe::Function::Filter" : {
81+
"file" : "lib/Metabrik/Client/Onyphe/Function/Filter.pm"
82+
},
7383
"Metabrik::Client::Onyphe::Function::Flat" : {
7484
"file" : "lib/Metabrik/Client/Onyphe/Function/Flat.pm"
7585
},
@@ -119,6 +129,6 @@
119129
"http://opensource.org/licenses/BSD-3-Clause"
120130
]
121131
},
122-
"version" : "3.04",
132+
"version" : "3.05",
123133
"x_serialization_backend" : "JSON::PP version 4.02"
124134
}

META.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ name: Metabrik-Client-Onyphe
1515
provides:
1616
Metabrik::Api::Onyphe:
1717
file: lib/Metabrik/Api/Onyphe.pm
18-
version: '3.04'
18+
version: '3.05'
1919
Metabrik::Client::Onyphe:
2020
file: lib/Metabrik/Client/Onyphe.pm
21-
version: '3.04'
21+
version: '3.05'
2222
Metabrik::Client::Onyphe::Function:
2323
file: lib/Metabrik/Client/Onyphe/Function.pm
24-
version: '3.04'
24+
version: '3.05'
2525
Metabrik::Client::Onyphe::Function::Addcount:
2626
file: lib/Metabrik/Client/Onyphe/Function/Addcount.pm
2727
Metabrik::Client::Onyphe::Function::Allowlist:
@@ -30,6 +30,8 @@ provides:
3030
file: lib/Metabrik/Client/Onyphe/Function/Blacklist.pm
3131
Metabrik::Client::Onyphe::Function::Blocklist:
3232
file: lib/Metabrik/Client/Onyphe/Function/Blocklist.pm
33+
Metabrik::Client::Onyphe::Function::Certcleaner:
34+
file: lib/Metabrik/Client/Onyphe/Function/Certcleaner.pm
3335
Metabrik::Client::Onyphe::Function::Count:
3436
file: lib/Metabrik/Client/Onyphe/Function/Count.pm
3537
Metabrik::Client::Onyphe::Function::Dedup:
@@ -40,8 +42,12 @@ provides:
4042
file: lib/Metabrik/Client/Onyphe/Function/Expand.pm
4143
Metabrik::Client::Onyphe::Function::Export:
4244
file: lib/Metabrik/Client/Onyphe/Function/Export.pm
45+
Metabrik::Client::Onyphe::Function::Fieldcount:
46+
file: lib/Metabrik/Client/Onyphe/Function/Fieldcount.pm
4347
Metabrik::Client::Onyphe::Function::Fields:
4448
file: lib/Metabrik/Client/Onyphe/Function/Fields.pm
49+
Metabrik::Client::Onyphe::Function::Filter:
50+
file: lib/Metabrik/Client/Onyphe/Function/Filter.pm
4551
Metabrik::Client::Onyphe::Function::Flat:
4652
file: lib/Metabrik/Client/Onyphe/Function/Flat.pm
4753
Metabrik::Client::Onyphe::Function::Httpshot:
@@ -73,8 +79,9 @@ provides:
7379
requires:
7480
Metabrik: '1.40'
7581
Metabrik::Repository: '1.40'
82+
Tie::IxHash: '0'
7683
perl: v5.6.1
7784
resources:
7885
license: http://opensource.org/licenses/BSD-3-Clause
79-
version: '3.04'
86+
version: '3.05'
8087
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ WriteMakefile(
1515
PREREQ_PM => {
1616
'Metabrik' => '1.40',
1717
'Metabrik::Repository' => '1.40',
18+
'Tie::IxHash' => 0,
1819
},
1920
EXE_FILES => [ qw(bin/onyphe) ],
2021
);

bin/onyphe

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use strict;
66
use warnings;
77

8+
our $VERSION = '3.05';
9+
810
use Getopt::Long;
911
use Metabrik::Client::Onyphe;
1012
use Metabrik::Client::Onyphe::Log;
@@ -41,6 +43,7 @@ GetOptions(
4143
"apikeepalive=i" => \$lopts{apikeepalive}, # -apikeelalive 1
4244
"apiauth=s" => \$lopts{apiauth}, # -apiauth user:pass
4345
"wait=i" => \$lopts{wait}, # -wait 3
46+
"version" => \$lopts{version}, # -version
4447
# API options:
4548
"category=s" => \$lopts{category}, # -category datascan,synscan
4649
"bulk" => \$lopts{bulk}, # -bulk
@@ -58,6 +61,11 @@ GetOptions(
5861
"alertthreshold=s" => \$lopts{alertthreshold}, # -alertthreshold '>0'
5962
) or usage();
6063

64+
if ($lopts{version}) {
65+
print "ONYPHE version: $VERSION\n";
66+
exit(0);
67+
}
68+
6169
my $arg = pop @ARGV; # Global argument
6270

6371
# Load API key from onyphe rc file
@@ -276,7 +284,7 @@ __END__
276284
277285
=head1 COPYRIGHT AND LICENSE
278286
279-
Copyright (c) 2018-2022, ONYPHE
287+
Copyright (c) 2018-2023, ONYPHE
280288
281289
You may distribute this module under the terms of The BSD 3-Clause License.
282290
See LICENSE file in the source distribution archive.

lib/Metabrik/Api/Onyphe.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package Metabrik::Api::Onyphe;
77
use strict;
88
use warnings;
99

10-
our $VERSION = '3.04';
10+
our $VERSION = '3.05';
1111

1212
use base qw(Metabrik::Client::Rest);
1313

lib/Metabrik/Client/Onyphe.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package Metabrik::Client::Onyphe;
77
use strict;
88
use warnings;
99

10-
our $VERSION = '3.04';
10+
our $VERSION = '3.05';
1111

1212
use base qw(Metabrik);
1313

lib/Metabrik/Client/Onyphe/Function.pm

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package Metabrik::Client::Onyphe::Function;
77
use strict;
88
use warnings;
99

10-
our $VERSION = '3.04';
10+
our $VERSION = '3.05';
1111

1212
use base qw(Metabrik::Client::Onyphe);
1313

@@ -43,6 +43,7 @@ sub brik_properties {
4343
'Data::Dumper' => [ ],
4444
'Text::ParseWords' => [ ],
4545
'Storable' => [ qw(dclone) ],
46+
'Tie::IxHash' => [ ],
4647
},
4748
};
4849
}
@@ -270,13 +271,13 @@ sub unflatten {
270271

271272
my @new = ();
272273
for my $flat (@$flats) {
273-
my $new = {};
274+
my $t = tie(my %new, 'Tie::IxHash');
274275

275276
for my $k (keys %$flat) {
276277
my @toks = split(/\./, $k);
277278
my $value = $flat->{$k};
278279

279-
my $current = $new;
280+
my $current = \%new;
280281
my $last = $#toks;
281282
for my $idx (0..$#toks) {
282283
if ($idx == $last) { # Last token
@@ -291,7 +292,9 @@ sub unflatten {
291292
}
292293
}
293294

294-
push @new, $new;
295+
$t->SortByKey;
296+
297+
push @new, \%new;
295298
}
296299

297300
return \@new;
@@ -381,7 +384,7 @@ sub parse {
381384
my $parsed = {};
382385
my $idx = 0;
383386
for (@a) {
384-
my ($k, $v) = split(/\s*=\s*/, $_);
387+
my ($k, $v) = split(/\s*[=:]\s*/, $_, 2);
385388
if (defined($k) && defined($v)) {
386389
$parsed->{$k} = [ sort { $a cmp $b } split(/\s*,\s*/, $v) ];
387390
}
@@ -413,7 +416,7 @@ In the case your process() method does not write anything to output argument, yo
413416
414417
=head1 COPYRIGHT AND LICENSE
415418
416-
Copyright (c) 2018-2022, Patrice E<lt>GomoRE<gt> Auffret
419+
Copyright (c) 2018-2023, Patrice E<lt>GomoRE<gt> Auffret
417420
418421
You may distribute this module under the terms of The BSD 3-Clause License.
419422
See LICENSE file in the source distribution archive.

0 commit comments

Comments
 (0)