Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve VPCFlow and Config items iteration #16325

Conversation

nico-stefani
Copy link
Member

@nico-stefani nico-stefani commented Mar 3, 2023

Related issue
#16138

Description

This PR closes #16138. It improves item iteration for VPCFlow and Config integrations. Now the module only scrolls over existent items in the bucket.

Before the changes we got:

VPC output
# wodles/aws/aws-s3 --bucket wazuh-vpcflow-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type vpcflow
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Table does not exist; create
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/20
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221121T1329Z_4594161841401432054.log
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/22
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221123T1329Z_4594161841401432054.log
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/24
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/25
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221126T1329Z_4594161841401432054.log
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/27
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/28
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/29
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/30
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/12/01
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/12/02
...
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2023/02/28
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2023/03/01
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2023/03/02
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2023/03/03
DEBUG: +++ No logs to process for fl-0754d951c16f517fa flow log ID in bucket: 819751203818/us-east-1
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/20
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221121T1329Z_4594161841401432054.log
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/22
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/23
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/24
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/25
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221126T1329Z_4594161841401432054.log
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/27
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/28
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/29
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/30
...
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2023/02/28
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2023/03/01
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2023/03/02
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2023/03/03
DEBUG: +++ No logs to process for fl-01462ab0a6f5abdcb flow log ID in bucket: 819751203818/us-east-2
DEBUG: +++ DB Maintenance
Config output
# wodles/aws/aws-s3 --bucket wazuh-config-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type config --debug 2
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Table does not exist; create
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/20
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/21
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/21/819751203818_Config_us-east-1_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/22
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/23
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/23/819751203818_Config_us-east-1_ConfigHistory_AWS_20221123T1419Z_9135633071561314633.json
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/24
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/25
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/26
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/26/819751203818_Config_us-east-1_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/27
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/28
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/29
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/30
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
...
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2023/2/27
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2023/2/28
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2023/3/1
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2023/3/2
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2023/3/3
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-1
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/20
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/21
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/21/819751203818_Config_us-east-2_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/22
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/23
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/24
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/25
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/26
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/26/819751203818_Config_us-east-2_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/27
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/28
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/29
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
...
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/2/25
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/2/26
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/2/27
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/2/28
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/3/1
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/3/2
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2023/3/3
DEBUG: +++ No logs to process in bucket: 819751203818/us-east-2
DEBUG: +++ DB Maintenance

And now:

VPCFlow output
# wodles/aws/aws-s3 --bucket wazuh-vpcflow-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type vpcflow
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Table does not exist; create
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/20
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221121T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221123T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221126T1329Z_4594161841401432054.log
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/20
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221121T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221126T1329Z_4594161841401432054.log
DEBUG: +++ DB Maintenance
Config output
# wodles/aws/aws-s3 --bucket wazuh-config-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type config --debug 2
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Table does not exist; create
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/20
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/21/819751203818_Config_us-east-1_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/23/819751203818_Config_us-east-1_ConfigHistory_AWS_20221123T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/26/819751203818_Config_us-east-1_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/20
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/21/819751203818_Config_us-east-2_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/26/819751203818_Config_us-east-2_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ DB Maintenance

Tests

Unit Tests

============================= test session starts ==============================
platform linux -- Python 3.9.9, pytest-5.4.3, py-1.11.0, pluggy-0.13.1
rootdir: /home/nstefani/git/wazuh
plugins: aiohttp-0.3.0, trio-0.7.0, tavern-1.0.0, sugar-0.9.6, html-2.1.1, asyncio-0.15.1, cov-2.12.0, metadata-2.0.4
collected 39 items

wodles/aws/tests/test_aws.py .......................................     [100%]

============================== 39 passed in 0.30s ==============================

Integration Tests

Tier 1

root@ubuntu-jammy:/home/vagrant/qa/tests/integration/test_aws# pytest -k 'config or vpc' --tier 1 --disable-warnings
================================================================================================ test session starts ================================================================================================
platform linux -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/vagrant/qa/tests/integration, configfile: pytest.ini
plugins: metadata-2.0.2, html-3.1.1, testinfra-5.0.0
collected 160 items / 158 deselected / 2 selected

test_only_logs_after.py ..                                                                                                                                                                                    [100%]

============================================================================= 2 passed, 158 deselected, 2 warnings in 71.03s (0:01:11) ==============================================================================

Tier 0

root@ubuntu-jammy:/home/vagrant/qa/tests/integration/test_aws# pytest -k 'config or vpc' --tier 0 --disable-warnings
================================================================================================ test session starts ================================================================================================
platform linux -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/vagrant/qa/tests/integration, configfile: pytest.ini
plugins: metadata-2.0.2, html-3.1.1, testinfra-5.0.0
collected 160 items / 132 deselected / 28 selected

test_basic.py ..                                                                                                                                                                                              [  7%]
test_discard_regex.py ..                                                                                                                                                                                      [ 14%]
test_only_logs_after.py ....                                                                                                                                                                                  [ 28%]
test_path.py ......                                                                                                                                                                                           [ 50%]
test_path_suffix.py ......                                                                                                                                                                                    [ 71%]
test_regions.py ....F.                                                                                                                                                                                        [ 92%]
test_remove_from_bucket.py ..                                                                                                                                                                                 [100%]

===================================================================================================== FAILURES ======================================================================================================
============================================================================================== short test summary info ==============================================================================================
FAILED test_regions.py::test_regions[vpc_inexistent_region] - TimeoutError: The AWS module did not show correct message about non-existent region
======================================================================= 1 failed, 27 passed, 132 deselected, 3 warnings in 681.92s (0:11:21) ========================================================================

The failed test is related to #15763

@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from b456785 to 6f71d17 Compare March 3, 2023 17:51
@nico-stefani nico-stefani linked an issue Mar 3, 2023 that may be closed by this pull request
6 tasks
@nico-stefani nico-stefani self-assigned this Mar 3, 2023
@nico-stefani nico-stefani marked this pull request as ready for review March 3, 2023 19:10
@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from 6f71d17 to 3a59747 Compare March 3, 2023 19:15
@nico-stefani
Copy link
Member Author

nico-stefani commented Mar 3, 2023

Because reparse option isn't contemplated in the integration tests, also I did some manual testing.

  • VPCFlow
root@9ab624e54776:/var/ossec# wodles/aws/aws-s3 --bucket wazuh-vpcflow-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type vpcflow --debug 2 --reparse
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/20
DEBUG: ++ Reparse mode enabled
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221121T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221121T1329Z_4594161841401432054.log
DEBUG: +++ File already marked complete, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/21/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221121T1329Z_4594161841401432054.log
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221123T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221123T1329Z_4594161841401432054.log
DEBUG: +++ File already marked complete, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/23/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221123T1329Z_4594161841401432054.log
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221126T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221126T1329Z_4594161841401432054.log
DEBUG: +++ File already marked complete, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-1/2022/11/26/819751203818_vpcflowlogs_us-east-1_fl-0754d951c16f517fa_20221126T1329Z_4594161841401432054.log
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/20
DEBUG: ++ Reparse mode enabled
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221121T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221121T1329Z_4594161841401432054.log
DEBUG: +++ File already marked complete, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/21/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221121T1329Z_4594161841401432054.log
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221126T1329Z_4594161841401432054.log
DEBUG: ++ Found new log: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221126T1329Z_4594161841401432054.log
DEBUG: +++ File already marked complete, but reparse flag set: AWSLogs/819751203818/vpcflowlogs/us-east-2/2022/11/26/819751203818_vpcflowlogs_us-east-2_fl-01462ab0a6f5abdcb_20221126T1329Z_4594161841401432054.log
DEBUG: +++ DB Maintenance
  • Config
root@9ab624e54776:/var/ossec# wodles/aws/aws-s3 --bucket wazuh-config-integration-tests --aws_profile qa --only_logs_after 2022-NOV-20 --type config --debug 2 --reparse
DEBUG: +++ Debug mode on - Level: 2
DEBUG: Generating default configuration for retries: mode standard - max_attempts 10
DEBUG: +++ Working on 819751203818 - us-east-1
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-1/2022/11/20
DEBUG: ++ Reparse mode enabled
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/Config/us-east-1/2022/11/21/819751203818_Config_us-east-1_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/21/819751203818_Config_us-east-1_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/Config/us-east-1/2022/11/23/819751203818_Config_us-east-1_ConfigHistory_AWS_20221123T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/23/819751203818_Config_us-east-1_ConfigHistory_AWS_20221123T1419Z_9135633071561314633.json
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/Config/us-east-1/2022/11/26/819751203818_Config_us-east-1_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-1/2022/11/26/819751203818_Config_us-east-1_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ DB Maintenance
DEBUG: +++ Working on 819751203818 - us-east-2
DEBUG: +++ Marker: AWSLogs/819751203818/Config/us-east-2/2022/11/20
DEBUG: ++ Reparse mode enabled
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/Config/us-east-2/2022/11/21/819751203818_Config_us-east-2_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/21/819751203818_Config_us-east-2_ConfigHistory_AWS_20221121T1419Z_9135633071561314633.json
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/819751203818/Config/us-east-2/2022/11/26/819751203818_Config_us-east-2_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: ++ Found new log: AWSLogs/819751203818/Config/us-east-2/2022/11/26/819751203818_Config_us-east-2_ConfigHistory_AWS_20221126T1419Z_9135633071561314633.json
DEBUG: +++ DB Maintenance

@fdalmaup fdalmaup self-requested a review March 6, 2023 13:11
Copy link
Member

@fdalmaup fdalmaup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the get_date_list and get_days_since_today methods are not used anymore, they should be removed. Also, the sql_get_date_last_log_processed and sql_find_last_log_processed strings from the AWSBucket and AWSCustomBucket classes respectively.

@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from 867b3b8 to 2ca5e85 Compare March 7, 2023 13:45
Copy link
Member

@fdalmaup fdalmaup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the number of blank lines between methods in the script, it should be PEP 8 compliant

wodles/aws/aws_s3.py Outdated Show resolved Hide resolved
@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from 2aa83cb to 2a0bbe1 Compare March 14, 2023 15:05
fdalmaup
fdalmaup previously approved these changes Mar 14, 2023
Copy link
Member

@fdalmaup fdalmaup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@fdalmaup fdalmaup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nico-stefani nico-stefani changed the base branch from 4.5 to fix/aws-module-improvements March 30, 2023 15:48
@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from aa02469 to ace0d20 Compare April 13, 2023 13:07
@nico-stefani nico-stefani force-pushed the feature/16138-improve-vpc-config-items-iteration branch from ace0d20 to 4e8d28b Compare April 14, 2023 15:29
@davidjiglesias davidjiglesias merged commit cf9f1a6 into fix/aws-module-improvements Apr 14, 2023
1 check passed
@davidjiglesias davidjiglesias deleted the feature/16138-improve-vpc-config-items-iteration branch April 14, 2023 15:39
nico-stefani added a commit that referenced this pull request Apr 18, 2023
* Implement basic changes

* Use methods inherited from AWSBucket

* Improve items iteration AWSVPCFlowBucket

* Use methods inherited from AWSBucket in AWSVPCFlowBucket

* Clean up unused methods and variables

* Fix too many blank lines

* Handle exception when an inexistent region was provided (#16332)

* Handle exception when an inexistent region was provided

* Get regions from constant
nico-stefani added a commit that referenced this pull request Apr 26, 2023
* Implement basic changes

* Use methods inherited from AWSBucket

* Improve items iteration AWSVPCFlowBucket

* Use methods inherited from AWSBucket in AWSVPCFlowBucket

* Clean up unused methods and variables

* Fix too many blank lines

* Handle exception when an inexistent region was provided (#16332)

* Handle exception when an inexistent region was provided

* Get regions from constant
nico-stefani added a commit that referenced this pull request May 9, 2023
* Implement basic changes

* Use methods inherited from AWSBucket

* Improve items iteration AWSVPCFlowBucket

* Use methods inherited from AWSBucket in AWSVPCFlowBucket

* Clean up unused methods and variables

* Fix too many blank lines

* Handle exception when an inexistent region was provided (#16332)

* Handle exception when an inexistent region was provided

* Get regions from constant
davidjiglesias pushed a commit that referenced this pull request May 10, 2023
* Validated the region passed before instantiating the service class (#16463)

* Validated the region passed before instantiating the service class

* Apply suggestions from code review

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Exit with error when receive and invalid region

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Show explicit messages when there aren't logs to process (#16365)

* Improve filter aguments for custom buckets

* Improve check for empty bucket in server access

* Fix custom bucket markers (#16410)

* Fix query paramters for CustomBucket.sql_find_last_key_processed

* Show message when there aren't logs to process in custom buckets

* Apply improvements to ServerAccessBucket.iter_files_in_bucket

* Add missing counter for processed_logs

* Apply suggestions from code review

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Fix method callbacks

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Improve VPCFlow and  Config items iteration (#16325)

* Implement basic changes

* Use methods inherited from AWSBucket

* Improve items iteration AWSVPCFlowBucket

* Use methods inherited from AWSBucket in AWSVPCFlowBucket

* Clean up unused methods and variables

* Fix too many blank lines

* Handle exception when an inexistent region was provided (#16332)

* Handle exception when an inexistent region was provided

* Get regions from constant

* Use AWSBucket.empty_bucket_message_template in AWSLBBucket class

* Add AWS parser validations (#16493)

* Fix bucket and service empty messages

* Fix bucket and service invalid value messages

* Improve regex validation for bucket name

* Improve regex validation for prefix and rename function

* Improved regex validation for region and avoided repeated ones

* Show error and exit for empty log group

* Added function to validate aws_log_groups argument

* Sorted regions after validation

* Use AWSBucket.empty_bucket_message_template native guarduty case

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>
mhamra pushed a commit that referenced this pull request May 24, 2023
* Validated the region passed before instantiating the service class (#16463)

* Validated the region passed before instantiating the service class

* Apply suggestions from code review

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Exit with error when receive and invalid region

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Show explicit messages when there aren't logs to process (#16365)

* Improve filter aguments for custom buckets

* Improve check for empty bucket in server access

* Fix custom bucket markers (#16410)

* Fix query paramters for CustomBucket.sql_find_last_key_processed

* Show message when there aren't logs to process in custom buckets

* Apply improvements to ServerAccessBucket.iter_files_in_bucket

* Add missing counter for processed_logs

* Apply suggestions from code review

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Fix method callbacks

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>

* Improve VPCFlow and  Config items iteration (#16325)

* Implement basic changes

* Use methods inherited from AWSBucket

* Improve items iteration AWSVPCFlowBucket

* Use methods inherited from AWSBucket in AWSVPCFlowBucket

* Clean up unused methods and variables

* Fix too many blank lines

* Handle exception when an inexistent region was provided (#16332)

* Handle exception when an inexistent region was provided

* Get regions from constant

* Use AWSBucket.empty_bucket_message_template in AWSLBBucket class

* Add AWS parser validations (#16493)

* Fix bucket and service empty messages

* Fix bucket and service invalid value messages

* Improve regex validation for bucket name

* Improve regex validation for prefix and rename function

* Improved regex validation for region and avoided repeated ones

* Show error and exit for empty log group

* Added function to validate aws_log_groups argument

* Sorted regions after validation

* Use AWSBucket.empty_bucket_message_template native guarduty case

---------

Co-authored-by: Facundo Dalmau <facundo.dalmau@wazuh.com>
@fdalmaup fdalmaup mentioned this pull request Apr 15, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve VPC and Config items iteration
3 participants