Skip to content

iptables: allow parsing of ulogd v2 logs with non-0x prefixed TOS field #4479

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

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Oct 20, 2022

What does this PR do?

The formatting of log lines by ulogd v2 does not prefix the TOS field with a hex 0x syntax[1].

buf_cur += sprintf(buf_cur,"LEN=%u TOS=%02X PREC=0x%02X TTL=%u ID=%u ",
		   ikey_get_u16(&res[KEY_IP_TOTLEN]),
		   ikey_get_u8(&res[KEY_IP_TOS]) & IPTOS_TOS_MASK,
		   ikey_get_u8(&res[KEY_IP_TOS]) & IPTOS_PREC_MASK,
		   ikey_get_u8(&res[KEY_IP_TTL]),
		   ikey_get_u16(&res[KEY_IP_ID]));

So make sure that we allow log lines without this syntax to be parsed.

[1]https://github.com/bootc/ulogd2/blob/f985da47cbfa24b6ec0b6fcbebe1ada09e31ee35/util/printpkt.c#L213-L218

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

The formatting of log lines by ulogd v2 does not prefix the TOS field with a hex
0x syntax[1].

	buf_cur += sprintf(buf_cur,"LEN=%u TOS=%02X PREC=0x%02X TTL=%u ID=%u ",
			   ikey_get_u16(&res[KEY_IP_TOTLEN]),
			   ikey_get_u8(&res[KEY_IP_TOS]) & IPTOS_TOS_MASK,
			   ikey_get_u8(&res[KEY_IP_TOS]) & IPTOS_PREC_MASK,
			   ikey_get_u8(&res[KEY_IP_TTL]),
			   ikey_get_u16(&res[KEY_IP_ID]));

So make sure that we allow log lines without this syntax to be parsed.

[1]https://github.com/bootc/ulogd2/blob/f985da47cbfa24b6ec0b6fcbebe1ada09e31ee35/util/printpkt.c#L213-L218
@elasticmachine
Copy link

elasticmachine commented Oct 20, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-10-20T04:18:42.068+0000

  • Duration: 16 min 5 sec

Test stats 🧪

Test Results
Failed 0
Passed 23
Skipped 1
Total 24

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@efd6 efd6 marked this pull request as ready for review October 20, 2022 04:34
@efd6 efd6 requested a review from a team as a code owner October 20, 2022 04:34
@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@elasticmachine
Copy link

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (1/1) 💚
Files 100.0% (1/1) 💚 2.465
Classes 100.0% (1/1) 💚 2.465
Methods 100.0% (16/16) 💚 9.131
Lines 92.453% (294/318) 👍 2.031
Conditionals 100.0% (0/0) 💚

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Thanks for tracking down the ulog2 source that supports making this change. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Integration:iptables Iptables
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants