Skip to content

Clam 2102 cl cvd unpack#690

Merged
val-ms merged 4 commits intoCisco-Talos:mainfrom
val-ms:CLAM-2102-cl_cvd_unpack
Oct 13, 2022
Merged

Clam 2102 cl cvd unpack#690
val-ms merged 4 commits intoCisco-Talos:mainfrom
val-ms:CLAM-2102-cl_cvd_unpack

Conversation

@val-ms
Copy link
Contributor

@val-ms val-ms commented Aug 30, 2022

  • libclamav API: Add cl_cvdunpack() function

    Add cl_cvdunpack() function to the public API.

    This new API has an option to disable verification, but otherwise it
    will attempt to verify that the CVD is correctly signed.

  • Freshclam, Sigtool: use public CVD unpack API

    In the interest of using the public API's as much as possible for our
    own applications (dog-fooding the API), this commit swaps sigtool and
    freshclam cli_cvdunpack() calls to cl_cvdunpack().

  • Tests: unit tests for cl_load(), cl_cvdverify(), cl_cvdunpack()

    Some basic testing is needed for the new cl_cvdunpack() API, so this
    commit adds basic unit tests for that.

    For reasons unknown, a number of cl_* API's have stubs for unit tests
    that weren't filled out. The CVD load/verify ones in particular
    required access to a signed CVD. We actually ship a very basic signed
    CVD with the databases now, so I added tests for those while I was at it.


fs = fopen(file, "rb");
if (NULL == fs) {
char err[128];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this cli_strerror call use err[128] when the others do not? This is not a static function or anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our cli_strerror is a wrapper for the poorly standardized strerror system function, not to be confused with cl_strerror, which is the clamav API for converting the clam error enum to a message.

The err[128] approach is something I copypasted from elsewhere in the code. Such as: https://github.com/Cisco-Talos/clamav/blob/main/libclamav/untar.c#L318-L319

@val-ms val-ms force-pushed the CLAM-2102-cl_cvd_unpack branch from e2c7f99 to 3b607d1 Compare October 4, 2022 22:37
@val-ms
Copy link
Contributor Author

val-ms commented Oct 4, 2022

Per our discussion today in status -- I'll create an example program that uses this. I may be able to create an automated test for it as well. It would be good if we tested our example programs, after all.

val-ms added 4 commits October 5, 2022 13:52
Add `cl_cvdunpack()` function to the public API.

This new API has an option to disable verification, but otherwise it
will attempt to verify that the CVD is correctly signed.
In the interest of using the public API's as much as possible for our
own applications (dog-fooding the API), this commit swaps sigtool and
freshclam `cli_cvdunpack()` calls to `cl_cvdunpack()`.
Some basic testing is needed for the new cl_cvdunpack() API, so this
commit adds basic unit tests for that.

For reasons unknown, a number of cl_* API's have stubs for unit tests
that weren't filled out.  The CVD load/verify ones in particular
required access to a signed CVD.  We actually ship a very basic signed
CVD with the databases now, so I added tests for those while I was at it.
@val-ms val-ms force-pushed the CLAM-2102-cl_cvd_unpack branch from 606b54d to e0f5bbd Compare October 5, 2022 20:52
@val-ms
Copy link
Contributor Author

val-ms commented Oct 5, 2022

Rebased and also fixed a PATHSEP issue on Windows with the new unit test.

@val-ms val-ms requested a review from TheRaynMan October 5, 2022 20:53
@val-ms val-ms merged commit a4e6868 into Cisco-Talos:main Oct 13, 2022
@val-ms val-ms deleted the CLAM-2102-cl_cvd_unpack branch October 13, 2022 04:47
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