akamai / uls

Unified Log Streamer (ULS)
Apache License 2.0
30 stars 10 forks source link

[BUG] configparser screws up case sensitivity #20

Closed MikeSchiessl closed 2 years ago

MikeSchiessl commented 2 years ago

Describe the bug When running ULS with the section specified in UPPERCASE e.g. ULS_SECTION=DEFAULT but specified the section name within the .edgerc lowercase [default], config parser seems to be able to find the section but the config value (e.g. 'host') cannot be found.

ULS will return something weird like this:

ULS D Section 'DEFAULT' found.
ULS C Required configuration value 'host' not found in section / file. Please see: https://github.com/akamai/uls/blob/main/docs/AKAMAI_API_CREDENTIALS.md - Exiting

To Reproduce

bin/uls.py -i etp -f threat -o raw --loglevel debug --edgerc /opt/akamai-uls/my-edge --section DEFAULT
...
ULS D Section 'DEFAULT' found.
ULS C Required configuration value 'host' not found in section / file. Please see: ..... 
bin/uls.py -i etp -f threat -o raw --loglevel debug --edgerc /opt/akamai-uls/my-edge --section default
...
ULS starts running as expected 
bin/uls.py -i etp -f threat -o raw --loglevel debug --edgerc /opt/akamai-uls/my-edge --section DeFauLt
...
ULS C Section 'DeFauLt' not found. Available sections: '['default']'. - Exiting

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

ULS Version output
please run the following and attach the output here.

Akamai Unified Log Streamer Version information
ULS Version             1.3.0

EAA Version             0.4.5
ETP Version             0.3.6
MFA Version             0.0.6

OS Plattform            Linux-5.4.172-90.336.amzn2.x86_64-x86_64-with-glibc2.31
OS Version              5.4.172-90.336.amzn2.x86_64
Python Version          3.10.1
Docker Status           True
RootPath                /opt/akamai-uls/uls

Additional context
Seems to be a bug inside the configparser module - we will need to dig into this little deeper. As "QuickFix" and for reference, I'll create a FAQ entry and leave this issue as reference.

MikeSchiessl commented 2 years ago

QuickFix:

Please watch out to specify the section exactly the same way (case sensitivity) as you have specified it in your .edgerc file.

bitonio commented 2 years ago

That seems to follow the original specs: https://docs.python.org/3.10/library/configparser.html#supported-ini-file-structure

By default, section names are case sensitive but keys are not.

mschiessl commented 2 years ago

@bitonio - agreed and actually being case sensitive would be awesome, but then this could not happen at all:

.edgerc

[default]
host=aka-....
...

command

bin/uls.py -i etp -f threat -o raw --loglevel debug --edgerc /opt/akamai-uls/my-edge --section DEFAULT
...
ULS D Section 'DEFAULT' found.
ULS C Required configuration value 'host' not found in section / file. Please see: ..... 

So this is the mismatch that broke my nose today ;)

MikeSchiessl commented 2 years ago

added to FAQ in v. 1.3.2 / 1.3.3