bd_kernel_vulns - Script to process the Linux Kernel in a BD project to assess vulns applicability based on supplied list of kernel source files (or folders)
Project description
Black Duck SCA Kernel Vuln Processor - bd_kernel_vulns.py v1.0.3
PROVISION OF THIS SCRIPT
This script is provided under the MIT license (see LICENSE file).
It does not represent any extension of licensed functionality of Black Duck Software itself and is provided as-is, without warranty or liability.
If you have comments or issues, please raise a GitHub issue here. Black Duck support is not able to respond to support tickets for this OSS utility. Users of this pilot project commit to engage properly with the authors to address any identified issues.
INTRODUCTION
OVERVIEW OF BD_KERNEL_VULNS
This utility accepts a file containing compiled kernel source files (or folders) to filter the vulnerabilities associated with the Linux Kernel component in a Black Duck SCA project version.
Vulnerabilities which reference a kernel source file or package, but which do not match files/folders in the supplied kernel source file will be marked as ignored.
INSTALLATION
- Create virtualenv
- Run
pip3 install bd_kernel_vulns --upgrade
Alternatively, if you want to build and install the utility locally:
- clone the repository
- Create virtualenv
- Build the utility
python3 -m build - Install the package
pip3 install dist/bd_kernel_vulns-1.0.X-py3-none-any.whl --upgrade
Alternatively, clone the repository locally:
- Clone the repository
- Ensure prerequisite packages are installed (see list in pyproject.toml)
PREREQUISITES
- Black Duck SCA server 2024.1 or newer
- Black Duck SCA API with either Global Project Manager roles or Project BOM Manager roles for an existing project
- Python 3.10 or newer
HOW TO RUN
If you installed the utility as a package:
- Invoke virtualenv where utility was installed
- Run
bd-kernel-vulns OPTIONS
Alternatively, if you have cloned the repository locally:
- Invoke virtualenv where dependency packages were installed
- Run
python3 PATH_TO_REPOSITORY/run.py OPTIONS
COMMAND LINE OPTIONS
usage: bd-scan-yocto-via-sbom [-h] [--blackduck_url BLACKDUCK_URL] [--blackduck_api_token BLACKDUCK_API_TOKEN] [--blackduck_trust_cert] [-p PROJECT] [-v VERSION] <OTHER OPTIONS>
Create BD Yocto project from license.manifest
-h, --help show this help message and exit
REQUIRED:
--blackduck_url BLACKDUCK_URL
Black Duck server URL (REQUIRED - will also use BLACKDUCK_URL env var)
--blackduck_api_token BLACKDUCK_API_TOKEN
Black Duck API token (REQUIRED - will also use BLACKDUCK_API_TOKEN env var)
-p PROJECT, --project PROJECT
Black Duck project to create (REQUIRED)
-v VERSION, --version VERSION
Black Duck project version to create (REQUIRED)
-k KERNEL_SOURCE_FILE, --kernel_source_file KERNEL_SOURCE_FILE
File containing list of source files (or folders) within the kernel (one per line).
OPTIONAL:
--blackduck_trust_cert
Black Duck trust server cert (can use BLACKDUCK_TRUST_CERT env var)
--folders
Supplied list is kernel source folders (not source files)
--kernel_comp_name
Alternate kernel component name (default 'Linux Kernel')
OBTAINING KERNEL SOURCE FILES
FROM RUNNING LINUX IMAGE
The lsmod and modinfo commands can be used to report the compiled objects in the running kernel.
An example bash script to produce the list of kernel source files is shown below:
lsmod | while read module otherfields
do
modinfo $module | grep '^filename:' | sed -e 's/filename: *//g' -e 's/\.ko\.zst//g'
done > kfiles.lst
FROM YOCTO BUILD
The bd_scan_yocto_via_sbom utility is recommended to
scan Yocto projects, and the --process_kernel_vulns option will call this utility to filter kernel vulnerabilities.
However, if not using this script then processing the module image archive can generate the list of compiled source files as follows:
- Locate the modules image archive file for the specific build (usually beneath the poky/build/tmp/deploy/images folder - for example
modules--6.12.31+git0+f2f3b6cbd9_fee8195f84-r0-qemux86-64-20250608200614.tgz) - Extract the list of modules from the file using
tar tf FILE | grep '.ko$' | sed -e 's/\.ko$/.c/g' > kfiles.lst
FROM BUILDROOT BUILD
- Locate the Kernel Build Directory - for example <buildroot_root_directory>/output/build/linux-<kernel_version>/
- Identify Compiled Object Files (.o files) by running
find <buildroot_root_directory>/output/build/linux-<kernel_version>/ -name "*.o" | sed -e 's/\.o$/.c/g' > kfiles.lst
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bd_kernel_vulns-1.0.3.tar.gz.
File metadata
- Download URL: bd_kernel_vulns-1.0.3.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da38c369e6e6cbc29c827ebf021eb5c8f484d933f87de4fd95dffaf05bdd443b
|
|
| MD5 |
c32ef02976a33531d615760e9d13c461
|
|
| BLAKE2b-256 |
1ab72f2c336ca315451fe2527502adf2e6d8d4ed2f36e4c81939053da42c1e77
|
Provenance
The following attestation bundles were made for bd_kernel_vulns-1.0.3.tar.gz:
Publisher:
publish_pypi.yaml on blackducksoftware/bd_kernel_vulns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bd_kernel_vulns-1.0.3.tar.gz -
Subject digest:
da38c369e6e6cbc29c827ebf021eb5c8f484d933f87de4fd95dffaf05bdd443b - Sigstore transparency entry: 246674321
- Sigstore integration time:
-
Permalink:
blackducksoftware/bd_kernel_vulns@c97f90639f93b294d580724ae6fb96a72a4b6562 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/blackducksoftware
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yaml@c97f90639f93b294d580724ae6fb96a72a4b6562 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bd_kernel_vulns-1.0.3-py3-none-any.whl.
File metadata
- Download URL: bd_kernel_vulns-1.0.3-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d4fb8a853002eaad89bdb9fae73c3a0836bcd4f14bd98e0b06aabf641e54822
|
|
| MD5 |
43d0903f8217ba8a915804a4b30e1dec
|
|
| BLAKE2b-256 |
5dbaa1e0d2ceddb08b0d1172e20e913a08b8443a64d67a9a907abb648b24a10f
|
Provenance
The following attestation bundles were made for bd_kernel_vulns-1.0.3-py3-none-any.whl:
Publisher:
publish_pypi.yaml on blackducksoftware/bd_kernel_vulns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bd_kernel_vulns-1.0.3-py3-none-any.whl -
Subject digest:
2d4fb8a853002eaad89bdb9fae73c3a0836bcd4f14bd98e0b06aabf641e54822 - Sigstore transparency entry: 246674332
- Sigstore integration time:
-
Permalink:
blackducksoftware/bd_kernel_vulns@c97f90639f93b294d580724ae6fb96a72a4b6562 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/blackducksoftware
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yaml@c97f90639f93b294d580724ae6fb96a72a4b6562 -
Trigger Event:
release
-
Statement type: