generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 30
feat: prepare Macaron GitHub Action to publish on GitHub Marketplace #1259
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7d7104b
docs: update documentation for macaron action
Demolus13 d0097d2
test: update path of test resource
Demolus13 dceae4e
docs: update docs on how to setup macaron
Demolus13 7965fde
docs: update docs and macaron setup script in macaron action
Demolus13 ac1b5c7
chore: check for macaron_image_tag for latest
Demolus13 5842f6d
chore: handle macaron_image_tag to get the macaron version
Demolus13 7575b6a
chore: get tags from repository
Demolus13 c4579bf
chore: get git tag from action repository
Demolus13 e15b37e
chore: set macaron output directory
Demolus13 e8f877b
docs: use hash in action quick usage example
Demolus13 f89a940
docs: update docs and action scripts
Demolus13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -184,7 +184,7 @@ jobs: | |
| package_url: pkg:maven/io.github.behnazh-w.demo/[email protected]?type=jar | ||
| repo_path: https://github.com/behnazh-w/example-maven-app | ||
| output_dir: macaron_output/detect_malicious_java_dep | ||
| sbom_path: ./resources/detect_malicious_java_dep/example-sbom.json | ||
| sbom_path: ./tests/tutorial_resources/detect_malicious_java_dep/example-sbom.json | ||
| deps_depth: '1' | ||
|
|
||
| - name: Run Macaron (verify policy - detect-malicious-upload) | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,11 +4,27 @@ | |
|
|
||
|  | ||
|
|
||
| [Full Documentation](https://oracle.github.io/macaron/index.html) | [Tutorials](https://oracle.github.io/macaron/pages/tutorials/index.html) | [Videos](https://www.youtube.com/watch?v=ebo0kGKP6bw) | [Papers](#publications) | [Presentations](#presentations) | ||
| [Full Documentation](https://oracle.github.io/macaron/index.html) | [Tutorials](https://oracle.github.io/macaron/pages/tutorials/index.html) | [Videos](https://www.youtube.com/watch?v=ebo0kGKP6bw) | [Papers](#publications) | [Presentations](#presentations) | [Macaron GitHub Action](https://oracle.github.io/macaron/pages/macaron_action.html) | ||
|
|
||
|
|
||
| **Macaron** is a software supply chain security analysis tool from Oracle Labs focused on verifying the **build integrity** of artifacts and their dependencies. It helps developers, security teams, and researchers ensure that packages are built as expected and have not been tampered with. | ||
|
|
||
| Use Macaron as a GitHub Action | ||
|
|
||
| To use the Macaron GitHub Action, add the following step to your workflow (adjust the version as needed). In this example, we use an example policy. For detailed instructions and a comprehensive list of available options, please refer to the [Macaron GitHub Action documentation](https://oracle.github.io/macaron/pages/macaron_action.html). | ||
|
|
||
| ```yaml | ||
| - uses: oracle/[email protected] | ||
| with: | ||
| repo_path: 'https://github.com/example/project' | ||
| policy_file: check-github-actions | ||
| policy_purl: 'pkg:github.com/example/project' | ||
| output_dir: 'macaron-output' | ||
| upload_attestation: true | ||
| ``` | ||
|
|
||
behnazh-w marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| For detailed instructions and a comprehensive list of available options, please refer to the [Macaron GitHub Action documentation](https://oracle.github.io/macaron/pages/macaron_action.html). | ||
|
|
||
| ## Key Capabilities | ||
|
|
||
| Macaron supports: | ||
|
|
||
This file contains hidden or 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 hidden or 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
behnazh-w marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,175 @@ | ||
| Macaron GitHub Action | ||
| ===================== | ||
|
|
||
| Overview | ||
| -------- | ||
|
|
||
| This document describes the composite GitHub Action defined in ``action.yaml`` at the repository root. The action uses the Macaron CLI to run supply-chain security analysis and policy verification from a GitHub Actions workflow. | ||
|
|
||
| Quick usage | ||
| ----------- | ||
|
|
||
| When using this action you can reference the action in your workflow. Example: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| jobs: | ||
| analyze: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| - name: Run Macaron Security Analysis | ||
| uses: oracle/[email protected] | ||
| with: | ||
| repo_path: 'https://github.com/example/project' | ||
| policy_file: check-github-actions | ||
| policy_purl: 'pkg:github.com/example/project' | ||
| output_dir: 'macaron-output' | ||
| upload_attestation: true | ||
|
|
||
| Example: policy verification only | ||
| ---------------------------------- | ||
|
|
||
| To run only the policy verification step (when you already have an output | ||
| database), call the action with ``policy_file`` and set ``output_dir`` to the | ||
| directory containing ``macaron.db``: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| - name: Verify policy | ||
| uses: oracle/[email protected] | ||
| with: | ||
| policy_file: policy.dl | ||
| output_dir: macaron-output | ||
| upload_attestation: true | ||
|
|
||
| Inputs | ||
| ------ | ||
| The action exposes a number of inputs which map directly to Macaron CLI | ||
| options. Key inputs are listed below (see ``action.yaml`` for the full list): | ||
behnazh-w marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 20 60 20 | ||
|
|
||
| * - Input | ||
| - Description | ||
| - Default | ||
| * - ``repo_path`` | ||
| - The path or URL of the repository to analyze. | ||
| - | ||
| * - ``package_url`` | ||
| - A PURL identifying a package to analyze instead of a repository. | ||
| - | ||
| * - ``sbom_path`` | ||
| - Path to an SBOM file to analyze. | ||
| - | ||
| * - ``python_venv`` | ||
| - Path to an existing Python virtualenv (used when analyzing Python | ||
| packages). | ||
| - | ||
| * - ``defaults_path`` | ||
| - Path to a Macaron defaults configuration file. | ||
| - | ||
| * - ``policy_file`` | ||
| - Path to a Datalog policy file for policy verification. | ||
| - | ||
| * - ``policy_purl`` | ||
| - PURL for a pre-defined policy to use with verification. | ||
| - | ||
| * - ``branch`` / ``digest`` | ||
| - Checkout options when analyzing a repository (branch name or commit | ||
| digest). | ||
| - | ||
| * - ``provenance_expectation`` | ||
| - The path to provenance expectation file or directory. | ||
| - | ||
| * - ``provenance_file`` | ||
| - The path to the provenance file in in-toto format. | ||
| - | ||
| * - ``deps_depth`` | ||
| - Dependency resolution depth (how many levels of transitive dependencies | ||
| to resolve). | ||
| - ``0`` | ||
| * - ``show_prelude`` | ||
| - Shows the Datalog prelude for the database. | ||
| - | ||
| * - ``github_token`` | ||
| - Token used by Macaron to access GitHub (for cloning, API access, | ||
| etc.). | ||
| - ``${{ github.token }}`` | ||
| * - ``output_dir`` | ||
| - Directory where Macaron writes results (database, reports, artifacts). | ||
| - ``output`` | ||
| * - ``upload_attestation`` | ||
| - When ``true``, the action will attempt to upload a generated | ||
| verification attestation (VSA) after policy verification. | ||
| - ``false`` | ||
| * - ``subject_path`` | ||
| - Path to the artifact serving as the subject of the attestation. | ||
| - ``${{ github.workspace }}`` | ||
|
|
||
| Outputs | ||
| ------- | ||
|
|
||
| The composite action exposes the following outputs (set by the | ||
| ``run_macaron_policy_verification.sh`` script when applicable): | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 20 70 | ||
|
|
||
| * - Output | ||
| - Description | ||
| * - ``policy_report`` | ||
| - Path to the generated policy report JSON file produced by | ||
| ``macaron verify-policy``. This file contains the policy evaluation | ||
| results. | ||
| * - ``vsa_report`` | ||
| - Path to the generated VSA (Verification Summary Attestation) in | ||
| `in-toto <https://in-toto.io/>`_ JSONL format. If no VSA was produced | ||
| during verification, the action emits the string ``"VSA Not Generated."`` | ||
| instead of a path. | ||
|
|
||
| Default Policies | ||
| ---------------- | ||
|
|
||
| Macaron provides policy templates to run pre-defined policies: | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 20 60 20 | ||
|
|
||
| * - Policy name | ||
| - Description | ||
| - Template | ||
| * - ``check-github-actions`` | ||
| - Detects whether a component was built using GitHub Actions that | ||
| are known to be vulnerable or otherwise unsafe. The policy | ||
| evaluates a check named `mcn_githubactions_vulnerabilities_1` and | ||
| reports a passed/failed result for the component when applied. | ||
| - `check-github-actions template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/check-github-actions.dl.template>`_ | ||
| * - ``malware-detection`` | ||
| - Checks a component for indicators of malicious or suspicious content. | ||
| The policy evaluates a check named mcn_detect_malicious_metadata_1 | ||
| and reports a passed/failed result for the component when applied. | ||
| - `malware-detection template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/malware-detection.dl.template>`_ | ||
| * - ``malware-detection-dependencies`` | ||
| - Checks the component and its transitive dependencies for indicators | ||
| of malicious or suspicious content. The policy ensures the component | ||
| and each dependency pass the `mcn_detect_malicious_metadata_1` check. | ||
| - `malware-detection-dependencies template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/malware-detection-dependencies.dl.template>`_ | ||
|
|
||
| How the action works | ||
| -------------------- | ||
|
|
||
| 1. ``Setup Macaron``: downloads ``run_macaron.sh`` script to install and run macaron in the action. | ||
|
|
||
| 2. ``Run Macaron Analysis``: calls ``scripts/actions/run_macaron_analysis.sh`` | ||
| which assembles the ``macaron analyze`` command from the inputs and runs | ||
| it. Results are written into ``output_dir``. | ||
|
|
||
| 3. ``Run Macaron Policy Verification``: if a policy file or PURL is supplied, | ||
| the corresponding script runs ``macaron verify-policy`` against the | ||
| analysis database and writes ``policy_report`` and ``vsa_report`` to | ||
| ``$GITHUB_OUTPUT`` when produced. | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.