Skip to content

Commit

Permalink
Merge pull request #8468 from inverse-inc/fix/fingerbank-update
Browse files Browse the repository at this point in the history
Only update things with value
  • Loading branch information
fdurand authored Jan 6, 2025
2 parents 2c8ba1a + 8a24df7 commit b994376
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/pf/fingerbank.pm
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,16 @@ Given a MAC address, the endpoint attributes (from the collector) and the Finger
sub record_result {
my ($mac, $attributes, $query_result) = @_;
my $timer = pf::StatsD::Timer->new({level => 7});
my %set = (
'device_type' => $query_result->{'device'}{'name'},
'device_class' => $query_result->{device_class},
'device_version' => $query_result->{'version'},
'device_score' => $query_result->{'score'},
'device_manufacturer' => $query_result->{'manufacturer'}->{'name'} // "",
map { $RECORD_RESULT_ATTR_MAP{$_} => $attributes->{$_} } grep { my $v = $attributes->{$_}; defined $v && length($v) } keys(%RECORD_RESULT_ATTR_MAP),
);
pf::dal::node->update_items(
-set => {
'device_type' => $query_result->{'device'}{'name'},
'device_class' => $query_result->{device_class},
'device_version' => $query_result->{'version'},
'device_score' => $query_result->{'score'},
'device_manufacturer' => $query_result->{'manufacturer'}->{'name'} // "",
map { $RECORD_RESULT_ATTR_MAP{$_} => $attributes->{$_} } keys(%RECORD_RESULT_ATTR_MAP),
},
-set => \%set,
-where => {
mac => $mac,
},
Expand Down

0 comments on commit b994376

Please sign in to comment.