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

Add new rewrite function: set-severity() #3115

Merged
merged 15 commits into from
Feb 24, 2020

Conversation

smortex
Copy link
Contributor

@smortex smortex commented Feb 4, 2020

This is a follow-up to #2602 by @Kokan

I rebased the code on top of master, fixed the build, and renamed the function set-severity as requested in #2602 (comment)

A few more points where under discussion, I will add in-line notes to discuss the topics further.

This PR also fixes cisco-parser $PRIORITY macro parsing.


Usage: set-severtity(TEMPLATE)

Accepted values are numeric strings [0-7] or named values (emerg, emergency, panic, alert, crit, critical, err, error, warning, warn, notice, info, informational, debug).

Examples:

rewrite {
  set-severity("info");
  set-severity("6");
  set-severity("${.json.severity}");
};

@kira-syslogng
Copy link
Contributor

This user does not have permission to start the build. Can one of the admins verify this patch and start the build?
(admin: you have the next options (make sure you checked the code):
"ok to test" to accept this pull request (and further changes) for testing
"test this please" for a one time test run
"add to whitelist" add author of a Pull Request to whitelist (globally, be careful, it means this user can trigger kira for any PR)
do nothing -> CI won't start)

2 similar comments
@kira-syslogng
Copy link
Contributor

This user does not have permission to start the build. Can one of the admins verify this patch and start the build?
(admin: you have the next options (make sure you checked the code):
"ok to test" to accept this pull request (and further changes) for testing
"test this please" for a one time test run
"add to whitelist" add author of a Pull Request to whitelist (globally, be careful, it means this user can trigger kira for any PR)
do nothing -> CI won't start)

@kira-syslogng
Copy link
Contributor

This user does not have permission to start the build. Can one of the admins verify this patch and start the build?
(admin: you have the next options (make sure you checked the code):
"ok to test" to accept this pull request (and further changes) for testing
"test this please" for a one time test run
"add to whitelist" add author of a Pull Request to whitelist (globally, be careful, it means this user can trigger kira for any PR)
do nothing -> CI won't start)

@Kokan
Copy link
Collaborator

Kokan commented Feb 4, 2020

@kira-syslogng ok to test

@kira-syslogng
Copy link
Contributor

Build FAILURE

@kira-syslogng
Copy link
Contributor

Build FAILURE

@Kokan Kokan self-requested a review February 4, 2020 08:24
@smortex smortex force-pushed the rewrite-pri branch 2 times, most recently from 57aa8ea to 7e0efd4 Compare February 4, 2020 09:11
Kokan and others added 6 commits February 3, 2020 23:11
Changes the message level based on its numeric value:
```
 rewrite {
   set-level("${user_macro}");
 };
```
The option is template that expects to be resolved into a numeric representation of a valid level.

Signed-off-by: Kokan <[email protected]>
```
rewrite {
   set-level("critical");
};
```
Now the macro accepts in text format the levels as well.

Signed-off-by: Kokan <[email protected]>
Signed-off-by: Romain Tartière <[email protected]>
Signed-off-by: Romain Tartière <[email protected]>
@kira-syslogng
Copy link
Contributor

Build FAILURE

@smortex
Copy link
Contributor Author

smortex commented Feb 4, 2020

I fixed a bunch of refactoring mistakes yesterday, but kira is still failing. May someone with access to kira logs help by providing some insights about what is going wrong? Thanks!

@Kokan
Copy link
Collaborator

Kokan commented Feb 4, 2020

@smortex Only one test failed, and that failure is actually test case issue. (Cisco parser tests actually asserts on wrong priority value.) I'll push the fix tomorrow, and rerun kira.

Also I plan to do a review, regarding the rename part. I'll probably have some not one backward compat.

@smortex smortex changed the title Rewrite pri New rewrite function: set-severity() Feb 4, 2020
@smortex smortex changed the title New rewrite function: set-severity() Add new rewrite function: set-severity() Feb 4, 2020
@Kokan
Copy link
Collaborator

Kokan commented Feb 5, 2020

@kira-syslogng retest this please; branch=kokan-github-pr-3115

@kira-syslogng
Copy link
Contributor

Build FAILURE

The "emergency" severity has numerical code 0, so this value should be
accepted as a valid severity for proper messages classification.

Signed-off-by: Romain Tartière <[email protected]>
@kira-syslogng
Copy link
Contributor

Build FAILURE

@gaborznagy
Copy link
Collaborator

@kira-syslogng retest this please branch=kokan-github-pr-3115;

gaborznagy
gaborznagy previously approved these changes Feb 21, 2020
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

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

@smortex Thank you for opening, fixing, and finishing this PR! 👍

I've found 2 bugs, only one of them seems important (set-severity() sets emerg when its template evaluates to an empty string).

lib/rewrite/tests/test_set_severity.c Show resolved Hide resolved
lib/rewrite/rewrite-set-severity.c Show resolved Hide resolved
lib/rewrite/rewrite-set-severity.c Show resolved Hide resolved
@kira-syslogng
Copy link
Contributor

Build FAILURE

@MrAnno
Copy link
Collaborator

MrAnno commented Feb 24, 2020

@kira-syslogng retest this please branch=kokan-github-pr-3115;

MrAnno
MrAnno previously approved these changes Feb 24, 2020
@kira-syslogng
Copy link
Contributor

Build SUCCESS

When a template evaulates as an empty string, strtol() returns 0 and
endptr[0] is NULL.  This result in a misclassification of the message
with a severity of 0, aka "emergency".

Fix this by ensuring that there is nothing left to be read AND the end
position is different from the start position.

Signed-off-by: Romain Tartière <[email protected]>
@kira-syslogng
Copy link
Contributor

Build FAILURE

@gaborznagy
Copy link
Collaborator

@kira-syslogng retest this please branch=kokan-github-pr-3115;

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@gaborznagy gaborznagy merged commit dc212b5 into syslog-ng:master Feb 24, 2020
gaborznagy pushed a commit to bazsi/syslog-ng that referenced this pull request Feb 24, 2020
Unfortunately, 20 years ago, syslog-ng choose the term "LEVEL" to refer to
the severity of a message, as that was the language used by syslog(3) manual
page.

Quoting the manpage:

       The priority argument is formed by ORing together a facility
       value and a level value (described below).  If no facility
       value is ORed into priority, then the default value set by
       openlog() is used, or, if there was no preceding openlog()
       call, a default of LOG_USER is employed.

However RFC3164 adopted the term "severity", quoting RFC3164:

       The number contained within these angle brackets is known as
       the Priority value and represents both the Facility and
       Severity as described below.

syslog-ng predates the choice in RFC3164, however I think it is highly time
to adopt the language of the RFC, especially as it is better than the
original.

See discussions in github PR syslog-ng#3115 for further details.

Signed-off-by: Balazs Scheidler <[email protected]>
MrAnno added a commit to MrAnno/syslog-ng that referenced this pull request Feb 24, 2020
Signed-off-by: László Várady <[email protected]>
alltilla pushed a commit to alltilla/syslog-ng that referenced this pull request Feb 25, 2020
Signed-off-by: László Várady <[email protected]>
@smortex smortex deleted the rewrite-pri branch March 2, 2020 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants