You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/pages/using.rst
+76-5Lines changed: 76 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,50 @@ To analyze a repository on a self-hosted GitLab instance, you need to do the fol
90
90
91
91
- Obtain a GitLab access token having at least the ``read_repository`` permission and store it into the ``MCN_SELF_HOSTED_GITLAB_TOKEN`` environment variable. For more detailed instructions, see `GitLab documentation <https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token>`_.
Instead of providing the repository path for the analysis software component, a `PURL <https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst>`_. string
98
+
for the target git repository could be used.
99
+
100
+
To begin with, we follow the same steps for the configuration if needed (especially for self-hosted GitLab instances). The PURL string for a git repository could be created using the following format:
101
+
102
+
.. code-block::
103
+
104
+
pkg:<git_service_domain>/<organization>/<name>
105
+
106
+
The list bellow shows examples for the corresponding PURL string for different git repositories:
107
+
108
+
.. list-table:: Example of PURL strings for git repositories.
- Both ``pkg:github/micronaut-projects/micronaut-core`` and ``pkg:github.com/micronaut-projects/micronaut-core`` are applicable as ``github`` is a pre-defined type as mentioned `here <https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst>`_.
116
+
* - ``https://bitbucket.org/snakeyaml/snakeyaml``
117
+
- Both ``pkg:github/micronaut-projects/micronaut-core`` and ``pkg:github.com/micronaut-projects/micronaut-core`` are applicable as ``bitbucket`` is a pre-defined type as mentioned `here <https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst>`_.
118
+
* - ``https://internal.gitlab.com/foo/bar``
119
+
- ``pkg:internal.gitlab.com/foo/bar``
120
+
* - ``https://gitlab.com/gitlab-org/gitlab``
121
+
- ``pkg:gitlab.com/gitlab-org/gitlab``
122
+
123
+
After the PURL string has been obtained, the analysis could be run with:
124
+
125
+
.. code-block:: shell
126
+
127
+
./run_macaron.sh analyze -purl <purl_string>
128
+
129
+
You can also provide the PURL string together with the repository path. In this case, the PURL string will be used as the unique identifier to the analysis target:
.. note:: When provide the PURL and the repository path, both branch name and commit digest must be provided as well.
136
+
93
137
-------------------------------------------------
94
138
Verifying provenance expectations in CUE language
95
139
-------------------------------------------------
@@ -218,8 +262,13 @@ Running the policy engine
218
262
Macaron's policy engine accepts policies specified in `Datalog <https://en.wikipedia.org/wiki/Datalog>`_. An example policy
219
263
can verify if a project and all its dependencies pass certain checks. We use `Soufflé <https://souffle-lang.github.io/index.html>`_
220
264
as the Datalog engine in Macaron. Once you run the checks on a target project as described :ref:`here <analyze-action>`,
221
-
the check results will be stored in ``macaron.db`` in the output directory. We can pass the check results to the policy
222
-
engine and provide a Datalog policy file to be enforced by the policy engine.
265
+
the check results will be stored in ``macaron.db`` in the output directory. Because the check results of different software component can be stored into the database at ``macaron.db``, we must specify the target software component in the Datalog policy file to be enforced by the policy engine. There are two ways that we could
266
+
specify the target software component in the Datalog policy file:
267
+
268
+
#. Using the complete name of the target component (e.g. ``github.com/oracle-quickstart/oci-micronaut``)
269
+
#. Using the PURL string of the target component (e.g. ``pkg:github.com/oracle-quickstart/oci-micronaut@<commit_sha>``).
270
+
271
+
However, the two methods would mostly share the same policy definition in the Datalog files.
223
272
224
273
We use `Micronaut MuShop <https://github.com/oracle-quickstart/oci-micronaut>`_ project as a case study to show how to run the policy engine.
225
274
Micronaut MuShop is a cloud-native microservices example for Oracle Cloud Infrastructure. When we run Macaron on the Micronaut MuShop GitHub
@@ -233,13 +282,35 @@ Now we can run the policy engine over these results and enforce a policy:
In this example, the Datalog policy files for both ways (as mentioned previously) are provided in `oci-micronaut-repo.dl <../_static/examples/oracle-quickstart/oci-micronaut/policies/oci-micronaut-repo.dl>`__ and `oci-micronaut-purl.dl <../_static/examples/oracle-quickstart/oci-micronaut/policies/oci-micronaut-purl.dl>`__.
288
+
289
+
The differences between the two policy files can be observed below:
290
+
291
+
.. tabs::
292
+
293
+
.. code-tab:: prolog Using repository complete name
> 2023-08-15 14:36:56,672 [INFO] PURL of the main target software component is 'pkg:github.com/oracle-quickstart/oci-micronaut@3ebe0c9520a25feeae983eac6eb956de7da29ead'.
In this example, the Datalog policy file is provided in `oci-micronaut.dl <../_static/examples/oracle-quickstart/oci-micronaut/policies/oci-micronaut.dl>`__.
239
310
This example policy can verify if the Micronaut MuShop project and all its dependencies pass the ``build_service`` check
240
311
and the Micronaut provenance documents meets the expectation provided as a `CUE file <../_static/examples/micronaut-projects/micronaut-core/policies/micronaut-core.cue>`__.
241
312
242
-
Thanks to Datalog’s expressive language model, it’s easy to add exception rules if certain dependencies do not meet a
313
+
Thanks to Datalog's expressive language model, it's easy to add exception rules if certain dependencies do not meet a
243
314
requirement. For example, `the Mysql Connector/J <https://slsa.dev/spec/v0.1/requirements#build-service>`_ dependency in
244
315
the Micronaut MuShop project does not pass the ``build_service`` check, but can be manually investigated and exempted if trusted. Overall, policies expressed in Datalog can be
245
316
enforced by Macaron as part of your CI/CD pipeline to detect regressions or unexpected behavior.
0 commit comments