Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Note that this will only generate the system packages from the Docker image. Sep
| Ruby | [trivy](https://github.com/aquasecurity/trivy) | `Gemfile.lock` |
| Go | [trivy](https://github.com/aquasecurity/trivy) | `go.mod` |
| Dart | [trivy](https://github.com/aquasecurity/trivy) | `pubspec.lock` |
| C++ | [trivy](https://github.com/aquasecurity/trivy) | `conan.lock` |

### `OUTPUT_FILE` (path)

Expand Down
4 changes: 4 additions & 0 deletions sbomify_action/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def _get_current_utc_timestamp() -> str:
COMMON_RUBY_LOCK_FILES = ["Gemfile.lock"]
COMMON_GO_LOCK_FILES = ["go.mod"]
COMMON_DART_LOCK_FILES = ["pubspec.lock"]
COMMON_CPP_LOCK_FILES = ["conan.lock"]


def process_lock_file(file_path: str) -> None:
Expand Down Expand Up @@ -194,6 +195,9 @@ def process_lock_file(file_path: str) -> None:
elif lock_file_name in COMMON_DART_LOCK_FILES:
logger.info("Detected Dart lockfile")
run_trivy_fs(lock_file=file_path, output_file="step_1.json")
elif lock_file_name in COMMON_CPP_LOCK_FILES:
logger.info("Detected C++ lockfile")
run_trivy_fs(lock_file=file_path, output_file="step_1.json")
else:
raise FileProcessingError(f"{file_path} is not a recognized lock file type")

Expand Down
106 changes: 106 additions & 0 deletions test_conan_generation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"serialNumber": "urn:uuid:751d39f7-1ae5-4d79-a4e5-34d40383f5ad",
"version": 1,
"metadata": {
"timestamp": "2025-09-01T08:27:46+00:00",
"tools": {
"components": [
{
"type": "application",
"group": "aquasecurity",
"name": "trivy",
"version": "0.62.1"
}
]
},
"component": {
"bom-ref": "09ca77ec-4128-47e5-833d-045e8a9d0d20",
"type": "application",
"name": "tests/test-data/conan.lock",
"properties": [
{
"name": "aquasecurity:trivy:SchemaVersion",
"value": "2"
}
]
}
},
"components": [
{
"bom-ref": "3821ffc2-f090-46b3-a6b6-7a362b3103e9",
"type": "application",
"name": "conan.lock",
"properties": [
{
"name": "aquasecurity:trivy:Class",
"value": "lang-pkgs"
},
{
"name": "aquasecurity:trivy:Type",
"value": "conan"
}
]
},
{
"bom-ref": "pkg:conan/cjson@1.7.18",
"type": "library",
"name": "cjson",
"version": "1.7.18",
"purl": "pkg:conan/cjson@1.7.18",
"properties": [
{
"name": "aquasecurity:trivy:PkgID",
"value": "cjson/1.7.18"
},
{
"name": "aquasecurity:trivy:PkgType",
"value": "conan"
}
]
},
{
"bom-ref": "pkg:conan/mbedtls@3.6.4",
"type": "library",
"name": "mbedtls",
"version": "3.6.4",
"purl": "pkg:conan/mbedtls@3.6.4",
"properties": [
{
"name": "aquasecurity:trivy:PkgID",
"value": "mbedtls/3.6.4"
},
{
"name": "aquasecurity:trivy:PkgType",
"value": "conan"
}
]
}
],
"dependencies": [
{
"ref": "09ca77ec-4128-47e5-833d-045e8a9d0d20",
"dependsOn": [
"3821ffc2-f090-46b3-a6b6-7a362b3103e9"
]
},
{
"ref": "3821ffc2-f090-46b3-a6b6-7a362b3103e9",
"dependsOn": [
"pkg:conan/cjson@1.7.18",
"pkg:conan/mbedtls@3.6.4"
]
},
{
"ref": "pkg:conan/cjson@1.7.18",
"dependsOn": []
},
{
"ref": "pkg:conan/mbedtls@3.6.4",
"dependsOn": []
}
],
"vulnerabilities": []
}
10 changes: 10 additions & 0 deletions tests/test-data/conan.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.5",
"requires": [
"mbedtls/3.6.4#b686248bee97f7bc92b88c6bc6e514a2%1752241954.6017513",
"cjson/1.7.18#e67d95071acf8902d892d89a858d31ab%1743006050.674"
],
"build_requires": [],
"python_requires": [],
"config_requires": []
}
9 changes: 9 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ def test_process_lock_file_rust_cargo(self, mock_trivy):

mock_trivy.assert_called_once_with(lock_file=test_file, output_file="step_1.json")

@patch("sbomify_action.cli.main.run_trivy_fs")
def test_process_lock_file_cpp_conan(self, mock_trivy):
"""Test processing C++ conan.lock file."""
test_file = "/path/to/conan.lock"

process_lock_file(test_file)

mock_trivy.assert_called_once_with(lock_file=test_file, output_file="step_1.json")

def test_process_lock_file_unsupported_type(self):
"""Test processing unsupported lock file type."""
test_file = "/path/to/unsupported.lock"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ def test_generation_cargo_lock(self):
)


class TestCppSBOMGeneration(unittest.TestCase):
def test_generation_conan_lock(self):
"""
Test CycloneDX generation of SBOM
from a `conan.lock` file.
"""

output_file = "test_conan_generation.json"

run_trivy_fs(
lock_file="tests/test-data/conan.lock",
output_file=output_file,
)


class TestDockerImageSBOMGeneration(unittest.TestCase):
def test_generation_docker_image(self):
"""
Expand Down