Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing deny unknown fields #371

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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