diff options
| author | Jeff Glaum <[email protected]> | 2025-09-08 15:15:38 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-08 15:15:38 -0700 |
| commit | 47e383545f4aac3bfaec0563429cc721540e665a (patch) | |
| tree | 14a65826c3b38cd86bfa26d28866c56835e3e8e3 | |
Initial commit
| -rw-r--r-- | .github/workflows/cargo-vet-pr-comment.yml | 137 | ||||
| -rw-r--r-- | .github/workflows/cargo-vet.yml | 53 | ||||
| -rw-r--r-- | .github/workflows/check.yml | 169 | ||||
| -rw-r--r-- | .github/workflows/nostd.yml | 30 | ||||
| -rw-r--r-- | .gitignore | 14 | ||||
| -rw-r--r-- | .vscode/settings.json | 14 | ||||
| -rw-r--r-- | CODEOWNERS | 1 | ||||
| -rw-r--r-- | CODE_OF_CONDUCT.md | 132 | ||||
| -rw-r--r-- | CONTRIBUTING.md | 35 | ||||
| -rw-r--r-- | Cargo.toml | 19 | ||||
| -rw-r--r-- | LICENSE | 21 | ||||
| -rw-r--r-- | README.md | 63 | ||||
| -rw-r--r-- | SECURITY.md | 66 | ||||
| -rw-r--r-- | deny.toml | 239 | ||||
| -rw-r--r-- | rust-toolchain.toml | 2 | ||||
| -rw-r--r-- | rustfmt.toml | 1 | ||||
| -rw-r--r-- | src/baremetal/mod.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 18 | ||||
| -rw-r--r-- | supply-chain/README.md | 83 | ||||
| -rw-r--r-- | supply-chain/audits.toml | 4 | ||||
| -rw-r--r-- | supply-chain/config.toml | 14 | ||||
| -rw-r--r-- | supply-chain/imports.lock | 8 |
22 files changed, 1129 insertions, 0 deletions
diff --git a/.github/workflows/cargo-vet-pr-comment.yml b/.github/workflows/cargo-vet-pr-comment.yml new file mode 100644 index 000000000..dd8ef37a6 --- /dev/null +++ b/.github/workflows/cargo-vet-pr-comment.yml | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | # This workflow triggers after cargo-vet workflow has run. | ||
| 2 | # It adds a comment to the PR with the results of the cargo vet run. | ||
| 3 | # It first adds a comment if the cargo vet run fails, | ||
| 4 | # and updates the comment if the cargo vet run succeeds after having failed at least once. | ||
| 5 | |||
| 6 | name: Cargo vet PR comment | ||
| 7 | |||
| 8 | on: | ||
| 9 | workflow_run: | ||
| 10 | workflows: [cargo-vet] | ||
| 11 | types: | ||
| 12 | - completed | ||
| 13 | |||
| 14 | permissions: | ||
| 15 | contents: read | ||
| 16 | pull-requests: write | ||
| 17 | |||
| 18 | concurrency: | ||
| 19 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| 20 | cancel-in-progress: true | ||
| 21 | |||
| 22 | jobs: | ||
| 23 | |||
| 24 | find-pr-comment: | ||
| 25 | # This job runs when the cargo-vet job fails or succeeds | ||
| 26 | # It will download the artifact from the failed job and post a comment on the PR | ||
| 27 | runs-on: ubuntu-latest | ||
| 28 | outputs: | ||
| 29 | comment-id: ${{ steps.get-comment-id.outputs.comment-id }} | ||
| 30 | pr-number: ${{ steps.get-pr-number.outputs.pr_number }} | ||
| 31 | if: github.event.workflow_run.event == 'pull_request' | ||
| 32 | steps: | ||
| 33 | - name: 'Download artifact' | ||
| 34 | uses: actions/download-artifact@v4 | ||
| 35 | with: | ||
| 36 | github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 37 | name: pr | ||
| 38 | path: pr/ | ||
| 39 | run-id: ${{ github.event.workflow_run.id }} | ||
| 40 | |||
| 41 | - name: 'Get PR number' | ||
| 42 | id: get-pr-number | ||
| 43 | run: echo "pr_number=$(cat ./pr/NR)" >> $GITHUB_OUTPUT | ||
| 44 | |||
| 45 | - name: 'Find existing comment' | ||
| 46 | id: find-comment | ||
| 47 | uses: peter-evans/find-comment@v3 | ||
| 48 | with: | ||
| 49 | issue-number: ${{ steps.get-pr-number.outputs.pr_number }} | ||
| 50 | comment-author: 'github-actions[bot]' | ||
| 51 | body-includes: 'comment-tag: [cargo-vet]' | ||
| 52 | |||
| 53 | - name: 'Get comment ID' | ||
| 54 | id: get-comment-id | ||
| 55 | if: ${{ steps.find-comment.outputs.comment-id != '' }} | ||
| 56 | run: echo "comment-id=${{ steps.find-comment.outputs.comment-id }}" >> $GITHUB_OUTPUT | ||
| 57 | |||
| 58 | post-comment-failure: | ||
| 59 | # This job runs when the cargo-vet job fails | ||
| 60 | # It will download the artifact from the failed job and post a comment on the PR | ||
| 61 | runs-on: ubuntu-latest | ||
| 62 | needs: find-pr-comment | ||
| 63 | if: github.event.workflow_run.conclusion == 'failure' | ||
| 64 | steps: | ||
| 65 | - name: 'Comment on PR - Failure' | ||
| 66 | uses: peter-evans/create-or-update-comment@v4 | ||
| 67 | with: | ||
| 68 | comment-id: ${{ needs.find-pr-comment.outputs.comment-id }} | ||
| 69 | issue-number: ${{ needs.find-pr-comment.outputs.pr-number }} | ||
| 70 | body: | | ||
| 71 | # Cargo Vet Audit Failed | ||
| 72 | |||
| 73 | `cargo vet` has failed in this PR. Please run `cargo vet --locked` locally to check for new or updated unvetted dependencies. | ||
| 74 | Details about the vetting process can be found in [supply-chain/README.md](../blob/main/supply-chain/README.md) | ||
| 75 | |||
| 76 | ## If the unvetted dependencies are not needed | ||
| 77 | Please modify Cargo.toml file to avoid including the dependencies. | ||
| 78 | |||
| 79 | ## If the unvetted dependencies are needed | ||
| 80 | Post a new comment with the questionnaire below to the PR to help the auditors vet the dependencies. | ||
| 81 | After the auditors have vetted the dependencies, the PR will need to be rebased to pick up the new audits and pass this check. | ||
| 82 | |||
| 83 | ### Copy and paste the questionnaire as a new comment and provide your answers: | ||
| 84 | |||
| 85 | **1. What crates (with version) need to be audited?** | ||
| 86 | |||
| 87 | **2. How many of the crates are version updates vs new dependencies?** | ||
| 88 | |||
| 89 | **3. To confirm none of the already included crates serve your needs, please provide a brief description of the purpose of the new crates.** | ||
| 90 | |||
| 91 | **4. Any extra notes to the auditors to help with their audits.** | ||
| 92 | |||
| 93 | <!-- | ||
| 94 | This comment is auto-generated by the cargo-vet workflow. | ||
| 95 | Please do not edit it directly. | ||
| 96 | |||
| 97 | comment-tag: [cargo-vet] | ||
| 98 | --> | ||
| 99 | edit-mode: replace | ||
| 100 | |||
| 101 | - name: 'Label PR' | ||
| 102 | uses: actions/github-script@v7 | ||
| 103 | with: | ||
| 104 | script: | | ||
| 105 | github.rest.issues.addLabels({ | ||
| 106 | issue_number: ${{ needs.find-pr-comment.outputs.pr-number }}, | ||
| 107 | owner: context.repo.owner, | ||
| 108 | repo: context.repo.repo, | ||
| 109 | labels: ['cargo vet'] | ||
| 110 | }) | ||
| 111 | |||
| 112 | post-comment-success: | ||
| 113 | # This job runs when the cargo-vet job succeeds | ||
| 114 | # It will update the comment on the PR with a success message | ||
| 115 | runs-on: ubuntu-latest | ||
| 116 | needs: find-pr-comment | ||
| 117 | if: github.event.workflow_run.conclusion == 'success' | ||
| 118 | steps: | ||
| 119 | - name: 'Comment on PR - Success' | ||
| 120 | # Only update the comment if it exists | ||
| 121 | # This is to avoid creating a new comment if the cargo-vet job has never failed before | ||
| 122 | if: ${{ needs.find-pr-comment.outputs.comment-id }} | ||
| 123 | uses: peter-evans/create-or-update-comment@v4 | ||
| 124 | with: | ||
| 125 | comment-id: ${{ needs.find-pr-comment.outputs.comment-id }} | ||
| 126 | issue-number: ${{ needs.find-pr-comment.outputs.pr-number }} | ||
| 127 | body: | | ||
| 128 | # Cargo Vet Audit Passed | ||
| 129 | `cargo vet` has passed in this PR. No new unvetted dependencies were found. | ||
| 130 | |||
| 131 | <!-- | ||
| 132 | This comment is auto-generated by the cargo-vet workflow. | ||
| 133 | Please do not edit it directly. | ||
| 134 | |||
| 135 | comment-tag: [cargo-vet] | ||
| 136 | --> | ||
| 137 | edit-mode: replace \ No newline at end of file | ||
diff --git a/.github/workflows/cargo-vet.yml b/.github/workflows/cargo-vet.yml new file mode 100644 index 000000000..864c138e9 --- /dev/null +++ b/.github/workflows/cargo-vet.yml | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | # This workflow runs whenever a PR is opened or updated. It runs cargo vet to check for unvetted dependencies in the Cargo.lock file. | ||
| 2 | permissions: | ||
| 3 | contents: read | ||
| 4 | on: | ||
| 5 | pull_request: | ||
| 6 | |||
| 7 | concurrency: | ||
| 8 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| 9 | cancel-in-progress: true | ||
| 10 | |||
| 11 | name: cargo-vet | ||
| 12 | jobs: | ||
| 13 | vet: | ||
| 14 | # cargo-vet checks for unvetted dependencies in the Cargo.lock file | ||
| 15 | # This is to ensure that new dependencies are vetted before they are added to the project | ||
| 16 | name: vet-dependencies | ||
| 17 | runs-on: ubuntu-latest | ||
| 18 | env: | ||
| 19 | CARGO_VET_VERSION: 0.10.1 | ||
| 20 | |||
| 21 | steps: | ||
| 22 | - uses: actions/checkout@v4 | ||
| 23 | with: | ||
| 24 | submodules: true | ||
| 25 | |||
| 26 | - uses: actions/cache@v4 | ||
| 27 | with: | ||
| 28 | path: ${{ runner.tool_cache }}/cargo-vet | ||
| 29 | key: cargo-vet-bin-${{ env.CARGO_VET_VERSION }} | ||
| 30 | |||
| 31 | - name: Add the tool cache directory to the search path | ||
| 32 | run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH | ||
| 33 | |||
| 34 | - name: Ensure that the tool cache is populated with the cargo-vet binary | ||
| 35 | run: cargo install --root ${{ runner.tool_cache }}/cargo-vet --version ${{ env.CARGO_VET_VERSION }} cargo-vet | ||
| 36 | |||
| 37 | - name: Invoke cargo-vet | ||
| 38 | run: cargo vet --locked | ||
| 39 | |||
| 40 | - name: Save PR number | ||
| 41 | # PR number is saved as an artifact so it can be used to determine the PR to comment on by the vet-pr-comment workflow | ||
| 42 | # vet-pr-comment workflow is triggered by the workflow_run event so it runs in the context of the base branch and not the PR branch | ||
| 43 | if: ${{ failure() }} || ${{ success() }} | ||
| 44 | run: | | ||
| 45 | mkdir -p ./pr | ||
| 46 | echo ${{ github.event.number }} > ./pr/NR | ||
| 47 | - uses: actions/upload-artifact@v4 | ||
| 48 | # Need to upload the artifact in both success and failure cases so comment can be updated in either case | ||
| 49 | if: ${{ failure() }} || ${{ success() }} | ||
| 50 | with: | ||
| 51 | name: pr | ||
| 52 | path: pr/ | ||
| 53 | overwrite: true \ No newline at end of file | ||
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 000000000..9bf402d61 --- /dev/null +++ b/.github/workflows/check.yml | |||
| @@ -0,0 +1,169 @@ | |||
| 1 | # This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs | ||
| 2 | # several checks: | ||
| 3 | # - commit_list: produces a list of commits to be checked | ||
| 4 | # - fmt: checks that the code is formatted according to rustfmt | ||
| 5 | # - clippy: checks that the code does not contain any clippy warnings | ||
| 6 | # - doc: checks that the code can be documented without errors | ||
| 7 | # - hack: check combinations of feature flags | ||
| 8 | # - msrv: check that the msrv specified in the crate is correct | ||
| 9 | permissions: | ||
| 10 | contents: read | ||
| 11 | # This configuration allows maintainers of this repo to create a branch and pull request based on | ||
| 12 | # the new branch. Restricting the push trigger to the main branch ensures that the PR only gets | ||
| 13 | # built once. | ||
| 14 | on: | ||
| 15 | push: | ||
| 16 | branches: [main] | ||
| 17 | pull_request: | ||
| 18 | # If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that | ||
| 19 | # we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 | ||
| 20 | concurrency: | ||
| 21 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| 22 | cancel-in-progress: true | ||
| 23 | name: check | ||
| 24 | jobs: | ||
| 25 | fmt: | ||
| 26 | runs-on: ubuntu-latest | ||
| 27 | name: stable / fmt | ||
| 28 | steps: | ||
| 29 | - uses: actions/checkout@v4 | ||
| 30 | with: | ||
| 31 | submodules: true | ||
| 32 | - name: Install stable | ||
| 33 | uses: dtolnay/rust-toolchain@stable | ||
| 34 | with: | ||
| 35 | components: rustfmt | ||
| 36 | - name: cargo fmt --check | ||
| 37 | run: cargo fmt --check | ||
| 38 | |||
| 39 | clippy: | ||
| 40 | runs-on: ubuntu-latest | ||
| 41 | name: ${{ matrix.toolchain }} / clippy | ||
| 42 | permissions: | ||
| 43 | contents: read | ||
| 44 | checks: write | ||
| 45 | strategy: | ||
| 46 | fail-fast: false | ||
| 47 | matrix: | ||
| 48 | # Get early warning of new lints which are regularly introduced in beta channels. | ||
| 49 | toolchain: [stable, beta] | ||
| 50 | steps: | ||
| 51 | - uses: actions/checkout@v4 | ||
| 52 | with: | ||
| 53 | submodules: true | ||
| 54 | - name: Install ${{ matrix.toolchain }} | ||
| 55 | uses: dtolnay/rust-toolchain@master | ||
| 56 | with: | ||
| 57 | toolchain: ${{ matrix.toolchain }} | ||
| 58 | components: clippy | ||
| 59 | - name: cargo clippy | ||
| 60 | uses: giraffate/clippy-action@v1 | ||
| 61 | with: | ||
| 62 | reporter: 'github-pr-check' | ||
| 63 | github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| 64 | |||
| 65 | # Enable once we have a released crate | ||
| 66 | # semver: | ||
| 67 | # runs-on: ubuntu-latest | ||
| 68 | # name: semver | ||
| 69 | # strategy: | ||
| 70 | # fail-fast: false | ||
| 71 | # steps: | ||
| 72 | # - uses: actions/checkout@v4 | ||
| 73 | # with: | ||
| 74 | # submodules: true | ||
| 75 | # - name: Install stable | ||
| 76 | # uses: dtolnay/rust-toolchain@stable | ||
| 77 | # with: | ||
| 78 | # components: rustfmt | ||
| 79 | # - name: cargo-semver-checks | ||
| 80 | # uses: obi1kenobi/cargo-semver-checks-action@v2 | ||
| 81 | |||
| 82 | doc: | ||
| 83 | # run docs generation on nightly rather than stable. This enables features like | ||
| 84 | # https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an | ||
| 85 | # API be documented as only available in some specific platforms. | ||
| 86 | runs-on: ubuntu-latest | ||
| 87 | name: nightly / doc | ||
| 88 | steps: | ||
| 89 | - uses: actions/checkout@v4 | ||
| 90 | with: | ||
| 91 | submodules: true | ||
| 92 | - name: Install nightly | ||
| 93 | uses: dtolnay/rust-toolchain@nightly | ||
| 94 | - name: cargo doc | ||
| 95 | run: cargo doc --no-deps --all-features | ||
| 96 | env: | ||
| 97 | RUSTDOCFLAGS: --cfg docsrs | ||
| 98 | |||
| 99 | hack: | ||
| 100 | # cargo-hack checks combinations of feature flags to ensure that features are all additive | ||
| 101 | # which is required for feature unification | ||
| 102 | runs-on: ubuntu-latest | ||
| 103 | name: ubuntu / stable / features | ||
| 104 | steps: | ||
| 105 | - uses: actions/checkout@v4 | ||
| 106 | with: | ||
| 107 | submodules: true | ||
| 108 | - name: Install stable | ||
| 109 | uses: dtolnay/rust-toolchain@stable | ||
| 110 | - name: cargo install cargo-hack | ||
| 111 | uses: taiki-e/install-action@cargo-hack | ||
| 112 | # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4 | ||
| 113 | # --feature-powerset runs for every combination of features | ||
| 114 | - name: cargo hack | ||
| 115 | run: cargo hack --feature-powerset check | ||
| 116 | |||
| 117 | deny: | ||
| 118 | # cargo-deny checks licenses, advisories, sources, and bans for | ||
| 119 | # our dependencies. | ||
| 120 | runs-on: ubuntu-latest | ||
| 121 | name: ubuntu / stable / deny | ||
| 122 | steps: | ||
| 123 | - uses: actions/checkout@v4 | ||
| 124 | with: | ||
| 125 | submodules: true | ||
| 126 | - name: Install stable | ||
| 127 | uses: dtolnay/rust-toolchain@stable | ||
| 128 | - name: cargo install cargo-deny | ||
| 129 | uses: EmbarkStudios/cargo-deny-action@v2 | ||
| 130 | with: | ||
| 131 | log-level: warn | ||
| 132 | manifest-path: ./Cargo.toml | ||
| 133 | command: check | ||
| 134 | arguments: --all-features | ||
| 135 | |||
| 136 | test: | ||
| 137 | runs-on: ubuntu-latest | ||
| 138 | name: ubuntu / stable / test | ||
| 139 | steps: | ||
| 140 | - uses: actions/checkout@v4 | ||
| 141 | with: | ||
| 142 | submodules: true | ||
| 143 | - name: Install stable | ||
| 144 | uses: dtolnay/rust-toolchain@stable | ||
| 145 | - name: cargo install cargo-hack | ||
| 146 | uses: taiki-e/install-action@cargo-hack | ||
| 147 | - name: cargo test | ||
| 148 | run: cargo hack --feature-powerset test | ||
| 149 | |||
| 150 | msrv: | ||
| 151 | # check that we can build using the minimal rust version that is specified by this crate | ||
| 152 | runs-on: ubuntu-latest | ||
| 153 | # we use a matrix here just because env can't be used in job names | ||
| 154 | # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability | ||
| 155 | strategy: | ||
| 156 | fail-fast: false | ||
| 157 | matrix: | ||
| 158 | msrv: ["1.85"] | ||
| 159 | name: ubuntu / ${{ matrix.msrv }} | ||
| 160 | steps: | ||
| 161 | - uses: actions/checkout@v4 | ||
| 162 | with: | ||
| 163 | submodules: true | ||
| 164 | - name: Install ${{ matrix.msrv }} | ||
| 165 | uses: dtolnay/rust-toolchain@master | ||
| 166 | with: | ||
| 167 | toolchain: ${{ matrix.msrv }} | ||
| 168 | - name: cargo +${{ matrix.msrv }} check | ||
| 169 | run: cargo check | ||
diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml new file mode 100644 index 000000000..532235851 --- /dev/null +++ b/.github/workflows/nostd.yml | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | # This workflow checks whether the library is able to run without the std library (e.g., embedded). | ||
| 2 | # This entire file should be removed if this crate does not support no-std. See check.yml for | ||
| 3 | # information about how the concurrency cancellation and workflow triggering works | ||
| 4 | permissions: | ||
| 5 | contents: read | ||
| 6 | on: | ||
| 7 | push: | ||
| 8 | branches: [main] | ||
| 9 | pull_request: | ||
| 10 | concurrency: | ||
| 11 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| 12 | cancel-in-progress: true | ||
| 13 | name: no-std | ||
| 14 | jobs: | ||
| 15 | nostd: | ||
| 16 | runs-on: ubuntu-latest | ||
| 17 | name: ${{ matrix.target }} | ||
| 18 | strategy: | ||
| 19 | matrix: | ||
| 20 | target: [thumbv8m.main-none-eabihf] | ||
| 21 | steps: | ||
| 22 | - uses: actions/checkout@v4 | ||
| 23 | with: | ||
| 24 | submodules: true | ||
| 25 | - name: Install stable | ||
| 26 | uses: dtolnay/rust-toolchain@stable | ||
| 27 | - name: rustup target add ${{ matrix.target }} | ||
| 28 | run: rustup target add ${{ matrix.target }} | ||
| 29 | - name: cargo check | ||
| 30 | run: cargo check --target ${{ matrix.target }} | ||
diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6985cf1bd --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | # Generated by Cargo | ||
| 2 | # will have compiled files and executables | ||
| 3 | debug/ | ||
| 4 | target/ | ||
| 5 | |||
| 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
| 7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
| 8 | Cargo.lock | ||
| 9 | |||
| 10 | # These are backup files generated by rustfmt | ||
| 11 | **/*.rs.bk | ||
| 12 | |||
| 13 | # MSVC Windows builds of rustc generate these, which store debugging information | ||
| 14 | *.pdb | ||
diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..ace00d468 --- /dev/null +++ b/.vscode/settings.json | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | { | ||
| 2 | "editor.formatOnSave": true, | ||
| 3 | "rust-analyzer.checkOnSave": true, | ||
| 4 | "rust-analyzer.check.allTargets": false, | ||
| 5 | "rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf", | ||
| 6 | "rust-analyzer.cargo.features": "all", | ||
| 7 | "rust-analyzer.check.command": "clippy", | ||
| 8 | "[toml]": { | ||
| 9 | "editor.defaultFormatter": "tamasfe.even-better-toml" | ||
| 10 | }, | ||
| 11 | "[rust]": { | ||
| 12 | "editor.defaultFormatter": "rust-lang.rust-analyzer" | ||
| 13 | } | ||
| 14 | } | ||
diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 000000000..e2a52ae39 --- /dev/null +++ b/CODEOWNERS | |||
| @@ -0,0 +1 @@ | |||
| * @felipebalbi @jerrysxie @tullom @RobertZ2011 @dymk | |||
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..8603671fb --- /dev/null +++ b/CODE_OF_CONDUCT.md | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | # Contributor Covenant Code of Conduct | ||
| 2 | |||
| 3 | ## Our Pledge | ||
| 4 | |||
| 5 | We as members, contributors, and leaders pledge to make participation in our | ||
| 6 | community a harassment-free experience for everyone, regardless of age, body | ||
| 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender | ||
| 8 | identity and expression, level of experience, education, socio-economic status, | ||
| 9 | nationality, personal appearance, race, caste, color, religion, or sexual | ||
| 10 | identity and orientation. | ||
| 11 | |||
| 12 | We pledge to act and interact in ways that contribute to an open, welcoming, | ||
| 13 | diverse, inclusive, and healthy community. | ||
| 14 | |||
| 15 | ## Our Standards | ||
| 16 | |||
| 17 | Examples of behavior that contributes to a positive environment for our | ||
| 18 | community include: | ||
| 19 | |||
| 20 | * Demonstrating empathy and kindness toward other people | ||
| 21 | * Being respectful of differing opinions, viewpoints, and experiences | ||
| 22 | * Giving and gracefully accepting constructive feedback | ||
| 23 | * Accepting responsibility and apologizing to those affected by our mistakes, | ||
| 24 | and learning from the experience | ||
| 25 | * Focusing on what is best not just for us as individuals, but for the overall | ||
| 26 | community | ||
| 27 | |||
| 28 | Examples of unacceptable behavior include: | ||
| 29 | |||
| 30 | * The use of sexualized language or imagery, and sexual attention or advances of | ||
| 31 | any kind | ||
| 32 | * Trolling, insulting or derogatory comments, and personal or political attacks | ||
| 33 | * Public or private harassment | ||
| 34 | * Publishing others' private information, such as a physical or email address, | ||
| 35 | without their explicit permission | ||
| 36 | * Other conduct which could reasonably be considered inappropriate in a | ||
| 37 | professional setting | ||
| 38 | |||
| 39 | ## Enforcement Responsibilities | ||
| 40 | |||
| 41 | Community leaders are responsible for clarifying and enforcing our standards of | ||
| 42 | acceptable behavior and will take appropriate and fair corrective action in | ||
| 43 | response to any behavior that they deem inappropriate, threatening, offensive, | ||
| 44 | or harmful. | ||
| 45 | |||
| 46 | Community leaders have the right and responsibility to remove, edit, or reject | ||
| 47 | comments, commits, code, wiki edits, issues, and other contributions that are | ||
| 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation | ||
| 49 | decisions when appropriate. | ||
| 50 | |||
| 51 | ## Scope | ||
| 52 | |||
| 53 | This Code of Conduct applies within all community spaces, and also applies when | ||
| 54 | an individual is officially representing the community in public spaces. | ||
| 55 | Examples of representing our community include using an official e-mail address, | ||
| 56 | posting via an official social media account, or acting as an appointed | ||
| 57 | representative at an online or offline event. | ||
| 58 | |||
| 59 | ## Enforcement | ||
| 60 | |||
| 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
| 62 | reported to the community leaders responsible for enforcement at | ||
| 63 | [email protected]. | ||
| 64 | All complaints will be reviewed and investigated promptly and fairly. | ||
| 65 | |||
| 66 | All community leaders are obligated to respect the privacy and security of the | ||
| 67 | reporter of any incident. | ||
| 68 | |||
| 69 | ## Enforcement Guidelines | ||
| 70 | |||
| 71 | Community leaders will follow these Community Impact Guidelines in determining | ||
| 72 | the consequences for any action they deem in violation of this Code of Conduct: | ||
| 73 | |||
| 74 | ### 1. Correction | ||
| 75 | |||
| 76 | **Community Impact**: Use of inappropriate language or other behavior deemed | ||
| 77 | unprofessional or unwelcome in the community. | ||
| 78 | |||
| 79 | **Consequence**: A private, written warning from community leaders, providing | ||
| 80 | clarity around the nature of the violation and an explanation of why the | ||
| 81 | behavior was inappropriate. A public apology may be requested. | ||
| 82 | |||
| 83 | ### 2. Warning | ||
| 84 | |||
| 85 | **Community Impact**: A violation through a single incident or series of | ||
| 86 | actions. | ||
| 87 | |||
| 88 | **Consequence**: A warning with consequences for continued behavior. No | ||
| 89 | interaction with the people involved, including unsolicited interaction with | ||
| 90 | those enforcing the Code of Conduct, for a specified period of time. This | ||
| 91 | includes avoiding interactions in community spaces as well as external channels | ||
| 92 | like social media. Violating these terms may lead to a temporary or permanent | ||
| 93 | ban. | ||
| 94 | |||
| 95 | ### 3. Temporary Ban | ||
| 96 | |||
| 97 | **Community Impact**: A serious violation of community standards, including | ||
| 98 | sustained inappropriate behavior. | ||
| 99 | |||
| 100 | **Consequence**: A temporary ban from any sort of interaction or public | ||
| 101 | communication with the community for a specified period of time. No public or | ||
| 102 | private interaction with the people involved, including unsolicited interaction | ||
| 103 | with those enforcing the Code of Conduct, is allowed during this period. | ||
| 104 | Violating these terms may lead to a permanent ban. | ||
| 105 | |||
| 106 | ### 4. Permanent Ban | ||
| 107 | |||
| 108 | **Community Impact**: Demonstrating a pattern of violation of community | ||
| 109 | standards, including sustained inappropriate behavior, harassment of an | ||
| 110 | individual, or aggression toward or disparagement of classes of individuals. | ||
| 111 | |||
| 112 | **Consequence**: A permanent ban from any sort of public interaction within the | ||
| 113 | community. | ||
| 114 | |||
| 115 | ## Attribution | ||
| 116 | |||
| 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], | ||
| 118 | version 2.1, available at | ||
| 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. | ||
| 120 | |||
| 121 | Community Impact Guidelines were inspired by | ||
| 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. | ||
| 123 | |||
| 124 | For answers to common questions about this code of conduct, see the FAQ at | ||
| 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at | ||
| 126 | [https://www.contributor-covenant.org/translations][translations]. | ||
| 127 | |||
| 128 | [homepage]: https://www.contributor-covenant.org | ||
| 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html | ||
| 130 | [Mozilla CoC]: https://github.com/mozilla/diversity | ||
| 131 | [FAQ]: https://www.contributor-covenant.org/faq | ||
| 132 | [translations]: https://www.contributor-covenant.org/translations \ No newline at end of file | ||
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..c45bc8e43 --- /dev/null +++ b/CONTRIBUTING.md | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | # Contributing to Open Device Partnership | ||
| 2 | |||
| 3 | The Open Device Partnership project welcomes your suggestions and contributions! Before opening your first issue or pull request, please review our | ||
| 4 | [Code of Conduct](CODE_OF_CONDUCT.md) to understand how our community interacts in an inclusive and respectful manner. | ||
| 5 | |||
| 6 | ## Contribution Licensing | ||
| 7 | |||
| 8 | Most of our code is distributed under the terms of the [MIT license](LICENSE), and when you contribute code that you wrote to our repositories, | ||
| 9 | you agree that you are contributing under those same terms. In addition, by submitting your contributions you are indicating that | ||
| 10 | you have the right to submit those contributions under those terms. | ||
| 11 | |||
| 12 | ## Other Contribution Information | ||
| 13 | |||
| 14 | If you wish to contribute code or documentation authored by others, or using the terms of any other license, please indicate that clearly in your | ||
| 15 | pull request so that the project team can discuss the situation with you. | ||
| 16 | |||
| 17 | ## Commit Message | ||
| 18 | |||
| 19 | * Use meaningful commit messages. See [this blogpost](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) | ||
| 20 | |||
| 21 | ## PR Etiquette | ||
| 22 | |||
| 23 | * Create a draft PR first | ||
| 24 | * Make sure that your branch has `.github` folder and all the code linting/sanity check workflows are passing in your draft PR before sending it out to code reviewers. | ||
| 25 | |||
| 26 | ## Clean Commit History | ||
| 27 | |||
| 28 | We disabled squashing of commit and would like to maintain a clean commit history. So please reorganize your commits with the following items: | ||
| 29 | |||
| 30 | * Each commit builds successfully without warning | ||
| 31 | * Miscellaneous commits to fix typos + formatting are squashed | ||
| 32 | |||
| 33 | ## Regressions | ||
| 34 | |||
| 35 | When reporting a regression, please ensure that you use `git bisect` to find the first offending commit, as that will help us finding the culprit a lot faster. | ||
diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..71c4806fe --- /dev/null +++ b/Cargo.toml | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | [package] | ||
| 2 | name = "embedded-rust-template" | ||
| 3 | version = "0.1.0" | ||
| 4 | edition = "2021" | ||
| 5 | license = "MIT" | ||
| 6 | repository = "https://github.com/OpenDevicePartnership/embedded-rust-template" | ||
| 7 | rust-version = "1.85" | ||
| 8 | |||
| 9 | [dependencies] | ||
| 10 | # dependencies for all targets | ||
| 11 | |||
| 12 | [target.'cfg(target_os = "none")'.dependencies] | ||
| 13 | # dependencies for no-std targets | ||
| 14 | |||
| 15 | [lints.clippy] | ||
| 16 | suspicious = "forbid" | ||
| 17 | correctness = "forbid" | ||
| 18 | perf = "forbid" | ||
| 19 | style = "forbid" | ||
diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..75092dc47 --- /dev/null +++ b/LICENSE | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) 2025 Open Device Partnership | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | of this software and associated documentation files (the "Software"), to deal | ||
| 7 | in the Software without restriction, including without limitation the rights | ||
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | copies of the Software, and to permit persons to whom the Software is | ||
| 10 | furnished to do so, subject to the following conditions: | ||
| 11 | |||
| 12 | The above copyright notice and this permission notice shall be included in all | ||
| 13 | copies or substantial portions of the Software. | ||
| 14 | |||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | SOFTWARE. \ No newline at end of file | ||
diff --git a/README.md b/README.md new file mode 100644 index 000000000..60b09c0a6 --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | # embedded-rust-template | ||
| 2 | Template repository for Embedded Rust development | ||
| 3 | |||
| 4 | ## Customizing This Template | ||
| 5 | |||
| 6 | ### Changing the Target Architecture | ||
| 7 | |||
| 8 | This template is configured for `thumbv8m.main-none-eabihf`, by default, but you can modify it for other targets (i.e. `aarch64-unknown-none`): | ||
| 9 | |||
| 10 | 1. **VSCode Settings**: Update the target in `.vscode/settings.json`: | ||
| 11 | ```json | ||
| 12 | "rust-analyzer.cargo.target": "your-target-architecture" | ||
| 13 | ``` | ||
| 14 | |||
| 15 | |||
| 16 | This configuration ensures that: | ||
| 17 | - Only the specified target architecture is analyzed, not the host platform | ||
| 18 | - Code is checked against the no_std environment | ||
| 19 | |||
| 20 | To temporarily analyze code for the host platform instead, you can remove the `rust-analyzer.cargo.target` setting. | ||
| 21 | |||
| 22 | 2. **GitHub Workflows**: Modify the target in two workflow files: | ||
| 23 | - `.github/workflows/nostd.yml`: Update the targets in the matrix: | ||
| 24 | ```yaml | ||
| 25 | matrix: | ||
| 26 | target: [your-target-architecture] | ||
| 27 | ``` | ||
| 28 | - `.github/workflows/check.yml`: If there are any target-specific checks, update them accordingly. | ||
| 29 | |||
| 30 | 3. **Cargo Configuration**: If needed, you can add target-specific configuration in a `.cargo/config.toml` file. | ||
| 31 | |||
| 32 | ### Converting from Binary to Library | ||
| 33 | |||
| 34 | To convert this project from a binary to a library: | ||
| 35 | |||
| 36 | 1. **Cargo.toml**: Update your project structure: | ||
| 37 | ```toml | ||
| 38 | [lib] | ||
| 39 | name = "your_library_name" | ||
| 40 | ``` | ||
| 41 | |||
| 42 | 2. **Directory Structure**: | ||
| 43 | - For a library, ensure you have a `src/lib.rs` file instead of `src/main.rs` | ||
| 44 | - Move your code from `main.rs` to `lib.rs` and adjust as needed | ||
| 45 | |||
| 46 | 3. **No-std Configuration**: If you're creating a no-std library, ensure you have: | ||
| 47 | ```rust | ||
| 48 | // In lib.rs | ||
| 49 | #![cfg_attr(target_os = "none", no_std)] | ||
| 50 | // Add other attributes as needed | ||
| 51 | ``` | ||
| 52 | |||
| 53 | ### Project Dependencies | ||
| 54 | |||
| 55 | Update the dependencies in `Cargo.toml` based on your target platform: | ||
| 56 | |||
| 57 | ```toml | ||
| 58 | [dependencies] | ||
| 59 | # Common dependencies for all targets | ||
| 60 | |||
| 61 | [target.'cfg(target_os = "none")'.dependencies] | ||
| 62 | # Dependencies for no-std targets | ||
| 63 | ``` | ||
diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..6ed358156 --- /dev/null +++ b/SECURITY.md | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | # Vulnerability Disclosure and Embargo Policy | ||
| 2 | |||
| 3 | The Open Device Partnership project welcomes the responsible disclosure of vulnerabilities. | ||
| 4 | |||
| 5 | ## Initial Contact | ||
| 6 | |||
| 7 | All security bugs in Open Device Partnership should be reported to the security team. | ||
| 8 | To do so, please reach out in the form of a | ||
| 9 | [Github Security Advisory](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities). | ||
| 10 | |||
| 11 | You will be invited to join this private area to discuss specifics. Doing so | ||
| 12 | allows us to start with a high level of confidentiality and relax it if the | ||
| 13 | issue is less critical, moving to work on the fix in the open. | ||
| 14 | |||
| 15 | Your initial contact will be acknowledged within 48 hours, and you’ll receive | ||
| 16 | a more detailed response within 96 hours indicating the next steps in handling | ||
| 17 | your report. | ||
| 18 | |||
| 19 | After the initial reply to your report, the security team will endeavor to | ||
| 20 | keep you informed of the progress being made towards a fix and full | ||
| 21 | announcement. As recommended by | ||
| 22 | [RFPolicy](https://dl.packetstormsecurity.net/papers/general/rfpolicy-2.0.txt), | ||
| 23 | these updates will be sent at least every five working days. | ||
| 24 | |||
| 25 | ## Disclosure Policy | ||
| 26 | |||
| 27 | The Open Device Partnership project has a 5 step disclosure process. | ||
| 28 | |||
| 29 | 1. Contact is established, a private channel created, and the security report | ||
| 30 | is received and is assigned a primary handler. This person will coordinate | ||
| 31 | the fix and release process. | ||
| 32 | 2. The problem is confirmed and a list of all affected versions is determined. | ||
| 33 | If an embargo is needed (see below), details of the embargo are decided. | ||
| 34 | 3. Code is audited to find any potential similar problems. | ||
| 35 | 4. Fixes are prepared for all releases which are still under maintenance. In | ||
| 36 | case of embargo, these fixes are not committed to the public repository but | ||
| 37 | rather held in a private fork pending the announcement. | ||
| 38 | 5. The changes are pushed to the public repository and new builds are deployed. | ||
| 39 | |||
| 40 | This process can take some time, especially when coordination is required | ||
| 41 | with maintainers of other projects. Every effort will be made to handle the bug | ||
| 42 | in as timely a manner as possible, however it is important that we follow the | ||
| 43 | release process above to ensure that the disclosure is handled in a consistent | ||
| 44 | manner. | ||
| 45 | |||
| 46 | ## Embargoes | ||
| 47 | |||
| 48 | While the Open Device Partnership project aims to follow the highest standards of | ||
| 49 | transparency and openness, handling some security issues may pose such an | ||
| 50 | immediate threat to various stakeholders and require coordination between | ||
| 51 | various actors that it cannot be made immediately public. | ||
| 52 | |||
| 53 | In this case, security issues will fall under an embargo. | ||
| 54 | |||
| 55 | An embargo can be called for in various cases: | ||
| 56 | |||
| 57 | - when disclosing the issue without simultaneously providing a mitigation | ||
| 58 | would seriously endanger users, | ||
| 59 | - when producing a fix requires coordinating between multiple actors (such as | ||
| 60 | upstream or downstream/dependency projects), or simply | ||
| 61 | - when proper analysis of the issue and its ramifications demands time. | ||
| 62 | |||
| 63 | If we determine that an issue you report requires an embargo, we will discuss | ||
| 64 | this with you and try to find a reasonable expiry date (aka “embargo | ||
| 65 | completion date”), as well as who should be included in the list of | ||
| 66 | need-to-know people. \ No newline at end of file | ||
diff --git a/deny.toml b/deny.toml new file mode 100644 index 000000000..9ddd12fca --- /dev/null +++ b/deny.toml | |||
| @@ -0,0 +1,239 @@ | |||
| 1 | # This template contains all of the possible sections and their default values | ||
| 2 | |||
| 3 | # Note that all fields that take a lint level have these possible values: | ||
| 4 | # * deny - An error will be produced and the check will fail | ||
| 5 | # * warn - A warning will be produced, but the check will not fail | ||
| 6 | # * allow - No warning or error will be produced, though in some cases a note | ||
| 7 | # will be | ||
| 8 | |||
| 9 | # The values provided in this template are the default values that will be used | ||
| 10 | # when any section or field is not specified in your own configuration | ||
| 11 | |||
| 12 | # Root options | ||
| 13 | |||
| 14 | # The graph table configures how the dependency graph is constructed and thus | ||
| 15 | # which crates the checks are performed against | ||
| 16 | [graph] | ||
| 17 | # If 1 or more target triples (and optionally, target_features) are specified, | ||
| 18 | # only the specified targets will be checked when running `cargo deny check`. | ||
| 19 | # This means, if a particular package is only ever used as a target specific | ||
| 20 | # dependency, such as, for example, the `nix` crate only being used via the | ||
| 21 | # `target_family = "unix"` configuration, that only having windows targets in | ||
| 22 | # this list would mean the nix crate, as well as any of its exclusive | ||
| 23 | # dependencies not shared by any other crates, would be ignored, as the target | ||
| 24 | # list here is effectively saying which targets you are building for. | ||
| 25 | targets = [ | ||
| 26 | # The triple can be any string, but only the target triples built in to | ||
| 27 | # rustc (as of 1.40) can be checked against actual config expressions | ||
| 28 | #"x86_64-unknown-linux-musl", | ||
| 29 | # You can also specify which target_features you promise are enabled for a | ||
| 30 | # particular target. target_features are currently not validated against | ||
| 31 | # the actual valid features supported by the target architecture. | ||
| 32 | #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, | ||
| 33 | ] | ||
| 34 | # When creating the dependency graph used as the source of truth when checks are | ||
| 35 | # executed, this field can be used to prune crates from the graph, removing them | ||
| 36 | # from the view of cargo-deny. This is an extremely heavy hammer, as if a crate | ||
| 37 | # is pruned from the graph, all of its dependencies will also be pruned unless | ||
| 38 | # they are connected to another crate in the graph that hasn't been pruned, | ||
| 39 | # so it should be used with care. The identifiers are [Package ID Specifications] | ||
| 40 | # (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) | ||
| 41 | #exclude = [] | ||
| 42 | # If true, metadata will be collected with `--all-features`. Note that this can't | ||
| 43 | # be toggled off if true, if you want to conditionally enable `--all-features` it | ||
| 44 | # is recommended to pass `--all-features` on the cmd line instead | ||
| 45 | all-features = false | ||
| 46 | # If true, metadata will be collected with `--no-default-features`. The same | ||
| 47 | # caveat with `all-features` applies | ||
| 48 | no-default-features = false | ||
| 49 | # If set, these feature will be enabled when collecting metadata. If `--features` | ||
| 50 | # is specified on the cmd line they will take precedence over this option. | ||
| 51 | #features = [] | ||
| 52 | |||
| 53 | # The output table provides options for how/if diagnostics are outputted | ||
| 54 | [output] | ||
| 55 | # When outputting inclusion graphs in diagnostics that include features, this | ||
| 56 | # option can be used to specify the depth at which feature edges will be added. | ||
| 57 | # This option is included since the graphs can be quite large and the addition | ||
| 58 | # of features from the crate(s) to all of the graph roots can be far too verbose. | ||
| 59 | # This option can be overridden via `--feature-depth` on the cmd line | ||
| 60 | feature-depth = 1 | ||
| 61 | |||
| 62 | # This section is considered when running `cargo deny check advisories` | ||
| 63 | # More documentation for the advisories section can be found here: | ||
| 64 | # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html | ||
| 65 | [advisories] | ||
| 66 | # The path where the advisory databases are cloned/fetched into | ||
| 67 | #db-path = "$CARGO_HOME/advisory-dbs" | ||
| 68 | # The url(s) of the advisory databases to use | ||
| 69 | #db-urls = ["https://github.com/rustsec/advisory-db"] | ||
| 70 | # A list of advisory IDs to ignore. Note that ignored advisories will still | ||
| 71 | # output a note when they are encountered. | ||
| 72 | ignore = [ | ||
| 73 | #"RUSTSEC-0000-0000", | ||
| 74 | #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, | ||
| 75 | #"[email protected]", # you can also ignore yanked crate versions if you wish | ||
| 76 | #{ crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" }, | ||
| 77 | { id = "RUSTSEC-2024-0370", reason = "proc-macro-error is unmaintained, no safe upgrade available, need upstream dependencies to migrate away from it." }, | ||
| 78 | { id = "RUSTSEC-2024-0436", reason = "there are no suitable replacements for paste right now; paste has been archived as read-only. It only affects compile time concatenation in macros. We will allow it for now" }, | ||
| 79 | ] | ||
| 80 | # If this is true, then cargo deny will use the git executable to fetch advisory database. | ||
| 81 | # If this is false, then it uses a built-in git library. | ||
| 82 | # Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. | ||
| 83 | # See Git Authentication for more information about setting up git authentication. | ||
| 84 | #git-fetch-with-cli = true | ||
| 85 | |||
| 86 | # This section is considered when running `cargo deny check licenses` | ||
| 87 | # More documentation for the licenses section can be found here: | ||
| 88 | # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html | ||
| 89 | [licenses] | ||
| 90 | # List of explicitly allowed licenses | ||
| 91 | # See https://spdx.org/licenses/ for list of possible licenses | ||
| 92 | # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. | ||
| 93 | allow = [ | ||
| 94 | "MIT", | ||
| 95 | "Apache-2.0", | ||
| 96 | "Unicode-3.0", | ||
| 97 | "BSD-3-Clause", | ||
| 98 | #"Apache-2.0 WITH LLVM-exception", | ||
| 99 | ] | ||
| 100 | # The confidence threshold for detecting a license from license text. | ||
| 101 | # The higher the value, the more closely the license text must be to the | ||
| 102 | # canonical license text of a valid SPDX license file. | ||
| 103 | # [possible values: any between 0.0 and 1.0]. | ||
| 104 | confidence-threshold = 0.8 | ||
| 105 | # Allow 1 or more licenses on a per-crate basis, so that particular licenses | ||
| 106 | # aren't accepted for every possible crate as with the normal allow list | ||
| 107 | exceptions = [ | ||
| 108 | # Each entry is the crate and version constraint, and its specific allow | ||
| 109 | # list | ||
| 110 | #{ allow = ["Zlib"], crate = "adler32" }, | ||
| 111 | ] | ||
| 112 | |||
| 113 | # Some crates don't have (easily) machine readable licensing information, | ||
| 114 | # adding a clarification entry for it allows you to manually specify the | ||
| 115 | # licensing information | ||
| 116 | #[[licenses.clarify]] | ||
| 117 | # The package spec the clarification applies to | ||
| 118 | #crate = "ring" | ||
| 119 | # The SPDX expression for the license requirements of the crate | ||
| 120 | #expression = "MIT AND ISC AND OpenSSL" | ||
| 121 | # One or more files in the crate's source used as the "source of truth" for | ||
| 122 | # the license expression. If the contents match, the clarification will be used | ||
| 123 | # when running the license check, otherwise the clarification will be ignored | ||
| 124 | # and the crate will be checked normally, which may produce warnings or errors | ||
| 125 | # depending on the rest of your configuration | ||
| 126 | #license-files = [ | ||
| 127 | # Each entry is a crate relative path, and the (opaque) hash of its contents | ||
| 128 | #{ path = "LICENSE", hash = 0xbd0eed23 } | ||
| 129 | #] | ||
| 130 | |||
| 131 | [licenses.private] | ||
| 132 | # If true, ignores workspace crates that aren't published, or are only | ||
| 133 | # published to private registries. | ||
| 134 | # To see how to mark a crate as unpublished (to the official registry), | ||
| 135 | # visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. | ||
| 136 | ignore = false | ||
| 137 | # One or more private registries that you might publish crates to, if a crate | ||
| 138 | # is only published to private registries, and ignore is true, the crate will | ||
| 139 | # not have its license(s) checked | ||
| 140 | registries = [ | ||
| 141 | #"https://sekretz.com/registry | ||
| 142 | ] | ||
| 143 | |||
| 144 | # This section is considered when running `cargo deny check bans`. | ||
| 145 | # More documentation about the 'bans' section can be found here: | ||
| 146 | # https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html | ||
| 147 | [bans] | ||
| 148 | # Lint level for when multiple versions of the same crate are detected | ||
| 149 | multiple-versions = "warn" | ||
| 150 | # Lint level for when a crate version requirement is `*` | ||
| 151 | wildcards = "allow" | ||
| 152 | # The graph highlighting used when creating dotgraphs for crates | ||
| 153 | # with multiple versions | ||
| 154 | # * lowest-version - The path to the lowest versioned duplicate is highlighted | ||
| 155 | # * simplest-path - The path to the version with the fewest edges is highlighted | ||
| 156 | # * all - Both lowest-version and simplest-path are used | ||
| 157 | highlight = "all" | ||
| 158 | # The default lint level for `default` features for crates that are members of | ||
| 159 | # the workspace that is being checked. This can be overridden by allowing/denying | ||
| 160 | # `default` on a crate-by-crate basis if desired. | ||
| 161 | workspace-default-features = "allow" | ||
| 162 | # The default lint level for `default` features for external crates that are not | ||
| 163 | # members of the workspace. This can be overridden by allowing/denying `default` | ||
| 164 | # on a crate-by-crate basis if desired. | ||
| 165 | external-default-features = "allow" | ||
| 166 | # List of crates that are allowed. Use with care! | ||
| 167 | allow = [ | ||
| 168 | #"[email protected]", | ||
| 169 | #{ crate = "[email protected]", reason = "you can specify a reason it is allowed" }, | ||
| 170 | ] | ||
| 171 | # List of crates to deny | ||
| 172 | deny = [ | ||
| 173 | #"[email protected]", | ||
| 174 | #{ crate = "[email protected]", reason = "you can specify a reason it is banned" }, | ||
| 175 | # Wrapper crates can optionally be specified to allow the crate when it | ||
| 176 | # is a direct dependency of the otherwise banned crate | ||
| 177 | #{ crate = "[email protected]", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, | ||
| 178 | ] | ||
| 179 | |||
| 180 | # List of features to allow/deny | ||
| 181 | # Each entry the name of a crate and a version range. If version is | ||
| 182 | # not specified, all versions will be matched. | ||
| 183 | #[[bans.features]] | ||
| 184 | #crate = "reqwest" | ||
| 185 | # Features to not allow | ||
| 186 | #deny = ["json"] | ||
| 187 | # Features to allow | ||
| 188 | #allow = [ | ||
| 189 | # "rustls", | ||
| 190 | # "__rustls", | ||
| 191 | # "__tls", | ||
| 192 | # "hyper-rustls", | ||
| 193 | # "rustls", | ||
| 194 | # "rustls-pemfile", | ||
| 195 | # "rustls-tls-webpki-roots", | ||
| 196 | # "tokio-rustls", | ||
| 197 | # "webpki-roots", | ||
| 198 | #] | ||
| 199 | # If true, the allowed features must exactly match the enabled feature set. If | ||
| 200 | # this is set there is no point setting `deny` | ||
| 201 | #exact = true | ||
| 202 | |||
| 203 | # Certain crates/versions that will be skipped when doing duplicate detection. | ||
| 204 | skip = [ | ||
| 205 | #"[email protected]", | ||
| 206 | #{ crate = "[email protected]", reason = "you can specify a reason why it can't be updated/removed" }, | ||
| 207 | ] | ||
| 208 | # Similarly to `skip` allows you to skip certain crates during duplicate | ||
| 209 | # detection. Unlike skip, it also includes the entire tree of transitive | ||
| 210 | # dependencies starting at the specified crate, up to a certain depth, which is | ||
| 211 | # by default infinite. | ||
| 212 | skip-tree = [ | ||
| 213 | #"[email protected]", # will be skipped along with _all_ of its direct and transitive dependencies | ||
| 214 | #{ crate = "[email protected]", depth = 20 }, | ||
| 215 | ] | ||
| 216 | |||
| 217 | # This section is considered when running `cargo deny check sources`. | ||
| 218 | # More documentation about the 'sources' section can be found here: | ||
| 219 | # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html | ||
| 220 | [sources] | ||
| 221 | # Lint level for what to happen when a crate from a crate registry that is not | ||
| 222 | # in the allow list is encountered | ||
| 223 | unknown-registry = "warn" | ||
| 224 | # Lint level for what to happen when a crate from a git repository that is not | ||
| 225 | # in the allow list is encountered | ||
| 226 | unknown-git = "warn" | ||
| 227 | # List of URLs for allowed crate registries. Defaults to the crates.io index | ||
| 228 | # if not specified. If it is specified but empty, no registries are allowed. | ||
| 229 | allow-registry = ["https://github.com/rust-lang/crates.io-index"] | ||
| 230 | # List of URLs for allowed Git repositories | ||
| 231 | allow-git = [] | ||
| 232 | |||
| 233 | [sources.allow-org] | ||
| 234 | # github.com organizations to allow git sources for | ||
| 235 | github = ["embassy-rs"] | ||
| 236 | # gitlab.com organizations to allow git sources for | ||
| 237 | gitlab = [] | ||
| 238 | # bitbucket.org organizations to allow git sources for | ||
| 239 | bitbucket = [] | ||
diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..367cc1fc3 --- /dev/null +++ b/rust-toolchain.toml | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | [toolchain] | ||
| 2 | components = ["rustfmt", "clippy"] | ||
diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..753065179 --- /dev/null +++ b/rustfmt.toml | |||
| @@ -0,0 +1 @@ | |||
| max_width = 120 | |||
diff --git a/src/baremetal/mod.rs b/src/baremetal/mod.rs new file mode 100644 index 000000000..c03b9538b --- /dev/null +++ b/src/baremetal/mod.rs | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | use core::panic::PanicInfo; | ||
| 2 | |||
| 3 | #[panic_handler] | ||
| 4 | fn panic(_info: &PanicInfo) -> ! { | ||
| 5 | loop {} | ||
| 6 | } | ||
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 000000000..7111536ff --- /dev/null +++ b/src/main.rs | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | #![cfg_attr(target_os = "none", no_std)] | ||
| 2 | #![cfg_attr(target_os = "none", no_main)] | ||
| 3 | |||
| 4 | #[cfg(target_os = "none")] | ||
| 5 | mod baremetal; | ||
| 6 | |||
| 7 | #[cfg(not(target_os = "none"))] | ||
| 8 | fn main() { | ||
| 9 | println!("Hello, world!"); | ||
| 10 | } | ||
| 11 | |||
| 12 | #[cfg(test)] | ||
| 13 | mod tests { | ||
| 14 | #[test] | ||
| 15 | fn it_works() { | ||
| 16 | assert_eq!(2 + 2, 4); | ||
| 17 | } | ||
| 18 | } | ||
diff --git a/supply-chain/README.md b/supply-chain/README.md new file mode 100644 index 000000000..d43d50485 --- /dev/null +++ b/supply-chain/README.md | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | # Working with cargo vet | ||
| 2 | |||
| 3 | ## Introduction | ||
| 4 | |||
| 5 | `cargo vet` is a tool to help ensure that third-party Rust dependencies have been audited by a trusted entity. | ||
| 6 | It matches all dependencies against a set of audits conducted by the authors of the project or entities they trust. | ||
| 7 | To learn more, visit [mozilla/cargo-vet](https://github.com/mozilla/cargo-vet) | ||
| 8 | |||
| 9 | --- | ||
| 10 | |||
| 11 | ## Adding a new dependency | ||
| 12 | |||
| 13 | When updating or adding a new dependency, we need to ensure it's audited before being merged into main. | ||
| 14 | For our repositories, we have designated experts who are responsible for vetting any new dependencies being added to their repository. | ||
| 15 | _It is the shared responsibility of the developer creating the PR and the auditors to conduct a successful audit._ | ||
| 16 | Follow the process below to ensure compliance: | ||
| 17 | |||
| 18 | ### For Developers | ||
| 19 | 1. **Respond to `cargo vet` failures**: | ||
| 20 | - If your PR fails the `cargo vet` step, the cargo-vet workflow will add a comment to the PR with a template questionnaire | ||
| 21 | - Copy the questionnaire, fill it out and paste it as a new comment on the PR. This greatly helps the auditors get some context of the changes requiring the new dependencies | ||
| 22 | |||
| 23 | 2. **Engage with auditors**: | ||
| 24 | - Respond to any questions that the auditors might have regarding the need of any new dependencies | ||
| 25 | |||
| 26 | 3. **Rebase and verify**: | ||
| 27 | - At their discretion, auditors will check in their audits into either [rust-crate-audits](https://github.com/OpenDevicePartnership/rust-crate-audits) or into the same repository | ||
| 28 | - Once the new audits have been merged, rebase your branch on main and verify it passes `cargo vet` | ||
| 29 | ```bash | ||
| 30 | git fetch upstream | ||
| 31 | git rebase upstream/main | ||
| 32 | cargo vet | ||
| 33 | ``` | ||
| 34 | |||
| 35 | 4. **Update PR**: | ||
| 36 | - If the audits were checked into rust-crate-audits, they will show up in _imports.lock_ on running `cargo vet`. In this case add the updated _imports.lock_ to your PR | ||
| 37 | - If the audits were checked into the same repository, they will be present in _audits.toml_ after rebase and you can simply force push to your PR after rebase | ||
| 38 | ```bash | ||
| 39 | git push -f | ||
| 40 | ``` | ||
| 41 | |||
| 42 | 5. **Check PR status**: | ||
| 43 | - The existing PR comment from the previous failure will be updated with a success message once the check passes | ||
| 44 | |||
| 45 | ### For Auditors | ||
| 46 | |||
| 47 | 1. **Review the questionnaire**: | ||
| 48 | - Check the filled questionnaire on the PR once the developer responds to the `cargo vet` failure | ||
| 49 | - Respond to the developer comment in case more information is needed | ||
| 50 | |||
| 51 | 2. **Audit new dependencies**: | ||
| 52 | - Inspect the `cargo vet` failures using your preferred method | ||
| 53 | - Use [gh pr checkout](https://cli.github.com/manual/gh_pr_checkout) to checkout the PR and run `cargo vet --locked` | ||
| 54 | - Use [Github Pull Requests for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) to checkout the PR and run `cargo vet --locked` | ||
| 55 | - For more suggestions: [Checking out pull requests locally](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally) | ||
| 56 | |||
| 57 | 3. **Follow `cargo vet` recommendations**: | ||
| 58 | - Follow the recommendations of the `cargo vet` command output, either `cargo vet diff` for version update or `cargo vet inspect` for new dependencies | ||
| 59 | |||
| 60 | 4. **Record audits**: | ||
| 61 | - Use `cargo vet certify` to add new audits to _audits.toml_ | ||
| 62 | - Verify all dependencies pass using `cargo vet` | ||
| 63 | |||
| 64 | 5. **Decide audit location**: | ||
| 65 | - **Shared audits**: New audits should ideally be shared across ODP repositories to reduce the overhead of multiple audits for the same dependencies. To facilitate this, it's recommended to cut and paste the new audits and submit as a separate PR to the _audits.toml_ in [rust-crate-audits](https://github.com/OpenDevicePartnership/rust-crate-audits) | ||
| 66 | - If due to business reasons, the audits are not to be shared across repositories, copy the updated _audits.toml_ to a new branch off main in the same repository and submit the PR to update the audits | ||
| 67 | |||
| 68 | 6. **Communicate successful audit**: | ||
| 69 | - Communicate to the PR developer via a PR comment so they can update the PR and get `cargo vet` to pass | ||
| 70 | |||
| 71 | --- | ||
| 72 | |||
| 73 | ## Tips for using `cargo vet`: | ||
| 74 | |||
| 75 | - **Update _imports.lock_**: | ||
| 76 | - Import trusted third party audits to reduce the number of new audits to be performed. Running `cargo vet` without `--locked` fetches new imports and updates _imports.lock_ with any audits that are helpful for our project. | ||
| 77 | |||
| 78 | - **Add exemptions**: | ||
| 79 | - If an audit cannot be performed for some dependency due to time sensitivity or business justified reasons, use `cargo vet add-exemption <PACKAGE> <VERSION>` to add the dependency to exemptions in _config.toml_ | ||
| 80 | - To add all remaining audits to exemptions at once, use `cargo vet regenerate exemptions` | ||
| 81 | |||
| 82 | - **Prune unnecessary entries**: | ||
| 83 | - Remove unnecessary exemptions and imports using `cargo vet prune` \ No newline at end of file | ||
diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml new file mode 100644 index 000000000..2772ccb21 --- /dev/null +++ b/supply-chain/audits.toml | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | |||
| 2 | # cargo-vet audits file | ||
| 3 | |||
| 4 | [audits] | ||
diff --git a/supply-chain/config.toml b/supply-chain/config.toml new file mode 100644 index 000000000..55618c2ff --- /dev/null +++ b/supply-chain/config.toml | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | |||
| 2 | # cargo-vet config file | ||
| 3 | |||
| 4 | [cargo-vet] | ||
| 5 | version = "0.10" | ||
| 6 | |||
| 7 | [imports.OpenDevicePartnership] | ||
| 8 | url = "https://raw.githubusercontent.com/OpenDevicePartnership/rust-crate-audits/main/audits.toml" | ||
| 9 | |||
| 10 | [imports.google] | ||
| 11 | url = "https://raw.githubusercontent.com/google/rust-crate-audits/main/audits.toml" | ||
| 12 | |||
| 13 | [imports.mozilla] | ||
| 14 | url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml" | ||
diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock new file mode 100644 index 000000000..219dba4ee --- /dev/null +++ b/supply-chain/imports.lock | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | |||
| 2 | # cargo-vet imports lock | ||
| 3 | |||
| 4 | [audits.OpenDevicePartnership.audits] | ||
| 5 | |||
| 6 | [audits.google.audits] | ||
| 7 | |||
| 8 | [audits.mozilla.audits] | ||
