matomo-org / matomo-log-analytics

Import any kind of server logs in Matomo for powerful log analytics. Universal log file parsing and reporting.
https://matomo.org/log-analytics/
GNU General Public License v3.0
224 stars 118 forks source link

password with && crashed script #353

Closed hanscees closed 1 year ago

hanscees commented 1 year ago

Hi,

you may close tickets, but that does not solve bugs.

If I use a passwd with && it crashes the script:

python3  ../import_logs1.py --url http://192.168.0.61:8080  --auth-user hanscees@hanscees.com --auth-password wrongpaswd   access.log-20230515.gz
Fatal error: the configuration file/home/config/config.ini.php could not be read. Please check permission. This file must be readable by the user running this script to get the authentication token

python3  ../import_logs1.py --url http://192.168.0.61:8080  --auth-user hanscees@hanscees.com --auth-password wrongpasswd&&5   access.log-20230515.gz
import_logs1.py: error: the following arguments are required: file
hanscees commented 1 year ago

I did a tcpdump and also the characters $$$ are not passed on correctly to the webserver by the script under http.

I got rid of the special characters in my passwords and now the script runs. Now I can enjoy what the script is for!

commnand I used:

python3  ../import_logs1.py --url http://192.168.0.61:8080  --login hanscees@hanscees.com --password seclet$$99   file access.log-20230516

tcpdump:

.J...r.POST / HTTP/1.1
Accept-Encoding: identity
Content-Length: 196
Host: 192.168.0.61:8080
Content-Type: application/x-www-form-urlencoded
User-Agent: Matomo/LogImport
Connection: close

21:14:21.762278 IP 192.168.0.2.50434 > 192.168.0.61.8080: Flags [P.], seq 191:387, ack 1, win 502, options [nop,nop,TS val 183782045 ecr 3702878922], length 196: HTTP
E.....@.@..a.......=.....)#.F.......lb.....

.J...r.module=API&format=json&method=UsersManager.createAppSpecificTokenAuth&filter_limit=-1&userLogin=hanscees%40hanscees.com&passwordConfirmation=seclet782699&description=Log+importer&expireHours=48
michalkleiner commented 1 year ago

Hi @hanscees, when you use characters that have special meaning in the command line itself, the strings containing them need to be quoted. It's not a problem of the importer itself, it's how command line works in general.

michalkleiner commented 1 year ago

Also the word file before the actual file name should not be in the command, as already suggested in the other issue. In the help/usage guide, it means the file itself.

file [file ...] means one or more actual file paths.