Skip to content

Commit 6785ac4

Browse files
authored
refactor!: remove the automatic sbom generation feature for Java (#1145)
This PR removes the automatic SBOM generation feature for Java projects in Macaron. Signed-off-by: behnazh-w <[email protected]>
1 parent 2bc60e9 commit 6785ac4

File tree

61 files changed

+2309
-20400
lines changed

Some content is hidden

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

61 files changed

+2309
-20400
lines changed

Makefile

Lines changed: 4 additions & 23 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 \
@@ -236,7 +221,7 @@ setup-integration-test-utility-for-docker:
236221
# Generate a Software Bill of Materials (SBOM).
237222
.PHONY: sbom
238223
sbom: requirements
239-
cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-sbom.json
224+
cyclonedx-py requirements --output-format json --output-file dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-sbom.json
240225
$$HOME/go/bin/cyclonedx-gomod mod -json -output dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-sbom-go.json $(REPO_PATH)
241226

242227
# Generate a requirements.txt file containing version and integrity hashes for all
@@ -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/Dockerfile.final

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Note that the local machine must login to ghcr.io so that Docker could pull the ghcr.io/oracle/macaron-base
1212
# image for this build.
1313

14-
FROM ghcr.io/oracle/macaron-base:latest@sha256:79b3b8b03cb9b6a124c6450f4baa58f96f83ee9e37f572c88a97597b35c7bc51
14+
FROM ghcr.io/oracle/macaron-base:latest@sha256:3b1f5ab197ee4429c598712bb8abb555a094e879f69e35439061777ac3bcb138
1515

1616
ENV HOME="/home/macaron"
1717

docker/user.sh

Lines changed: 1 addition & 32 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" ]];
@@ -80,8 +51,6 @@ fi
8051

8152
# The directory that could be mounted to the host machine file systems should
8253
# have the owner as the current user in the host machine.
83-
chown --recursive macaron:macaron "$HOME"/.m2
84-
chown --recursive macaron:macaron "$HOME"/.gradle
8554
chown --recursive macaron:macaron "$HOME"/output
8655

8756
# Run the provided Macaron command with the user macaron.

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/installation.rst

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,3 @@ You can run the following command to make sure the proxy settings are updated:
119119
.. code-block:: shell
120120
121121
sudo systemctl show --property=Environment docker
122-
123-
'''''''''''''''''''''''''''''''
124-
Maven and Gradle proxy settings
125-
'''''''''''''''''''''''''''''''
126-
127-
Maven and Gradle do not use the system proxy settings. If the target software component (repository)
128-
is using either of these build tools, make sure to set up the following environment variables:
129-
130-
.. code-block:: shell
131-
132-
export MAVEN_OPTS="-Dhttp.proxyHost=wwww-example-proxy -Dhttp.proxyPort=80 -Dhttps.proxyHost=wwww-example-proxy -Dhttps.proxyPort=80"
133-
export GRADLE_OPTS="-Dhttp.proxyHost=wwww-example-proxy -Dhttp.proxyPort=80 -Dhttps.proxyHost=wwww-example-proxy -Dhttps.proxyPort=80"
134-
135-
In addition, Macaron uses the global settings files for Maven and Gradle if present on the host machine and copies them to
136-
the Docker container. You can set up your proxy settings in the following files:
137-
138-
* ``~/.m2/settings.xml``
139-
* ``~/.gradle/gradle.properties``
140-
141-
See the `Maven <https://maven.apache.org/settings.html#proxies>`_ and `Gradle <https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy>`_ documentations for more information on setting up proxies.

docs/source/pages/output_files.rst

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Top level structure
2020
.. code-block::
2121
2222
output/
23-
├── .gradle/
24-
├── .m2/
2523
├── build_log/
2624
├── git_repos/
2725
├── reports/
@@ -182,18 +180,10 @@ This file stores the log messages from the latest run of Macaron.
182180
build_log
183181
^^^^^^^^^
184182

185-
This is the directory for storing the log from running external components such as `CycloneDx SBOM Maven plugin <https://github.com/CycloneDX/cyclonedx-maven-plugin>`_, `CycloneDx SBOM Gradle plugin <https://github.com/CycloneDX/cyclonedx-gradle-plugin>`_ or the `slsa-verifier <https://github.com/slsa-framework/slsa-verifier>`_.
183+
This is the directory for storing the log from running external components, such as `slsa-verifier <https://github.com/slsa-framework/slsa-verifier>`_.
186184

187185
^^^^^^^^^^^^^^^
188186
sbom_debug.json
189187
^^^^^^^^^^^^^^^
190188

191189
This file contain the debug information for running the SBOM generator to obtain dependencies of a repository.
192-
193-
^^^^^^^^^^^^^^^
194-
.m2 and .gradle
195-
^^^^^^^^^^^^^^^
196-
197-
These two directories cache the content of ``~/.m2`` and ``~/.gradle`` in the Docker container between different runs (which are
198-
mainly updated by the CycloneDX SBOM plugins).
199-
This will helps subsequent runs on the same target repository faster.

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
]

0 commit comments

Comments
 (0)