Skip to content

Commit 138cf9d

Browse files
author
GomoR
committed
4.14 Thu 28 Mar 11:24:29 CET 2024
- New: Onyphe::Api: Ondemand Scope Hostname API - New: Onyphe::Api: Ondemand Scope Hostname Bulk API - New proc added: orlookup - Bugfix: on printing errors from API calls (now handling text & JSON responses) - Bugfix: lookup/allowlist/blocklist procs to be case insensitive - Update: OPP::Proc: set() to accept writing fields as ARRAYs - Update: addfield proc to support adding data to an existing field - Update: OPP: pipeone() needs output flush at each round
1 parent 79d871c commit 138cf9d

File tree

13 files changed

+149
-62
lines changed

13 files changed

+149
-62
lines changed

Changes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
Revision history for Perl extension Onyphe.
22

3+
4.14 Thu 28 Mar 11:24:29 CET 2024
4+
- New: Onyphe::Api: Ondemand Scope Hostname API
5+
- New: Onyphe::Api: Ondemand Scope Hostname Bulk API
6+
- New proc added: orlookup
7+
- Bugfix: on printing errors from API calls (now handling text & JSON responses)
8+
- Bugfix: lookup/allowlist/blocklist procs to be case insensitive
9+
- Update: OPP::Proc: set() to accept writing fields as ARRAYs
10+
- Update: addfield proc to support adding data to an existing field
11+
- Update: OPP: pipeone() needs output flush at each round
12+
313
4.13 Sun 11 Feb 17:46:49 CET 2024
414
- New: pipeone() function in OPP
515
- New proc added: exists

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ lib/OPP/Proc/Flatten.pm
3737
lib/OPP/Proc/Lookup.pm
3838
lib/OPP/Proc/Merge.pm
3939
lib/OPP/Proc/Noop.pm
40+
lib/OPP/Proc/Orlookup.pm
4041
lib/OPP/Proc/Output.pm
4142
lib/OPP/Proc/Pivots.pm
4243
lib/OPP/Proc.pm

META.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
"file" : "lib/OPP/Proc/Noop.pm",
129129
"version" : "1.00"
130130
},
131+
"OPP::Proc::Orlookup" : {
132+
"file" : "lib/OPP/Proc/Orlookup.pm",
133+
"version" : "1.00"
134+
},
131135
"OPP::Proc::Output" : {
132136
"file" : "lib/OPP/Proc/Output.pm",
133137
"version" : "1.00"
@@ -170,11 +174,11 @@
170174
},
171175
"Onyphe" : {
172176
"file" : "lib/Onyphe.pm",
173-
"version" : "4.13"
177+
"version" : "4.14"
174178
},
175179
"Onyphe::Api" : {
176180
"file" : "lib/Onyphe/Api.pm",
177-
"version" : "4.13"
181+
"version" : "4.14"
178182
}
179183
},
180184
"release_status" : "stable",
@@ -183,6 +187,6 @@
183187
"http://opensource.org/licenses/BSD-3-Clause"
184188
]
185189
},
186-
"version" : "4.13",
190+
"version" : "4.14",
187191
"x_serialization_backend" : "JSON::PP version 4.06"
188192
}

META.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ provides:
7979
OPP::Proc::Noop:
8080
file: lib/OPP/Proc/Noop.pm
8181
version: '1.00'
82+
OPP::Proc::Orlookup:
83+
file: lib/OPP/Proc/Orlookup.pm
84+
version: '1.00'
8285
OPP::Proc::Output:
8386
file: lib/OPP/Proc/Output.pm
8487
version: '1.00'
@@ -111,10 +114,10 @@ provides:
111114
version: '1.00'
112115
Onyphe:
113116
file: lib/Onyphe.pm
114-
version: '4.13'
117+
version: '4.14'
115118
Onyphe::Api:
116119
file: lib/Onyphe/Api.pm
117-
version: '4.13'
120+
version: '4.14'
118121
requires:
119122
Carp: '0'
120123
Config::INI::Tiny: '0'
@@ -133,5 +136,5 @@ requires:
133136
Tie::IxHash: '0'
134137
resources:
135138
license: http://opensource.org/licenses/BSD-3-Clause
136-
version: '4.13'
139+
version: '4.14'
137140
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

bin/onyphe

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env perl
22
#
3-
# $Id: onyphe,v 8e53a91709f9 2024/02/11 16:47:12 gomor $
3+
# $Id: onyphe,v 45178b147667 2024/03/27 14:29:16 gomor $
44
#
55
use strict;
66
use warnings;
@@ -70,6 +70,8 @@ GetOptions(
7070
"ondemand-scope-ip-bulk=s" => \$lopts{'ondemand-scope-ip-bulk'}, # -ondemand-scope-ip-bulk INPUT.txt
7171
"ondemand-scope-domain=s" => \$lopts{'ondemand-scope-domain'}, # -ondemand-scope-domain DOMAIN
7272
"ondemand-scope-domain-bulk=s" => \$lopts{'ondemand-scope-domain-bulk'}, # -ondemand-scope-domain-bulk INPUT.txt
73+
"ondemand-scope-hostname=s" => \$lopts{'ondemand-scope-hostname'}, # -ondemand-scope-hostname HOSTNAME
74+
"ondemand-scope-hostname-bulk=s" => \$lopts{'ondemand-scope-hostname-bulk'}, # -ondemand-scope-hostname-bulk INPUT.txt
7375
"ondemand-scope-result=s" => \$lopts{'ondemand-scope-result'}, # -ondemand-scope-result ID
7476
"ondemand-resolver-domain=s" => \$lopts{'ondemand-resolver-domain'}, # -ondemand-resolver-domain DOMAIN
7577
"ondemand-resolver-result=s" => \$lopts{'ondemand-resolver-result'}, # -ondemand-resolver-result ID
@@ -299,6 +301,28 @@ elsif (defined($lopts{'ondemand-scope-domain-bulk'})) {
299301
$param->{import} = $lopts{import} if defined $lopts{import};
300302
$oa->ondemand_scope_domain_bulk($v, $param, $opp_perl_cb, $opl);
301303
}
304+
elsif (defined($lopts{'ondemand-scope-hostname'})) {
305+
my $v = $lopts{'ondemand-scope-hostname'};
306+
my $param;
307+
$param->{maxscantime} = $lopts{maxscantime} if defined $lopts{maxscantime};
308+
$param->{urlscan} = $lopts{urlscan} if defined $lopts{urlscan};
309+
$param->{vulnscan} = $lopts{vulnscan} if defined $lopts{vulnscan};
310+
$param->{riskscan} = $lopts{riskscan} if defined $lopts{riskscan};
311+
$param->{asm} = $lopts{asm} if defined $lopts{asm};
312+
$param->{import} = $lopts{import} if defined $lopts{import};
313+
$oa->ondemand_scope_hostname($v, $param, $opp_perl_cb, $opl);
314+
}
315+
elsif (defined($lopts{'ondemand-scope-hostname-bulk'})) {
316+
my $v = $lopts{'ondemand-scope-hostname-bulk'};
317+
my $param;
318+
$param->{maxscantime} = $lopts{maxscantime} if defined $lopts{maxscantime};
319+
$param->{urlscan} = $lopts{urlscan} if defined $lopts{urlscan};
320+
$param->{vulnscan} = $lopts{vulnscan} if defined $lopts{vulnscan};
321+
$param->{riskscan} = $lopts{riskscan} if defined $lopts{riskscan};
322+
$param->{asm} = $lopts{asm} if defined $lopts{asm};
323+
$param->{import} = $lopts{import} if defined $lopts{import};
324+
$oa->ondemand_scope_hostname_bulk($v, $param, $opp_perl_cb, $opl);
325+
}
302326
elsif (defined($lopts{'ondemand-scope-result'})) {
303327
my $v = $lopts{'ondemand-scope-result'};
304328
my $param;
@@ -400,6 +424,8 @@ APIs:
400424
-ondemand-scope-ip-bulk 'input.txt' use Ondemand Scope Ip Bulk API to launch a scan against a given list of IPs from an input file
401425
-ondemand-scope-domain 'DOMAIN' use Ondemand Scope Domain API to launch a scan against given domain
402426
-ondemand-scope-domain-bulk 'input.txt' use Ondemand Scope Domain Bulk API to launch a scan against a given list of domain from an input file
427+
-ondemand-scope-hostname 'HOSTNAME' use Ondemand Scope Hostname API to launch a scan against given hostname
428+
-ondemand-scope-hostname-bulk 'input.txt' use Ondemand Scope Hostname Bulk API to launch a scan against a given list of hostname from an input file
403429
-ondemand-scope-result \$scan_id use Ondemand Scope Result API with Scan ID
404430
-ondemand-resolver-domain 'DOMAIN' use Ondemand Resolver Domain API to launch a DNS enumeration and resolution against given domain
405431
-ondemand-resolver-result \$scan_id use Ondemand Resolver Result API with Scan ID

lib/OPP.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: OPP.pm,v 06a2fc71a0d8 2023/11/10 11:06:24 gomor $
2+
# $Id: OPP.pm,v dd33ef647b17 2024/03/14 13:56:07 gomor $
33
#
44
package OPP;
55
use strict;
@@ -250,8 +250,8 @@ sub pipeone {
250250

251251
if (defined($self->output->docs)) {
252252
my $docs = $self->unflatten($self->output->docs);
253+
$self->output->flush;
253254
return $docs;
254-
#$self->output->flush; # Don't flush output when processed, let user's do it
255255
}
256256

257257
return;

lib/OPP/Proc.pm

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: Proc.pm,v 58d7ce835577 2023/03/25 10:34:10 gomor $
2+
# $Id: Proc.pm,v 683f32a81df6 2024/03/07 08:31:39 gomor $
33
#
44
package OPP::Proc;
55
use strict;
@@ -166,7 +166,7 @@ sub delete {
166166
#
167167
sub set {
168168
my $self = shift;
169-
my ($flat, $field, $value) = @_;
169+
my ($flat, $field, $value, $asarray) = @_;
170170

171171
croak("set: need flat argument") unless defined($flat);
172172
croak("set: need field argument") unless defined($field);
@@ -176,14 +176,25 @@ sub set {
176176
if (my $split = $self->is_nested($field)) {
177177
my $root = $split->[0];
178178
my $leaf = $split->[1];
179-
# Delete at the leaf level:
179+
# Set at the leaf level:
180180
if (defined($leaf)) {
181181
$flat->{$root} = [ { $leaf => $value } ];
182182
}
183183
}
184184
# Handle standard fields:
185185
else {
186-
$flat->{$field} = $value;
186+
if ($asarray) {
187+
$flat->{$field} ||= [];
188+
$flat->{$field} = ref($flat->{$field}) eq 'ARRAY'
189+
? $flat->{$field} : [ $flat->{$field} ];
190+
push @{$flat->{$field}}, $value;
191+
#print STDERR Data::Dumper::Dumper($flat->{$field})."\n";
192+
my %h = map { $_ => 1 } @{$flat->{$field}};
193+
$flat->{$field} = [ sort { $a cmp $b } keys %h ]; # Make uniq
194+
}
195+
else {
196+
$flat->{$field} = $value;
197+
}
187198
}
188199

189200
return $flat;
@@ -257,19 +268,15 @@ __END__
257268
258269
OPP::Proc - base class for OPP's processors
259270
260-
=head1 SYNOPSIS
261-
262-
=head1 DESCRIPTION
263-
264271
=head1 COPYRIGHT AND LICENSE
265272
266-
Copyright (c) 2023, Patrice E<lt>GomoRE<gt> Auffret
273+
Copyright (c) 2024, ONYPHE SAS
267274
268275
You may distribute this module under the terms of The BSD 3-Clause License.
269276
See LICENSE file in the source distribution archive.
270277
271278
=head1 AUTHOR
272279
273-
Patrice E<lt>GomoRE<gt> Auffret
280+
ONYPHE E<lt>contact_at_onyphe.ioE<gt>
274281
275282
=cut

lib/OPP/Proc/Addfield.pm

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: Addfield.pm,v 3c62c12dda1e 2023/09/10 07:48:40 gomor $
2+
# $Id: Addfield.pm,v 683f32a81df6 2024/03/07 08:31:39 gomor $
33
#
44
package OPP::Proc::Addfield;
55
use strict;
@@ -28,7 +28,16 @@ sub process {
2828

2929
for my $k (keys %fields) {
3030
next unless defined($fields{$k});
31-
$input->{$k} = $fields{$k};
31+
my $values = $self->value($input, $k);
32+
if (defined($input->{$k})) {
33+
my $current = $input->{$k};
34+
$current = ref($current) eq 'ARRAY' ? $current : [ $current ];
35+
my %values = map { $_ => 1 } ( @$current, $fields{$k} );
36+
$input->{$k} = [ sort { $a cmp $b } keys %values ];
37+
}
38+
else {
39+
$input->{$k} = $fields{$k};
40+
}
3241
}
3342

3443
$self->output->add($input);
@@ -42,21 +51,17 @@ __END__
4251
4352
=head1 NAME
4453
45-
OPP::Proc::Addfield - addfiel processor
46-
47-
=head1 SYNOPSIS
48-
49-
=head1 DESCRIPTION
54+
OPP::Proc::Addfield - addfield processor
5055
5156
=head1 COPYRIGHT AND LICENSE
5257
53-
Copyright (c) 2023, Patrice E<lt>GomoRE<gt> Auffret
58+
Copyright (c) 2024, ONYPHE SAS
5459
5560
You may distribute this module under the terms of The BSD 3-Clause License.
5661
See LICENSE file in the source distribution archive.
5762
5863
=head1 AUTHOR
5964
60-
Patrice E<lt>GomoRE<gt> Auffret
65+
ONYPHE E<lt>contact_at_onyphe.ioE<gt>
6166
6267
=cut

lib/OPP/Proc/Allowlist.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: Allowlist.pm,v dd1d616d0c52 2024/01/24 15:23:37 gomor $
2+
# $Id: Allowlist.pm,v 1a6ad59d015b 2024/02/16 09:27:25 gomor $
33
#
44
package OPP::Proc::Allowlist;
55
use strict;
@@ -43,7 +43,7 @@ sub _load {
4343
my $h = {};
4444
my $idx = 0;
4545
for my $this (@$header) {
46-
$h->{$this} = $line->[$idx++];
46+
$h->{$this} = lc($line->[$idx++]);
4747
}
4848
push @$csv, $h if keys %$h;
4949
}
@@ -105,7 +105,7 @@ sub process {
105105
else { # Exact field match mode
106106
for my $v (@$values) {
107107
#print STDERR "*** match field [$field] vs v[$v]\n";
108-
if (defined($line->{$field}) && $v eq $line->{$field}) {
108+
if (defined($line->{$field}) && lc($v) eq $line->{$field}) {
109109
$this_skip++;
110110
last;
111111
}
@@ -138,7 +138,7 @@ OPP::Proc::Allowlist - allowlist processor
138138
139139
=head1 COPYRIGHT AND LICENSE
140140
141-
Copyright (c) 2023, Patrice E<lt>GomoRE<gt> Auffret
141+
Copyright (c) 2024, Patrice E<lt>GomoRE<gt> Auffret
142142
143143
You may distribute this module under the terms of The BSD 3-Clause License.
144144
See LICENSE file in the source distribution archive.

lib/OPP/Proc/Blocklist.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: Blocklist.pm,v dd1d616d0c52 2024/01/24 15:23:37 gomor $
2+
# $Id: Blocklist.pm,v 1a6ad59d015b 2024/02/16 09:27:25 gomor $
33
#
44
package OPP::Proc::Blocklist;
55
use strict;
@@ -43,7 +43,7 @@ sub _load {
4343
my $h = {};
4444
my $idx = 0;
4545
for my $this (@$header) {
46-
$h->{$this} = $line->[$idx++];
46+
$h->{$this} = lc($line->[$idx++]);
4747
}
4848
push @$csv, $h if keys %$h;
4949
}
@@ -106,7 +106,7 @@ sub process {
106106
else { # Exact field match mode
107107
for my $v (@$values) {
108108
#print STDERR "*** match field [$field] vs v[$v]\n";
109-
if (defined($line->{$field}) && $v eq $line->{$field}) {
109+
if (defined($line->{$field}) && lc($v) eq $line->{$field}) {
110110
$this_skip++;
111111
last;
112112
}
@@ -139,7 +139,7 @@ OPP::Proc::Blocklist - blocklist processor
139139
140140
=head1 COPYRIGHT AND LICENSE
141141
142-
Copyright (c) 2023, Patrice E<lt>GomoRE<gt> Auffret
142+
Copyright (c) 2024, Patrice E<lt>GomoRE<gt> Auffret
143143
144144
You may distribute this module under the terms of The BSD 3-Clause License.
145145
See LICENSE file in the source distribution archive.

0 commit comments

Comments
 (0)