Skip to content

Commit 3ef861e

Browse files
authored
Merge pull request #99 from hug-dev/stronger-lints
Add cargo clippy lints to the CI
2 parents f9b496b + ec49fe3 commit 3ef861e

File tree

9 files changed

+337
-106
lines changed

9 files changed

+337
-106
lines changed

Cargo.lock

Lines changed: 205 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ version = "0.1.0"
44
authors = ["Paul Howard <[email protected]>",
55
"Ionut Mihalcea <[email protected]>",
66
"Hugues de Valon <[email protected]>"]
7+
description = "A language-agnostic API to secure services in a platform-agnostic way"
8+
license = "Apache-2.0"
9+
repository = "https://github.com/parallaxsecond/parsec"
10+
readme = "README.md"
11+
keywords = ["security", "service"]
12+
categories = ["cryptography", "hardware-support"]
713
edition = "2018"
814

915
[[bin]]
1016
name = "parsec"
1117
path = "src/bin/main.rs"
1218

1319
[dependencies]
14-
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", tag = "0.6.0" }
20+
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", tag = "0.6.1" }
1521
rand = "0.7.2"
1622
base64 = "0.10.1"
1723
uuid = "0.7.4"
@@ -33,7 +39,7 @@ derivative = "1.0.3"
3339
arbitrary = { version = "0.4.0", features = ["derive"], optional = true }
3440

3541
[dev-dependencies]
36-
parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.13" }
42+
parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.14" }
3743
num_cpus = "1.10.1"
3844

3945
[build-dependencies]

build.rs

Lines changed: 85 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@
1212
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
15+
16+
#![deny(
17+
nonstandard_style,
18+
const_err,
19+
dead_code,
20+
improper_ctypes,
21+
non_shorthand_field_patterns,
22+
no_mangle_generic_items,
23+
overflowing_literals,
24+
path_statements,
25+
patterns_in_fns_without_body,
26+
private_in_public,
27+
unconditional_recursion,
28+
unused,
29+
unused_allocation,
30+
unused_comparisons,
31+
unused_parens,
32+
while_true,
33+
missing_debug_implementations,
34+
trivial_casts,
35+
trivial_numeric_casts,
36+
unused_extern_crates,
37+
unused_import_braces,
38+
unused_qualifications,
39+
unused_results,
40+
missing_copy_implementations
41+
)]
42+
// This one is hard to avoid.
43+
#![allow(clippy::multiple_crate_versions)]
44+
1545
use cargo_toml::{Manifest, Value};
1646
use serde::Deserialize;
1747
use std::env;
@@ -75,63 +105,67 @@ fn get_value_from_table<'a>(table: &'a Value, key: &str) -> Result<&'a Value> {
75105
// parameters to the setup_mbed_crypto.sh script which clones and builds Mbed Crypto and create
76106
// a static library.
77107
fn setup_mbed_crypto(mbed_config: &MbedConfig, mbed_version: &str) -> Result<()> {
78-
let mut run_script = ::std::process::Command::new(SETUP_MBED_SCRIPT_PATH);
79-
run_script.arg(mbed_version).arg(
80-
mbed_config
81-
.mbed_path
82-
.clone()
83-
.unwrap_or(String::from(env::var("OUT_DIR").unwrap())),
84-
);
85-
86-
let toolchain;
87-
let mbed_compiler;
88-
let mbed_archiver;
89-
if std::env::var("TARGET").unwrap() == "aarch64-unknown-linux-gnu" {
90-
toolchain = mbed_config
91-
.aarch64_unknown_linux_gnu
92-
.as_ref()
93-
.ok_or_else(|| {
108+
let (mbed_compiler, mbed_archiver) =
109+
if std::env::var("TARGET").unwrap() == "aarch64-unknown-linux-gnu" {
110+
let toolchain;
111+
toolchain = mbed_config
112+
.aarch64_unknown_linux_gnu
113+
.as_ref()
114+
.ok_or_else(|| {
115+
Error::new(
116+
ErrorKind::InvalidInput,
117+
"The aarch64_unknown_linux_gnu subtable of mbed_config should exist",
118+
)
119+
})?;
120+
(
121+
toolchain
122+
.mbed_compiler
123+
.clone()
124+
.unwrap_or_else(|| DEFAULT_ARM64_MBED_COMPILER.to_string()),
125+
toolchain
126+
.mbed_archiver
127+
.clone()
128+
.unwrap_or_else(|| DEFAULT_ARM64_MBED_ARCHIVER.to_string()),
129+
)
130+
} else {
131+
let toolchain;
132+
toolchain = mbed_config.native.as_ref().ok_or_else(|| {
94133
Error::new(
95134
ErrorKind::InvalidInput,
96-
"The aarch64_unknown_linux_gnu subtable of mbed_config should exist",
135+
"The native subtable of mbed_config should exist",
97136
)
98137
})?;
99-
mbed_compiler = toolchain
100-
.mbed_compiler
101-
.clone()
102-
.unwrap_or(DEFAULT_ARM64_MBED_COMPILER.to_string());
103-
mbed_archiver = toolchain
104-
.mbed_archiver
105-
.clone()
106-
.unwrap_or(DEFAULT_ARM64_MBED_ARCHIVER.to_string());
107-
} else {
108-
toolchain = mbed_config.native.as_ref().ok_or_else(|| {
109-
Error::new(
110-
ErrorKind::InvalidInput,
111-
"The native subtable of mbed_config should exist",
138+
(
139+
toolchain
140+
.mbed_compiler
141+
.clone()
142+
.unwrap_or_else(|| DEFAULT_NATIVE_MBED_COMPILER.to_string()),
143+
toolchain
144+
.mbed_archiver
145+
.clone()
146+
.unwrap_or_else(|| DEFAULT_NATIVE_MBED_ARCHIVER.to_string()),
112147
)
113-
})?;
114-
mbed_compiler = toolchain
115-
.mbed_compiler
116-
.clone()
117-
.unwrap_or(DEFAULT_NATIVE_MBED_COMPILER.to_string());
118-
mbed_archiver = toolchain
119-
.mbed_archiver
120-
.clone()
121-
.unwrap_or(DEFAULT_NATIVE_MBED_ARCHIVER.to_string());
122-
}
148+
};
123149

124-
run_script.arg(format!("CC={}", mbed_compiler));
125-
run_script.arg(format!("AR={}", mbed_archiver));
150+
let script_fail = |_| {
151+
Err(Error::new(
152+
ErrorKind::Other,
153+
"setup_mbed_crypto.sh script failed",
154+
))
155+
};
126156

127-
if !run_script
157+
if !::std::process::Command::new(SETUP_MBED_SCRIPT_PATH)
158+
.arg(mbed_version)
159+
.arg(
160+
mbed_config
161+
.mbed_path
162+
.clone()
163+
.unwrap_or_else(|| env::var("OUT_DIR").unwrap()),
164+
)
165+
.arg(format!("CC={}", mbed_compiler))
166+
.arg(format!("AR={}", mbed_archiver))
128167
.status()
129-
.or_else(|_| {
130-
Err(Error::new(
131-
ErrorKind::Other,
132-
"setup_mbed_crypto.sh script failed",
133-
))
134-
})?
168+
.or_else(script_fail)?
135169
.success()
136170
{
137171
Err(Error::new(
@@ -147,7 +181,7 @@ fn generate_mbed_bindings(mbed_config: &MbedConfig, mbed_version: &str) -> Resul
147181
let mbed_include_dir = mbed_config
148182
.mbed_path
149183
.clone()
150-
.unwrap_or(String::from(env::var("OUT_DIR").unwrap()))
184+
.unwrap_or_else(|| env::var("OUT_DIR").unwrap())
151185
+ "/mbed-crypto-"
152186
+ mbed_version
153187
+ "/include";
@@ -236,7 +270,7 @@ fn main() -> Result<()> {
236270
"cargo:rustc-link-search=native={}/mbed-crypto-{}/library/",
237271
mbed_config
238272
.mbed_path
239-
.unwrap_or(String::from(env::var("OUT_DIR").unwrap())),
273+
.unwrap_or_else(|| env::var("OUT_DIR").unwrap()),
240274
mbed_version,
241275
);
242276
println!("cargo:rustc-link-lib=static=mbedcrypto");

src/bin/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
const_err,
1818
dead_code,
1919
improper_ctypes,
20-
legacy_directory_ownership,
2120
non_shorthand_field_patterns,
2221
no_mangle_generic_items,
2322
overflowing_literals,
2423
path_statements,
2524
patterns_in_fns_without_body,
26-
plugin_as_library,
2725
private_in_public,
28-
safe_extern_statics,
2926
unconditional_recursion,
3027
unused,
3128
unused_allocation,
@@ -43,6 +40,8 @@
4340
unused_results,
4441
missing_copy_implementations
4542
)]
43+
// This one is hard to avoid.
44+
#![allow(clippy::multiple_crate_versions)]
4645

4746
use log::info;
4847
use parsec::utils::{ServiceBuilder, ServiceConfig};

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
const_err,
1818
dead_code,
1919
improper_ctypes,
20-
legacy_directory_ownership,
2120
non_shorthand_field_patterns,
2221
no_mangle_generic_items,
2322
overflowing_literals,
2423
path_statements,
2524
patterns_in_fns_without_body,
26-
plugin_as_library,
2725
private_in_public,
28-
safe_extern_statics,
2926
unconditional_recursion,
3027
unused,
3128
unused_allocation,
@@ -43,6 +40,8 @@
4340
unused_results,
4441
missing_copy_implementations
4542
)]
43+
// This one is hard to avoid.
44+
#![allow(clippy::multiple_crate_versions)]
4645

4746
pub mod authenticators;
4847
pub mod back;

tests/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ then
101101
fi
102102
if rustup component list | grep -q clippy
103103
then
104-
cargo clippy --all-targets $FEATURES -- -D clippy::all
104+
cargo clippy --all-targets $FEATURES -- -D clippy::all -D clippy::cargo
105105
fi
106106

107107
############################

tests/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,35 @@
1212
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
15+
16+
#![deny(
17+
nonstandard_style,
18+
const_err,
19+
dead_code,
20+
improper_ctypes,
21+
non_shorthand_field_patterns,
22+
no_mangle_generic_items,
23+
overflowing_literals,
24+
path_statements,
25+
patterns_in_fns_without_body,
26+
private_in_public,
27+
unconditional_recursion,
28+
unused,
29+
unused_allocation,
30+
unused_comparisons,
31+
unused_parens,
32+
while_true,
33+
missing_debug_implementations,
34+
trivial_casts,
35+
trivial_numeric_casts,
36+
unused_extern_crates,
37+
unused_import_braces,
38+
unused_qualifications,
39+
unused_results,
40+
missing_copy_implementations
41+
)]
42+
// This one is hard to avoid.
43+
#![allow(clippy::multiple_crate_versions)]
44+
1545
mod all_providers;
1646
mod per_provider;

tests/per_provider/normal_tests/export_public_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn export_public_key() -> Result<()> {
2323

2424
client.create_rsa_sign_key(key_name.clone())?;
2525

26-
client.export_public_key(key_name)?;
26+
let _ = client.export_public_key(key_name)?;
2727

2828
Ok(())
2929
}

tests/per_provider/provider_cfg/mbed-crypto/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ FROM ubuntu:latest
33
RUN apt-get update && \
44
apt-get install -y git make gcc python3 python curl wget libgcc1 && \
55
# These libraries are needed for bindgen as it uses libclang.so
6-
apt-get install -y clang libclang-dev
6+
apt-get install -y clang libclang-dev && \
7+
# Needed for Open SSL
8+
apt-get install -y pkg-config libssl-dev
79

810
WORKDIR /tmp
911
RUN wget https://github.com/ARMmbed/mbed-crypto/archive/mbedcrypto-2.0.0.tar.gz

0 commit comments

Comments
 (0)