Skip to content

Commit

Permalink
Apply typos to project.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 committed Mar 18, 2024
1 parent c04fa09 commit c91b74e
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Spelling with the use of `typos`.

## [0.1.2] - 2024-03-05

### Added
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Structure requirements on commit messages, issues and pull requests are other th
set -e

# Make sure the toolchain is up to date and includes the
# neccessary components specified in rust-toolchain.toml:
# necessary components specified in rust-toolchain.toml:
rustup update "$(rustup toolchain list | rg override | cut -d ' ' -f1)"

# Make sure things are properly formatted
Expand All @@ -27,7 +27,7 @@ taplo fmt --check --diff
# Make sure things follow common linting recommendations
cargo clippy --all-features --tests -- -D warnings

# Check documention
# Check documentation
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --workspace --exclude rops-cli

# Some may also want to uncomment:
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Cli {
.and_then(|file_extension| {
<Format as ValueEnum>::from_str(file_extension.to_str().expect("invalid unicode"), true).ok()
})
.ok_or_else(|| UndeterminedFormatError::NoFileExtention(file_path.to_path_buf()).into()),
.ok_or_else(|| UndeterminedFormatError::NoFileExtension(file_path.to_path_buf()).into()),
None => Err(UndeterminedFormatError::FoundNeither.into()),
},
}
Expand All @@ -74,12 +74,12 @@ mod tests {
use super::*;

#[test]
fn infers_format_by_extesion() {
fn infers_format_by_extension() {
assert_eq!(Format::Yaml, Cli::get_format(Some(Path::new("test.yaml")), None).unwrap())
}

#[test]
fn infers_format_by_extesion_alias() {
fn infers_format_by_extension_alias() {
assert_eq!(Format::Yaml, Cli::get_format(Some(Path::new("test.yml")), None).unwrap())
}

Expand All @@ -95,7 +95,7 @@ mod tests {
fn errors_on_missing_file_extension() {
assert!(matches!(
Cli::get_format(Some(Path::new("test")), None).unwrap_err(),
RopsCliError::UndeterminedFormat(UndeterminedFormatError::NoFileExtention(_))
RopsCliError::UndeterminedFormat(UndeterminedFormatError::NoFileExtension(_))
))
}
}
10 changes: 5 additions & 5 deletions crates/cli/src/cli/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ impl Cli {
#[rustfmt::skip]
mod temp_file_format {
use super::*;
pub trait TempFileFormat: FileFormat { const TEMP_EXTENTION: &'static str; }
impl TempFileFormat for YamlFileFormat { const TEMP_EXTENTION: &'static str = "yaml"; }
impl TempFileFormat for JsonFileFormat { const TEMP_EXTENTION: &'static str = "json"; }
impl TempFileFormat for TomlFileFormat { const TEMP_EXTENTION: &'static str = "toml"; }
pub trait TempFileFormat: FileFormat { const TEMP_EXTENSION: &'static str; }
impl TempFileFormat for YamlFileFormat { const TEMP_EXTENSION: &'static str = "yaml"; }
impl TempFileFormat for JsonFileFormat { const TEMP_EXTENSION: &'static str = "json"; }
impl TempFileFormat for TomlFileFormat { const TEMP_EXTENSION: &'static str = "toml"; }
}

fn edit_encrypted_file<F: temp_file_format::TempFileFormat>(explicit_file_path: Option<&Path>) -> anyhow::Result<()> {
Expand All @@ -32,7 +32,7 @@ impl Cli {
.decrypt_and_save_parameters::<F>()?;

let temp_file = tempfile::Builder::new()
.suffix(&format!(".{}", F::TEMP_EXTENTION))
.suffix(&format!(".{}", F::TEMP_EXTENSION))
// Create locally to avoid file being picked up by temporary resource cleaners.
.tempfile_in("./")?;

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/config/retrieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub type DefaulConfigFileFormat = TomlFileFormat;
const ROPS_CONFIG_ENV_VAR_NAME: &str = "ROPS_CONFIG";
const ROPS_CONFIG_DEFAULT_FILE_NAME: &str = ".rops.toml";

// seperated with generic parameter to simplify unit testing of strategy
// separated with generic parameter to simplify unit testing of strategy
pub(super) fn retrieve_impl<T: DeserializeOwned + Default>(optional_config_path: Option<&Path>) -> anyhow::Result<T> {
if let Some(arg_path) = optional_config_path {
return read_fs_path_and_deserialize::<T>(arg_path);
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use thiserror::Error;

#[derive(Debug, PartialEq, Error)]
pub enum RopsCliError {
#[error("multiple inputs; recieved content from stdin when a file path was provided")]
#[error("multiple inputs; received content from stdin when a file path was provided")]
MultipleInputs,
#[error("missing input; neither a file path nor stdin were provided")]
MissingInput,
Expand All @@ -17,7 +17,7 @@ pub enum UndeterminedFormatError {
#[error("found neither format nor file arguments")]
FoundNeither,
#[error("unable to determine file extension for {0} when no format argument was found")]
NoFileExtention(PathBuf),
NoFileExtension(PathBuf),
}

pub const IN_PLACE_PANIC: &str = "inplace argument not declared with a #[requires = \"file\"] field attribute.";
8 changes: 4 additions & 4 deletions crates/lib/src/file/format/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait FileFormatValueAdapter {

fn encrypted_to_internal<C: Cipher>(
self,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError>;

fn encrypted_from_internal<C: Cipher>(internal_tree: RopsTree<EncryptedMap<C>>) -> Self;
Expand Down Expand Up @@ -69,19 +69,19 @@ where

fn encrypted_to_internal<F, C: Cipher>(
self,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
recursive_value_fn: F,
) -> Result<RopsMap<EncryptedMap<C>>, FormatToInternalMapError>
where
F: Fn(Self::Value, ResolvedPartialEncrpytion) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError>,
F: Fn(Self::Value, ResolvedPartialEncryption) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError>,
{
let mut tree_map = IndexMap::default();

for (format_key, format_value) in self {
let key_string = format_key.validate()?;
let mut resolved_partial_encryption = resolved_partial_encryption;

if let ResolvedPartialEncrpytion::No(partial_encryption_config) = resolved_partial_encryption {
if let ResolvedPartialEncryption::No(partial_encryption_config) = resolved_partial_encryption {
resolved_partial_encryption = partial_encryption_config.resolve(&key_string);
}

Expand Down
6 changes: 3 additions & 3 deletions crates/lib/src/file/format/json/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ mod metadata {
IntegrationMetadataUnit<I>: MockFileFormatUtil<JsonFileFormat>,
{
let integration_metadata = IntegrationMetadataUnit::<I>::mock_format_display();
let (first_metadata_line, remaning_metata_lines) = integration_metadata
let (first_metadata_line, remaining_metata_lines) = integration_metadata
.split_once('\n')
.expect("no newline delimeter in integration metadata");
.expect("no newline delimiter in integration metadata");

indoc::formatdoc!(
"\"{}\": [
Expand All @@ -137,7 +137,7 @@ mod metadata {
",
metadata_field_name,
first_metadata_line,
textwrap::indent(remaning_metata_lines, " ")
textwrap::indent(remaining_metata_lines, " ")
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/file/format/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl FileFormatValueAdapter for JsonValue {

fn encrypted_to_internal<C: Cipher>(
self,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError> {
Ok(match self {
JsonValue::Object(map) => RopsTree::Map(map.encrypted_to_internal(resolved_partial_encryption, Self::encrypted_to_internal)?),
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/file/format/test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ macro_rules! generate_file_format_test_suite {

#[test]
#[should_panic]
fn dissallows_out_of_range_integers() {
fn disallows_out_of_range_integers() {
assert!(!matches!(
$file_format::key_value_map::<DecryptedMap>("invalid_integer", u64::MAX)
.to_internal()
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/file/format/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl FileFormatValueAdapter for TomlValue {

fn encrypted_to_internal<C: Cipher>(
self,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError> {
Ok(match self {
TomlValue::Table(map) => RopsTree::Map(map.encrypted_to_internal(resolved_partial_encryption, Self::encrypted_to_internal)?),
Expand Down
6 changes: 3 additions & 3 deletions crates/lib/src/file/format/yaml/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ mod metadata {
IntegrationMetadataUnit<I>: MockFileFormatUtil<YamlFileFormat>,
{
let integration_metadata = IntegrationMetadataUnit::<I>::mock_format_display();
let (first_metadata_line, remaning_metata_lines) = integration_metadata
let (first_metadata_line, remaining_metata_lines) = integration_metadata
.split_once('\n')
.expect("no newline delimeter in integration metadata");
.expect("no newline delimiter in integration metadata");

indoc::formatdoc! {"
{}:
- {}
{}",
metadata_field_name,
first_metadata_line,
textwrap::indent(remaning_metata_lines, " ")
textwrap::indent(remaining_metata_lines, " ")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/file/format/yaml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl FileFormatValueAdapter for YamlValue {
Ok(match self {
// SOPS simply throws away tags, so do we for now.
// It can, however, deserialize manually added tags to encrypted documents,
// so we could in theory keep the tags somewhere without breaking SOPS compatability.
// so we could in theory keep the tags somewhere without breaking SOPS compatibility.
YamlValue::Tagged(tagged) => tagged.value.decrypted_to_internal()?,
YamlValue::Mapping(map) => RopsTree::Map(YamlMap::decrypted_to_internal(map)?),
YamlValue::Bool(boolean) => RopsTree::Leaf(RopsValue::Boolean(boolean)),
Expand All @@ -87,7 +87,7 @@ impl FileFormatValueAdapter for YamlValue {

fn encrypted_to_internal<C: Cipher>(
self,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
) -> Result<RopsTree<EncryptedMap<C>>, FormatToInternalMapError> {
Ok(match self {
YamlValue::Tagged(tagged) => tagged.value.encrypted_to_internal(resolved_partial_encryption)?,
Expand Down
6 changes: 3 additions & 3 deletions crates/lib/src/file/map/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RopsMap<DecryptedMap> {
fn encrypt_map_recursive<Ci: Cipher>(
decrypted_map: RopsMap<DecryptedMap>,
data_key: &DataKey,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
key_path: &KeyPath,
optional_saved_nonces: &Option<&SavedRopsMapNonces<Ci>>,
) -> Result<RopsMap<EncryptedMap<Ci>>, Ci::Error> {
Expand All @@ -46,7 +46,7 @@ impl RopsMap<DecryptedMap> {
let key_path = key_path.join(&key);
let mut resolved_partial_encryption = resolved_partial_encryption;

if let ResolvedPartialEncrpytion::No(partial_encryption_config) = resolved_partial_encryption {
if let ResolvedPartialEncryption::No(partial_encryption_config) = resolved_partial_encryption {
resolved_partial_encryption = partial_encryption_config.resolve(key_path.last())
}

Expand All @@ -68,7 +68,7 @@ impl RopsMap<DecryptedMap> {
fn encrypt_tree_recursive<Ci: Cipher>(
decrypted_tree: RopsTree<DecryptedMap>,
data_key: &DataKey,
resolved_partial_encryption: ResolvedPartialEncrpytion,
resolved_partial_encryption: ResolvedPartialEncryption,
key_path: &KeyPath,
optional_saved_nonces: &Option<&SavedRopsMapNonces<Ci>>,
) -> Result<RopsTree<EncryptedMap<Ci>>, Ci::Error> {
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/file/map/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod aes_gcm {
}
}

fn encrypted_leaf(encrpyted_value_str: &str) -> RopsTree<EncryptedMap<AES256GCM>> {
RopsTree::Leaf(RopsMapEncryptedLeaf::Encrypted(encrpyted_value_str.parse().unwrap()))
fn encrypted_leaf(encrypted_value_str: &str) -> RopsTree<EncryptedMap<AES256GCM>> {
RopsTree::Leaf(RopsMapEncryptedLeaf::Encrypted(encrypted_value_str.parse().unwrap()))
}
}
12 changes: 6 additions & 6 deletions crates/lib/src/file/metadata/integration/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ impl IntegrationMetadata {
.into_iter()
.map(|key_id| I::Config::new(key_id))
.map(|integration_config| IntegrationMetadataUnit::<I>::new(integration_config, data_key))
.try_for_each(|integation_metada_unit_result| {
I::select_metadata_units(self).insert(integation_metada_unit_result?);
.try_for_each(|integration_metadata_unit_result| {
I::select_metadata_units(self).insert(integration_metadata_unit_result?);
Ok(())
})
}
Expand Down Expand Up @@ -75,13 +75,13 @@ mod tests {

#[test]
fn adds_keys() {
let mut integation_metadata = IntegrationMetadata::default();
assert!(integation_metadata.age.is_empty());
let mut integration_metadata = IntegrationMetadata::default();
assert!(integration_metadata.age.is_empty());

integation_metadata
integration_metadata
.add_keys::<AgeIntegration>(Some(<AgeIntegration as Integration>::KeyId::mock()), &DataKey::mock())
.unwrap();

assert!(!integation_metadata.age.is_empty())
assert!(!integration_metadata.age.is_empty())
}
}
2 changes: 1 addition & 1 deletion crates/lib/src/file/metadata/mac/decrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<H: Hasher> Mac<H> {
for (key, tree) in map.iter() {
let mut mac_only_encrypted_config = mac_only_encrypted_config;

if let ResolvedPartialEncrpytion::No(partial_encryption_config) = mac_only_encrypted_config.resolved_partial_encryption
if let ResolvedPartialEncryption::No(partial_encryption_config) = mac_only_encrypted_config.resolved_partial_encryption
{
mac_only_encrypted_config.resolved_partial_encryption = partial_encryption_config.resolve(key);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/file/metadata/mac/mac_only_encrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::*;
#[derive(Clone, Copy)]
pub struct MacOnlyEncryptedConfig<'a> {
pub mac_only_encrypted: bool,
pub resolved_partial_encryption: ResolvedPartialEncrpytion<'a>,
pub resolved_partial_encryption: ResolvedPartialEncryption<'a>,
}

impl MacOnlyEncryptedConfig<'_> {
Expand All @@ -26,7 +26,7 @@ mod mock {
fn mock() -> Self {
Self {
mac_only_encrypted: false,
resolved_partial_encryption: ResolvedPartialEncrpytion::mock(),
resolved_partial_encryption: ResolvedPartialEncryption::mock(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/file/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ pub(crate) use mac::*;

mod partial_encryption;
pub use partial_encryption::PartialEncryptionConfig;
pub(crate) use partial_encryption::ResolvedPartialEncrpytion;
pub(crate) use partial_encryption::ResolvedPartialEncryption;
22 changes: 11 additions & 11 deletions crates/lib/src/file/metadata/partial_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum PartialEncryptionConfig {
pub struct EscapeEncryption(pub bool);

impl PartialEncryptionConfig {
pub fn resolve(&self, key_str: &str) -> ResolvedPartialEncrpytion {
pub fn resolve(&self, key_str: &str) -> ResolvedPartialEncryption {
let maybe_escape_encryption: Option<EscapeEncryption> = match self {
PartialEncryptionConfig::EncryptedSuffix(suffix) => key_str.ends_with(suffix).then_some(EscapeEncryption(false)),
PartialEncryptionConfig::EncryptedRegex(regex) => regex.is_match(key_str).then_some(EscapeEncryption(false)),
Expand All @@ -26,35 +26,35 @@ impl PartialEncryptionConfig {
};

match maybe_escape_encryption {
Some(escape_encryption) => ResolvedPartialEncrpytion::Yes(escape_encryption),
None => ResolvedPartialEncrpytion::No(self),
Some(escape_encryption) => ResolvedPartialEncryption::Yes(escape_encryption),
None => ResolvedPartialEncryption::No(self),
}
}
}

#[derive(Clone, Copy)]
pub enum ResolvedPartialEncrpytion<'a> {
pub enum ResolvedPartialEncryption<'a> {
Yes(EscapeEncryption),
No(&'a PartialEncryptionConfig),
}

impl ResolvedPartialEncrpytion<'_> {
impl ResolvedPartialEncryption<'_> {
pub fn escape_encryption(&self) -> bool {
match self {
ResolvedPartialEncrpytion::Yes(escape_encryption) => escape_encryption.0,
ResolvedPartialEncrpytion::No(partial_encryption_config) => match partial_encryption_config {
ResolvedPartialEncryption::Yes(escape_encryption) => escape_encryption.0,
ResolvedPartialEncryption::No(partial_encryption_config) => match partial_encryption_config {
PartialEncryptionConfig::EncryptedSuffix(_) | PartialEncryptionConfig::EncryptedRegex(_) => true,
PartialEncryptionConfig::UnencryptedSuffix(_) | PartialEncryptionConfig::UnencryptedRegex(_) => false,
},
}
}
}

impl<'a> From<Option<&'a PartialEncryptionConfig>> for ResolvedPartialEncrpytion<'a> {
impl<'a> From<Option<&'a PartialEncryptionConfig>> for ResolvedPartialEncryption<'a> {
fn from(optional_partial_encryption_config: Option<&'a PartialEncryptionConfig>) -> Self {
match optional_partial_encryption_config {
Some(partial_encryption_config) => ResolvedPartialEncrpytion::No(partial_encryption_config),
None => ResolvedPartialEncrpytion::Yes(EscapeEncryption(false)),
Some(partial_encryption_config) => ResolvedPartialEncryption::No(partial_encryption_config),
None => ResolvedPartialEncryption::Yes(EscapeEncryption(false)),
}
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ mod mock {

static LAZY_PARTIAL_ENCRYPTION_CONFIG: Lazy<PartialEncryptionConfig> = Lazy::new(PartialEncryptionConfig::mock);

impl MockTestUtil for ResolvedPartialEncrpytion<'_> {
impl MockTestUtil for ResolvedPartialEncryption<'_> {
fn mock() -> Self {
Self::No(&LAZY_PARTIAL_ENCRYPTION_CONFIG)
}
Expand Down
Loading

0 comments on commit c91b74e

Please sign in to comment.