Skip to content

parseNameValue: fix no quoting support #234

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

Closed
wants to merge 1 commit into from

Conversation

bdolez
Copy link

@bdolez bdolez commented Dec 15, 2016

Function description announce support of quoted variable :

  • name=value
  • name="value"
  • name='value'

... but there is nothing in the code to really support quoted string.
I had small fixes to support it.

My tests :
$ cat > test.txt <<EOF
a=
a=123
a=123
a='123'
a="123"
a=123 b=456
a=123 b="456"
a=123 b="456" c=
a=123 b="456'789" c=
a=123 b="456 789" c=
a=123 b="456 789' c=
a=123 b=456 789 c=
EOF

$ cat > test.rb << EOF
version=2
rule=test-ok:%[
{"type": "name-value-list"}
]%
EOF

$ cat test.txt | ./lognormalizer -r test.rb -T
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "originalmsg": "a=123 b="456 789' c= ", "unparsed-data": "a=123 b="456 789' c= " }
{ "originalmsg": "a=123 b=456 789 c= ", "unparsed-data": "a=123 b=456 789 c= " }

@bdolez
Copy link
Author

bdolez commented Feb 14, 2017

Hi,

Is Someone can take a look on the travis build problem ?

Benoit

@rgerhards
Copy link
Member

please rebase to master, than this should go away

@bdolez bdolez force-pushed the fix/name-value-list branch from 090e2d2 to efce0c2 Compare February 14, 2017 13:38
@bdolez
Copy link
Author

bdolez commented Feb 14, 2017 via email

Function description announce support of quoted variable :
- name=value
- name="value"
- name='value'

... but there is nothing in the code to really support quoted string.
I had small fixes to support it.

My tests :
$ cat > test.txt <<EOF
a=
a=123
a=123
a='123'
a="123"
a=123 b=456
a=123 b="456"
a=123 b="456" c=
a=123 b="456'789" c=
a=123 b="456 789" c=
a=123 b="456 789' c=
a=123 b=456 789 c=
EOF

$ cat > test.rb << EOF
version=2
rule=test-ok:%[
  {"type": "name-value-list"}
  ]%
EOF

$ cat test.txt | ./lognormalizer -r test.rb -T
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "event.tags": [ "test-ok" ] }
{ "originalmsg": "a=123 b=\"456 789' c= ", "unparsed-data": "a=123 b=\"456 789' c= " }
{ "originalmsg": "a=123 b=456 789 c= ", "unparsed-data": "a=123 b=456 789 c= " }
@bdolez bdolez force-pushed the fix/name-value-list branch from efce0c2 to 69392da Compare February 14, 2017 14:16
@bdolez
Copy link
Author

bdolez commented Feb 14, 2017

Ok, I have found the problem : a extraneous whitespace at end of line.

@bdolez
Copy link
Author

bdolez commented Mar 14, 2017

Hi,

Do you think it can be merged ?

Regards

@rgerhards
Copy link
Member

Sorry for the long silence. I would like to do some additional verification that nothing in existing use is broken. I am not sure if the current testbench is sufficient in this regards.

Pre-merging this PR the state is known good and stable. So I think I'll craft a release with existing code today, then work on some tests and see that I merge the new changes within the next two weeks (pls ping me if I don't do!!!). Then, we can craft yet another release.

@solhuebner
Copy link
Contributor

solhuebner commented May 11, 2018

@bdolez is this maybe also something for #297?

@bdolez
Copy link
Author

bdolez commented Jun 12, 2018

Hi
I'm back !
Do you think the merge is possible ?
Regards
Benoit

@bdolez
Copy link
Author

bdolez commented Jun 12, 2018

@solhuebner, yes but your sample log isn't compliant because of spaces in key fields

@gabidrg
Copy link

gabidrg commented Jan 28, 2019

@rgerhards Would it be possible to have this PR merged? Is there more work to be done or any help needed with testing this issue? Thanks!

@KGuillemot
Copy link
Contributor

This PR is very important for us, could you please consider merging it ?

@rgerhards
Copy link
Member

mhhh.. somehow I have lost track. Going through the comments my concern still is that we may break existing implementations. I think the new behavior needs to be guarded by an option which explicitly needs to be opted in.

@mjbnz
Copy link

mjbnz commented Dec 4, 2019

mhhh.. somehow I have lost track. Going through the comments my concern still is that we may break existing implementations. I think the new behavior needs to be guarded by an option which explicitly needs to be opted in.

I've been trying to implement a key-value mmnormalize parser, and this patch would have made it a whole lot simpler!

@rgerhards - Unless existing implementations have unbalanced quotes for values, my reading of this patch is that it won't hurt anything. It correctly parses quoted values only if the quotes exist in the first and last character positions, and are the same type of quotes.

Can you think of a particular implementation that might be broken by this?

@bdolez
Copy link
Author

bdolez commented May 9, 2020

Hi, it has been a long time ...

I rebase this PR on last master, but I do not have access to old repo (inactive company one). Can you change the reference to this one : https://github.com/bdolez/liblognorm/tree/fix/name-value-list

As I understand, you want an option to prevent inconsistant operation ? How would you define this option ? in rulebase file ? Perhaps duplicate code to a new type ?

Regards

Benoit

@lometur
Copy link

lometur commented Jun 19, 2020

Hello,

Any update on the PR? This would be extremely useful!!

We are attempting to parse Fortigate logs which come in a lot of different varieties, but always in key value pairs. The key value pairs come in all sorts of different formats that this PR accomplishes. And I agree with @mjbnz, this just seems to extend support as opposed to alter it. Unless there is a specific use case in mind, then maybe have a new keyword for this or some opt-in keyword in the RB.

I would like to note, I pulled this and tested and verified that this works as intended.

@nosmircss
Copy link

Hello,

Any update on the PR? This would be extremely useful!!

We are attempting to parse Fortigate logs which come in a lot of different varieties, but always in key value pairs. The key value pairs come in all sorts of different formats that this PR accomplishes. And I agree with @mjbnz, this just seems to extend support as opposed to alter it. Unless there is a specific use case in mind, then maybe have a new keyword for this or some opt-in keyword in the RB.

I would like to note, I pulled this and tested and verified that this works as intended.

I would just expect a param option to enable the feature something like %type:name-value-list{"extended":"yes"}%. If we needed to keep it behind an option. not sure its needed but would solve backwards compatibility concerns i think.

@bdolez
Copy link
Author

bdolez commented Jul 6, 2020

Hi,

I have no response from @rgerhards about changing PR reference. Can someone tell him to check this problem ?

Ok for the option (extended:yes). There is more code to change to add an option to type name-value-list ... I'm not sure what to do. Can someone confirm before I begin ?

  • change PARSER_ENTRY_NO_DATA to PARSER_ENTRY
  • add struct data_NameValueList
  • add PARSER_Construct() / PARSER_Destruct functions to store the option
  • adapt PARSER_Parse(NameValue) to use this value

Benoit

@bdolez
Copy link
Author

bdolez commented Jul 6, 2020

Check PR #335.

It seems to be doing the same thing and is already planning options.

@rgerhards
Copy link
Member

Thx for the heads-up. I will check #335 this week (if you don't hear back pls ping me). If it is backwards-compatible, it should be easy to merge.

@rgerhards
Copy link
Member

replaced by #335

@rgerhards rgerhards closed this Jul 7, 2020
julthomas added a commit to zenetys/rpm-rsyslog that referenced this pull request Feb 24, 2021
liblognorm pull request #234
parseNameValue: fix no quoting support
rsyslog/liblognorm#234
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.

8 participants