Skip to content

Commit f2dde1f

Browse files
author
Trong Nhan Mai
committed
chore: update Sphinx documentation
1 parent d30215b commit f2dde1f

File tree

4 files changed

+65
-31
lines changed

4 files changed

+65
-31
lines changed

docs/source/pages/cli_usage/command_analyze.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Usage
2222
usage: ./run_macaron.sh analyze
2323
[-h] [-sbom SBOM_PATH] [-purl PURL] [-rp REPO_PATH] [-b BRANCH]
2424
[-d DIGEST] [-pe PROVENANCE_EXPECTATION] [-c CONFIG_PATH]
25-
[--skip-deps] [-g TEMPLATE_PATH]
25+
[--skip-deps] [--deps-depth DEPS_DEPTH] [-g TEMPLATE_PATH]
26+
[--python-venv PYTHON_VENV]
2627
2728
-------
2829
Options
@@ -34,7 +35,7 @@ Options
3435

3536
.. option:: -sbom SBOM_PATH, --sbom-path SBOM_PATH
3637

37-
The path to the SBOM of the analysis target.
38+
The path to the SBOM of the analysis target. If this is set, dependency resolution must be enabled with '--deps-depth'.
3839

3940
.. option:: -purl PACKAGE_URL, --package-url PACKAGE_URL
4041

@@ -68,12 +69,20 @@ Options
6869

6970
.. option:: --skip-deps
7071

71-
Skip automatic dependency analysis.
72+
DEPRECATED. Dependency resolution is off by default. This flag does nothing and will be removed in the next release.
73+
74+
.. option:: --deps-depth DEPS_DEPTH
75+
76+
The depth of the dependency resolution. 0: disable, 1: direct dependencies, inf: all transitive dependencies. (Default: 0)
7277

7378
.. option:: -g TEMPLATE_PATH, --template-path TEMPLATE_PATH
7479

7580
The path to the Jinja2 html template (please make sure to use .html or .j2 extensions).
7681

82+
.. option:: --python-venv PYTHON_VENV
83+
84+
The path to the Python virtual environment of the target software component.If this is set, dependency resolution must be enabled with '--deps-depth'.
85+
7786
-----------
7887
Environment
7988
-----------

docs/source/pages/supported_technologies/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ Provenances
107107
* The provenance should be published on JFrog Artifactory
108108
- :doc:`page </pages/supported_technologies/jfrog>`
109109

110+
.. _supported_automatic_deps_resolution:
111+
112+
-------------------------------
113+
Automatic dependency resolution
114+
-------------------------------
115+
116+
Currently, we support the following type of project for automatic dependency resolution.
117+
118+
* Java Maven
119+
* Java gradle
120+
110121
--------
111122
See also
112123
--------

docs/source/pages/tutorials/detect_malicious_package.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,27 +172,17 @@ Let's assume ``/tmp/.django_venv`` is the virtual environment where ``django@5.0
172172

173173
.. note:: If you want Macaron to analyze the virtual environment directly to identify the dependencies, we require Python 3.11 to be used to install the package. Alternatively, you can generate the SBOM as instructed :ref:`here <python-sbom>` and pass it to Macaron as input.
174174

175-
Run Macaron as follows to analyze ``django`` and its dependencies.
175+
Run Macaron as follows to analyze ``django`` and its direct dependencies.
176176

177177
.. code-block:: shell
178178
179-
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv"
179+
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv" --deps-depth=1
180180
181-
182-
By default Macaron only checks the direct dependencies. To turn on recursive dependency analysis, add the following to the ``configurations.ini`` file:
183-
184-
.. code-block:: ini
185-
186-
[dependency.resolver]
187-
recursive = True
188-
189-
And pass that to the ``analyze`` command:
181+
Or alternatively, run Macaron as follows to analyze ``django`` and all its transitive dependencies.
190182

191183
.. code-block:: shell
192184
193-
./run_macaron.sh --defaults-path configurations.ini analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv"
194-
195-
To learn more about changing configurations see :ref:`here <change-config>`.
185+
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv" --deps-depth=inf
196186
197187
Now we can enforce the policy below to ensure that the ``mcn_detect_malicious_metadata_1`` check always passes on ``django`` and its dependencies, indicating that none of the dependencies have malicious behavior.
198188

docs/source/pages/using.rst

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Using Macaron
1717
Analyzing an artifact with a PURL string
1818
----------------------------------------
1919

20-
Macaron can analyze an artifact (and its dependencies) to determine its supply chain security posture. To analyze an artifact, you need to provide the PURL identifier of the artifact:
20+
Macaron can analyze an artifact to determine its supply chain security posture. To analyze an artifact, you need to provide the PURL identifier of the artifact:
2121

2222
.. code-block::
2323
@@ -51,6 +51,7 @@ To run Macaron on an artifact, we use the following command:
5151
5252
./run_macaron.sh analyze -purl <artifact-purl>
5353
54+
Macaron can also analyze the package's dependencies. Please see :ref:`automate-deps-resolution`.
5455

5556
''''''''''''''''''''''''''''''''''''''
5657
Automated repository and commit finder
@@ -79,6 +80,7 @@ Within the configuration file under the ``repofinder.java`` header, three option
7980
- ``repo_pom_paths`` (Values: List of POM tags) - Determines where to search for repository information in the POM files. E.g. scm.url.
8081
- ``find_parents`` (Values: True or False) - When enabled, the Repository Finding feature will also search for repository URLs in parents POM files of the current dependency.
8182

83+
.. note:: Dependency related configurations like ``artifact_repositories`` or ``find_parents`` can affect :ref:`Macaron automatic dependency resolution <automate-deps-resolution>`.
8284

8385
.. note:: Finding repositories requires at least one remote call, adding some additional overhead to an analysis run.
8486

@@ -113,7 +115,7 @@ Analyzing a source code repository
113115
Analyzing a public GitHub repository
114116
''''''''''''''''''''''''''''''''''''
115117

116-
Macaron can also analyze a public GitHub repository (and potentially the repositories of its dependencies).
118+
Macaron can also analyze a public GitHub repository.
117119

118120
To run Macaron on a GitHub public repository, we use the following command:
119121

@@ -135,14 +137,6 @@ For example, to analyze the SLSA posture of `micronaut-core <https://github.com/
135137
136138
./run_macaron.sh analyze -rp https://github.com/micronaut-projects/micronaut-core -b 4.0.x -d 82d115b4901d10226552ac67b0a10978cd5bc603
137139
138-
.. note:: Macaron automatically detects and analyzes **direct** dependencies for Java Maven and Gradle projects. This process might take a while and can be skipped by using the ``--skip-deps`` option.
139-
140-
Take the same example as above, to disable analyzing `micronaut-core <https://github.com/micronaut-projects/micronaut-core>`_ direct dependencies, we could use the following command:
141-
142-
.. code-block:: shell
143-
144-
./run_macaron.sh analyze -rp https://github.com/micronaut-projects/micronaut-core -b 4.0.x -d 82d115b4901d10226552ac67b0a10978cd5bc603 --skip-deps
145-
146140
.. note:: By default, Macaron would generate report files into the ``output`` directory in the current working directory. To understand the structure of this directory please see :ref:`Output Files Guide <output_files_guide>`.
147141

148142
With the example above, the generated output reports can be seen here:
@@ -263,6 +257,32 @@ where ``micronaut-core.cue`` file can contain:
263257
.. note::
264258
The provenance expectation is verified via the ``provenance_expectation`` check in Macaron. You can see the result of this check in the HTML or JSON report and see if the provenance found by Macaron meets the expectation CUE file.
265259

260+
.. _automate-deps-resolution:
261+
262+
------------------------------------
263+
Analyzing dependencies automatically
264+
------------------------------------
265+
266+
Macaron supports automatically detecting and analyzing dependencies for certain types of projects (:ref:`supported_automatic_deps_resolution`). This feature is disabled by default and can be enabled with the CLI flag ``--deps-depth``.
267+
268+
The ``--deps-depth`` flag currently accepts these values:
269+
270+
* ``0``: Disable dependency resolution (Default).
271+
* ``1``: Resolve and analyze direct dependencies.
272+
* ``inf``: Resolve and analyze all transitive dependencies.
273+
274+
For example, to analyze `micronaut-core <https://github.com/micronaut-projects/micronaut-core>`_ and its **direct** dependencies, we could use the following command:
275+
276+
.. code-block:: shell
277+
278+
./run_macaron.sh analyze \
279+
-rp https://github.com/micronaut-projects/micronaut-core \
280+
-b 4.0.x \
281+
-d 82d115b4901d10226552ac67b0a10978cd5bc603 \
282+
--deps-depth=1
283+
284+
.. note:: This process might take a while. Alternatively, you can help Macaron by providing the dependencies information through : :ref:`an sbom <with-sbom>` or :ref:`a Python virtual environment <python-venv-deps>` (for Python packages only).
285+
266286
.. _with-sbom:
267287

268288
----------------------
@@ -283,10 +303,12 @@ To run the analysis against that SBOM, run this command:
283303

284304
.. code-block:: shell
285305
286-
./run_macaron.sh analyze -purl pkg:maven/org.apache.maven/maven@3.9.7?type=pom -sbom <path_to_sbom>
306+
./run_macaron.sh analyze -purl pkg:maven/org.apache.maven/maven@3.9.7?type=pom -sbom <path_to_sbom> --deps-depth=1
287307
288308
Where ``path_to_sbom`` is the path to the SBOM you want to use.
289309

310+
.. note:: Make sure to enable dependency resolution with ``--deps-depth``.
311+
290312
.. _python-sbom:
291313

292314
''''''''''''''''''''''''
@@ -305,7 +327,7 @@ Then run Macaron and pass the SBOM file as input:
305327

306328
.. code-block:: shell
307329
308-
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 -sbom <path_to_django_sbom.json>
330+
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 -sbom <path_to_django_sbom.json> --deps-depth=1
309331
310332
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
311333
Analyzing dependencies in the SBOM without the main software component
@@ -320,7 +342,7 @@ Then the analysis can be run as follows:
320342

321343
.. code-block:: shell
322344
323-
./run_macaron.sh analyze -purl pkg:maven/private.apache.maven/maven@4.0.0-alpha-1-SNAPSHOT?type=pom -sbom <path_to_sbom>
345+
./run_macaron.sh analyze -purl pkg:maven/private.apache.maven/maven@4.0.0-alpha-1-SNAPSHOT?type=pom -sbom <path_to_sbom> --deps-depth=1
324346
325347
Where ``path_to_sbom`` is the path to the SBOM you want to use.
326348

@@ -344,10 +366,12 @@ Then run Macaron as follows:
344366

345367
.. code-block:: shell
346368
347-
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv"
369+
./run_macaron.sh analyze -purl pkg:pypi/django@5.0.6 --python-venv "/tmp/.django_venv" --deps-depth=1
348370
349371
Where ``--python-venv`` is the path to virtual environment.
350372

373+
.. note:: Make sure to enable dependency resolution with ``--deps-depth``.
374+
351375
Alternatively, you can create an SBOM for the python package and provide it to Macaron as input as explained :ref:`here <with-sbom>`.
352376

353377
.. note:: We only support Python 3.11 for this feature of Macaron. Please make sure to install the package using this version of Python.

0 commit comments

Comments
 (0)