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

Remove AclMatchedName from ACL::ParseAclLine() #239

Conversation

eduard-bagdasaryan
Copy link

@eduard-bagdasaryan eduard-bagdasaryan commented Nov 21, 2023

The “ugly” use of AclMatchedName global supplied ACL name to error
reporting during ACL (re)configuration. To solve this problem, we could
pass ACL::name to the reporting code. This, however, is difficult
because the reporting code is located in stateless functions, such as
aclDomainCompare() or acl_ip_data::NetworkCompare() without access to
ACL::name.

Another approach (implemented in this PR) is to reuse CodeContext
concept for ACLs: the name of the ACL being parsed is appended to those
debugs() automatically by CodeContext infrastructure.

The “ugly” use of AclMatchedName global supplied ACL name to error
reporting during ACL (re)configuration. To solve this problem, we could
pass ACL::name to the reporting code. This, however, is difficult
because reporting code is located in stateless functions, such as
aclDomainCompare() or acl_ip_data::NetworkCompare() without access to
ACL::name.

Another approach (implemented in this PR) is to reuse CodeContext
concept for ACLs: the name of the ACL being parsed is appended to those
debugs() automatically by CodeContext infrastructure.
so that each parser (e.g., ACL::ParseAclLine()) could configure its
context accordingly.

Also configure ACL code context as early as possible.
Copy link
Author

@eduard-bagdasaryan eduard-bagdasaryan left a comment

Choose a reason for hiding this comment

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

Done (up to a0bda44).

Copy link

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Excellent progress, thank you!

Copy link
Author

@eduard-bagdasaryan eduard-bagdasaryan left a comment

Choose a reason for hiding this comment

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

Done (up to 504788).

@@ -0,0 +1 @@
expect-message WARNING:.*is.a.subrange.of.*Because.of.this.*isignored
Copy link
Author

Choose a reason for hiding this comment

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

a simple way to catch mismatching instruction files

If we are going to keep to the "bad-" for negative tests, we can require that each "bad-" had an instruction file - that should be easy to adjust, I think. If positive tests (i.e., all other ones) do not need instruction files, then we can also prohibit such files for them.

@@ -99,6 +94,12 @@ then
exit 0;
fi

if ! grep -q "# *define *\b$defineName\b $defineValue" $autoconfHeader
then
echo "$here: WARNING: Skipping $configFile test because $defineName is not $defineValue in $autoconfHeader";

Choose a reason for hiding this comment

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

Please note that we want to keep the second parameter (i.e. $p2 and $defineValue) optional (rather than require it in all use cases).

eduard-bagdasaryan and others added 14 commits January 16, 2024 17:17
There are similar official tests added at 0898d0.
After merge new tests became broken because some of them contained
duplicated lines in '*.instructions' files. This happened because the
uniqueness of these lines was previously ensured by adding a unique ACL
name to each of them. This is not possible now because we removed
AclMatchedName from parsing code).

I had to adjust ACLs to make debugging unique without ACL name addition.
It was especially wrong to make that responsibility a secret.

TODO: Do not hide c-string-to-SBuf conversion.
The function does not parse contexts. It calls some parser inside the
given (parsing) context.
... addressing an earlier branch commit TODO.
... except where a single acl directive emits more than one warning.
@rousskov
Copy link

This PR became official PR 1642.

@rousskov rousskov closed this Jan 17, 2024
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.

2 participants