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

PCRE2 #2015

Merged
merged 4 commits into from
Sep 5, 2023
Merged

PCRE2 #2015

merged 4 commits into from
Sep 5, 2023

Conversation

evgenyz
Copy link
Contributor

@evgenyz evgenyz commented Aug 28, 2023

This PR introduces support for PCRE2 library for regular expression handling. It does it in a backward-compatible way, keeping the possibility of linking with now-obsolete PCRE1 library.

No changes in the code are required to switch between libraries, the oscap_pcre_* group of functions would take care of all the differences between compilation and matching API.

By default the build system will try to link with the old PCRE1 library. To force the new PCRE2 one must pass -DWITH_PCRE2=True argument during CMake configuration step.

This PR also moves oscap_get_substrings function from utils into oscap_pcre module, because of the semantics and implicit dependencies of this function.

It also get rid of code that handles PCRE_ERROR_BADPARTIAL match error, as this error is not actual for any usable version of the library.

@evgenyz evgenyz added this to the 1.3.9 milestone Aug 28, 2023
@@ -577,35 +446,15 @@ static int process_pattern_match(const char *path, pcre **regex_out)
}
*/
break;
case PCRE_ERROR_BADPARTIAL:
Copy link
Contributor Author

@evgenyz evgenyz Aug 28, 2023

Choose a reason for hiding this comment

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

We don't need that case anymore. Any more or less recent version of the library does not have limits on partial matches. This is just a dead code block now.

src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Fixed Show fixed Hide fixed
src/common/oscap_pcre.c Outdated Show resolved Hide resolved
src/common/oscap_pcre.c Show resolved Hide resolved
openscap.spec Show resolved Hide resolved
openscap.spec Show resolved Hide resolved
docs/developer/developer.adoc Show resolved Hide resolved
tests/API/probes/oval_fts_list.c Show resolved Hide resolved
@evgenyz evgenyz marked this pull request as ready for review September 4, 2023 22:38
Copy link
Member

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

Overall, the changes look OK to me. Thanks for your patch!

I have reviewed the build and test results and I have seen that we build and test with PCRE2 in GH CI.

Regarding the Developer Guide, I understand your point, but I think that you should mention it there that there is an option to build the project with PCRE2. You can also make the Developer Guide ready for the situation that PCRE will be sunset in future Fedora.

Lastly, please fix the Windows build, we have committed that we will make sure that OpenSCAP is buildable on Windows for the entire lifetime of version 1.3.x (https://github.com/OpenSCAP/openscap/blob/maint-1.3/docs/windows.md). I think it'd be possible to replace the bzero() by calloc().

Recognize PCRE2 library in the build system.

Add wrapper for pcre_/pcre2_ functions.
Use oscap_pcre_* wrapper in the code.
Move the oscap_get_substring into the oscap_pcre.c module
and rename it into oscap_pcre_get_substring.

The function imposes implicit dependencies on PCRE/PCRE2 symbols
even for utils.c users that won't use PCRE at all (SCE library).
Make use of the PCRE2 library (in Fedora CI + PackIt and Ubuntu IC).
@evgenyz
Copy link
Contributor Author

evgenyz commented Sep 5, 2023

Regarding the Developer Guide, I understand your point, but I think that you should mention it there that there is an option to build the project with PCRE2. You can also make the Developer Guide ready for the situation that PCRE will be sunset in future Fedora.

Done. Also: #2022.

Lastly, please fix the Windows build, we have committed that we will make sure that OpenSCAP is buildable on Windows for the entire lifetime of version 1.3.x (https://github.com/OpenSCAP/openscap/blob/maint-1.3/docs/windows.md). I think it'd be possible to replace the bzero() by calloc().

Done, thanks for reminding.

@jan-cerny jan-cerny merged commit 4704813 into OpenSCAP:maint-1.3 Sep 5, 2023
19 checks passed
@evgenyz evgenyz deleted the pcre2 branch September 5, 2023 11:43
@evgenyz evgenyz mentioned this pull request Sep 5, 2023
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.

2 participants