Skip to content

Commit fddc69f

Browse files
authored
Merge pull request #109 from ANSSI-FR/dependabot/cargo/clap-3
Update clap requirement from 2 to 3
2 parents 566ebd1 + 2626552 commit fddc69f

3 files changed

Lines changed: 55 additions & 62 deletions

File tree

mla/src/layers/encrypt.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,14 @@ impl ArchiveWriterConfig {
127127
}
128128
}
129129

130+
#[derive(Default)]
130131
pub struct EncryptionReaderConfig {
131132
/// Private key(s) to use
132133
private_keys: Vec<StaticSecret>,
133134
/// Symmetric encryption key and nonce, if decrypted successfully from header
134135
encrypt_parameters: Option<(Key, [u8; NONCE_SIZE])>,
135136
}
136137

137-
impl std::default::Default for EncryptionReaderConfig {
138-
fn default() -> Self {
139-
Self {
140-
private_keys: Vec::new(),
141-
encrypt_parameters: None,
142-
}
143-
}
144-
}
145-
146138
impl EncryptionReaderConfig {
147139
pub fn load_persistent(
148140
&mut self,

mlar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "../README.md"
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
clap = "2"
16+
clap = "3"
1717
glob = "0.3"
1818
mla = { path = "../mla", version = "1" }
1919
curve25519-parser = { path = "../curve25519-parser", version = "0.2" }

mlar/src/main.rs

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clap::{App, Arg, ArgMatches, SubCommand};
1+
use clap::{App, Arg, ArgMatches};
22
use curve25519_parser::{
33
generate_keypair, parse_openssl_25519_privkey, parse_openssl_25519_pubkey,
44
};
@@ -415,17 +415,17 @@ fn add_file_or_dir(mla: &mut ArchiveWriter<OutputTypes>, path: &Path) -> Result<
415415

416416
/// Recursively explore a dir to add all the files
417417
/// Ignore empty directory
418-
fn add_dir(mut mla: &mut ArchiveWriter<OutputTypes>, dir: &Path) -> Result<(), Error> {
418+
fn add_dir(mla: &mut ArchiveWriter<OutputTypes>, dir: &Path) -> Result<(), Error> {
419419
for file in read_dir(dir)? {
420420
let new_path = file?.path();
421-
add_file_or_dir(&mut mla, &new_path)?;
421+
add_file_or_dir(mla, &new_path)?;
422422
}
423423
Ok(())
424424
}
425425

426-
fn add_from_stdin(mut mla: &mut ArchiveWriter<OutputTypes>) -> Result<(), Error> {
426+
fn add_from_stdin(mla: &mut ArchiveWriter<OutputTypes>) -> Result<(), Error> {
427427
for line in io::stdin().lock().lines() {
428-
add_file_or_dir(&mut mla, Path::new(&line?))?;
428+
add_file_or_dir(mla, Path::new(&line?))?;
429429
}
430430
Ok(())
431431
}
@@ -856,45 +856,46 @@ fn info(matches: &ArgMatches) -> Result<(), Error> {
856856
fn main() {
857857
// Common arguments list, for homogeneity
858858
let input_args = vec![
859-
Arg::with_name("input")
859+
Arg::new("input")
860860
.help("Archive path")
861861
.long("input")
862-
.short("i")
862+
.short('i')
863863
.number_of_values(1)
864864
.required(true),
865-
Arg::with_name("private_keys")
865+
Arg::new("private_keys")
866866
.long("private_keys")
867-
.short("k")
867+
.short('k')
868868
.help("Candidates ED25519 private key paths (DER or PEM format)")
869869
.number_of_values(1)
870-
.multiple(true)
870+
.multiple_occurrences(true)
871+
.allow_invalid_utf8(true)
871872
.takes_value(true),
872873
];
873-
let layers = ["compress", "encrypt"];
874874
let output_args = vec![
875-
Arg::with_name("output")
875+
Arg::new("output")
876876
.help("Output file path. Use - for stdout")
877877
.long("output")
878-
.short("o")
878+
.short('o')
879879
.takes_value(true)
880880
.required(true),
881-
Arg::with_name("public_keys")
881+
Arg::new("public_keys")
882882
.help("ED25519 Public key paths (DER or PEM format)")
883883
.long("pubkey")
884-
.short("p")
884+
.short('p')
885885
.number_of_values(1)
886-
.multiple(true),
887-
Arg::with_name("layers")
886+
.allow_invalid_utf8(true)
887+
.multiple_occurrences(true),
888+
Arg::new("layers")
888889
.long("layers")
889-
.short("l")
890+
.short('l')
890891
.help("Layers to use. Default is 'compress,encrypt'")
891-
.possible_values(&layers)
892+
.possible_values(["compress", "encrypt"])
892893
.number_of_values(1)
893-
.multiple(true)
894+
.multiple_occurrences(true)
894895
.min_values(0),
895-
Arg::with_name("compression_level")
896+
Arg::new("compression_level")
896897
.group("Compression layer")
897-
.short("-q")
898+
.short('q')
898899
.long("compression_level")
899900
.help("Compression level (0-11); ; bigger values cause denser, but slower compression")
900901
.takes_value(true),
@@ -905,123 +906,123 @@ fn main() {
905906
.version(env!("CARGO_PKG_VERSION"))
906907
.about(env!("CARGO_PKG_DESCRIPTION"))
907908
.subcommand(
908-
SubCommand::with_name("create")
909+
App::new("create")
909910
.about("Create a new MLA Archive")
910911
.args(&output_args)
911-
.arg(Arg::with_name("files").help("Files to add").multiple(true)),
912+
.arg(Arg::new("files").help("Files to add").multiple_occurrences(true)),
912913
)
913914
.subcommand(
914-
SubCommand::with_name("list")
915+
App::new("list")
915916
.about("List files inside a MLA Archive")
916917
.args(&input_args)
917918
.arg(
918-
Arg::with_name("verbose")
919-
.short("-v")
920-
.multiple(true)
919+
Arg::new("verbose")
920+
.short('v')
921+
.multiple_occurrences(true)
921922
.takes_value(false)
922923
.help("Verbose listing, with additional information"),
923924
),
924925
)
925926
.subcommand(
926-
SubCommand::with_name("extract")
927+
App::new("extract")
927928
.about("Extract files from a MLA Archive")
928929
.args(&input_args)
929930
.arg(
930-
Arg::with_name("outputdir")
931+
Arg::new("outputdir")
931932
.help("Output directory where files are extracted")
932933
.long("output")
933-
.short("o")
934+
.short('o')
934935
.number_of_values(1)
935936
.default_value("."),
936937
)
937938
.arg(
938-
Arg::with_name("glob")
939+
Arg::new("glob")
939940
.long("glob")
940-
.short("-g")
941+
.short('g')
941942
.takes_value(false)
942943
.help("Treat specified files as glob patterns"),
943944
)
944-
.arg(Arg::with_name("files").help("List of extracted files (all if none given)"))
945+
.arg(Arg::new("files").help("List of extracted files (all if none given)"))
945946
.arg(
946-
Arg::with_name("verbose")
947+
Arg::new("verbose")
947948
.long("verbose")
948-
.short("-v")
949+
.short('v')
949950
.takes_value(false)
950951
.help("List files as they are extracted"),
951952
),
952953
)
953954
.subcommand(
954-
SubCommand::with_name("cat")
955+
App::new("cat")
955956
.about("Display files from a MLA Archive, like 'cat'")
956957
.args(&input_args)
957958
.arg(
958-
Arg::with_name("output")
959+
Arg::new("output")
959960
.help("Output file where files are displayed")
960961
.long("output")
961-
.short("o")
962+
.short('o')
962963
.number_of_values(1)
963964
.default_value("-"),
964965
)
965966
.arg(
966-
Arg::with_name("glob")
967+
Arg::new("glob")
967968
.long("glob")
968-
.short("-g")
969+
.short('g')
969970
.takes_value(false)
970971
.help("Treat given files as glob patterns"),
971972
)
972973
.arg(
973-
Arg::with_name("files")
974+
Arg::new("files")
974975
.required(true)
975976
.help("List of displayed files"),
976977
),
977978
)
978979
.subcommand(
979-
SubCommand::with_name("to-tar")
980+
App::new("to-tar")
980981
.about("Convert a MLA Archive to a TAR Archive")
981982
.args(&input_args)
982983
.arg(
983-
Arg::with_name("output")
984+
Arg::new("output")
984985
.help("Tar Archive path")
985986
.long("output")
986-
.short("o")
987+
.short('o')
987988
.number_of_values(1)
988989
.required(true),
989990
),
990991
)
991992
.subcommand(
992-
SubCommand::with_name("repair")
993+
App::new("repair")
993994
.about("Try to repair a MLA Archive into a fresh MLA Archive")
994995
.args(&input_args)
995996
.args(&output_args),
996997
)
997998
.subcommand(
998-
SubCommand::with_name("convert")
999+
App::new("convert")
9991000
.about(
10001001
"Convert a MLA Archive to a fresh new one, with potentially different options",
10011002
)
10021003
.args(&input_args)
10031004
.args(&output_args),
10041005
)
10051006
.subcommand(
1006-
SubCommand::with_name("keygen")
1007+
App::new("keygen")
10071008
.about(
10081009
"Generate a public/private keypair, in OpenSSL Ed25519 format, to be used by mlar",
10091010
)
10101011
.arg(
1011-
Arg::with_name("output")
1012+
Arg::new("output")
10121013
.help("Output file for the private key. The public key is in {output}.pub")
10131014
.number_of_values(1)
10141015
.required(true)
10151016
)
10161017
)
10171018
.subcommand(
1018-
SubCommand::with_name("info")
1019+
App::new("info")
10191020
.about("Get info on a MLA Archive")
10201021
.args(&input_args)
10211022
.arg(
1022-
Arg::with_name("verbose")
1023+
Arg::new("verbose")
10231024
.long("verbose")
1024-
.short("-v")
1025+
.short('v')
10251026
.takes_value(false)
10261027
.help("Get extra info for encryption and compression layers"),
10271028
),

0 commit comments

Comments
 (0)