Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Reject unknown fields in manifest(#69)
Browse files Browse the repository at this point in the history
Resolves #69
  • Loading branch information
Andy Lok authored and Andy Lok committed Aug 14, 2019
1 parent 2bc7de8 commit cb175b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/package/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use walkdir::{DirEntry, WalkDir};
//
// With this in place, we can safely avoid module namespace conflicts.

#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Manifest {
pub package: PackageInfo,
Expand Down Expand Up @@ -150,6 +151,7 @@ impl FromStr for Manifest {
}
}

#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct PackageInfo {
pub name: Name,
Expand All @@ -167,7 +169,7 @@ pub struct PackageInfo {
}

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(untagged)]
#[serde(untagged, deny_unknown_fields)]
pub enum DepReq {
Registry(Constraint),
RegLong {
Expand Down Expand Up @@ -227,6 +229,7 @@ impl DepReq {
}
}

#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
pub struct Targets {
pub lib: Option<LibTarget>,
Expand All @@ -236,6 +239,7 @@ pub struct Targets {
pub test: Vec<TestTarget>,
}

#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct LibTarget {
#[serde(default = "default_lib_subpath")]
Expand All @@ -249,6 +253,7 @@ fn default_lib_subpath() -> SubPath {
SubPath::from_path(Path::new("src")).unwrap()
}

#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
pub struct BinTarget {
pub name: String,
Expand All @@ -267,6 +272,7 @@ fn default_bin_subpath() -> SubPath {
/// the difference in default path.
///
/// I know, code duplication sucks and is stupid, but what can ya do :v
#[serde(deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
pub struct TestTarget {
pub name: Option<String>,
Expand Down

0 comments on commit cb175b6

Please sign in to comment.