Commit graph

121 commits

Author SHA1 Message Date
David Prevot 77c8c3dead New upstream version 0.12.2 2024-04-16 14:43:13 +02:00
Dominik Pataky 71fb316a24 Hotfix release v0.12.2 2023-08-20 14:44:44 +02:00
Dominik Pataky 098acc1ae9 Fix tests by removing type hints 2023-08-19 19:22:43 +02:00
Dominik Pataky 942df30bf6 Release v0.12.1 2023-08-19 19:16:02 +02:00
Dominik Pataky a829d428bf Add test for IPFIX padding handling 2023-08-19 14:33:12 +02:00
Dominik Pataky d26914234d Github Workflow: run tests on release branch 2023-08-19 10:58:28 +02:00
Dominik Pataky 97c99f51b3 Fix type comparison from '==' to 'is' 2023-08-19 10:57:01 +02:00
Dominik Pataky bb0ab89615 Squashed commit of branch feature/ipfix-padding:
commit 63abf52ec640a019f8c45c1208f0dfb585641781

    Padding: add offset!=length check to reduce safety check calls

    Adds another check when parsing a set. The check "offset !=
    self.header.length" allows to skip the padding checks if the offset is
    the same as the length, not calling rest_is_padding_zeroes and wasting
    CPU time.

commit 8d1cf9cac12c45c0af70591b646d898ba5c923fc

    Finish IPFIX padding handling

    Tested implementation of IPFIX set padding handling. Uses TK-Khaw's
    proposed no_padding_last_offset calculation, extended as modulo
    calculation to match multiple data set records.

    Tests were conducted by capturing live traffic on a test machine with
    tcpdump, then this capture file was read in by softflowd 1.1.0, with the
    collector.py as the export target. The exported IPFIX (v10) packets were
    then using both no padding and padding, so that tests could be
    validated.

    Closes #34

    Signed-off-by: Dominik Pataky <software+pynetflow@dpataky.eu>

commit 51ce4eaa268e4bda5be89e1d430477d12fc8a72c

    Fix and optimize padding calculation for IPFIX sets.
    Refs #34

commit 9d3c4135385ca9714b7631a0c5af46feb891a9fb
Author: Khaw Teng Kang <tk.khaw@attrelogix.com>
Date:   Tue Jul 5 16:29:12 2022 +0800

    Reverted changes to template_record, data_length is now computed using field length in template.

    Signed-off-by: Khaw Teng Kang <tk.khaw@attrelogix.com>

commit 3c4f8e62892876d4a2d42288843890b97244df55

    IPFIX: handle padding (zero bytes) in sets

    Adds a check to each IPFIX set ID branch, checking if the rest of the
    bytes in this set is padding/zeroes.

    Refs #34

Signed-off-by: Dominik Pataky <software+pynetflow@dpataky.eu>
2023-08-19 09:26:08 +02:00
Dominik Pataky d9859e4dc2 Fix workflow pyenv matrix Python 3.9 and 3.11
There's no 3.9.3, only 3.9.2, which is also the correct Debian version.

3.11.1 is available in pyenv 2.3.8, but 2.3.7 is currently in use by the
  Github action. So 3.11 is used, which uses the latest patch version
2023-01-30 14:33:18 +01:00
Dominik Pataky bbc75ff0ca Update Github test workflow with matrix 2023-01-30 13:56:48 +01:00
Dominik Pataky a410ef7de9 Bump to v0.11.3
Includes fixes for enterprise bit flag and templatefield type check.
2023-01-30 13:30:53 +01:00
Dominik Pataky e36dbb997c Merge branch 'fix/gitoldgrumpy-enterprise-flag'
Resolves #44
2022-12-03 09:34:56 +01:00
Dominik Pataky fe1d3df296 IPFIX: improve bitwise operation on enterprise flag bit 2022-12-03 09:33:24 +01:00
Dominik Pataky 2eb2283873 Fix test runner to ubuntu-20.04 2022-12-03 09:11:34 +01:00
Dominik Pataky 073a212290 IPFIX: extend string field conversion to fallback to str()
Closes #42
2022-12-03 09:11:34 +01:00
Paul Glaß 88f864036b Fixed string conversion from bytes 2022-12-03 09:11:34 +01:00
Dominik Pataky dbfc737e43 Fix test runner to ubuntu-20.04 2022-12-03 08:55:20 +01:00
Dominik Pataky 0afa4b37e8 IPFIX: extend string field conversion to fallback to str()
Closes #42
2022-12-02 17:24:55 +01:00
GitOldGrumpy affef1a972 Fix for clearing enteprise flag bit 2022-09-02 16:01:11 +01:00
Paul Glaß 4e065644fa Fixed string conversion from bytes 2022-09-02 15:23:59 +02:00
Dominik Pataky a94ad57f3e IPFIX: fix usage of field data type (instead of name)
Refs #40
2022-07-02 12:09:29 +02:00
Dominik Pataky ff24da9743 Merge branch 'grafolean-fix/performance-improvements'
Bump version to v0.11.2

Closes #38
Closes #39
2022-07-02 11:53:12 +02:00
Dominik Pataky 7ea24a900c Small addition to grafolean fix (comments, endianness hint) 2022-07-02 11:50:18 +02:00
Anze 92b221aa10 Fix: f-strings might not be supported 2022-05-08 22:01:34 +02:00
Anze 1bffe3a2a3 Performance improvement: rearrange netflow v9 packet parsing (use struct.unpack to extract all of the values at once) 2022-05-08 18:31:06 +02:00
Anze c12507343b Performance improvement: no need to copy a part of the buffer when using struct.unpack_from() 2022-05-08 18:30:11 +02:00
Anze 77da7b16b6 Performance improvement: use struct.unpack instead of manually constructing bytes when possible 2022-05-08 17:54:05 +02:00
Anze b10dc5faef Performance improvement: rearrange code so that instead of converting IP addresses to integers first, we construct them from bytes directly 2022-05-08 17:52:51 +02:00
Anze ef99464fc5 Performance improvement: when checking if a field contains an IP address, compare the keys (which are integers) instead of values (strings) 2022-05-08 17:51:56 +02:00
Dominik Pataky 0e24ad9e64 Merge branch 'medigateio-fix/avoid-infinite-loop-in-V9ExportPacket-constructor' 2022-04-25 20:29:59 +02:00
Dominik Pataky 8b5675913d Small changes to PR #37 preventing infinite loops; bump version
Closes #37
2022-04-25 20:26:04 +02:00
Vitali Sepetnitsky b8e911a40a avoid infinite loop in V9ExportPacket's constructor 2022-02-16 18:39:15 +02:00
Dominik Pataky 87c1bfb892 Release v0.11.0; adds Netflow v9 option headers 2021-11-14 17:53:27 +01:00
cookie a86fe7c731
Merge pull request #35 from bitkeks/add_v9_options
Add v9 options
2021-11-14 17:45:11 +01:00
Dominik Pataky 3b207c3568 Update README 2021-05-02 16:15:38 +02:00
Dominik Pataky ab32ce93b5 Fix counters in options templates
Counters in 4-packs used '/ 4' instead of '// 4', passing a float into
range(), instead of int.

Refs #30
2021-05-02 15:48:20 +02:00
Dominik Pataky 5adde00aec Implement options templates/records handling for V9
Previously, option templates and their data records were not correctly
recognized. This is fixed now. Collectors can now use the
V9ExportPacket.options field to get a list of V9OptionsDataRecord, with
scopes and data fields.

Templates are mixed in the templates dict. They will have both data
templates and option templates. Let's hope exporters do not mix them
(re-use the same IDs for both template types).

During development, the search for the correct template was refactored.
The templates are not pased into the V9DataFlowSet any more. Only the
one single matching template is passed into V9DataFlowSet and
V9OptionsDataFlowset, as should be.

Refs #30
2021-04-05 13:07:32 +02:00
Dominik Pataky e43980fe4a Add stub implementation to store V9 options templates
This is a hacky workaround to handle V9 options templates, without
implementing the full corresponding spec. This solves missing templates
which raise a V9TemplateNotRecognized exception, even though an exporter
might do everything correctly.

Refs #29
Refs #30
2021-04-04 20:42:49 +02:00
Dominik Pataky 3f62e4a163 Merge branch 'j-licht-master' 2021-04-04 10:54:02 +02:00
Dominik Pataky 54e19af8c2 Adapt new V9OptionsTemplateFlowSet stub
Resolves #29
2021-04-04 10:35:08 +02:00
cookie fcddb49a6a Update run_tests.yml
Add pyenv action to support Python 3.5.3
2021-04-04 10:15:40 +02:00
cookie 3981721900 Create run_tests.yml 2021-04-04 10:15:40 +02:00
cookie 699ec116a4
Update run_tests.yml
Add pyenv action to support Python 3.5.3
2021-04-04 07:23:18 +00:00
cookie 536277eac6
Create run_tests.yml 2021-04-04 07:09:25 +00:00
Jonas Licht 5b823052f1 Stub parsing of option templates to can ignore option datasets 2021-03-26 16:46:27 +01:00
Dominik Pataky 06d7c0c5d0 Improve parse_packet documentation and error handling (exception)
The parse_packet function is one of the main functions for usage of this
library in other scripts. It works, but was under-documented until now.
Especially the 'templates' parameter might lead to confusions for new
users who have not yet worked with templates. This commit should make
things clearer.

Refs #28
2020-08-01 12:33:40 +02:00
Dominik Pataky 81d57f3c4c Handle SIGINT and SIGTERM in yielding listener
Signals INT and TERM were not correctly handled in the 'while True' loop
of the yielding listener function. Now, the loop breaks as expected,
terminating the listener thread and the application.
2020-08-01 10:46:35 +02:00
Dominik Pataky 5cdb514ffc Ensure compatibility with Python 3.5.3
This commit replaces multiple occurences of new features which were not
yet implemented with Python 3.5.3, which is the reference backwards
compatibility version for this package. The version is based on the
current Python version in Debian Stretch (oldstable). According to
pkgs.org, all other distros use 3.6+, so 3.5.3 is the lower boundary.

Changes:
  * Add maxsize argument to functools.lru_cache decorator
  * Replace f"" with .format()
  * Replace variable type hints "var: type = val" with "# type:" comments
  * Replace pstats.SortKey enum with strings in performance tests

Additionally, various styling fixes were applied.
The version compatibility was tested with tox, pyenv and Python 3.5.3,
but there is no tox.ini yet which automates this test.

Bump patch version number to 0.10.3
Update author's email address.

Resolves #27
2020-04-24 16:52:25 +02:00
Dominik Pataky 5d1c5b8710 IPFIX: add template withdrawal handling; bump version to v0.10.2
Templates may be withdrawn as per RFC7011. Receiving a template with an
existing template_id and a field_count of 0 now triggers deletion of
this template.
2020-04-06 17:27:26 +02:00
Dominik Pataky 742f5a0a48 IPFIX: enhance (data|field) types and parsing; extend tests
Parts of the IPFIXFieldTypes class were extracted into the new
IPFIXDataTypes class, to increase readability and stability.

The IPFIXDataRecord class and its field parser is now more in tune with
the specifications, handling signed and unsigned, as well as float,
boolean and UTF8 strings etc.

Corresponding tests were extended with softflowd packets (level
"ethernet") and value checks (e.g. MAC address).

Resolves #25
2020-04-06 17:02:52 +02:00