Skip to content

Commit 5eb92e9

Browse files
committed
refactor!: remove the automatic sbom generation feature for Java
Signed-off-by: behnazh-w <[email protected]>
1 parent 9b05632 commit 5eb92e9

File tree

53 files changed

+2313
-19837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2313
-19837
lines changed

Makefile

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,19 @@ venv:
8585
# So we create the dist dir if it doesn't exist in the setup target.
8686
# See https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives.
8787
# We also install cyclonedx-go to generate SBOM for Go, compile the Go modules,
88-
# install SLSA verifier binary, download mvnw, and gradlew.
88+
# and install SLSA verifier binary.
8989
.PHONY: setup
9090
setup: force-upgrade setup-go setup-binaries setup-schemastore
9191
pre-commit install
9292
mkdir -p dist
9393
go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]
9494
setup-go:
9595
go build -o $(PACKAGE_PATH)/bin/ $(REPO_PATH)/golang/cmd/...
96-
setup-binaries: $(PACKAGE_PATH)/bin/slsa-verifier $(PACKAGE_PATH)/resources/mvnw $(PACKAGE_PATH)/resources/gradlew souffle gnu-sed
96+
setup-binaries: $(PACKAGE_PATH)/bin/slsa-verifier souffle gnu-sed
9797
$(PACKAGE_PATH)/bin/slsa-verifier:
9898
git clone --depth 1 https://github.com/slsa-framework/slsa-verifier.git -b v2.7.1
9999
cd slsa-verifier/cli/slsa-verifier && go build -o $(PACKAGE_PATH)/bin/
100100
cd $(REPO_PATH) && rm -rf slsa-verifier
101-
$(PACKAGE_PATH)/resources/mvnw:
102-
cd $(PACKAGE_PATH)/resources \
103-
&& wget https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper-distribution/3.1.1/maven-wrapper-distribution-3.1.1-bin.zip \
104-
&& unzip -o maven-wrapper-distribution-3.1.1-bin.zip \
105-
&& rm -r maven-wrapper-distribution-3.1.1-bin.zip \
106-
&& echo -e "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip\nwrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" > .mvn/wrapper/maven-wrapper.properties \
107-
&& cd $(REPO_PATH)
108-
$(PACKAGE_PATH)/resources/gradlew:
109-
cd $(PACKAGE_PATH)/resources \
110-
&& export GRADLE_VERSION=7.6 \
111-
&& wget https://services.gradle.org/distributions/gradle-$$GRADLE_VERSION-bin.zip \
112-
&& unzip -o gradle-$$GRADLE_VERSION-bin.zip \
113-
&& rm -r gradle-$$GRADLE_VERSION-bin.zip \
114-
&& gradle-$$GRADLE_VERSION/bin/gradle wrapper \
115-
&& cd $(REPO_PATH)
116101
setup-schemastore: $(PACKAGE_PATH)/resources/schemastore/github-workflow.json $(PACKAGE_PATH)/resources/schemastore/LICENSE $(PACKAGE_PATH)/resources/schemastore/NOTICE
117102
$(PACKAGE_PATH)/resources/schemastore/github-workflow.json:
118103
cd $(PACKAGE_PATH)/resources \
@@ -433,11 +418,7 @@ clean: dist-clean bin-clean docs-clean
433418
nuke-caches: clean
434419
find src/ -type d -name __pycache__ -exec rm -fr {} +
435420
find tests/ -type d -name __pycache__ -exec rm -fr {} +
436-
nuke-mvnw:
437-
cd $(PACKAGE_PATH)/resources \
438-
&& rm mvnw mvnw.cmd mvnwDebug mvnwDebug.cmd \
439-
&& cd $(REPO_PATH)
440-
nuke: nuke-caches nuke-mvnw
421+
nuke: nuke-caches
441422
if [ ! -z "${VIRTUAL_ENV}" ]; then \
442423
echo "Please deactivate the virtual environment first!" && exit 1; \
443424
fi

docker/user.sh

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright (c) 2022 - 2024, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
55

66
# We update the GID and UID of the existing macaron user in the container
@@ -16,35 +16,6 @@ else
1616
echo "Consider providing the GID and UID via the env variables USER_GID and USER_UID respectively."
1717
fi
1818

19-
# Prepare settings.xml because
20-
# We mount .m2 dir to the host machine
21-
# We cannot copy those files while building the image
22-
# because they will be bypassed.
23-
if [[ ! -f "$HOME/.m2/settings.xml" ]] && [[ -n "$PACKAGE_PATH" ]];
24-
then
25-
if [[ ! -d "$HOME/.m2" ]];
26-
then
27-
mkdir --parents "$HOME"/.m2
28-
fi
29-
cp "$PACKAGE_PATH"/resources/settings.xml "$HOME"/.m2/
30-
fi
31-
32-
# Overwrite $HOME/.m2/settings.xml if the global settings.xml file is mounted from the host machine.
33-
if [[ -f "$HOME/settings.xml" ]];
34-
then
35-
cp "$HOME/settings.xml" "$HOME/.m2/settings.xml"
36-
fi
37-
38-
# Create $HOME/.gradle/gradle.properties if the global gradle.properties file is mounted from the host machine.
39-
if [[ ! -d "$HOME/.gradle" ]];
40-
then
41-
mkdir --parents "$HOME"/.gradle
42-
fi
43-
if [[ -f "$HOME/gradle.properties" ]];
44-
then
45-
cp "$HOME"/gradle.properties "$HOME/.gradle/gradle.properties"
46-
fi
47-
4819
# Prepare the output directory. The output directory will be already existed
4920
# if we mount from the host machine.
5021
if [[ ! -d "$HOME/output" ]];

docs/source/pages/developers_guide/apidoc/macaron.dependency_analyzer.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@ macaron.dependency\_analyzer.cyclonedx module
1717
:show-inheritance:
1818
:undoc-members:
1919

20-
macaron.dependency\_analyzer.cyclonedx\_gradle module
21-
-----------------------------------------------------
22-
23-
.. automodule:: macaron.dependency_analyzer.cyclonedx_gradle
24-
:members:
25-
:show-inheritance:
26-
:undoc-members:
27-
28-
macaron.dependency\_analyzer.cyclonedx\_mvn module
29-
--------------------------------------------------
30-
31-
.. automodule:: macaron.dependency_analyzer.cyclonedx_mvn
32-
:members:
33-
:show-inheritance:
34-
:undoc-members:
35-
3620
macaron.dependency\_analyzer.cyclonedx\_python module
3721
-----------------------------------------------------
3822

docs/source/pages/developers_guide/apidoc/macaron.malware_analyzer.pypi_heuristics.metadata.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ macaron.malware\_analyzer.pypi\_heuristics.metadata.empty\_project\_link module
3333
:show-inheritance:
3434
:undoc-members:
3535

36+
macaron.malware\_analyzer.pypi\_heuristics.metadata.fake\_email module
37+
----------------------------------------------------------------------
38+
39+
.. automodule:: macaron.malware_analyzer.pypi_heuristics.metadata.fake_email
40+
:members:
41+
:show-inheritance:
42+
:undoc-members:
43+
3644
macaron.malware\_analyzer.pypi\_heuristics.metadata.high\_release\_frequency module
3745
-----------------------------------------------------------------------------------
3846

@@ -49,6 +57,14 @@ macaron.malware\_analyzer.pypi\_heuristics.metadata.one\_release module
4957
:show-inheritance:
5058
:undoc-members:
5159

60+
macaron.malware\_analyzer.pypi\_heuristics.metadata.similar\_projects module
61+
----------------------------------------------------------------------------
62+
63+
.. automodule:: macaron.malware_analyzer.pypi_heuristics.metadata.similar_projects
64+
:members:
65+
:show-inheritance:
66+
:undoc-members:
67+
5268
macaron.malware\_analyzer.pypi\_heuristics.metadata.source\_code\_repo module
5369
-----------------------------------------------------------------------------
5470

docs/source/pages/supported_technologies/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ Automatic dependency resolution
115115

116116
Currently, we support the following type of project for automatic dependency resolution.
117117

118-
* Java Maven
119-
* Java Gradle
120118
* Python (with a Python virtual environment created and packages installed using Python3.11, see :ref:`providing Python virtual environment <python-venv-deps>`.)
121119

122120
--------

docs/source/pages/tutorials/detect_malicious_java_dep.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ Skip this section if you already know how to install Macaron.
6666
Run ``analyze`` command
6767
***********************
6868

69-
First, we need to run the ``analyze`` command of Macaron to run a number of :ref:`checks <checks>` and collect evidence for ``example-maven-app`` and its dependencies.
69+
First, we need to run the ``analyze`` command of Macaron to run a number of :ref:`checks <checks>` and collect evidence for ``example-maven-app`` and its dependencies. You need to generate the SBOM and provide it to Macaron. For more details see the instructions : :ref:`here <with-sbom>`.
7070

7171
.. code-block:: shell
7272
73-
./run_macaron.sh analyze -purl pkg:maven/io.github.behnazh-w.demo/[email protected]?type=jar -rp https://github.com/behnazh-w/example-maven-app --deps-depth=1
73+
./run_macaron.sh analyze -purl pkg:maven/io.github.behnazh-w.demo/[email protected]?type=jar -rp https://github.com/behnazh-w/example-maven-app --deps-depth=1 -sbom sbom.json
7474
7575
.. note:: By default, Macaron clones the repositories and creates output files under the ``output`` directory. To understand the structure of this directory please see :ref:`Output Files Guide <output_files_guide>`.
7676

@@ -98,7 +98,7 @@ As you can see, some of the checks are passing and some are failing. In summary,
9898
* but it is not deploying any artifacts automatically (``mcn_build_as_code_1``)
9999
* and no CI workflow runs are detected that automatically publish artifacts (``mcn_find_artifact_pipeline_1``)
100100

101-
As you scroll down in the HTML report, you will see a section for the dependencies that were automatically identified:
101+
As you scroll down in the HTML report, you will see a section for the dependencies that were identified from the provided ``sbom.json``:
102102

103103
.. _fig_example-maven-app-deps:
104104

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ dependencies = [
3232
"packageurl-python >= 0.11.1,<1.0.0",
3333
"ruamel.yaml >= 0.18.6,<1.0.0",
3434
"jsonschema >= 4.22.0,<5.0.0",
35-
"cyclonedx-bom >=4.0.0,<5.0.0",
36-
"cyclonedx-python-lib[validation] >=7.3.4,<8.0.0",
35+
"cyclonedx-bom >=7.0.0,<8.0.0",
36+
"cyclonedx-python-lib[validation] >=8.0.0,<11.0.0",
3737
"beautifulsoup4 >= 4.12.0,<5.0.0",
3838
"problog >= 2.2.6,<3.0.0",
3939
"cryptography >=44.0.0,<45.0.0",
@@ -78,7 +78,7 @@ dev = [
7878
"types-jsonschema >=4.22.0,<5.0.0",
7979
"pip-audit >=2.5.6,<3.0.0",
8080
"pylint >=3.0.3,<4.0.0",
81-
"cyclonedx-bom >=4.0.0,<5.0.0",
81+
"cyclonedx-bom >=7.0.0,<8.0.0",
8282
"types-beautifulsoup4 >= 4.12.0,<5.0.0",
8383
]
8484
docs = [
@@ -274,5 +274,7 @@ filterwarnings = [
274274
# https://docs.pytest.org/en/latest/how-to/failures.html#warning-about-unraisable-exceptions-and-unhandled-thread-exceptions
275275
"error::pytest.PytestUnraisableExceptionWarning",
276276
"error::pytest.PytestUnhandledThreadExceptionWarning",
277+
# Remove the following when this issue is fixed: https://github.com/CycloneDX/cyclonedx-python-lib/issues/870
278+
"ignore::DeprecationWarning:cyclonedx.model.tool",
277279
"error::DeprecationWarning:pkg_resources",
278280
]

src/macaron/config/defaults.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ timeout = 30
3333

3434
# This is the dependency resolver tool to generate SBOM.
3535
[dependency.resolver]
36-
# Should be in <tool>:<version> format.
37-
# The supported tools for Maven is cyclonedx-maven.
38-
# The supported tools for Gradle is cyclonedx-gradle.
39-
# The version of the dependency resolver should conform with semantic versioning.
40-
dep_tool_maven = cyclonedx-maven:2.6.2
41-
dep_tool_gradle = cyclonedx-gradle:1.7.4
4236
# This is the timeout (in seconds) to run the dependency resolver.
4337
timeout = 2400
4438
# Determines whether the CycloneDX BOM file should be validated or not.

src/macaron/config/global_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def load(
7373
local_repos_path : str
7474
The directory to look for local repositories.
7575
resources_path : str
76-
The path to the resources files needed for the analysis (i.e. mvnw, gradlew, etc.)
76+
The path to the resource files needed for the analysis.
7777
"""
7878
self.macaron_path = macaron_path
7979
self.output_path = output_path

0 commit comments

Comments
 (0)