|
| 1 | +Macaron GitHub Action |
| 2 | +===================== |
| 3 | + |
| 4 | +Overview |
| 5 | +-------- |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +Quick usage |
| 10 | +----------- |
| 11 | + |
| 12 | +When using this action you can reference the action in your workflow. Example: |
| 13 | + |
| 14 | +.. code-block:: yaml |
| 15 | +
|
| 16 | + jobs: |
| 17 | + analyze: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 21 | + - name: Run Macaron Security Analysis |
| 22 | + |
| 23 | + with: |
| 24 | + repo_path: 'https://github.com/example/project' |
| 25 | + policy_file: check-github-actions |
| 26 | + policy_purl: 'pkg:github.com/example/project' |
| 27 | + output_dir: 'macaron-output' |
| 28 | + upload_attestation: true |
| 29 | +
|
| 30 | +Example: policy verification only |
| 31 | +---------------------------------- |
| 32 | + |
| 33 | +To run only the policy verification step (when you already have an output |
| 34 | +database), call the action with ``policy_file`` and set ``output_dir`` to the |
| 35 | +directory containing ``macaron.db``: |
| 36 | + |
| 37 | +.. code-block:: yaml |
| 38 | +
|
| 39 | + - name: Verify policy |
| 40 | + |
| 41 | + with: |
| 42 | + policy_file: policy.dl |
| 43 | + output_dir: macaron-output |
| 44 | + upload_attestation: true |
| 45 | +
|
| 46 | +Inputs |
| 47 | +------ |
| 48 | +The action exposes a number of inputs which map directly to Macaron CLI |
| 49 | +options. Key inputs are listed below (see ``action.yaml`` for the full list): |
| 50 | + |
| 51 | +.. list-table:: |
| 52 | + :header-rows: 1 |
| 53 | + :widths: 20 60 20 |
| 54 | + |
| 55 | + * - Input |
| 56 | + - Description |
| 57 | + - Default |
| 58 | + * - ``repo_path`` |
| 59 | + - The path or URL of the repository to analyze. |
| 60 | + - |
| 61 | + * - ``package_url`` |
| 62 | + - A PURL identifying a package to analyze instead of a repository. |
| 63 | + - |
| 64 | + * - ``sbom_path`` |
| 65 | + - Path to an SBOM file to analyze. |
| 66 | + - |
| 67 | + * - ``python_venv`` |
| 68 | + - Path to an existing Python virtualenv (used when analyzing Python |
| 69 | + packages). |
| 70 | + - |
| 71 | + * - ``defaults_path`` |
| 72 | + - Path to a Macaron defaults configuration file. |
| 73 | + - |
| 74 | + * - ``policy_file`` |
| 75 | + - Path to a Datalog policy file for policy verification. |
| 76 | + - |
| 77 | + * - ``policy_purl`` |
| 78 | + - PURL for a pre-defined policy to use with verification. |
| 79 | + - |
| 80 | + * - ``branch`` / ``digest`` |
| 81 | + - Checkout options when analyzing a repository (branch name or commit |
| 82 | + digest). |
| 83 | + - |
| 84 | + * - ``provenance_expectation`` |
| 85 | + - The path to provenance expectation file or directory. |
| 86 | + - |
| 87 | + * - ``provenance_file`` |
| 88 | + - The path to the provenance file in in-toto format. |
| 89 | + - |
| 90 | + * - ``deps_depth`` |
| 91 | + - Dependency resolution depth (how many levels of transitive dependencies |
| 92 | + to resolve). |
| 93 | + - ``0`` |
| 94 | + * - ``show_prelude`` |
| 95 | + - Shows the Datalog prelude for the database. |
| 96 | + - |
| 97 | + * - ``github_token`` |
| 98 | + - Token used by Macaron to access GitHub (for cloning, API access, |
| 99 | + etc.). |
| 100 | + - ``${{ github.token }}`` |
| 101 | + * - ``output_dir`` |
| 102 | + - Directory where Macaron writes results (database, reports, artifacts). |
| 103 | + - ``output`` |
| 104 | + * - ``upload_attestation`` |
| 105 | + - When ``true``, the action will attempt to upload a generated |
| 106 | + verification attestation (VSA) after policy verification. |
| 107 | + - ``false`` |
| 108 | + * - ``subject_path`` |
| 109 | + - Path to the artifact serving as the subject of the attestation. |
| 110 | + - ``${{ github.workspace }}`` |
| 111 | + |
| 112 | +Outputs |
| 113 | +------- |
| 114 | + |
| 115 | +The composite action exposes the following outputs (set by the |
| 116 | +``run_macaron_policy_verification.sh`` script when applicable): |
| 117 | + |
| 118 | +.. list-table:: |
| 119 | + :header-rows: 1 |
| 120 | + :widths: 20 70 |
| 121 | + |
| 122 | + * - Output |
| 123 | + - Description |
| 124 | + * - ``policy_report`` |
| 125 | + - Path to the generated policy report JSON file produced by |
| 126 | + ``macaron verify-policy``. This file contains the policy evaluation |
| 127 | + results. |
| 128 | + * - ``vsa_report`` |
| 129 | + - Path to the generated VSA (Verification Summary Attestation) in |
| 130 | + `in-toto <https://in-toto.io/>`_ JSONL format. If no VSA was produced |
| 131 | + during verification, the action emits the string ``"VSA Not Generated."`` |
| 132 | + instead of a path. |
| 133 | + |
| 134 | +Default Policies |
| 135 | +---------------- |
| 136 | + |
| 137 | +Macaron provides policy templates to run pre-defined policies: |
| 138 | + |
| 139 | +.. list-table:: |
| 140 | + :header-rows: 1 |
| 141 | + :widths: 20 60 20 |
| 142 | + |
| 143 | + * - Policy name |
| 144 | + - Description |
| 145 | + - Template |
| 146 | + * - ``check-github-actions`` |
| 147 | + - Detects whether a component was built using GitHub Actions that |
| 148 | + are known to be vulnerable or otherwise unsafe. The policy |
| 149 | + evaluates a check named `mcn_githubactions_vulnerabilities_1` and |
| 150 | + reports a passed/failed result for the component when applied. |
| 151 | + - `check-github-actions template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/check-github-actions.dl.template>`_ |
| 152 | + * - ``malware-detection`` |
| 153 | + - Checks a component for indicators of malicious or suspicious content. |
| 154 | + The policy evaluates a check named mcn_detect_malicious_metadata_1 |
| 155 | + and reports a passed/failed result for the component when applied. |
| 156 | + - `malware-detection template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/malware-detection.dl.template>`_ |
| 157 | + * - ``malware-detection-dependencies`` |
| 158 | + - Checks the component and its transitive dependencies for indicators |
| 159 | + of malicious or suspicious content. The policy ensures the component |
| 160 | + and each dependency pass the `mcn_detect_malicious_metadata_1` check. |
| 161 | + - `malware-detection-dependencies template <https://github.com/oracle/macaron/blob/main/src/macaron/resources/policies/datalog/malware-detection-dependencies.dl.template>`_ |
| 162 | + |
| 163 | +How the action works |
| 164 | +-------------------- |
| 165 | + |
| 166 | +1. ``Setup Macaron``: downloads ``run_macaron.sh`` script to install and run macaron in the action. |
| 167 | + |
| 168 | +2. ``Run Macaron Analysis``: calls ``scripts/actions/run_macaron_analysis.sh`` |
| 169 | + which assembles the ``macaron analyze`` command from the inputs and runs |
| 170 | + it. Results are written into ``output_dir``. |
| 171 | + |
| 172 | +3. ``Run Macaron Policy Verification``: if a policy file or PURL is supplied, |
| 173 | + the corresponding script runs ``macaron verify-policy`` against the |
| 174 | + analysis database and writes ``policy_report`` and ``vsa_report`` to |
| 175 | + ``$GITHUB_OUTPUT`` when produced. |
0 commit comments