diff --git a/.devcontainer/devcontainer.json.license b/.devcontainer/devcontainer.json.license new file mode 100644 index 00000000..73197491 --- /dev/null +++ b/.devcontainer/devcontainer.json.license @@ -0,0 +1,9 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 diff --git a/.dockerignore b/.dockerignore index bfac5188..6d7850dc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + * !docker/ !dist/ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a02fff33..af2374dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -192,7 +192,7 @@ jobs: go-version: '1.25' cache: false - uses: astral-sh/setup-uv@v7 - # Install Python dependencies and tools (prek, ruff, ty) + # Install Python dependencies and tools (prek, reuse, ruff, ty) - run: uv sync --group tools # Cache prek hooks - uses: actions/cache@v5 diff --git a/.gitignore b/.gitignore index f80548b3..6fa6c5fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + target/ dist/ __pycache__/ @@ -5,3 +15,4 @@ __pycache__/ .devenv/ .devenv.flake.nix gen/ +.idea diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 21800043..f9db1632 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -1,8 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation # SPDX-License-Identifier: Apache-2.0 - +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 default: true MD013: line_length: 1000 +MD024: + siblings_only: true MD033: false MD060: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 57bc1764..8dfda810 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,26 +12,13 @@ repos: - id: check-json - id: check-merge-conflict - id: end-of-file-fixer + - id: check-json - id: trailing-whitespace - id: mixed-line-ending - repo: https://github.com/google/yamlfmt rev: v0.21.0 hooks: - id: yamlfmt - - repo: local - hooks: - - id: cargo-fmt - name: cargo fmt - entry: cargo fmt --all -- --check - language: system - types: [rust] - pass_filenames: false - - id: cargo-clippy - name: cargo clippy - entry: cargo clippy --locked --workspace --all-targets --all-features --no-deps -- -D warnings -A clippy::doc_markdown - language: system - types: [rust] - pass_filenames: false - repo: https://github.com/bnjbvr/cargo-machete rev: v0.9.2 hooks: @@ -66,3 +53,14 @@ repos: hooks: - id: conventional-pre-commit stages: [commit-msg] + - repo: https://github.com/eclipse-opensovd/cicd-workflows + rev: d26f544863efabd6694f3cd9562b7bd59bfbf603 + hooks: + - id: reuse-annotate + - id: no-unicode-check + args: + - --allowed-chars=µ,§ + - id: validate-cargo-lints + - id: cargo-fmt + - id: clippy + - id: check-hooks diff --git a/.reuse/styles.toml b/.reuse/styles.toml new file mode 100644 index 00000000..3aad06ad --- /dev/null +++ b/.reuse/styles.toml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + +# Map file patterns to reuse annotate --style values. +# Keys = reuse style names, values = shell glob patterns matched against basename. +# Every file type MUST have a matching pattern - unmatched files will error. +# +# Downstream repos can override by committing their own .reuse/styles.toml. + +[styles] +c = ["*.rs", "*.kt", "*.kts"] +html = ["*.odx-*"] diff --git a/.reuse/templates/opensovd.jinja2 b/.reuse/templates/opensovd.jinja2 new file mode 100644 index 00000000..569e5d46 --- /dev/null +++ b/.reuse/templates/opensovd.jinja2 @@ -0,0 +1,25 @@ +{# +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 +#} + +{% for expression in spdx_expressions %} +SPDX-License-Identifier: {{ expression }} +{% endfor %} +{% for copyright_line in copyright_lines %} +{{ copyright_line }} +{% endfor %} + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 diff --git a/.rustfmt.toml b/.rustfmt.toml index 881132a4..5711a1ad 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,6 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation # SPDX-License-Identifier: Apache-2.0 - -group_imports = "StdExternalCrate" +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 style_edition = "2024" max_width = 100 +newline_style = "Unix" +group_imports = "StdExternalCrate" +imports_granularity = "Crate" diff --git a/.yamlfmt b/.yamlfmt index 0d7c56df..9f2a31b3 100644 --- a/.yamlfmt +++ b/.yamlfmt @@ -1,3 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 formatter: type: basic retain_line_breaks_single: true diff --git a/Cargo.lock.license b/Cargo.lock.license new file mode 100644 index 00000000..73197491 --- /dev/null +++ b/Cargo.lock.license @@ -0,0 +1,9 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 diff --git a/Cargo.toml b/Cargo.toml index 19251fd8..b056ea88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,6 +89,7 @@ unwrap_used = "deny" arithmetic_side_effects = "deny" separated_literal_suffix = "deny" doc_markdown = "allow" +similar_names = "allow" print_stdout = "deny" print_stderr = "deny" unwrap_in_result = "deny" diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 00000000..137069b8 --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 00000000..e819f2e2 --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + +version = 1 + +[[annotations]] +path = ["LICENSE", "NOTICE", "CONTRIBUTORS", "LICENSES/**.txt"] +SPDX-FileCopyrightText = "The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS)" +SPDX-License-Identifier = "Apache-2.0" diff --git a/benches/src/main.rs b/benches/src/main.rs index cce82dbf..73bba87f 100644 --- a/benches/src/main.rs +++ b/benches/src/main.rs @@ -9,8 +9,7 @@ use std::sync::LazyLock; use axum::{Router, body::Body, http::Request, routing::get}; use criterion::{Criterion, criterion_group, criterion_main}; use jsonwebtoken::{Algorithm, EncodingKey, Header, encode}; -use opensovd_extra::auth::jwt::Claims; -use opensovd_extra::{JwtAlgorithm, JwtAuthenticator, RegorusAuthorizer}; +use opensovd_extra::{JwtAlgorithm, JwtAuthenticator, RegorusAuthorizer, auth::jwt::Claims}; use opensovd_server::{AllowAll, AuthenticationLayer, AuthorizationLayer, NoAuth}; use tower::ServiceExt; diff --git a/devenv.yaml b/devenv.yaml index 8e70a0ee..de62ff9e 100644 --- a/devenv.yaml +++ b/devenv.yaml @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + caches: - https://devenv.cachix.org - https://nix-community.cachix.org diff --git a/docs/architecture.md b/docs/architecture.md index c5e5cecc..6c4de969 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,3 +1,15 @@ + + # Architecture ## Class Diagram diff --git a/docs/ci.md b/docs/ci.md index c7fb24d9..b0514f3c 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -1,3 +1,15 @@ + + # CI/CD Pipeline This document describes the GitHub Actions CI/CD pipeline for opensovd. diff --git a/docs/testing.md b/docs/testing.md index 1180340b..f9c1781f 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -1,3 +1,15 @@ + + # Testing pytest serves as the unified test driver, orchestrating tests across different tools: diff --git a/examples/client/src/client.rs b/examples/client/src/client.rs index 457359ca..95a71935 100644 --- a/examples/client/src/client.rs +++ b/examples/client/src/client.rs @@ -29,8 +29,7 @@ use clap::Parser; use http::{HeaderMap, Request, Response}; use http_body_util::Full; use opensovd_client::Client; -use tower_http::classify::ServerErrorsFailureClass; -use tower_http::trace::TraceLayer; +use tower_http::{classify::ServerErrorsFailureClass, trace::TraceLayer}; use tracing::Span; #[derive(Parser)] @@ -39,13 +38,14 @@ use tracing::Span; #[command(after_help = "\ Examples: # Connect over TCP (default) - client --url http://localhost:7690/sovd/v1 - - # Connect over a Unix socket (filesystem path) - client --unix-socket /tmp/opensovd.sock --url http://localhost/sovd/v1 + client --url http://localhost:7690/sovd/v1# \ + Connect over a Unix socket (filesystem path) + client --unix-socket /tmp/opensovd.sock \ + --url http://localhost/sovd/v1 # Connect over an abstract Unix socket - client --unix-socket @opensovd --url http://localhost/sovd/v1 + client \ + --unix-socket @opensovd --url http://localhost/sovd/v1 ")] struct Cli { /// Base URL of the SOVD server (including version prefix). diff --git a/examples/server/auth/auth.rs b/examples/server/auth/auth.rs index 5356bff2..14f3923d 100644 --- a/examples/server/auth/auth.rs +++ b/examples/server/auth/auth.rs @@ -13,8 +13,7 @@ use std::io::Cursor; use jsonwebtoken::{Algorithm, EncodingKey, Header, encode}; -use opensovd_extra::auth::jwt::Claims; -use opensovd_extra::{JwtAlgorithm, JwtAuthenticator, RegorusAuthorizer}; +use opensovd_extra::{JwtAlgorithm, JwtAuthenticator, RegorusAuthorizer, auth::jwt::Claims}; use opensovd_mocks::create_mock_topology; use opensovd_server::Server; use tokio::net::TcpListener; diff --git a/examples/server/auth/sovd_data.json.license b/examples/server/auth/sovd_data.json.license new file mode 100644 index 00000000..73197491 --- /dev/null +++ b/examples/server/auth/sovd_data.json.license @@ -0,0 +1,9 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 diff --git a/examples/server/mtls/mtls.rs b/examples/server/mtls/mtls.rs index 2d13402e..d6e17a82 100644 --- a/examples/server/mtls/mtls.rs +++ b/examples/server/mtls/mtls.rs @@ -21,8 +21,7 @@ use std::sync::Arc; use opensovd_mocks::create_mock_topology; use opensovd_server::Server; -use rustls::pki_types::pem::PemObject; -use rustls::pki_types::{CertificateDer, PrivateKeyDer}; +use rustls::pki_types::{CertificateDer, PrivateKeyDer, pem::PemObject}; use tokio::net::TcpListener; // paths relative to workspace root; run scripts/mkcerts.sh to generate. @@ -66,7 +65,7 @@ async fn main() -> Result<(), Box> { .build()?; tracing::info!("mTLS server on https://127.0.0.1:8443/sovd"); - tracing::info!("Client cert required — run mkcerts.sh to generate test certs"); + tracing::info!("Client cert required -- run mkcerts.sh to generate test certs"); server.serve().await?; Ok(()) diff --git a/examples/server/simple/README.md b/examples/server/simple/README.md index 14458d1b..d40d494e 100644 --- a/examples/server/simple/README.md +++ b/examples/server/simple/README.md @@ -1,3 +1,15 @@ + + # Simple Example Minimal OpenSOVD server exposing a single Linux system component with live data. diff --git a/examples/server/simple/sampler.yaml b/examples/server/simple/sampler.yaml index 7194cb36..f0052f05 100644 --- a/examples/server/simple/sampler.yaml +++ b/examples/server/simple/sampler.yaml @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + variables: base_url: http://localhost:7690/sovd/v1/components/linux/data diff --git a/examples/server/simple/simple.rs b/examples/server/simple/simple.rs index a33312cd..443fc3e9 100644 --- a/examples/server/simple/simple.rs +++ b/examples/server/simple/simple.rs @@ -10,9 +10,11 @@ //! //! Run with: `cargo run -p opensovd-examples-server --example simple` -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; -use std::time::Instant; +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, + time::Instant, +}; use async_trait::async_trait; use opensovd_core::Component; diff --git a/examples/server/systemd/systemd.rs b/examples/server/systemd/systemd.rs index a357ce06..8c8adbbd 100644 --- a/examples/server/systemd/systemd.rs +++ b/examples/server/systemd/systemd.rs @@ -58,5 +58,5 @@ async fn main() -> Result<(), Box> { #[cfg(not(target_os = "linux"))] fn main() { - eprintln!("This example is only available on Linux"); + panic!("This example is only available on Linux"); } diff --git a/opensovd-cli/gateway/src/cli.rs b/opensovd-cli/gateway/src/cli.rs index 62166545..ec042acd 100644 --- a/opensovd-cli/gateway/src/cli.rs +++ b/opensovd-cli/gateway/src/cli.rs @@ -28,12 +28,12 @@ const VERSION_STRING: &str = concat!( #[command(after_help = "\ Examples: # Listen on all interfaces on port 8080 - opensovd-gateway --url http://0.0.0.0:8080/sovd + opensovd-gateway --url \ + http://0.0.0.0:8080/sovd # Custom base URI path - opensovd-gateway --url http://localhost:7690/api/sovd - - # Listen on a Unix socket (filesystem path) + opensovd-gateway --url http://localhost:7690/api/sovd# \ + Listen on a Unix socket (filesystem path) opensovd-gateway --unix-socket /tmp/opensovd.sock # Listen on an abstract Unix socket @@ -127,8 +127,7 @@ impl TlsArgs { pub fn build(self) -> anyhow::Result> { use std::sync::Arc; - use rustls::pki_types::pem::PemObject; - use rustls::pki_types::{CertificateDer, PrivateKeyDer}; + use rustls::pki_types::{CertificateDer, PrivateKeyDer, pem::PemObject}; let (cert_path, key_path) = match (self.cert, self.key) { (Some(c), Some(k)) => (c, k), diff --git a/opensovd-cli/lib/src/lib.rs b/opensovd-cli/lib/src/lib.rs index ccd07a26..1c046c31 100644 --- a/opensovd-cli/lib/src/lib.rs +++ b/opensovd-cli/lib/src/lib.rs @@ -5,14 +5,15 @@ pub mod trace; -use std::fmt; -use std::path::Path; - -use tracing_subscriber::fmt::{ - FmtContext, FormattedFields, - format::{self, FormatEvent, FormatFields}, +use std::{fmt, path::Path}; + +use tracing_subscriber::{ + fmt::{ + FmtContext, FormattedFields, + format::{self, FormatEvent, FormatFields}, + }, + registry::LookupSpan, }; -use tracing_subscriber::registry::LookupSpan; struct CompactFormat; diff --git a/opensovd-cli/lib/src/trace.rs b/opensovd-cli/lib/src/trace.rs index cf5b98db..373717e8 100644 --- a/opensovd-cli/lib/src/trace.rs +++ b/opensovd-cli/lib/src/trace.rs @@ -6,8 +6,10 @@ use std::time::Duration; use http::{Request, Response}; -use tower_http::classify::ServerErrorsFailureClass; -use tower_http::trace::{MakeSpan, OnFailure, OnRequest, OnResponse, TraceLayer}; +use tower_http::{ + classify::ServerErrorsFailureClass, + trace::{MakeSpan, OnFailure, OnRequest, OnResponse, TraceLayer}, +}; use tracing::Span; const TARGET: &str = "srv"; diff --git a/opensovd-cli/mcp/src/main.rs b/opensovd-cli/mcp/src/main.rs index af91a543..3305dab8 100644 --- a/opensovd-cli/mcp/src/main.rs +++ b/opensovd-cli/mcp/src/main.rs @@ -3,8 +3,7 @@ mod cli; -use std::fmt::Write; -use std::process::ExitCode; +use std::{fmt::Write, process::ExitCode}; use clap::Parser; use opensovd_client::Client; @@ -93,16 +92,14 @@ impl McpServer { impl McpServer { #[prompt( name = "explore-topology", - description = "Explore the vehicle diagnostic topology by listing components, areas, and apps." + description = "Explore the vehicle diagnostic topology by listing components, areas, and \ + apps." )] async fn explore_topology(&self) -> GetPromptResult { GetPromptResult::new(vec![PromptMessage::new_text( PromptMessageRole::User, - "Read the sovd://topology resource, then:\n\ - 1. List components\n\ - 2. List areas\n\ - 3. List apps and their hosting relationships\n\ - 4. Summarize the vehicle's diagnostic topology", + "Read the sovd://topology resource, then:\n1. List components\n2. List areas\n3. List \ + apps and their hosting relationships\n4. Summarize the vehicle's diagnostic topology", )]) .with_description("Explore the vehicle diagnostic topology exposed by the SOVD server.") } @@ -122,12 +119,10 @@ impl ServerHandler for McpServer { ServerInfo::new(capabilities) .with_server_info(server_info) .with_instructions( - "OpenSOVD MCP server for vehicle diagnostics. \ - Base URI: /sovd/v1. \ - Entity hierarchy: Areas > Components > Apps > Functions. \ - Each entity may expose: data, faults, operations, configurations, \ - bulk-data, locks, and modes. \ - Use the topology resource to explore the vehicle.", + "OpenSOVD MCP server for vehicle diagnostics. Base URI: /sovd/v1. Entity \ + hierarchy: Areas > Components > Apps > Functions. Each entity may expose: data, \ + faults, operations, configurations, bulk-data, locks, and modes. Use the \ + topology resource to explore the vehicle.", ) } @@ -277,8 +272,10 @@ async fn serve(url: &str) -> anyhow::Result<()> { #[cfg(test)] mod tests { use opensovd_models::discovery::EntityReference; - use rmcp::model::{CallToolRequestParams, GetPromptRequestParams}; - use rmcp::service::{RoleClient, RunningService}; + use rmcp::{ + model::{CallToolRequestParams, GetPromptRequestParams}, + service::{RoleClient, RunningService}, + }; use super::*; diff --git a/opensovd-client/src/client.rs b/opensovd-client/src/client.rs index 15d6da12..0de84182 100644 --- a/opensovd-client/src/client.rs +++ b/opensovd-client/src/client.rs @@ -16,9 +16,11 @@ use tower::{ util::{BoxCloneSyncService, MapErrLayer, MapResponseLayer}, }; -use crate::entities::{App, Area, Component}; -use crate::error::{Error, Result}; -use crate::list::ListEntitiesRequest; +use crate::{ + entities::{App, Area, Component}, + error::{Error, Result}, + list::ListEntitiesRequest, +}; /// Boxed error type for HTTP service flexibility with layers. pub(crate) type BoxError = Box; diff --git a/opensovd-client/src/data.rs b/opensovd-client/src/data.rs index 63860b4e..d9917a45 100644 --- a/opensovd-client/src/data.rs +++ b/opensovd-client/src/data.rs @@ -1,12 +1,16 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use opensovd_models::Response; -use opensovd_models::data::{DataList, ReadResponse, WriteRequest}; +use opensovd_models::{ + Response, + data::{DataList, ReadResponse, WriteRequest}, +}; use serde::Serialize; -use crate::client::{Client, schema_query}; -use crate::error::Result; +use crate::{ + client::{Client, schema_query}, + error::Result, +}; /// Request builder for listing data items on an entity. pub struct ListDataRequest<'a> { diff --git a/opensovd-client/src/entities/app.rs b/opensovd-client/src/entities/app.rs index 5fbc1746..8d0f89ea 100644 --- a/opensovd-client/src/entities/app.rs +++ b/opensovd-client/src/entities/app.rs @@ -1,12 +1,16 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use opensovd_models::data::{DataCategories, DataGroups}; -use opensovd_models::discovery::Entities; +use opensovd_models::{ + data::{DataCategories, DataGroups}, + discovery::Entities, +}; -use crate::client::{Client, encode}; -use crate::data::{DataRequest, ListDataRequest}; -use crate::error::Result; +use crate::{ + client::{Client, encode}, + data::{DataRequest, ListDataRequest}, + error::Result, +}; /// A reference to a specific app. pub struct App<'a> { diff --git a/opensovd-client/src/entities/area.rs b/opensovd-client/src/entities/area.rs index 1a80af3b..7ebf30f2 100644 --- a/opensovd-client/src/entities/area.rs +++ b/opensovd-client/src/entities/area.rs @@ -3,8 +3,7 @@ use opensovd_models::discovery::Entities; -use crate::client::Client; -use crate::error::Result; +use crate::{client::Client, error::Result}; /// A reference to a specific area. pub struct Area<'a> { diff --git a/opensovd-client/src/entities/component.rs b/opensovd-client/src/entities/component.rs index 7586a062..2b88c723 100644 --- a/opensovd-client/src/entities/component.rs +++ b/opensovd-client/src/entities/component.rs @@ -1,12 +1,16 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use opensovd_models::data::{DataCategories, DataGroups}; -use opensovd_models::discovery::Entities; +use opensovd_models::{ + data::{DataCategories, DataGroups}, + discovery::Entities, +}; -use crate::client::{Client, encode}; -use crate::data::{DataRequest, ListDataRequest}; -use crate::error::Result; +use crate::{ + client::{Client, encode}, + data::{DataRequest, ListDataRequest}, + error::Result, +}; /// A reference to a specific component. pub struct Component<'a> { diff --git a/opensovd-client/src/list.rs b/opensovd-client/src/list.rs index 856e1192..a1b2efdc 100644 --- a/opensovd-client/src/list.rs +++ b/opensovd-client/src/list.rs @@ -1,11 +1,12 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use opensovd_models::Response; -use opensovd_models::discovery::Entities; +use opensovd_models::{Response, discovery::Entities}; -use crate::client::{Client, schema_query}; -use crate::error::Result; +use crate::{ + client::{Client, schema_query}, + error::Result, +}; /// Request builder for listing entities in a collection. pub struct ListEntitiesRequest<'a> { diff --git a/opensovd-client/src/unix.rs b/opensovd-client/src/unix.rs index f30a602a..a09260f8 100644 --- a/opensovd-client/src/unix.rs +++ b/opensovd-client/src/unix.rs @@ -1,10 +1,12 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use std::future::Future; -use std::path::{Path, PathBuf}; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + future::Future, + path::{Path, PathBuf}, + pin::Pin, + task::{Context, Poll}, +}; use hyper::Uri; use hyper_util::rt::TokioIo; diff --git a/opensovd-client/tests/client.rs b/opensovd-client/tests/client.rs index 333a074a..72eea65a 100644 --- a/opensovd-client/tests/client.rs +++ b/opensovd-client/tests/client.rs @@ -76,8 +76,7 @@ async fn with_layer_builds_client() { async fn timeout_layer_times_out() { use std::time::Duration; - use tokio::io::AsyncWriteExt; - use tokio::net::TcpListener; + use tokio::{io::AsyncWriteExt, net::TcpListener}; use tower::timeout::TimeoutLayer; // Spawn a slow server that delays 2s before responding diff --git a/opensovd-client/tests/unix.rs b/opensovd-client/tests/unix.rs index b32067eb..800d726e 100644 --- a/opensovd-client/tests/unix.rs +++ b/opensovd-client/tests/unix.rs @@ -4,8 +4,10 @@ #![cfg(unix)] #![allow(clippy::unwrap_used)] -use tokio::io::{AsyncReadExt, AsyncWriteExt}; -use tokio::net::UnixListener; +use tokio::{ + io::{AsyncReadExt, AsyncWriteExt}, + net::UnixListener, +}; /// Accept one connection, read HTTP headers, then write a canned 200 response. async fn serve_one(listener: &UnixListener, body: &str) { diff --git a/opensovd-core/src/entity/app.rs b/opensovd-core/src/entity/app.rs index 7242fba5..77ad2f94 100644 --- a/opensovd-core/src/entity/app.rs +++ b/opensovd-core/src/entity/app.rs @@ -3,11 +3,9 @@ //! App entity implementation. -use std::collections::HashMap; -use std::fmt; +use std::{collections::HashMap, fmt}; -use crate::data::DataProvider; -use crate::entity::EntityRef; +use crate::{data::DataProvider, entity::EntityRef}; pub struct App { entity_ref: EntityRef, diff --git a/opensovd-core/src/entity/area.rs b/opensovd-core/src/entity/area.rs index ff4c7536..2b65cfca 100644 --- a/opensovd-core/src/entity/area.rs +++ b/opensovd-core/src/entity/area.rs @@ -6,11 +6,9 @@ //! Areas represent logical views of vehicle architecture and can be used to describe //! various vehicle topologies (e.g., domain architectures, zone architectures). -use std::collections::HashMap; -use std::fmt; +use std::{collections::HashMap, fmt}; -use crate::data::DataProvider; -use crate::entity::EntityRef; +use crate::{data::DataProvider, entity::EntityRef}; /// Area entity representing a logical view of vehicle architecture pub struct Area { diff --git a/opensovd-core/src/entity/component.rs b/opensovd-core/src/entity/component.rs index 5faf9f4d..492aa478 100644 --- a/opensovd-core/src/entity/component.rs +++ b/opensovd-core/src/entity/component.rs @@ -3,11 +3,9 @@ //! Component entity implementation. -use std::collections::HashMap; -use std::fmt; +use std::{collections::HashMap, fmt}; -use crate::data::DataProvider; -use crate::entity::EntityRef; +use crate::{data::DataProvider, entity::EntityRef}; pub struct Component { entity_ref: EntityRef, diff --git a/opensovd-core/src/topology.rs b/opensovd-core/src/topology.rs index 5e1f16e1..70468c4d 100644 --- a/opensovd-core/src/topology.rs +++ b/opensovd-core/src/topology.rs @@ -3,13 +3,9 @@ //! Entity topology management. -use std::collections::HashMap; -use std::ops::Deref; -use std::sync::Arc; +use std::{collections::HashMap, ops::Deref, sync::Arc}; -use indexmap::IndexMap; -use indexmap::IndexSet; -use indexmap::map::Values; +use indexmap::{IndexMap, IndexSet, map::Values}; use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard, broadcast}; use crate::entity::{App, Area, Component, EntityRef}; diff --git a/opensovd-extra/src/auth/jwt.rs b/opensovd-extra/src/auth/jwt.rs index b796a692..61be4fc4 100644 --- a/opensovd-extra/src/auth/jwt.rs +++ b/opensovd-extra/src/auth/jwt.rs @@ -3,9 +3,7 @@ //! JWT authentication supporting HS512 and RS512 algorithms. -use std::fmt; -use std::str::FromStr; -use std::sync::Arc; +use std::{fmt, str::FromStr, sync::Arc}; use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode}; use opensovd_server::{AuthError, Authenticator}; @@ -250,9 +248,11 @@ mod tests { ); } - use aws_lc_rs::encoding::AsDer; - use aws_lc_rs::rsa::KeySize; - use aws_lc_rs::signature::{KeyPair, RsaKeyPair}; + use aws_lc_rs::{ + encoding::AsDer, + rsa::KeySize, + signature::{KeyPair, RsaKeyPair}, + }; struct RsaTestKeys { private_pem: Vec, diff --git a/opensovd-extra/src/auth/rego.rs b/opensovd-extra/src/auth/rego.rs index e24ddc1f..8d6966c9 100644 --- a/opensovd-extra/src/auth/rego.rs +++ b/opensovd-extra/src/auth/rego.rs @@ -3,9 +3,11 @@ //! Rego policy-based authorization using regorus. -use std::io::Read; -use std::path::Path; -use std::sync::{Arc, RwLock}; +use std::{ + io::Read, + path::Path, + sync::{Arc, RwLock}, +}; use opensovd_server::{AuthError, Authorizer}; use regorus::Engine; diff --git a/opensovd-models/src/data.rs b/opensovd-models/src/data.rs index bc455694..dda5cfcc 100644 --- a/opensovd-models/src/data.rs +++ b/opensovd-models/src/data.rs @@ -3,8 +3,7 @@ use serde::{Deserialize, Serialize}; -use crate::error::GenericError; -use crate::{Items, JsonPointer}; +use crate::{Items, JsonPointer, error::GenericError}; /// Data category type. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/opensovd-providers/src/data/resource.rs b/opensovd-providers/src/data/resource.rs index 19ea414e..c95ff8d2 100644 --- a/opensovd-providers/src/data/resource.rs +++ b/opensovd-providers/src/data/resource.rs @@ -6,8 +6,7 @@ use async_trait::async_trait; use opensovd_core::DataError; use schemars::Schema; -use serde::Serialize; -use serde::de::DeserializeOwned; +use serde::{Serialize, de::DeserializeOwned}; /// Read-only data resource. /// diff --git a/opensovd-server/src/auth.rs b/opensovd-server/src/auth.rs index 0b1e42f3..453d17b0 100644 --- a/opensovd-server/src/auth.rs +++ b/opensovd-server/src/auth.rs @@ -3,10 +3,12 @@ //! Authentication and authorization middleware. -use std::future::Future; -use std::marker::PhantomData; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; use axum::{ body::Body, diff --git a/opensovd-server/src/body.rs b/opensovd-server/src/body.rs index dfda257a..79fb41fa 100644 --- a/opensovd-server/src/body.rs +++ b/opensovd-server/src/body.rs @@ -8,8 +8,10 @@ //! we introduce this newtype and bridge with `.map_request()` / //! `.map_response()` inside [`crate::ServerBuilder::service`]. -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + pin::Pin, + task::{Context, Poll}, +}; /// An opaque HTTP body type used by [`crate::ServerBuilder::service`]. /// diff --git a/opensovd-server/src/connect_info.rs b/opensovd-server/src/connect_info.rs index 8d82c6e2..45102571 100644 --- a/opensovd-server/src/connect_info.rs +++ b/opensovd-server/src/connect_info.rs @@ -5,8 +5,7 @@ use std::net::SocketAddr; -use axum::extract::connect_info::Connected; -use axum::serve::IncomingStream; +use axum::{extract::connect_info::Connected, serve::IncomingStream}; use tokio::net::TcpListener; #[cfg(unix)] use tokio::net::UnixListener; diff --git a/opensovd-server/src/routes/data.rs b/opensovd-server/src/routes/data.rs index c6d657bb..6d82445a 100644 --- a/opensovd-server/src/routes/data.rs +++ b/opensovd-server/src/routes/data.rs @@ -23,16 +23,19 @@ use axum::{ routing::get, }; use axum_extra::extract::WithRejection; -use opensovd_core::DataFilter; -use opensovd_core::Topology; -use opensovd_models::Response; -use opensovd_models::data::{ - DataCategories, DataCategoryInformation, DataGroups, DataGroupsQuery, DataList, DataQuery, - Group, Metadata, ReadDataQuery, ReadResponse, WriteRequest, +use opensovd_core::{DataFilter, Topology}; +use opensovd_models::{ + Response, + data::{ + DataCategories, DataCategoryInformation, DataGroups, DataGroupsQuery, DataList, DataQuery, + Group, Metadata, ReadDataQuery, ReadResponse, WriteRequest, + }, }; -use super::AppState; -use super::error::{Error, Result}; +use super::{ + AppState, + error::{Error, Result}, +}; use crate::schema::JsonSchema; pub fn routes() -> Router> diff --git a/opensovd-server/src/routes/entities/app.rs b/opensovd-server/src/routes/entities/app.rs index aba0aaea..e1e1aefb 100644 --- a/opensovd-server/src/routes/entities/app.rs +++ b/opensovd-server/src/routes/entities/app.rs @@ -10,14 +10,20 @@ use axum::{ }; use axum_extra::extract::WithRejection; use opensovd_core::Topology; -use opensovd_models::Response; -use opensovd_models::discovery::{ - Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, +use opensovd_models::{ + Response, + discovery::{ + Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, + }, }; -use super::super::AppState; -use super::super::error::{Error, Result}; -use super::encode_path_segment; +use super::{ + super::{ + AppState, + error::{Error, Result}, + }, + encode_path_segment, +}; use crate::schema::JsonSchema; pub(super) fn routes() -> Router> diff --git a/opensovd-server/src/routes/entities/area.rs b/opensovd-server/src/routes/entities/area.rs index d7b05c74..d10e294d 100644 --- a/opensovd-server/src/routes/entities/area.rs +++ b/opensovd-server/src/routes/entities/area.rs @@ -10,14 +10,20 @@ use axum::{ }; use axum_extra::extract::WithRejection; use opensovd_core::Topology; -use opensovd_models::Response; -use opensovd_models::discovery::{ - Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, +use opensovd_models::{ + Response, + discovery::{ + Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, + }, }; -use super::super::AppState; -use super::super::error::{Error, Result}; -use super::encode_path_segment; +use super::{ + super::{ + AppState, + error::{Error, Result}, + }, + encode_path_segment, +}; use crate::schema::JsonSchema; pub(super) fn routes() -> Router> diff --git a/opensovd-server/src/routes/entities/component.rs b/opensovd-server/src/routes/entities/component.rs index a58ece5f..0dad7d5b 100644 --- a/opensovd-server/src/routes/entities/component.rs +++ b/opensovd-server/src/routes/entities/component.rs @@ -10,14 +10,20 @@ use axum::{ }; use axum_extra::extract::WithRejection; use opensovd_core::Topology; -use opensovd_models::Response; -use opensovd_models::discovery::{ - Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, +use opensovd_models::{ + Response, + discovery::{ + Entities, EntitiesQuery, EntityCapabilities, EntityCapabilitiesQuery, EntityReference, + }, }; -use super::super::AppState; -use super::super::error::{Error, Result}; -use super::encode_path_segment; +use super::{ + super::{ + AppState, + error::{Error, Result}, + }, + encode_path_segment, +}; use crate::schema::JsonSchema; pub(super) fn routes() -> Router> diff --git a/opensovd-server/src/routes/entities/mod.rs b/opensovd-server/src/routes/entities/mod.rs index 98b16ed7..78cfdc9d 100644 --- a/opensovd-server/src/routes/entities/mod.rs +++ b/opensovd-server/src/routes/entities/mod.rs @@ -30,12 +30,16 @@ use axum::{ }; use axum_extra::extract::WithRejection; use opensovd_core::Topology; -use opensovd_models::Response; -use opensovd_models::discovery::{EntityCapabilities, EntityCapabilitiesQuery}; +use opensovd_models::{ + Response, + discovery::{EntityCapabilities, EntityCapabilitiesQuery}, +}; use percent_encoding::{AsciiSet, CONTROLS, utf8_percent_encode}; -use super::AppState; -use super::error::{Error, Result}; +use super::{ + AppState, + error::{Error, Result}, +}; use crate::schema::JsonSchema; pub fn routes() -> Router> diff --git a/opensovd-server/src/routes/version.rs b/opensovd-server/src/routes/version.rs index 2fbe7a9d..e825293d 100644 --- a/opensovd-server/src/routes/version.rs +++ b/opensovd-server/src/routes/version.rs @@ -14,12 +14,13 @@ use axum::{ routing::get, }; use axum_extra::extract::WithRejection; -use opensovd_models::Response; -use opensovd_models::version::{SovdInfo, VersionInfo, VersionInfoQuery}; +use opensovd_models::{ + Response, + version::{SovdInfo, VersionInfo, VersionInfoQuery}, +}; use serde::Serialize; -use super::AppState; -use super::error::Error; +use super::{AppState, error::Error}; use crate::schema::JsonSchema; pub fn routes() -> Router> diff --git a/opensovd-server/src/server.rs b/opensovd-server/src/server.rs index 7b8db84b..0d0bb43d 100644 --- a/opensovd-server/src/server.rs +++ b/opensovd-server/src/server.rs @@ -3,28 +3,30 @@ //! Server builder and listener types. -use std::future::Future; -use std::pin::Pin; +use std::{future::Future, pin::Pin}; use axum::Router; -use futures::future::{FutureExt, Shared}; -use futures::stream::StreamExt; +use futures::{ + future::{FutureExt, Shared}, + stream::StreamExt, +}; use opensovd_core::{DiscoveryProvider, EntityKind, Topology}; use serde::Serialize; use thiserror::Error; use tokio::net::TcpListener; #[cfg(unix)] use tokio::net::UnixListener; -use tower::Service as TowerService; -use tower::ServiceExt; -use tower::layer::util::{Identity, Stack}; -use tower::util::BoxCloneSyncService; +use tower::{ + Service as TowerService, ServiceExt, + layer::util::{Identity, Stack}, + util::BoxCloneSyncService, +}; -use crate::auth::{ - AllowAll, AuthenticationLayer, Authenticator, AuthorizationLayer, Authorizer, NoAuth, +use crate::{ + auth::{AllowAll, AuthenticationLayer, Authenticator, AuthorizationLayer, Authorizer, NoAuth}, + connect_info::ConnectInfo, + routes::VendorInfo, }; -use crate::connect_info::ConnectInfo; -use crate::routes::VendorInfo; pub(crate) type Service = BoxCloneSyncService< http::Request, diff --git a/opensovd-server/src/tls.rs b/opensovd-server/src/tls.rs index 615c7eba..4394c24f 100644 --- a/opensovd-server/src/tls.rs +++ b/opensovd-server/src/tls.rs @@ -1,15 +1,11 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 Contributors to the Eclipse Foundation // SPDX-License-Identifier: Apache-2.0 -use std::io; -use std::net::SocketAddr; -use std::sync::Arc; -use std::time::Duration; +use std::{io, net::SocketAddr, sync::Arc, time::Duration}; use rustls::ServerConfig; use tokio::net::TcpListener; -use tokio_rustls::TlsAcceptor; -use tokio_rustls::server::TlsStream; +use tokio_rustls::{TlsAcceptor, server::TlsStream}; // max number of TLS handshakes that can be made at the same time; const MAX_PENDING_HANDSHAKES: usize = 256; @@ -81,7 +77,7 @@ impl axum::serve::Listener for TlsListener { }); } Err(_) => { - // handshake queue full — drop the stream, TCP RST sent to client + // handshake queue full -- drop the stream, TCP RST sent to client tracing::warn!(peer = %addr, "handshake queue full, dropping connection"); } } diff --git a/opensovd-server/tests/auth.rs b/opensovd-server/tests/auth.rs index 5a0b9de2..9dd52f4f 100644 --- a/opensovd-server/tests/auth.rs +++ b/opensovd-server/tests/auth.rs @@ -5,11 +5,9 @@ use http_body_util::BodyExt; use hyper::Request; -use hyper_util::client::legacy::Client; -use hyper_util::rt::TokioExecutor; +use hyper_util::{client::legacy::Client, rt::TokioExecutor}; use opensovd_server::{AuthError, Authenticator, Authorizer, Parts, Server}; -use tokio::net::TcpListener; -use tokio::sync::oneshot; +use tokio::{net::TcpListener, sync::oneshot}; #[derive(Clone, Debug)] struct Claims { diff --git a/opensovd-server/tests/common/mod.rs b/opensovd-server/tests/common/mod.rs index f0ef7bf3..96fd5895 100644 --- a/opensovd-server/tests/common/mod.rs +++ b/opensovd-server/tests/common/mod.rs @@ -5,12 +5,10 @@ use std::collections::HashMap; -use hyper_util::client::legacy::Client; -use hyper_util::rt::TokioExecutor; +use hyper_util::{client::legacy::Client, rt::TokioExecutor}; use opensovd_core::{Component, DiscoveryProvider, Topology}; use opensovd_server::Server; -use tokio::net::TcpListener; -use tokio::sync::oneshot; +use tokio::{net::TcpListener, sync::oneshot}; pub struct TestEntity; diff --git a/opensovd-server/tests/routes.rs b/opensovd-server/tests/routes.rs index 0b218ae8..b46c8897 100644 --- a/opensovd-server/tests/routes.rs +++ b/opensovd-server/tests/routes.rs @@ -4,9 +4,7 @@ #![cfg_attr(coverage_nightly, feature(coverage_attribute))] #![allow(unsafe_code)] -use axum::Router; -use axum::extract::ConnectInfo as AxumConnectInfo; -use axum::routing::get; +use axum::{Router, extract::ConnectInfo as AxumConnectInfo, routing::get}; use opensovd_server::ConnectInfo; use tokio::net::TcpListener; #[cfg(target_os = "linux")] diff --git a/pyproject.toml b/pyproject.toml index a6c05835..9be96295 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ ] [dependency-groups] -tools = ["prek>=0.3.13", "ruff>=0.15.12", "ty>=0.0.34"] +tools = ["prek>=0.3.13", "reuse>=5.0.2", "ruff>=0.15.12", "ty>=0.0.34"] docs = ["sphinx>=9.1", "furo>=2025.12.19", "myst-parser>=5.0"] dev = [ "pytest-html>=4.2.0", diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..66fd595e --- /dev/null +++ b/ruff.toml @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +line-length = 100 + +[lint] +select = [ + "E", # pycodestyle (error) + "F", # pyflakes + "B", # bugbear + "B9", + "C4", # flake8-comprehensions + "SIM", # flake8-simplify + "I", # isort + "UP", # pyupgrade + "PIE", # flake8-pie + "PGH", # pygrep-hooks + "PYI", # flake8-pyi + "RUF", + "PT", # flake8-pytest-style +] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e80cf379..b72b603f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + [toolchain] channel = "nightly-2026-05-07" components = ["rustfmt", "clippy", "rust-analyzer", "llvm-tools-preview"] diff --git a/rustfmt.toml b/rustfmt.toml index 92e42649..fb2af380 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + newline_style = "Unix" group_imports = "StdExternalCrate" imports_granularity = "Crate" diff --git a/scripts/mkcerts.sh b/scripts/mkcerts.sh index 36349380..665bedff 100755 --- a/scripts/mkcerts.sh +++ b/scripts/mkcerts.sh @@ -12,9 +12,9 @@ # OUTPUT_DIR defaults to gen/certs relative to the workspace root. # # Files created: -# ca.key / ca.crt — self-signed CA (10-year validity) -# server.key / server.crt — server cert signed by the CA (SAN: 127.0.0.1, localhost) -# client.key / client.crt — client cert signed by the CA (clientAuth EKU) +# ca.key / ca.crt -- self-signed CA (10-year validity) +# server.key / server.crt -- server cert signed by the CA (SAN: 127.0.0.1, localhost) +# client.key / client.crt -- client cert signed by the CA (clientAuth EKU) set -euo pipefail @@ -55,11 +55,11 @@ rm -f "$OUT/server.csr" "$OUT/client.csr" "$OUT/ca.srl" echo "" echo "==> Generated certificates in $OUT:" -echo " ca.crt — CA certificate (trust anchor)" -echo " server.crt — server certificate" -echo " server.key — server private key" -echo " client.crt — client certificate" -echo " client.key — client private key" +echo " ca.crt -- CA certificate (trust anchor)" +echo " server.crt -- server certificate" +echo " server.key -- server private key" +echo " client.crt -- client certificate" +echo " client.key -- client private key" echo "" echo "==> Gateway usage:" echo "" diff --git a/tests/__init__.py b/tests/__init__.py index e69de29b..68a8f197 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 diff --git a/tests/bruno/bruno.json.license b/tests/bruno/bruno.json.license new file mode 100644 index 00000000..73197491 --- /dev/null +++ b/tests/bruno/bruno.json.license @@ -0,0 +1,9 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0 diff --git a/tests/opensovd-gateway/cli/test_mtls.py b/tests/opensovd-gateway/cli/test_mtls.py index 80ff6e10..72aac711 100644 --- a/tests/opensovd-gateway/cli/test_mtls.py +++ b/tests/opensovd-gateway/cli/test_mtls.py @@ -43,7 +43,7 @@ def test_mtls_transport(client): def test_mtls_valid_client_cert(client): - """mTLS: client presents a valid cert — request should succeed.""" + """mTLS: client presents a valid cert -- request should succeed.""" response = client.get("/version-info") assert response.status_code == 200 data = response.json() @@ -51,7 +51,7 @@ def test_mtls_valid_client_cert(client): def test_mtls_rejects_missing_client_cert(client, tls_certs): - """mTLS: client sends no cert — TLS handshake must be rejected by the server.""" + """mTLS: client sends no cert -- TLS handshake must be rejected by the server.""" ca_path = tls_certs["ca_crt"] ssl_ctx = ssl.create_default_context(cafile=str(ca_path)) no_cert = httpx.Client(base_url=client.base_url, verify=ssl_ctx) diff --git a/uv.lock b/uv.lock index f5f78ae1..76e5ff38 100644 --- a/uv.lock +++ b/uv.lock @@ -75,6 +75,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/1a/39/47f9197bdd44df24d67ac8893641e16f386c984a0619ef2ee4c51fbbc019/beautifulsoup4-4.14.3-py3-none-any.whl", hash = "sha256:0918bfe44902e6ad8d57732ba310582e98da931428d231a5ecb9e7c703a735bb", size = 107721, upload-time = "2025-11-30T15:08:24.087Z" }, ] +[[package]] +name = "boolean-py" +version = "5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c4/cf/85379f13b76f3a69bca86b60237978af17d6aa0bc5998978c3b8cf05abb2/boolean_py-5.0.tar.gz", hash = "sha256:60cbc4bad079753721d32649545505362c754e121570ada4658b852a3a318d95", size = 37047, upload-time = "2025-04-03T10:39:49.734Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/ca/78d423b324b8d77900030fa59c4aa9054261ef0925631cd2501dd015b7b7/boolean_py-5.0-py3-none-any.whl", hash = "sha256:ef28a70bd43115208441b53a045d1549e2f0ec6e3d08a9d142cbc41c1938e8d9", size = 26577, upload-time = "2025-04-03T10:39:48.449Z" }, +] + [[package]] name = "certifi" version = "2025.11.12" @@ -170,6 +179,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" }, ] +[[package]] +name = "click" +version = "8.3.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bb/63/f9e1ea081ce35720d8b92acde70daaedace594dc93b693c869e0d5910718/click-8.3.3.tar.gz", hash = "sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2", size = 328061, upload-time = "2026-04-22T15:11:27.506Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ae/44/c1221527f6a71a01ec6fbad7fa78f1d50dfa02217385cf0fa3eec7087d59/click-8.3.3-py3-none-any.whl", hash = "sha256:a2bf429bb3033c89fa4936ffb35d5cb471e3719e1f3c8a7c3fff0b8314305613", size = 110502, upload-time = "2026-04-22T15:11:25.044Z" }, +] + [[package]] name = "colorama" version = "0.4.6" @@ -400,6 +421,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/59/97/9b410ed8fbc6e79c1ee8b13f8777a80137d4bc189caf2c6202358e66192c/lazy_object_proxy-1.12.0-cp314-cp314-win_amd64.whl", hash = "sha256:7601ec171c7e8584f8ff3f4e440aa2eebf93e854f04639263875b8c2971f819f", size = 26988, upload-time = "2025-08-22T13:49:57.302Z" }, ] +[[package]] +name = "license-expression" +version = "30.4.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "boolean-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/40/71/d89bb0e71b1415453980fd32315f2a037aad9f7f70f695c7cec7035feb13/license_expression-30.4.4.tar.gz", hash = "sha256:73448f0aacd8d0808895bdc4b2c8e01a8d67646e4188f887375398c761f340fd", size = 186402, upload-time = "2025-07-22T11:13:32.17Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/40/791891d4c0c4dab4c5e187c17261cedc26285fd41541577f900470a45a4d/license_expression-30.4.4-py3-none-any.whl", hash = "sha256:421788fdcadb41f049d2dc934ce666626265aeccefddd25e162a26f23bcbf8a4", size = 120615, upload-time = "2025-07-22T11:13:31.217Z" }, +] + [[package]] name = "markdown-it-py" version = "4.0.0" @@ -561,6 +594,7 @@ docs = [ ] tools = [ { name = "prek" }, + { name = "reuse" }, { name = "ruff" }, { name = "ty" }, ] @@ -587,6 +621,7 @@ docs = [ ] tools = [ { name = "prek", specifier = ">=0.3.13" }, + { name = "reuse", specifier = ">=5.0.2" }, { name = "ruff", specifier = ">=0.15.12" }, { name = "ty", specifier = ">=0.0.34" }, ] @@ -796,6 +831,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3e/43/7e7b2ec865caa92f67b8f0e9231a798d102724ca4c0e1f414316be1c1ef2/pytest_metadata-3.1.1-py3-none-any.whl", hash = "sha256:c8e0844db684ee1c798cfa38908d20d67d0463ecb6137c72e91f418558dd5f4b", size = 11428, upload-time = "2024-02-12T19:38:42.531Z" }, ] +[[package]] +name = "python-debian" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "charset-normalizer" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/eb/f4/ec7ba072029399a89a2670bcef4df79c52f2efaa672f86e0a86252313333/python_debian-1.1.0.tar.gz", hash = "sha256:afe3c7267d81c29c79ab44d803a0756d0796b0e41bb0a05c5cafcdd2b980d4e6", size = 127848, upload-time = "2026-02-09T02:13:24.491Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0a/66/af49103279c07900b89b7ebac53111910aa8eb6d898be0b47220036b0b03/python_debian-1.1.0-py3-none-any.whl", hash = "sha256:3e553b6d0b886272a26649e13106e33c382bcd21c80b09f5c0c81fc7c8c8c743", size = 137984, upload-time = "2026-02-09T02:13:22.54Z" }, +] + [[package]] name = "python-dotenv" version = "1.2.2" @@ -805,6 +852,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0b/d7/1959b9648791274998a9c3526f6d0ec8fd2233e4d4acce81bbae76b44b2a/python_dotenv-1.2.2-py3-none-any.whl", hash = "sha256:1d8214789a24de455a8b8bd8ae6fe3c6b69a5e3d64aa8a8e5d68e694bbcb285a", size = 22101, upload-time = "2026-03-01T16:00:25.09Z" }, ] +[[package]] +name = "python-magic" +version = "0.4.27" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/da/db/0b3e28ac047452d079d375ec6798bf76a036a08182dbb39ed38116a49130/python-magic-0.4.27.tar.gz", hash = "sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b", size = 14677, upload-time = "2022-06-07T20:16:59.508Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/73/9f872cb81fc5c3bb48f7227872c28975f998f3e7c2b1c16e95e6432bbb90/python_magic-0.4.27-py2.py3-none-any.whl", hash = "sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3", size = 13840, upload-time = "2022-06-07T20:16:57.763Z" }, +] + [[package]] name = "pyyaml" version = "6.0.3" @@ -869,6 +925,21 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/56/5d/c814546c2333ceea4ba42262d8c4d55763003e767fa169adc693bd524478/requests-2.33.0-py3-none-any.whl", hash = "sha256:3324635456fa185245e24865e810cecec7b4caf933d7eb133dcde67d48cee69b", size = 65017, upload-time = "2026-03-25T15:10:40.382Z" }, ] +[[package]] +name = "reuse" +version = "6.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "click" }, + { name = "jinja2" }, + { name = "license-expression" }, + { name = "python-debian" }, + { name = "python-magic" }, + { name = "tomlkit" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/05/35/298d9410b3635107ce586725cdfbca4c219c08d77a3511551f5e479a78db/reuse-6.2.0.tar.gz", hash = "sha256:4feae057a2334c9a513e6933cdb9be819d8b822f3b5b435a36138bd218897d23", size = 1615611, upload-time = "2025-10-27T15:25:46.336Z" } + [[package]] name = "rfc3339-validator" version = "0.1.4" @@ -1102,6 +1173,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/52/a7/d2782e4e3f77c8450f727ba74a8f12756d5ba823d81b941f1b04da9d033a/sphinxcontrib_serializinghtml-2.0.0-py3-none-any.whl", hash = "sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331", size = 92072, upload-time = "2024-07-29T01:10:08.203Z" }, ] +[[package]] +name = "tomlkit" +version = "0.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/51/db/03eaf4331631ef6b27d6e3c9b68c54dc6f0d63d87201fed600cc409307fd/tomlkit-0.15.0.tar.gz", hash = "sha256:7d1a9ecba3086638211b13814ea79c90dd54dd11993564376f3aa92271f5c7a3", size = 161875, upload-time = "2026-05-10T07:38:22.245Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/43/8bd850ee71a191bf072e31302c73a66be413fecdd98fdcd111ecbcce13ca/tomlkit-0.15.0-py3-none-any.whl", hash = "sha256:4dbc8f0fc024412b57ced8757ac7461305126a648ff8c2c807fcb8e133a78738", size = 41328, upload-time = "2026-05-10T07:38:23.517Z" }, +] + [[package]] name = "ty" version = "0.0.34" diff --git a/uv.lock.license b/uv.lock.license new file mode 100644 index 00000000..73197491 --- /dev/null +++ b/uv.lock.license @@ -0,0 +1,9 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0