Skip to content

Commit 2fc1b53

Browse files
author
Trong Nhan Mai
authored
docs: update the Command Line Usage page in the Sphinx documentation (#269)
Signed-off-by: Trong Nhan Mai <[email protected]>
1 parent 58602b1 commit 2fc1b53

File tree

8 files changed

+201
-16
lines changed

8 files changed

+201
-16
lines changed

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Macaron documentation
1010
pages/installation
1111
pages/using
1212
pages/output_files
13-
pages/cli_options
13+
pages/cli_usage/index
1414
pages/apidoc/index

docs/source/pages/cli_options.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. _analyze-action-cli:
2+
3+
=======
4+
Analyze
5+
=======
6+
7+
-----------
8+
Description
9+
-----------
10+
11+
Analyze a public GitHub repository (and optionally the repositories of its dependencies) to determine its SLSA posture. We currently support `SLSA v0.1 <https://slsa.dev/spec/v0.1/>`_. The support for `SLSA v1.0 <https://slsa.dev/spec/v1.0/>`_ will be added in future.
12+
13+
-----
14+
Usage
15+
-----
16+
17+
.. code-block:: shell
18+
19+
usage: ./run_macaron.sh analyze
20+
[-h] [-sbom SBOM_PATH] [-rp REPO_PATH] [-b BRANCH]
21+
[-d DIGEST] [-pe PROVENANCE_EXPECTATION] [-c CONFIG_PATH]
22+
[--skip-deps] [-g TEMPLATE_PATH]
23+
24+
-------
25+
Options
26+
-------
27+
28+
.. option:: -h, --help
29+
30+
Show this help message and exit
31+
32+
.. option:: -sbom SBOM_PATH, --sbom-path SBOM_PATH
33+
34+
The path to the SBOM of the analysis target.
35+
36+
.. option:: -rp REPO_PATH, --repo-path REPO_PATH
37+
38+
The path to the repository, can be local or remote
39+
40+
41+
.. option:: -b BRANCH, --branch BRANCH
42+
43+
The branch of the repository that we want to checkout. If not set, Macaron will use the default branch
44+
45+
.. option:: -d DIGEST, --digest DIGEST
46+
47+
The digest of the commit we want to checkout in the branch. If not set, Macaron will use the latest commit
48+
49+
.. option:: -pe PROVENANCE_EXPECTATION, --provenance-expectation PROVENANCE_EXPECTATION
50+
51+
The path to provenance expectation file or directory.
52+
53+
.. option:: -c CONFIG_PATH, --config-path CONFIG_PATH
54+
55+
The path to the user configuration.
56+
57+
.. option:: --skip-deps
58+
59+
Skip automatic dependency analysis.
60+
61+
.. option:: -g TEMPLATE_PATH, --template-path TEMPLATE_PATH
62+
63+
The path to the Jinja2 html template (please make sure to use .html or .j2 extensions).
64+
65+
-----------
66+
Environment
67+
-----------
68+
69+
``GITHUB_TOKEN`` – The GitHub personal access token is needed for to run the analysis. For more information on how to obtain a GitHub token, see instructions in :ref:`Prepare GitHub access token <prepare-github-token>`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=============
2+
Dump Defaults
3+
=============
4+
5+
-----------
6+
Description
7+
-----------
8+
9+
Dumps the ``defaults.ini`` configuration file used by Macaron to the output directory. You can make changes to this configuration file and pass it to Macaron using the ``--defaults-path`` option. See :ref:`Analyze <analyze-action-cli>` for more information.
10+
11+
-----
12+
Usage
13+
-----
14+
15+
.. code-block:: shell
16+
17+
usage: ./run_macaron.sh dump-defaults [-h]
18+
19+
-------
20+
Options
21+
-------
22+
23+
.. option:: -h, --help
24+
25+
Show this help message and exit
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=============
2+
Verify Policy
3+
=============
4+
5+
-----------
6+
Description
7+
-----------
8+
9+
Verify the analysis results against a Souffle Datalog policy.
10+
11+
-----
12+
Usage
13+
-----
14+
15+
.. code-block:: shell
16+
17+
usage: ./run_macaron.sh verify-policy [-h] -d DATABASE (-f FILE | -s)
18+
19+
-------
20+
Options
21+
-------
22+
23+
.. option:: -h, --help
24+
25+
Show this help message and exit
26+
27+
.. option:: -d DATABASE, --database DATABASE
28+
29+
Path to the database.
30+
31+
.. option:: -f FILE, --file FILE
32+
33+
Path to the Datalog policy.
34+
35+
.. option:: -s, --show-prelude
36+
37+
Show policy prelude.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.. Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
2+
.. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3+
4+
.. _cli-usage:
5+
6+
==================
7+
Command Line Usage
8+
==================
9+
10+
Use the bash script ``run_macaron.sh`` to run Macaron as a Docker container (for more information on how to get this script, please see :ref:`Download <download-macaron>`).
11+
12+
-----
13+
Usage
14+
-----
15+
16+
.. code-block:: shell
17+
18+
usage: ./run_macaron.sh [-h] [-V] [-v] [-o OUTPUT_DIR] [-dp DEFAULTS_PATH] [-lr LOCAL_REPOS_PATH] {analyze,dump-defaults,verify-policy} ...
19+
20+
Macaron's CLI has multiple common flags (e.g ``-h``, ``-V``) and different action commands (e.g. ``analyze``), which have their own set of flags.
21+
22+
.. note:: Running ``--help`` on the main entry ``macaron`` will only print out the help for common flags. To print the help messages for action-specific flags, please provide the name of the action you want to know about. For example: ``./run_macaron.sh analyze --help``. The documented flags for each action can be found at `Action Commands`_.
23+
24+
--------------
25+
Common Options
26+
--------------
27+
28+
.. option:: -h, --help
29+
30+
Show this help message and exit
31+
32+
.. option:: -V, --version
33+
34+
Show Macaron's version number and exit
35+
36+
.. option:: -v, --verbose
37+
38+
Run Macaron with more debug logs
39+
40+
.. option:: -o OUTPUT_DIR, --output-dir OUTPUT_DIR
41+
42+
The output destination path for Macaron
43+
44+
.. option:: -dp DEFAULTS_PATH, --defaults-path DEFAULTS_PATH
45+
46+
The path to the defaults configuration file.
47+
48+
.. option:: -lr LOCAL_REPOS_PATH, --local-repos-path LOCAL_REPOS_PATH
49+
50+
The directory where Macaron looks for already cloned repositories.
51+
52+
---------------
53+
Action Commands
54+
---------------
55+
56+
.. toctree::
57+
:glob:
58+
:maxdepth: 1
59+
60+
action*

docs/source/pages/installation.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Prerequisites
1313
- Installations of ``wget`` or ``curl`` and ``bash`` must be available and on the path.
1414
- Docker (or docker equivalent for your host OS) must be installed, with a docker command line equivalent to Docker 17.06 (Oracle Container Runtime 19.03) and the user should be a member of the operating system group ``docker`` (to run Docker in `rootless mode <https://docs.docker.com/engine/security/rootless/>`_).
1515

16+
.. _download-macaron:
17+
1618
--------
1719
Download
1820
--------
@@ -41,13 +43,15 @@ To verify your setup, go to the directory containing the downloaded ``run_macaro
4143
4244
.. note:: In the first execution, this script will download the Macaron Docker image from ``ghcr.io/oracle-samples/macaron`` which can take some time. However, the next time you run it, the docker image available on your local host will be used.
4345

44-
.. note:: By default, ``latest`` is used as the tag for the downloaded image. You could specify the tag you want to run by assigning the environment variable ``MACARON_IMAGE_TAG``. For example to run Macaron v0.1: ``MACARON_IMAGE_TAG=0.1 && ./run_macaron.sh --help``
46+
.. note:: By default, ``latest`` is used as the tag for the downloaded image. You can choose a specific tag by assigning the environment variable ``MACARON_IMAGE_TAG``. For example to run Macaron v0.1.0 run: ``MACARON_IMAGE_TAG=v0.1.0 && ./run_macaron.sh --help``
47+
48+
.. _prepare-github-token:
4549

4650
---------------------------
4751
Prepare GitHub access token
4852
---------------------------
4953

50-
A GitHub access token is **always** required when using the **analyze** command (see example below) of Macaron as it may query information from GitHub API about public repositories. More information on this analyze command is can be found in :ref:`Using Guide <using-guide>`.
54+
A GitHub access token is **always** required when using the **analyze** command (see example below) of Macaron as it may query information from GitHub API about public repositories. More information on this analyze command is can be found in :ref:`Using Macaron <using-macaron>`.
5155

5256
.. code-block:: shell
5357
@@ -62,4 +66,4 @@ Ideally, the GitHub token must have **read** permissions for the repositories th
6266

6367
After generating a GitHub personal-access token, please store its value in an environment variable called ``GITHUB_TOKEN``. This environment variable will be read by Macaron for its **analyze** command.
6468

65-
Now that you have successfully downloaded and installed Macaron, please refer to :ref:`Using Guide <using-guide>` for the instructions on how to use Macaron.
69+
Now that you have successfully downloaded and installed Macaron, please refer to :ref:`Using Macaron <using-macaron>` for the instructions on how to use Macaron.

docs/source/pages/using.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
22
.. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33
4-
.. _using-guide:
4+
.. _using-macaron:
55

66
=============
77
Using Macaron
@@ -98,6 +98,6 @@ We can run Macaron against the local repository at ``target`` by using this comm
9898
9999
With ``rest_of_args`` being the arguments to the ``analyze`` command (e.g. ``-b``, ``-d`` or ``--skip-deps`` similar to two previous examples)
100100

101-
The ``-lr`` flag configure Macaron to looks into ``path/to/boo/foo`` for local repositories. For more information, please see :ref:`CLI options <cli-options>`.
101+
The ``-lr`` flag configure Macaron to looks into ``path/to/boo/foo`` for local repositories. For more information, please see :ref:`Command Line Usage <cli-usage>`.
102102

103103
.. note:: If ``-lr`` is not provided, Macaron will looks inside ``<working_directory>/output/git_repos/local_repos/`` whenever you provide a local path to ``-rp``.

0 commit comments

Comments
 (0)