Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add purl as a CLI options #401

Merged
merged 11 commits into from
Aug 28, 2023

Conversation

tromai
Copy link
Member

@tromai tromai commented Aug 4, 2023

Description

This Pull request adds a CLI option to Macaron, called -purl/--package-url, for the user to provide the Package URL (see the specification here) for the main analysis software component.

Types of PURL this feature supports.

A "repo-based" PURL.

According to the PURL specification, a PURL string could be used to reference a git repository path.
The format for a "repo-based" PURL would be:

pkg:<type>/<organization>/<repo-name>

Where:

  • type: could be the pre-defined types for git-based packages as mentioned here. At the current time of this PR, there are only two git-based PURL: github and bitbucket. However, the user could use the git service domain as the type (e.g. github.com or gitlab.com).
  • organization/repo-name: the repository fullname, which is expected to have 2 components. Example: apache/maven or oracle/macaron,

Other PURL types

At this stage, this type contains PURL strings which do not belong to the first type.

Supported use case

Provide the repository path

This use case is what Macaron has been offering. No changes are made to it.

Provide PURL only

When only the PURL is provided for the main software component:

  • If that PURL is a repo-based PURL, Macaron can find the repository for it and run the current checks against that repository.
  • If that PURL is not a repo-based PURL, Macaron would still create a software component entry (see feat!: introduce a new data model and software components based on PURL #305 for more information) but because Macaron could not find a repository path at this stage (upcoming PR would try to address this issue), the checks won't be run against this software component.

Example:

macaron analyze -purl pkg:github.com/apache/maven

Provide PURL with repository path

This is used for the case where the user want to analyze a software component not being a git repository. The repository path is provided from the user to map with that software component.

Note that the branch name and the commit hash must be provide. This enforcement is to prevent Macaron mapping the software component with an incorrect repository snapshot.

Example:

macaron analyze -purl pkg:maven/apache/maven -rp https://github.com/apache/maven -b <branch_name> -d <commit_digest>

@tromai tromai added feature A new feature request cli related to the Command-line Interface purl Related to PURL usage labels Aug 4, 2023
@tromai tromai self-assigned this Aug 4, 2023
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 4, 2023
@tromai tromai force-pushed the 375-accept-purl-identifier-as-cli-input branch 3 times, most recently from 75c3e6e to f3375ef Compare August 14, 2023 05:29
@tromai tromai force-pushed the 375-accept-purl-identifier-as-cli-input branch 2 times, most recently from e195002 to 145c2ac Compare August 17, 2023 02:05
@tromai tromai marked this pull request as ready for review August 17, 2023 02:06
@tromai tromai requested a review from behnazh-w as a code owner August 17, 2023 02:06
@tromai tromai changed the title feat: add purl as a CLI options (WIP) feat: add purl as a CLI options Aug 17, 2023
@behnazh-w behnazh-w requested a review from benmss August 17, 2023 02:13
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
@tromai tromai linked an issue Aug 22, 2023 that may be closed by this pull request
@benmss
Copy link
Member

benmss commented Aug 22, 2023

I have no further suggestions or comments for this PR. The only minor comments I could raise relate to the functions that will be moved into the Repo Finder as part of PR 388. I see no reason to discuss them here when that PR will change them anyway, and is blocked by this one.

@tromai tromai force-pushed the 375-accept-purl-identifier-as-cli-input branch from 7a84f6f to fe7d780 Compare August 23, 2023 00:03
…ith PURL and repository path

Signed-off-by: Trong Nhan Mai <[email protected]>
src/macaron/slsa_analyzer/analyzer.py Outdated Show resolved Hide resolved
This method is used to handle the cases where the purl type value is not the git domain but a pre-defined
repo-based type in https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst.

Note that this method will be updated when there are new pre-defined type as per the PURL specification.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note that this method will be updated when there are new pre-defined type as per the PURL specification.
Note that this method will be updated when there are new pre-defined types as per the PURL specification.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f66b0be

docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved

pkg:<git_service_domain>/<organization>/<name>

The list bellow shows examples for the corresponding PURL string for different git repositories:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The list bellow shows examples for the corresponding PURL string for different git repositories:
The list bellow shows examples for the corresponding PURL strings for different git repositories:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 229e039

docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
docs/source/pages/using.rst Outdated Show resolved Hide resolved
scripts/dev_scripts/integration_tests.sh Outdated Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/__main__.py Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/__main__.py Outdated Show resolved Hide resolved
src/macaron/slsa_analyzer/analyzer.py Outdated Show resolved Hide resolved
src/macaron/slsa_analyzer/analyzer.py Show resolved Hide resolved
@tromai tromai merged commit 2d6871f into staging Aug 28, 2023
12 checks passed
@tromai tromai deleted the 375-accept-purl-identifier-as-cli-input branch August 28, 2023 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to the Command-line Interface feature A new feature request OCA Verified All contributors have signed the Oracle Contributor Agreement. purl Related to PURL usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accept PURL identifier as CLI input
3 participants