Skip to content

Sigtool: fix --diff bugs and add support for '_' in cvd name - #1541

Merged
val-ms merged 3 commits into
Cisco-Talos:mainfrom
val-ms:CLAM-2815-sigtool-diff
Jul 24, 2025
Merged

Sigtool: fix --diff bugs and add support for '_' in cvd name#1541
val-ms merged 3 commits into
Cisco-Talos:mainfrom
val-ms:CLAM-2815-sigtool-diff

Conversation

@val-ms

@val-ms val-ms commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Sigtool's --diff CVD_OLD CVD_NEW feature will fail with preclass_tcfa (or any other CVD with an underscore).
Apparently '_' is not a supported character in that code.  

While debugging this, I found some other issues:

  • The call to verify the .script created with the --diff feature fails since adding the .sign digital signature verification code, because I called it wrong. We didn't notice because there are no automated tests for this feature.

  • The --diff feature assumes you're in the same directory as the CVD files and that it is a relative path. 

  • The --diff feature will change directories to a temp directory to verify the diff and then fail to apply the script because it has a relative path and now in a totally different directory

I don't know how (2) or (3) ever worked right.
One require absolute paths, while the other didn't provide a buffer big enough for absolute paths. So confused!

This commit should make it so relative or absolute paths are fine for the CVD's and the cvd name may now include underscores.

CLAM-2815

@val-ms
val-ms requested review from rsundriyal and tj-cisco July 11, 2025 01:53
Comment thread libclamav_rust/src/cdiff.rs
Comment thread libclamav_rust/src/cdiff.rs
Sigtool's `--diff CVD_OLD CVD_NEW` feature will fail with preclass_tcfa
(or any other CVD with an underscore).
Apparently '_' is not a supported character in that code.  

While debugging this, I found some other issues:

* The call to verify the `.script` created with the `--diff` feature
  fails since adding the .sign digital signature verification code,
  because I called it wrong.
  We didn't notice because there are no automated tests for this feature.

* The --diff feature assumes you're in the same directory as the CVD
  files and that it is a relative path. 

* The --diff feature will change directories to a temp directory to
  verify the diff and then fail to apply the script because it has a
  relative path and now in a totally different directory

I don't know how (2) or (3) ever worked right.
One require absolute paths, while the other didn't provide a buffer
big enough for absolute paths. So confused!

This commit should make it so relative or absolute paths are fine for
the CVD's and the cvd name may now include underscores.

CLAM-2815
@val-ms
val-ms force-pushed the CLAM-2815-sigtool-diff branch from 0c9ff79 to b5665f3 Compare July 11, 2025 23:13
The new feature test found a small leak when making cdiffs
@val-ms
val-ms requested review from tj-cisco July 15, 2025 22:39
tj-cisco
tj-cisco previously approved these changes Jul 16, 2025
tj-cisco
tj-cisco previously approved these changes Jul 22, 2025
rsundriyal
rsundriyal previously approved these changes Jul 22, 2025
The new Sigtool feature tests are failing on Windows because CMake is
providing the CVD_CERTS_DIR environment variable with '/' path separators.

My fix is to convert '/' to '\\' when converting paths to UNC paths.
I have also changed CMake to provide CVD_CERTS_DIR with native paths.

I also made a couple of fixes to the Sigtool tests because Windows wants
to make CRLF line endings in Python unless you write byte-strings and
Sigtool will get upset when making a diff if a signature file contains
CRLF line endings.
And putting Windows path separators into 'verify_output()' for the tests
gets confused because it is actually a regex string and the backslashes
mess it up.
@val-ms
val-ms dismissed stale reviews from rsundriyal and tj-cisco via 9208d26 July 22, 2025 20:15
@val-ms
val-ms force-pushed the CLAM-2815-sigtool-diff branch from 0d3cd1f to 9208d26 Compare July 22, 2025 20:15
@val-ms
val-ms merged commit 33a6176 into Cisco-Talos:main Jul 24, 2025
22 of 24 checks passed
@val-ms
val-ms deleted the CLAM-2815-sigtool-diff branch July 24, 2025 16:07
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.

4 participants