generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable repo finder to support more languages via Open Source In…
…sights (#388) This feature modifies the Repo Finder, so that it can: be usable from anywhere within Macaron; accept PURL strings as input; and, support more languages via Google's Open Source Insights (deps.dev) This enables Macaron to accept artifact PURLs as input, whereby the Repo Finder will be used to attempt to retrieve the related repository. Additional languages include those supported by deps.dev: Python, NodeJS, .Net, and Rust. Note that currently these will only work when specifying an artifact PURL as input, or providing an SBOM. Full support for these extra languages will require the addition of new dependency analyzers. A new config option is also provided to disable API calls to Google's Open Source Insights, if desired. Signed-off-by: Ben Selwyn-Smith <[email protected]>
- Loading branch information
Showing
30 changed files
with
2,785 additions
and
1,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
docs/source/pages/developers_guide/apidoc/macaron.repo_finder.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
macaron.repo\_finder package | ||
============================ | ||
|
||
.. automodule:: macaron.repo_finder | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
macaron.repo\_finder.repo\_finder module | ||
---------------------------------------- | ||
|
||
.. automodule:: macaron.repo_finder.repo_finder | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
macaron.repo\_finder.repo\_finder\_base module | ||
---------------------------------------------- | ||
|
||
.. automodule:: macaron.repo_finder.repo_finder_base | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
macaron.repo\_finder.repo\_finder\_deps\_dev module | ||
--------------------------------------------------- | ||
|
||
.. automodule:: macaron.repo_finder.repo_finder_deps_dev | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
macaron.repo\_finder.repo\_finder\_java module | ||
---------------------------------------------- | ||
|
||
.. automodule:: macaron.repo_finder.repo_finder_java | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
macaron.repo\_finder.repo\_validator module | ||
------------------------------------------- | ||
|
||
.. automodule:: macaron.repo_finder.repo_validator | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ To simplify the examples, we use the same configurations as above if needed (e.g | |
The list bellow shows examples for the corresponding PURL strings for different git repositories: | ||
|
||
.. list-table:: Example of PURL strings for git repositories. | ||
.. list-table:: Examples of PURL strings for git repositories. | ||
:widths: 50 50 | ||
:header-rows: 1 | ||
|
||
|
@@ -133,6 +133,39 @@ You can also provide the PURL string together with the repository path. In this | |
.. note:: When providing the PURL and the repository path, both the branch name and commit digest must be provided as well. | ||
|
||
'''''''''''''''''''''''''''''''''''''' | ||
Providing an artifact as a PURL string | ||
'''''''''''''''''''''''''''''''''''''' | ||
|
||
The PURL format supports artifacts as well as repositories, and Macaron supports (some of) these too. | ||
|
||
.. code-block:: | ||
pkg:<package_type>/<artifact_details> | ||
Where ``artifact_details`` varies based on the provided ``package_type``. Examples for those currently supported by Macaron are as follows: | ||
|
||
.. list-table:: Examples of PURL strings for artifacts. | ||
:widths: 50 50 | ||
:header-rows: 1 | ||
|
||
* - Package Type | ||
- PURL String | ||
* - Maven (Java) | ||
- ``pkg:maven/org.apache.xmlgraphics/[email protected]`` | ||
* - PyPi (Python) | ||
- ``pkg:pypi/[email protected]`` | ||
* - Cargo (Rust) | ||
- ``pkg:cargo/[email protected]`` | ||
* - NuGet (.Net) | ||
- ``pkg:nuget/[email protected]`` | ||
* - NPM (NodeJS) | ||
- ``pkg:npm/%40angular/[email protected]`` | ||
|
||
For more detailed information on converting a given artifact into a PURL, see `PURL Specification <https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst>`_ and `PURL Types <https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst>`_ | ||
|
||
.. note:: If a repository is not also provided, Macaron will try to discover it based on the artifact purl. For this to work, ``find_repos`` in the configuration file **must be enabled**\. See `Analyzing more dependencies <#more-deps>`_ for more information about the configuration options of the Repository Finding feature. | ||
|
||
------------------------------------------------- | ||
Verifying provenance expectations in CUE language | ||
------------------------------------------------- | ||
|
@@ -191,6 +224,8 @@ With the example above, the generated output reports can be seen here: | |
- `micronaut-core.html <../_static/examples/micronaut-projects/micronaut-core/analyze_with_sbom/micronaut-core.html>`__ | ||
- `micronaut-core.json <../_static/examples/micronaut-projects/micronaut-core/analyze_with_sbom/micronaut-core.json>`__ | ||
|
||
.. _more-deps: | ||
|
||
''''''''''''''''''''''''''' | ||
Analyzing more dependencies | ||
''''''''''''''''''''''''''' | ||
|
@@ -203,30 +238,38 @@ This feature is enabled by default. To disable, or configure its behaviour in ot | |
|
||
See :ref:`dump-defaults <action_dump_defaults>`, the CLI command to dump the default configurations in ``defaults.ini``. After making changes, see :ref:`analyze <analyze-action-cli>` CLI command for the option to pass the modified ``defaults.ini`` file. | ||
|
||
Within the configuration file under the ``repofinder.java`` header, five options exist: ``find_repos``, ``artifact_repositories``, ``repo_pom_paths``, ``find_parents``, ``artifact_ignore_list``. These options behave as follows: | ||
Within the configuration file under the ``repofinder.java`` header, three options exist: ``artifact_repositories``, ``repo_pom_paths``, ``find_parents``. These options behave as follows: | ||
|
||
- ``find_repos`` (Values: True or False) - Enables or disables the Repository Finding feature. | ||
- ``artifact_repositories`` (Values: List of URLs) - Determines the remote artifact repositories to attempt to retrieve dependency information from. | ||
- ``repo_pom_paths`` (Values: List of POM tags) - Determines where to search for repository information in the POM files. E.g. scm.url. | ||
- ``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. | ||
- ``artifact_ignore_list`` (Values: List of GAs) - The Repository Finding feature will skip any artifact in this list. Format is "GroupId":"ArtifactId". E.g. org.apache.maven:maven | ||
|
||
Under the related header ``repofinder``, two more options exist: ``find_repos``, and ``use_open_source_insights``: | ||
|
||
- ``find_repos`` (Values: True or False) - Enables or disables the Repository Finding feature. | ||
- ``use_open_source_insights`` (Values: True or False) - Enables or disables use of Google's Open Source Insights API. | ||
|
||
.. note:: Finding repositories requires at least one remote call, adding some additional overhead to an analysis run. | ||
|
||
.. note:: Google's Open Source Insights API is currently used to find repositories for: Python, Rust, .Net, NodeJS | ||
|
||
An example configuration file for utilising this feature: | ||
|
||
.. code-block:: ini | ||
[repofinder.java] | ||
[repofinder] | ||
find_repos = True | ||
use_open_source_insights = True | ||
[repofinder.java] | ||
artifact_repositories = https://repo.maven.apache.org/maven2 | ||
repo_pom_paths = | ||
scm.url | ||
scm.connection | ||
scm.developerConnection | ||
find_parents = True | ||
artifact_ignore_list = | ||
org.apache.maven:maven | ||
------------------------------------- | ||
Analyzing a locally cloned repository | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.