Skip to content

Commit 95702ae

Browse files
Merge pull request #2 from veraison/ci
Add CI
2 parents f48bbb3 + aef3f1f commit 95702ae

File tree

6 files changed

+341
-45
lines changed

6 files changed

+341
-45
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v5
19+
- name: Formatting checks
20+
run: cargo fmt --all -- --check
21+
- name: Clippy checks
22+
run: cargo clippy --all-targets -- -D clippy::all -D clippy::cargo -A clippy::multiple-crate-versions
23+
- name: Build
24+
run: cargo build --verbose
25+
- name: Run tests
26+
run: cargo test --verbose
27+
28+
# Recommended pipeline if using advisories, to avoid sudden breakages
29+
# From: https://github.com/EmbarkStudios/cargo-deny-action
30+
cargo-deny:
31+
runs-on: ubuntu-latest
32+
strategy:
33+
matrix:
34+
checks:
35+
- advisories
36+
- bans licenses sources
37+
38+
# Prevent sudden announcement of a new advisory from failing ci:
39+
continue-on-error: ${{ matrix.checks == 'advisories' }}
40+
41+
steps:
42+
- uses: actions/checkout@v5
43+
- uses: EmbarkStudios/cargo-deny-action@v2
44+
with:
45+
command: check ${{ matrix.checks }}

Cargo.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22
name = "cmw"
33
version = "0.1.0"
44
edition = "2021"
5+
authors = ["Ionut Mihalcea <[email protected]>"]
6+
homepage = "https://github.com/veraison/rust-cmw"
7+
repository = "https://github.com/veraison/rust-cmw"
8+
description = "Rust implementation of CMW"
9+
keywords = ["cmw", "ietf", "cbor", "json", "attestation", "rats"]
10+
categories = [
11+
"os",
12+
"os::linux-apis",
13+
"parsing",
14+
"network-programming",
15+
"hardware-support",
16+
]
17+
exclude = [".gitignore", ".github/*"]
18+
rust-version = "1.85.0"
19+
license = "Apache-2.0"
520

621
[dependencies]
722
serde = { version = "1.0", features = ["derive"] }
823
serde_json = "1.0"
9-
serde_cbor = "0.11"
1024
base64 = { version = "0.22", features = ["alloc"]}
1125
base64-serde = "0.8.0"
1226
iri-string = "0.7.8"
@@ -19,6 +33,7 @@ mime = "0.3.17"
1933
hex = "0.4.3"
2034
lazy_static = "1.5.0"
2135
minicbor = { version = "1.0.0", features = ["std"]}
36+
minicbor-serde = { version = "0.6.2", features = ["alloc"] }
2237

2338
[build-dependencies]
2439
xml-rs = "0.8"
@@ -27,4 +42,4 @@ reqwest = { version = "0.12", features = ["blocking"] }
2742

2843
[features]
2944
default = []
30-
rebuild-cfmap = []
45+
rebuild-cfmap = []

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2025 Contributors to the Veraison project
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

deny.toml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
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+
[graph]
14+
# If 1 or more target triples (and optionally, target_features) are specified,
15+
# only the specified targets will be checked when running `cargo deny check`.
16+
# This means, if a particular package is only ever used as a target specific
17+
# dependency, such as, for example, the `nix` crate only being used via the
18+
# `target_family = "unix"` configuration, that only having windows targets in
19+
# this list would mean the nix crate, as well as any of its exclusive
20+
# dependencies not shared by any other crates, would be ignored, as the target
21+
# list here is effectively saying which targets you are building for.
22+
targets = [
23+
# The triple can be any string, but only the target triples built in to
24+
# rustc (as of 1.40) can be checked against actual config expressions
25+
#{ triple = "x86_64-unknown-linux-musl" },
26+
# You can also specify which target_features you promise are enabled for a
27+
# particular target. target_features are currently not validated against
28+
# the actual valid features supported by the target architecture.
29+
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
30+
]
31+
# When creating the dependency graph used as the source of truth when checks are
32+
# executed, this field can be used to prune crates from the graph, removing them
33+
# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate
34+
# is pruned from the graph, all of its dependencies will also be pruned unless
35+
# they are connected to another crate in the graph that hasn't been pruned,
36+
# so it should be used with care. The identifiers are [Package ID Specifications]
37+
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
38+
#exclude = []
39+
# If true, metadata will be collected with `--all-features`. Note that this can't
40+
# be toggled off if true, if you want to conditionally enable `--all-features` it
41+
# is recommended to pass `--all-features` on the cmd line instead
42+
all-features = false
43+
# If true, metadata will be collected with `--no-default-features`. The same
44+
# caveat with `all-features` applies
45+
no-default-features = false
46+
# If set, these feature will be enabled when collecting metadata. If `--features`
47+
# is specified on the cmd line they will take precedence over this option.
48+
#features = []
49+
50+
# This section is considered when running `cargo deny check advisories`
51+
# More documentation for the advisories section can be found here:
52+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
53+
[advisories]
54+
# The path where the advisory database is cloned/fetched into
55+
db-path = "~/.cargo/advisory-db"
56+
# The url(s) of the advisory databases to use
57+
db-urls = ["https://github.com/rustsec/advisory-db"]
58+
# The lint level for unmaintained crates
59+
unmaintained = "workspace"
60+
# The lint level for crates that have been yanked from their source registry
61+
yanked = "warn"
62+
# A list of advisory IDs to ignore. Note that ignored advisories will still
63+
# output a note when they are encountered.
64+
ignore = [
65+
# NOTE: This is a TEMPORARY recognition of the cbindgen use of clap+atty that
66+
# requires clap to update its dependencies
67+
#"RUSTSEC-2021-0145",
68+
]
69+
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
70+
# lower than the range specified will be ignored. Note that ignored advisories
71+
# will still output a note when they are encountered.
72+
# * None - CVSS Score 0.0
73+
# * Low - CVSS Score 0.1 - 3.9
74+
# * Medium - CVSS Score 4.0 - 6.9
75+
# * High - CVSS Score 7.0 - 8.9
76+
# * Critical - CVSS Score 9.0 - 10.0
77+
#severity-threshold =
78+
79+
# If this is true, then cargo deny will use the git executable to fetch advisory database.
80+
# If this is false, then it uses a built-in git library.
81+
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
82+
# See Git Authentication for more information about setting up git authentication.
83+
#git-fetch-with-cli = true
84+
85+
# This section is considered when running `cargo deny check licenses`
86+
# More documentation for the licenses section can be found here:
87+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
88+
[licenses]
89+
# List of explicitly allowed licenses
90+
# See https://spdx.org/licenses/ for list of possible licenses
91+
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
92+
allow = [
93+
"MIT",
94+
"Apache-2.0",
95+
"BlueOak-1.0.0",
96+
"BSD-3-Clause",
97+
"ISC",
98+
"OpenSSL",
99+
"Unicode-3.0",
100+
#"Apache-2.0 WITH LLVM-exception",
101+
# Considered Copyleft, but permitted in this project
102+
"MPL-2.0",
103+
]
104+
# The confidence threshold for detecting a license from license text.
105+
# The higher the value, the more closely the license text must be to the
106+
# canonical license text of a valid SPDX license file.
107+
# [possible values: any between 0.0 and 1.0].
108+
confidence-threshold = 0.8
109+
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
110+
# aren't accepted for every possible crate as with the normal allow list
111+
exceptions = [
112+
# Each entry is the crate and version constraint, and its specific allow
113+
# list
114+
#{ allow = ["Zlib"], name = "adler32", version = "*" },
115+
]
116+
117+
# Some crates don't have (easily) machine readable licensing information,
118+
# adding a clarification entry for it allows you to manually specify the
119+
# licensing information
120+
[[licenses.clarify]]
121+
# The name of the crate the clarification applies to
122+
name = "ring"
123+
# The optional version constraint for the crate
124+
version = "*"
125+
# The SPDX expression for the license requirements of the crate
126+
expression = "MIT AND ISC AND OpenSSL"
127+
# One or more files in the crate's source used as the "source of truth" for
128+
# the license expression. If the contents match, the clarification will be used
129+
# when running the license check, otherwise the clarification will be ignored
130+
# and the crate will be checked normally, which may produce warnings or errors
131+
# depending on the rest of your configuration
132+
license-files = [
133+
# Each entry is a crate relative path, and the (opaque) hash of its contents
134+
{ path = "LICENSE", hash = 0xbd0eed23 }
135+
]
136+
137+
[licenses.private]
138+
# If true, ignores workspace crates that aren't published, or are only
139+
# published to private registries.
140+
# To see how to mark a crate as unpublished (to the official registry),
141+
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
142+
ignore = false
143+
# One or more private registries that you might publish crates to, if a crate
144+
# is only published to private registries, and ignore is true, the crate will
145+
# not have its license(s) checked
146+
registries = [
147+
#"https://sekretz.com/registry
148+
]
149+
150+
# This section is considered when running `cargo deny check bans`.
151+
# More documentation about the 'bans' section can be found here:
152+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
153+
[bans]
154+
# Lint level for when multiple versions of the same crate are detected
155+
# NOTE: Veraison has unusually complex dependencies across platforms
156+
# Explicitly allowing duplicates here TEMPORARILY.
157+
multiple-versions = "allow"
158+
# Lint level for when a crate version requirement is `*`
159+
wildcards = "allow"
160+
# The graph highlighting used when creating dotgraphs for crates
161+
# with multiple versions
162+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
163+
# * simplest-path - The path to the version with the fewest edges is highlighted
164+
# * all - Both lowest-version and simplest-path are used
165+
highlight = "all"
166+
# The default lint level for `default` features for crates that are members of
167+
# the workspace that is being checked. This can be overriden by allowing/denying
168+
# `default` on a crate-by-crate basis if desired.
169+
workspace-default-features = "allow"
170+
# The default lint level for `default` features for external crates that are not
171+
# members of the workspace. This can be overriden by allowing/denying `default`
172+
# on a crate-by-crate basis if desired.
173+
external-default-features = "allow"
174+
# List of crates that are allowed. Use with care!
175+
allow = [
176+
#{ name = "ansi_term", version = "=0.11.0" },
177+
]
178+
# List of crates to deny
179+
deny = [
180+
# Each entry the name of a crate and a version range. If version is
181+
# not specified, all versions will be matched.
182+
#{ name = "ansi_term", version = "=0.11.0" },
183+
#
184+
# Wrapper crates can optionally be specified to allow the crate when it
185+
# is a direct dependency of the otherwise banned crate
186+
#{ name = "ansi_term", version = "=0.11.0", wrappers = [] },
187+
]
188+
189+
# List of features to allow/deny
190+
# Each entry the name of a crate and a version range. If version is
191+
# not specified, all versions will be matched.
192+
#[[bans.features]]
193+
#name = "reqwest"
194+
# Features to not allow
195+
#deny = ["json"]
196+
# Features to allow
197+
#allow = [
198+
# "rustls",
199+
# "__rustls",
200+
# "__tls",
201+
# "hyper-rustls",
202+
# "rustls",
203+
# "rustls-pemfile",
204+
# "rustls-tls-webpki-roots",
205+
# "tokio-rustls",
206+
# "webpki-roots",
207+
#]
208+
# If true, the allowed features must exactly match the enabled feature set. If
209+
# this is set there is no point setting `deny`
210+
#exact = true
211+
212+
# Certain crates/versions that will be skipped when doing duplicate detection.
213+
skip = [
214+
#{ name = "ansi_term", version = "=0.11.0" },
215+
]
216+
# Similarly to `skip` allows you to skip certain crates during duplicate
217+
# detection. Unlike skip, it also includes the entire tree of transitive
218+
# dependencies starting at the specified crate, up to a certain depth, which is
219+
# by default infinite.
220+
skip-tree = [
221+
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
222+
]
223+
224+
# This section is considered when running `cargo deny check sources`.
225+
# More documentation about the 'sources' section can be found here:
226+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
227+
[sources]
228+
# Lint level for what to happen when a crate from a crate registry that is not
229+
# in the allow list is encountered
230+
unknown-registry = "warn"
231+
# Lint level for what to happen when a crate from a git repository that is not
232+
# in the allow list is encountered
233+
unknown-git = "warn"
234+
# List of URLs for allowed crate registries. Defaults to the crates.io index
235+
# if not specified. If it is specified but empty, no registries are allowed.
236+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
237+
# List of URLs for allowed Git repositories
238+
allow-git = []
239+
240+
[sources.allow-org]
241+
# 1 or more github.com organizations to allow git sources for
242+
# github = [""]
243+
# 1 or more gitlab.com organizations to allow git sources for
244+
# gitlab = [""]
245+
# 1 or more bitbucket.org organizations to allow git sources for
246+
# bitbucket = [""]

src/monad.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Monad {
132132
let tval = serde_json::to_value(&self.typ).map_err(Error::Json)?;
133133
arr.push(tval);
134134
// value
135-
let vval = serde_json::to_value(&self.val).map_err(Error::Json)?;
135+
let vval = self.val.to_json_value()?;
136136
arr.push(vval);
137137
// indicator if nonzero
138138
if let Some(ind) = self.ind {
@@ -162,7 +162,7 @@ impl Monad {
162162
// type
163163
let typ: Type = serde_json::from_value(arr[0].clone()).map_err(Error::Json)?;
164164
// value
165-
let val: Value = serde_json::from_value(arr[1].clone()).map_err(Error::Json)?;
165+
let val: Value = Value::from_json_value(&arr[1])?;
166166
let ind = if alen == 3 {
167167
let ind_num: u8 = serde_json::from_value(arr[2].clone()).map_err(Error::Json)?;
168168
Some(Indicator::from_bits_truncate(ind_num))

0 commit comments

Comments
 (0)