Giter VIP home page Giter VIP logo

Comments (3)

nistorj avatar nistorj commented on June 5, 2024 1

Amazing, thank you so much!

from aggregator.

Maikuolan avatar Maikuolan commented on June 5, 2024

Thanks for spotting this. 👍

Investigating now; Will reply again shortly.

from aggregator.

Maikuolan avatar Maikuolan commented on June 5, 2024

I've figured out what's going on, and I've pushed a fix. :-)

Not sure if this is the best place or not, or if better before in the previous function on the intake?

I've opted to throw the fix there, seeing as that's where NumberEntered was previously being populated anyhow. At the moment, I feel it's probably the best place, but we can always refactor later anyway if opinions change, if we find a better way to do this or whatever else, so all good, I think. :-)


Bug introduced by 8a32242..7b56b20:L254-R265:

-       if (!empty($this->Results)) {
-           $this->NumberEntered = count($In);
+       $InCount = count($In);
+       if (isset($this->callbacks['newParse']) && is_callable($this->callbacks['newParse'])) {
+           $this->callbacks['newParse']($InCount);
+       }
+       if (isset($this->CIDRAM['Results'])) {
+           $this->CIDRAM['Results']['In'] = $InCount;

Bug fixed by b584d27..7b56b20:R259-R261:

+       if (!empty($this->Results)) {
+           $this->NumberEntered = $InCount;
+       }

Using test script:

<?php
use \CIDRAM\Aggregator\Aggregator;

$Input = '127.0.0.1 Some arbitrary single IPs from here
127.0.0.2
127.0.0.3
1::
1::1
1:2:3:4::0
1:2:3:4::1
1:2:3:4::2
1:2:3:4::3
2002::1
127.0.0.4
127.0.0.5
257.0.0.999 Some arbitrary INVALID single IPs from here
555.666.777.888
2002:abcd:efgh::1
10.0.0.0/9 Some arbitrary CIDRs from here
10.128.0.0/9
10.192.0.0/10
11.128.0.0/10
11.192.0.0/10
12.0.0.0/9
12.128.0.0/9
13.0.0.0/9
13.128.0.0/9
192.168.0.0/8 Some arbitrary INVALID CIDRs from here
192.168.0.0/9
192.168.0.0/10
192.168.192.0/10
192.169.0.0/10
192.169.64.0/10
1.2.3.4/255.255.255.254 Some arbitrary netmasks from here
2.3.4.5/255.255.255.255
99.99.99.99/255.255.255.255
99.10.10.0/255.255.255.0
99.10.11.0/255.255.255.0
99.8.0.0/255.252.0.0
11.11.11.11/11.11.11.11 Some arbitrary INVALID netmasks from here
255.255.255.254/1.2.3.4
6.7.8.9/255.255.255.254
88.88.88.88/255.255.254.255
Foobar Some garbage data from here
ASDFQWER!@#$
>>HelloWorld<<
SDFSDFSDF
QWEQWEQWE';

$Aggregator = new Aggregator();
$Aggregator->Results = true;
$Output = $Aggregator->aggregate($Input);
echo $Aggregator->NumberEntered . "\n";
echo $Aggregator->NumberRejected . "\n";
echo $Aggregator->NumberAccepted . "\n";
echo $Aggregator->NumberMerged . "\n";
echo $Aggregator->NumberReturned . "\n";

Before fix, produces:

0
-26
26
12
14

After fix, produces:

45
19
26
12
14

Changelog excerpt:

- [2020.01.14; Bug-fix; Maikuolan]: Due to some lines mistakenly removed in an
  earlier commit (2019.12.12), NumberEntered was failing to populate, therefore
  causing erroneous result values to be reported when aggregating; Fixed.
  Thanks to nistorj for reporting this bug.

Marking as fixed and closing.

from aggregator.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.