-
Notifications
You must be signed in to change notification settings - Fork 857
Add support for scanning Zstandard (zstd) compressed files #1700
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
Open
burakemir
wants to merge
5
commits into
Cisco-Talos:main
Choose a base branch
from
burakemir:zstd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1b4bb81
Add support for scanning Zstandard (zstd) compressed files
burakemir d3fb514
Fix cli_scanzstd() to handle concatenated zstd frames
burakemir e81340f
Fix cli_scanzstd() error handling for stream errors and empty inputs
burakemir 68e8000
Fix cli_scanzstd() output draining and C90 compliance
burakemir 5a47ab8
Fix FindZSTD.cmake to use HINTS for pkg-config library dirs
burakemir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # Distributed under the OSI-approved BSD 3-Clause License. See accompanying | ||
| # file Copyright.txt or https://cmake.org/licensing for details. | ||
|
|
||
| #[=======================================================================[.rst: | ||
| FindZSTD | ||
| ------- | ||
|
|
||
| Finds the Zstandard (zstd) library. | ||
|
|
||
| Imported Targets | ||
| ^^^^^^^^^^^^^^^^ | ||
|
|
||
| This module provides the following imported targets, if found: | ||
|
|
||
| ``ZSTD::zstd`` | ||
| The Zstandard library | ||
|
|
||
| Result Variables | ||
| ^^^^^^^^^^^^^^^^ | ||
|
|
||
| This will define the following variables: | ||
|
|
||
| ``ZSTD_FOUND`` | ||
| True if the system has the zstd library. | ||
| ``ZSTD_VERSION`` | ||
| The version of the zstd library which was found. | ||
| ``ZSTD_INCLUDE_DIRS`` | ||
| Include directories needed to use zstd. | ||
| ``ZSTD_LIBRARIES`` | ||
| Libraries needed to link to zstd. | ||
|
|
||
| Cache Variables | ||
| ^^^^^^^^^^^^^^^ | ||
|
|
||
| The following cache variables may also be set: | ||
|
|
||
| ``ZSTD_INCLUDE_DIR`` | ||
| The directory containing ``zstd.h``. | ||
| ``ZSTD_LIBRARY`` | ||
| The path to the zstd library. | ||
|
|
||
| #]=======================================================================] | ||
|
|
||
| find_package(PkgConfig QUIET) | ||
| pkg_check_modules(PC_ZSTD QUIET libzstd) | ||
|
|
||
| find_path(ZSTD_INCLUDE_DIR | ||
| NAMES zstd.h | ||
| PATHS ${PC_ZSTD_INCLUDE_DIRS} | ||
| PATH_SUFFIXES zstd include/zstd | ||
| ) | ||
|
|
||
| if(ZSTD_LIBRARY) | ||
| set(ZSTD_LIBRARIES "${ZSTD_LIBRARY}") | ||
| endif() | ||
|
|
||
| if(NOT ZSTD_LIBRARIES) | ||
| find_library(ZSTD_LIBRARY_RELEASE | ||
| NAMES zstd NAMES_PER_DIR ${PC_ZSTD_LIBRARY_DIRS} PATH_SUFFIXES lib) | ||
| find_library(ZSTD_LIBRARY_DEBUG | ||
| NAMES zstdd NAMES_PER_DIR ${PC_ZSTD_LIBRARY_DIRS} PATH_SUFFIXES lib) | ||
|
|
||
| include(SelectLibraryConfigurations) | ||
| SELECT_LIBRARY_CONFIGURATIONS(ZSTD) | ||
| else() | ||
| file(TO_CMAKE_PATH "${ZSTD_LIBRARIES}" ZSTD_LIBRARIES) | ||
| endif() | ||
|
|
||
| set(ZSTD_VERSION ${PC_ZSTD_VERSION}) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(ZSTD | ||
| FOUND_VAR ZSTD_FOUND | ||
| REQUIRED_VARS | ||
| ZSTD_LIBRARIES | ||
| ZSTD_INCLUDE_DIR | ||
| VERSION_VAR ZSTD_VERSION | ||
| ) | ||
|
|
||
| if(ZSTD_FOUND) | ||
| set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) | ||
| set(ZSTD_DEFINITIONS ${PC_ZSTD_CFLAGS_OTHER}) | ||
|
|
||
| if(NOT TARGET ZSTD::zstd) | ||
| add_library(ZSTD::zstd UNKNOWN IMPORTED) | ||
| set_target_properties(ZSTD::zstd PROPERTIES | ||
| INTERFACE_COMPILE_OPTIONS "${PC_ZSTD_CFLAGS_OTHER}" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}") | ||
|
|
||
| if(ZSTD_LIBRARY_RELEASE) | ||
| set_property(TARGET ZSTD::zstd APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS RELEASE) | ||
| set_target_properties(ZSTD::zstd PROPERTIES | ||
| IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}" | ||
| ) | ||
| endif() | ||
|
|
||
| if(ZSTD_LIBRARY_DEBUG) | ||
| set_property(TARGET ZSTD::zstd APPEND PROPERTY | ||
| IMPORTED_CONFIGURATIONS DEBUG) | ||
| set_target_properties(ZSTD::zstd PROPERTIES | ||
| IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}" | ||
| ) | ||
| endif() | ||
|
|
||
| if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG) | ||
| set_property(TARGET ZSTD::zstd APPEND PROPERTY | ||
| IMPORTED_LOCATION "${ZSTD_LIBRARY}") | ||
| endif() | ||
| endif() | ||
| endif() | ||
|
|
||
| mark_as_advanced( | ||
| ZSTD_INCLUDE_DIR | ||
| ZSTD_LIBRARY | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.