Skip to content

Commit

Permalink
Add missing deny unknown fields (#371)
Browse files Browse the repository at this point in the history
* Remove unused struct

No clue why clippy didn't catch this.

* Add missing deny_unknown_fields

* Add changelog
  • Loading branch information
schneems authored Dec 13, 2024
1 parent 16b3b73 commit a79408d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 4 additions & 0 deletions buildpacks/ruby/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Layer metadata deserialization to Rust structs is now using `#[serde(deny_unknown_fields)]` this prevents the accidental scenario where metadata containing a superset of fields could accidentally be deserialized to the wrong struct. It's unlikely this is currently happening with the current buildpack, but it's a possibly-observable difference so it's being listed ([#371](https://github.com/heroku/buildpacks-ruby/pull/371))

## [4.0.1] - 2024-12-11

### Fixed
Expand Down
9 changes: 1 addition & 8 deletions buildpacks/ruby/src/layers/bundle_install_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pub(crate) struct MetadataV2 {
}

#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, CacheDiff)]
#[serde(deny_unknown_fields)]
pub(crate) struct MetadataV3 {
#[cache_diff(rename = "OS Distribution")]
pub(crate) os_distribution: OsDistribution,
Expand Down Expand Up @@ -316,14 +317,6 @@ fn display_name(cmd: &mut Command, env: &Env) -> String {
)
}

#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, Default)]
#[serde(deny_unknown_fields)]
pub(crate) struct BundleDigest {
env: String,
gemfile: String,
lockfile: String,
}

#[cfg(test)]
mod test {
use crate::layers::shared::strip_ansi;
Expand Down
1 change: 1 addition & 0 deletions buildpacks/ruby/src/layers/ruby_install_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub(crate) struct MetadataV2 {
}

#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, CacheDiff)]
#[serde(deny_unknown_fields)]
pub(crate) struct MetadataV3 {
#[cache_diff(rename = "OS Distribution")]
pub(crate) os_distribution: OsDistribution,
Expand Down

0 comments on commit a79408d

Please sign in to comment.